2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Fix crash COM_ListMaps (#791)

* Fix crash COM_ListMaps
This commit is contained in:
Juice 2020-11-12 01:40:08 +03:00 committed by GitHub
parent 543728dad2
commit 954ec3237c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2280,13 +2280,15 @@ void COM_ListMaps(char *pszSubString)
while (findfn != NULL)
{
Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn);
if (Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn) < ARRAYSIZE(curDir))
{
FS_GetLocalPath(curDir, curDir, ARRAYSIZE(curDir));
if (strstr(curDir, com_gamedir) && (!nSubStringLen || !Q_strnicmp(findfn, pszSubString, nSubStringLen)))
if (Q_strstr(curDir, com_gamedir) && (!nSubStringLen || !Q_strnicmp(findfn, pszSubString, nSubStringLen)))
{
if (Q_snprintf(pFileName, ARRAYSIZE(pFileName), "maps/%s", findfn) < ARRAYSIZE(pFileName))
{
Q_memset(&header, 0, sizeof(dheader_t));
Q_sprintf(pFileName, "maps/%s", findfn);
fp = FS_Open(pFileName, "rb");
@ -2298,6 +2300,16 @@ void COM_ListMaps(char *pszSubString)
COM_CheckPrintMap(&header, findfn, bShowOutdated != 0);
}
else
{
Con_Printf("Map name too long: %s\n", findfn);
}
}
}
else
{
Con_Printf("Map name too long: %s\n", findfn);
}
findfn = Sys_FindNext(NULL);
}