diff options
author | sapier <Sapier at GMX dot net> | 2014-04-06 15:12:04 +0200 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-04-19 11:56:19 +0200 |
commit | eda9214f81b32d9606f425e3777616e8cfc0a44f (patch) | |
tree | 4c526f45edea82d4ddd205b975d600401873295c /src/connection.cpp | |
parent | a230e1e7360eb561429bf69ad8793745fbd5e7c3 (diff) | |
download | hax-minetest-server-eda9214f81b32d9606f425e3777616e8cfc0a44f.tar.gz hax-minetest-server-eda9214f81b32d9606f425e3777616e8cfc0a44f.zip |
Bunch of small fixes (coding style, very unlikely errors, warning messages)
Diffstat (limited to '')
-rw-r--r-- | src/connection.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/connection.cpp b/src/connection.cpp index 32634ac89..ae1e4a1db 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -111,10 +111,10 @@ SharedBuffer<u8> makeOriginalPacket( u32 packet_size = data.getSize() + header_size; SharedBuffer<u8> b(packet_size); - writeU8(&b[0], TYPE_ORIGINAL); - - memcpy(&b[header_size], *data, data.getSize()); - + writeU8(&(b[0]), TYPE_ORIGINAL); + if (data.getSize() > 0) { + memcpy(&(b[header_size]), *data, data.getSize()); + } return b; } @@ -2266,14 +2266,14 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel, if(packetdata.getSize() < 1) throw InvalidIncomingDataException("packetdata.getSize() < 1"); - u8 type = readU8(&packetdata[0]); + u8 type = readU8(&(packetdata[0])); if(type == TYPE_CONTROL) { if(packetdata.getSize() < 2) throw InvalidIncomingDataException("packetdata.getSize() < 2"); - u8 controltype = readU8(&packetdata[1]); + u8 controltype = readU8(&(packetdata[1])); if( (controltype == CONTROLTYPE_ACK) && (peer_id <= MAX_UDP_PEERS)) @@ -2398,15 +2398,15 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel, } else if(type == TYPE_ORIGINAL) { - if(packetdata.getSize() < ORIGINAL_HEADER_SIZE) + if(packetdata.getSize() <= ORIGINAL_HEADER_SIZE) throw InvalidIncomingDataException - ("packetdata.getSize() < ORIGINAL_HEADER_SIZE"); + ("packetdata.getSize() <= ORIGINAL_HEADER_SIZE"); LOG(dout_con<<m_connection->getDesc() <<"RETURNING TYPE_ORIGINAL to user" <<std::endl); // Get the inside packet out and return it SharedBuffer<u8> payload(packetdata.getSize() - ORIGINAL_HEADER_SIZE); - memcpy(*payload, &packetdata[ORIGINAL_HEADER_SIZE], payload.getSize()); + memcpy(*payload, &(packetdata[ORIGINAL_HEADER_SIZE]), payload.getSize()); return payload; } else if(type == TYPE_SPLIT) |