diff options
author | nerzhul <loic.blot@unix-experience.fr> | 2016-02-23 10:58:13 +0100 |
---|---|---|
committer | nerzhul <loic.blot@unix-experience.fr> | 2016-02-23 14:24:21 +0100 |
commit | 147425483a9e1afa2a2a4d9c0d5fa8b68d105644 (patch) | |
tree | 35b2ab0e0a0f41767cbd8481ba691cdc62a617d1 | |
parent | f3f4af3fb9148d30480ffa1c9f4cf55e879c51c0 (diff) | |
download | minetest-147425483a9e1afa2a2a4d9c0d5fa8b68d105644.tar.gz minetest-147425483a9e1afa2a2a4d9c0d5fa8b68d105644.tar.bz2 minetest-147425483a9e1afa2a2a4d9c0d5fa8b68d105644.zip |
GOTBLOCKS & DELETEBLOCKS: test packet size only once
-rw-r--r-- | src/network/serverpackethandler.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 7e348a94d..ef99a634f 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -762,14 +762,14 @@ void Server::handleCommand_GotBlocks(NetworkPacket* pkt) RemoteClient *client = getClient(pkt->getPeerId()); - for (u16 i = 0; i < count; i++) { - if ((s16)pkt->getSize() < 1 + (i + 1) * 6) - throw con::InvalidIncomingDataException + if ((s16)pkt->getSize() < 1 + (int)count * 6) { + throw con::InvalidIncomingDataException ("GOTBLOCKS length is too short"); - v3s16 p; + } + for (u16 i = 0; i < count; i++) { + v3s16 p; *pkt >> p; - client->GotBlock(p); } } @@ -865,13 +865,14 @@ void Server::handleCommand_DeletedBlocks(NetworkPacket* pkt) RemoteClient *client = getClient(pkt->getPeerId()); - for (u16 i = 0; i < count; i++) { - if ((s16)pkt->getSize() < 1 + (i + 1) * 6) - throw con::InvalidIncomingDataException + if ((s16)pkt->getSize() < 1 + (int)count * 6) { + throw con::InvalidIncomingDataException ("DELETEDBLOCKS length is too short"); + } + + for (u16 i = 0; i < count; i++) { v3s16 p; *pkt >> p; - client->SetBlockNotSent(p); } } |