mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
GOTBLOCKS & DELETEBLOCKS: test packet size only once
This commit is contained in:
parent
f3f4af3fb9
commit
147425483a
1 changed files with 10 additions and 9 deletions
|
@ -762,14 +762,14 @@ void Server::handleCommand_GotBlocks(NetworkPacket* pkt)
|
||||||
|
|
||||||
RemoteClient *client = getClient(pkt->getPeerId());
|
RemoteClient *client = getClient(pkt->getPeerId());
|
||||||
|
|
||||||
for (u16 i = 0; i < count; i++) {
|
if ((s16)pkt->getSize() < 1 + (int)count * 6) {
|
||||||
if ((s16)pkt->getSize() < 1 + (i + 1) * 6)
|
|
||||||
throw con::InvalidIncomingDataException
|
throw con::InvalidIncomingDataException
|
||||||
("GOTBLOCKS length is too short");
|
("GOTBLOCKS length is too short");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u16 i = 0; i < count; i++) {
|
||||||
v3s16 p;
|
v3s16 p;
|
||||||
|
|
||||||
*pkt >> p;
|
*pkt >> p;
|
||||||
|
|
||||||
client->GotBlock(p);
|
client->GotBlock(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,13 +865,14 @@ void Server::handleCommand_DeletedBlocks(NetworkPacket* pkt)
|
||||||
|
|
||||||
RemoteClient *client = getClient(pkt->getPeerId());
|
RemoteClient *client = getClient(pkt->getPeerId());
|
||||||
|
|
||||||
for (u16 i = 0; i < count; i++) {
|
if ((s16)pkt->getSize() < 1 + (int)count * 6) {
|
||||||
if ((s16)pkt->getSize() < 1 + (i + 1) * 6)
|
|
||||||
throw con::InvalidIncomingDataException
|
throw con::InvalidIncomingDataException
|
||||||
("DELETEDBLOCKS length is too short");
|
("DELETEDBLOCKS length is too short");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (u16 i = 0; i < count; i++) {
|
||||||
v3s16 p;
|
v3s16 p;
|
||||||
*pkt >> p;
|
*pkt >> p;
|
||||||
|
|
||||||
client->SetBlockNotSent(p);
|
client->SetBlockNotSent(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue