net: second part of buffer overflow check correction.

This was supposed to go into the last commit, but I did
 git commit --amend
without adding the changes to the index. Now I'm too lazy to sort
things out.

git-svn-id: https://svn.eduke32.com/eduke32@2736 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-06-03 19:20:39 +00:00
parent 18eba11657
commit 9b40534c8f

View file

@ -1722,12 +1722,26 @@ void Net_UpdateClients(void)
} }
{ {
char buf[PACKBUF_SIZE+512]; char buf[PACKBUF_SIZE+400];
#if 1
// We're screwed anyway if this fails:
Bassert(siz <= PACKBUF_SIZE);
#else
if (siz >= PACKBUF_SIZE) if (siz >= PACKBUF_SIZE)
{
initprintf("Global packet buffer overflow! Size of packet: %i\n", siz); initprintf("Global packet buffer overflow! Size of packet: %i\n", siz);
return;
}
#endif
siz = qlz_compress(packbuf+1, buf, siz, state_compress); siz = qlz_compress(packbuf+1, buf, siz, state_compress);
if (siz >= PACKBUF_SIZE-1)
{
initprintf("Packet buffer overflow! Size of compressed MOVE payload: %d\n", siz);
return;
}
Bmemcpy(packbuf+1, buf, siz); Bmemcpy(packbuf+1, buf, siz);
siz++; siz++;
} }
@ -1776,7 +1790,8 @@ void Net_StreamLevel(void)
if (osize >= PACKBUF_SIZE) if (osize >= PACKBUF_SIZE)
{ {
// XXX: this currently happens when e.g. switching levels // XXX: this currently happens when e.g. switching levels
initprintf("Packet buffer overflow! Size of packet after diff before compress: %u\n", osize); initprintf("Packet buffer overflow! GAMESTATE payload size "
"after diff before compress: %u\n", osize);
return; return;
} }
@ -1784,7 +1799,8 @@ void Net_StreamLevel(void)
if (siz >= PACKBUF_SIZE-1) if (siz >= PACKBUF_SIZE-1)
{ {
initprintf("Global packet buffer overflow! Size of packet after diff and compress: %d\n", siz); initprintf("Global packet buffer overflow! GAMESTATE payload size "
"after diff and compress: %d\n", siz);
return; return;
} }