2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-01 01:25:38 +03:00

PVS/PAS buffer overrun fix (#282)

Fix buffer overrun in adding to fat PVS/PAS.
This commit is contained in:
LevShisterov 2016-12-20 02:06:39 +05:00 committed by theAsmodai
parent 1f96d176e7
commit 97b072a9f6

View File

@ -2078,9 +2078,9 @@ void SV_ReplaceSpecialCharactersInName(char *newname, const char *oldname)
for (const char *s = oldname; *s != '\0' && remainChars; s++)
{
if (*s == '#' ||
*s == '%' ||
*s == '&' ||
(n && newname[n-1] == '+' && (signed char)*s > 0 && isalnum(*s)))
*s == '%' ||
*s == '&' ||
(n && newname[n-1] == '+' && (signed char)*s > 0 && isalnum(*s)))
{
if (remainChars < 3)
break;
@ -3979,7 +3979,11 @@ void SV_AddToFatPVS(vec_t *org, mnode_t *node)
unsigned char* EXT_FUNC SV_FatPVS(float *org)
{
#ifdef REHLDS_FIXES
fatbytes = gPVSRowBytes;
#else // REHLDS_FIXES
fatbytes = (g_psv.worldmodel->numleafs + 31) >> 3;
#endif // REHLDS_FIXES
Q_memset(fatpvs, 0, fatbytes);
SV_AddToFatPVS(org, g_psv.worldmodel->nodes);
return fatpvs;
@ -4030,7 +4034,11 @@ void SV_AddToFatPAS(vec_t *org, mnode_t *node)
unsigned char* EXT_FUNC SV_FatPAS(float *org)
{
#ifdef REHLDS_FIXES
fatpasbytes = gPVSRowBytes;
#else // REHLDS_FIXES
fatpasbytes = (g_psv.worldmodel->numleafs + 31) >> 3;
#endif // REHLDS_FIXES
Q_memset(fatpas, 0, fatpasbytes);
SV_AddToFatPAS(org, g_psv.worldmodel->nodes);
return fatpas;
@ -6093,7 +6101,7 @@ void FilterToString(const ipfilter_t &f, char *s)
bool IsFilterIncludesAnotherFilter(const ipfilter_t &f, const ipfilter_t &f2)
{
return f2.mask >= f.mask
&& (f2.compare.u32 & f.mask) == f.compare.u32;
&& (f2.compare.u32 & f.mask) == f.compare.u32;
}
qboolean StringToFilter(const char *s, ipfilter_t *f)
@ -6775,10 +6783,10 @@ void SV_AddIP_f(void)
if (Cmd_Argc() != 3)
{
#ifdef REHLDS_FIXES
Con_Printf("Usage: addip <minutes> <ipaddress>\n\
addip <minutes> <ipaddress/CIDR>\n\
Use 0 minutes for permanent\n\
ipaddress A.B.C.D/24 is equivalent to A.B.C.0 and A.B.C\n");
Con_Printf("Usage: addip <minutes> <ipaddress>\n"
" addip <minutes> <ipaddress/CIDR>\n"
"Use 0 minutes for permanent\n"
"ipaddress A.B.C.D/24 is equivalent to A.B.C.0 and A.B.C\n");
#else // REHLDS_FIXES
Con_Printf("Usage: addip <minutes> <ipaddress>\nUse 0 minutes for permanent\n");
#endif // REHLDS_FIXES
@ -6876,9 +6884,9 @@ void SV_RemoveIP_f(void)
int argCount = Cmd_Argc();
if (argCount != 2 && argCount != 3)
{
Con_Printf("Usage: removeip <ipaddress> {removeAll}\n\
removeip <ipaddress/CIDR> {removeAll}\n\
Use removeAll to delete all ip filters which ipaddress or ipaddress/CIDR includes\n");
Con_Printf("Usage: removeip <ipaddress> {removeAll}\n"
"removeip <ipaddress/CIDR> {removeAll}\n"
"Use removeAll to delete all ip filters which ipaddress or ipaddress/CIDR includes\n");
return;
}
@ -6889,10 +6897,10 @@ Use removeAll to delete all ip filters which ipaddress or ipaddress/CIDR include
if (!StringToFilter(Cmd_Argv(1), &f))
{
#ifdef REHLDS_FIXES
Con_Printf("Invalid IP address\n\
Usage: removeip <ipaddress> {removeAll}\n\
removeip <ipaddress/CIDR> {removeAll}\n\
Use removeAll to delete all ip filters which ipaddress or ipaddress/CIDR includes\n");
Con_Printf("Invalid IP address\n"
"Usage: removeip <ipaddress> {removeAll}\n"
" removeip <ipaddress/CIDR> {removeAll}\n"
"Use removeAll to delete all ip filters which ipaddress or ipaddress/CIDR includes\n");
#endif // REHLDS_FIXES
return;