diff options
author | Sergeanur <s.anureev@yandex.ua> | 2020-04-18 22:58:43 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2020-04-18 22:58:43 +0200 |
commit | fce2e02444a056cc420be6b32844de039fbfafac (patch) | |
tree | bd1aa187dd24640469ee956e7551341cc9819ad5 /src | |
parent | slider fix (diff) | |
download | re3-fce2e02444a056cc420be6b32844de039fbfafac.tar re3-fce2e02444a056cc420be6b32844de039fbfafac.tar.gz re3-fce2e02444a056cc420be6b32844de039fbfafac.tar.bz2 re3-fce2e02444a056cc420be6b32844de039fbfafac.tar.lz re3-fce2e02444a056cc420be6b32844de039fbfafac.tar.xz re3-fce2e02444a056cc420be6b32844de039fbfafac.tar.zst re3-fce2e02444a056cc420be6b32844de039fbfafac.zip |
Diffstat (limited to '')
-rw-r--r-- | src/save/GenericGameStorage.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/save/GenericGameStorage.cpp b/src/save/GenericGameStorage.cpp index 763f516a..5e483dc7 100644 --- a/src/save/GenericGameStorage.cpp +++ b/src/save/GenericGameStorage.cpp @@ -112,14 +112,22 @@ GenericSave(int file) // Save simple vars lastMissionPassed = TheText.Get(CStats::LastMissionPassedName); - if (*lastMissionPassed) { + if (lastMissionPassed[0] != '\0') { 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); int len = UnicodeStrlen(saveName); +#endif saveName[len] = '\0'; - if (len > 22) - TextCopy(saveName + 18, suffix); - saveName[23] = '\0'; + if (len > ARRAY_SIZE(saveName)-2) + TextCopy(&saveName[ARRAY_SIZE(saveName)-ARRAY_SIZE(suffix)], suffix); + saveName[ARRAY_SIZE(saveName)-1] = '\0'; } WriteDataToBufferPointer(buf, saveName); GetLocalTime(&saveTime); |