mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-23 09:30:00 +00:00
Fix savename buffer overflow
This commit is contained in:
parent
9bfcaff849
commit
fce2e02444
|
@ -112,14 +112,22 @@ GenericSave(int file)
|
||||||
|
|
||||||
// Save simple vars
|
// Save simple vars
|
||||||
lastMissionPassed = TheText.Get(CStats::LastMissionPassedName);
|
lastMissionPassed = TheText.Get(CStats::LastMissionPassedName);
|
||||||
if (*lastMissionPassed) {
|
if (lastMissionPassed[0] != '\0') {
|
||||||
AsciiToUnicode("...'", suffix);
|
AsciiToUnicode("...'", suffix);
|
||||||
|
#ifdef FIX_BUGS
|
||||||
|
// fix buffer overflow
|
||||||
|
int len = UnicodeStrlen(lastMissionPassed);
|
||||||
|
if (len > ARRAY_SIZE(saveName)-1)
|
||||||
|
len = ARRAY_SIZE(saveName)-1;
|
||||||
|
memcpy(saveName, lastMissionPassed, sizeof(wchar) * len);
|
||||||
|
#else
|
||||||
TextCopy(saveName, lastMissionPassed);
|
TextCopy(saveName, lastMissionPassed);
|
||||||
int len = UnicodeStrlen(saveName);
|
int len = UnicodeStrlen(saveName);
|
||||||
|
#endif
|
||||||
saveName[len] = '\0';
|
saveName[len] = '\0';
|
||||||
if (len > 22)
|
if (len > ARRAY_SIZE(saveName)-2)
|
||||||
TextCopy(saveName + 18, suffix);
|
TextCopy(&saveName[ARRAY_SIZE(saveName)-ARRAY_SIZE(suffix)], suffix);
|
||||||
saveName[23] = '\0';
|
saveName[ARRAY_SIZE(saveName)-1] = '\0';
|
||||||
}
|
}
|
||||||
WriteDataToBufferPointer(buf, saveName);
|
WriteDataToBufferPointer(buf, saveName);
|
||||||
GetLocalTime(&saveTime);
|
GetLocalTime(&saveTime);
|
||||||
|
|
Loading…
Reference in a new issue