2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-28 15:45:46 +03:00

Merge pull request #60 from WPMGPRoSToTeMa/fragoverflowfix

Fixed net_message overflow in Netchan_CopyNormalFragments()
This commit is contained in:
dreamstalker 2015-07-16 11:44:43 +04:00
commit 474ab2cbc1
2 changed files with 26 additions and 1 deletions

View File

@ -250,7 +250,7 @@ typedef struct flow_s
#ifndef REHLDS_FIXES
#define MAX_FRAGMENTS 25000
#else
#define MAX_FRAGMENTS ((NET_MAX_PAYLOAD + FRAGMENT_SIZE - 1) / FRAGMENT_SIZE) // should be enough for any send buf
#define MAX_FRAGMENTS (NET_MAX_PAYLOAD / FRAGMENT_SIZE) // should be enough for any send buf
#endif
#define UDP_HEADER_SIZE 28

View File

@ -1399,16 +1399,41 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
SZ_Clear(&net_message);
MSG_BeginReading();
#ifdef REHLDS_FIXES
bool overflowed = false;
#endif // REHLDS_FIXES
while (p)
{
n = p->next;
#ifdef REHLDS_FIXES
if (net_message.cursize + p->frag_message.cursize <= net_message.maxsize)
SZ_Write(&net_message, p->frag_message.data, p->frag_message.cursize);
else
overflowed = true;
#else // REHLDS_FIXES
SZ_Write(&net_message, p->frag_message.data, p->frag_message.cursize);
#endif // REHLDS_FIXES
Mem_Free(p);
p = n;
}
#ifdef REHLDS_FIXES
if (overflowed)
{
Con_Printf("Netchan_CopyNormalFragments: Overflowed\n");
SZ_Clear(&net_message);
chan->incomingbufs[FRAG_NORMAL_STREAM] = NULL;
chan->incomingready[FRAG_NORMAL_STREAM] = false;
return FALSE;
}
#endif // REHLDS_FIXES
if (*(uint32 *)net_message.data == MAKEID('B', 'Z', '2', '\0'))
{
char uncompressed[65536];