- Fix potential out-of-bounds read in files.c, fix by using new FS_IsExt

- Add capability to load demos with com_protocol suffix, partially applied patches from Simon McVittie
- Fix demo loading if protocol number has more digits than 2
- Minor refactoring, replace all occurances of suffix "dm_" with global macro DEMOEXT
This commit is contained in:
Thilo Schulz 2011-03-07 22:08:48 +00:00
parent fef4d12d68
commit c0cca7a0a8
6 changed files with 125 additions and 48 deletions

View file

@ -162,7 +162,7 @@ void UI_LoadBestScores(const char *map, int game) {
}
UI_SetBestScores(&newInfo, qfalse);
Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.dm_%d", map, game, (int)trap_Cvar_VariableValue("protocol"));
Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.%s%d", map, game, DEMOEXT, (int)trap_Cvar_VariableValue("protocol"));
uiInfo.demoAvailable = qfalse;
if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) {
uiInfo.demoAvailable = qtrue;

View file

@ -2877,11 +2877,11 @@ static void UI_LoadDemos( void ) {
char *demoname;
int i, len;
Com_sprintf(demoExt, sizeof(demoExt), "dm_%d", (int)trap_Cvar_VariableValue("protocol"));
Com_sprintf(demoExt, sizeof(demoExt), "%s%d", DEMOEXT, (int)trap_Cvar_VariableValue("protocol"));
uiInfo.demoCount = trap_FS_GetFileList( "demos", demoExt, demolist, 4096 );
Com_sprintf(demoExt, sizeof(demoExt), ".dm_%d", (int)trap_Cvar_VariableValue("protocol"));
Com_sprintf(demoExt, sizeof(demoExt), ".%s%d", DEMOEXT, (int)trap_Cvar_VariableValue("protocol"));
if (uiInfo.demoCount) {
if (uiInfo.demoCount > MAX_DEMOS) {