mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-28 04:00:41 +00:00
Enforce MAX_REASONLENGTH when reading ban.txt.
This commit is contained in:
parent
8addea0d45
commit
cd6b1b2cd9
1 changed files with 16 additions and 3 deletions
|
@ -2761,9 +2761,9 @@ static void Command_ClearBans(void)
|
||||||
void D_LoadBan(boolean warning)
|
void D_LoadBan(boolean warning)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
size_t i;
|
size_t i, j;
|
||||||
const char *address, *mask;
|
char *address, *mask;
|
||||||
const char *username, *reason;
|
char *username, *reason;
|
||||||
time_t unbanTime = NO_BAN_TIME;
|
time_t unbanTime = NO_BAN_TIME;
|
||||||
char buffer[MAX_WADPATH];
|
char buffer[MAX_WADPATH];
|
||||||
boolean banmode = 0;
|
boolean banmode = 0;
|
||||||
|
@ -2817,6 +2817,19 @@ void D_LoadBan(boolean warning)
|
||||||
reason = strtok(NULL, "\"\r\n"); // go until next "
|
reason = strtok(NULL, "\"\r\n"); // go until next "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enforce MAX_REASONLENGTH.
|
||||||
|
if (reason)
|
||||||
|
{
|
||||||
|
j = 0;
|
||||||
|
while (reason[j] != '\0')
|
||||||
|
{
|
||||||
|
if ((j++) < MAX_REASONLENGTH)
|
||||||
|
continue;
|
||||||
|
reason[j] = '\0';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
I_SetBanAddress(address, mask);
|
I_SetBanAddress(address, mask);
|
||||||
|
|
||||||
if (I_SetUnbanTime)
|
if (I_SetUnbanTime)
|
||||||
|
|
Loading…
Reference in a new issue