hotfix for potential buffer-overflow

This commit is contained in:
condret 2017-04-23 22:07:28 +00:00
parent d3b459ba0d
commit 63b0760329
1 changed files with 3 additions and 0 deletions

View File

@ -2079,6 +2079,8 @@ bool cheatsImportGSACodeFile(const char* name, int game, bool v3)
fread(&codes, 1, 4, f);
while (codes > 0) {
fread(&len, 1, 4, f);
if (len > 255)
goto evil_gsa_code_file; //XXX: this functione needs a rewrite in general, so for the short this is better than nothing
fread(desc, 1, len, f);
desc[len] = 0;
desc[31] = 0;
@ -2098,6 +2100,7 @@ bool cheatsImportGSACodeFile(const char* name, int game, bool v3)
codes--;
}
}
evil_gsa_code_file:
fclose(f);
return true;
}