Enforce MAX_REASONLENGTH when reading ban.txt.

This commit is contained in:
toaster 2022-06-14 21:42:41 +01:00
parent 8addea0d45
commit cd6b1b2cd9

View file

@ -2761,9 +2761,9 @@ static void Command_ClearBans(void)
void D_LoadBan(boolean warning)
{
FILE *f;
size_t i;
const char *address, *mask;
const char *username, *reason;
size_t i, j;
char *address, *mask;
char *username, *reason;
time_t unbanTime = NO_BAN_TIME;
char buffer[MAX_WADPATH];
boolean banmode = 0;
@ -2817,6 +2817,19 @@ void D_LoadBan(boolean warning)
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);
if (I_SetUnbanTime)