2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-28 15:45:46 +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,23 +2280,35 @@ void COM_ListMaps(char *pszSubString)
while (findfn != NULL)
{
Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn);
FS_GetLocalPath(curDir, curDir, ARRAYSIZE(curDir));
if (strstr(curDir, com_gamedir) && (!nSubStringLen || !Q_strnicmp(findfn, pszSubString, nSubStringLen)))
if (Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn) < ARRAYSIZE(curDir))
{
Q_memset(&header, 0, sizeof(dheader_t));
Q_sprintf(pFileName, "maps/%s", findfn);
FS_GetLocalPath(curDir, curDir, ARRAYSIZE(curDir));
fp = FS_Open(pFileName, "rb");
if (fp)
if (Q_strstr(curDir, com_gamedir) && (!nSubStringLen || !Q_strnicmp(findfn, pszSubString, nSubStringLen)))
{
FS_Read(&header, sizeof(dheader_t), 1, fp);
FS_Close(fp);
}
if (Q_snprintf(pFileName, ARRAYSIZE(pFileName), "maps/%s", findfn) < ARRAYSIZE(pFileName))
{
Q_memset(&header, 0, sizeof(dheader_t));
COM_CheckPrintMap(&header, findfn, bShowOutdated != 0);
fp = FS_Open(pFileName, "rb");
if (fp)
{
FS_Read(&header, sizeof(dheader_t), 1, fp);
FS_Close(fp);
}
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);