mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-16 00:28:20 +03:00
Merge pull request #60 from WPMGPRoSToTeMa/fragoverflowfix
Fixed net_message overflow in Netchan_CopyNormalFragments()
This commit is contained in:
commit
474ab2cbc1
@ -250,7 +250,7 @@ typedef struct flow_s
|
|||||||
#ifndef REHLDS_FIXES
|
#ifndef REHLDS_FIXES
|
||||||
#define MAX_FRAGMENTS 25000
|
#define MAX_FRAGMENTS 25000
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
#define UDP_HEADER_SIZE 28
|
#define UDP_HEADER_SIZE 28
|
||||||
|
@ -1399,16 +1399,41 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
|
|||||||
SZ_Clear(&net_message);
|
SZ_Clear(&net_message);
|
||||||
MSG_BeginReading();
|
MSG_BeginReading();
|
||||||
|
|
||||||
|
#ifdef REHLDS_FIXES
|
||||||
|
bool overflowed = false;
|
||||||
|
#endif // REHLDS_FIXES
|
||||||
|
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
n = p->next;
|
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);
|
SZ_Write(&net_message, p->frag_message.data, p->frag_message.cursize);
|
||||||
|
#endif // REHLDS_FIXES
|
||||||
|
|
||||||
Mem_Free(p);
|
Mem_Free(p);
|
||||||
p = n;
|
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'))
|
if (*(uint32 *)net_message.data == MAKEID('B', 'Z', '2', '\0'))
|
||||||
{
|
{
|
||||||
char uncompressed[65536];
|
char uncompressed[65536];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user