[Scummvm-git-logs] scummvm master -> 55136a8f7e2ae07e0937464b359f48a6ddc98263
antoniou79
a.antoniou79 at gmail.com
Tue Jul 21 13:59:27 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
55136a8f7e SKY: Prevent manual save to slot 0
Commit: 55136a8f7e2ae07e0937464b359f48a6ddc98263
https://github.com/scummvm/scummvm/commit/55136a8f7e2ae07e0937464b359f48a6ddc98263
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2020-07-21T16:57:38+03:00
Commit Message:
SKY: Prevent manual save to slot 0
Slot 0 is reserved for autosave but ScummVM in-game would allow saving on it
This was causing segmentation fault (_selectedGame would overflow and also saveGameTexts would be indexed with a -1 index
Changed paths:
engines/sky/control.cpp
engines/sky/detection.cpp
engines/sky/sky.cpp
diff --git a/engines/sky/control.cpp b/engines/sky/control.cpp
index ec8eac003f..07a56cef7b 100644
--- a/engines/sky/control.cpp
+++ b/engines/sky/control.cpp
@@ -1140,7 +1140,7 @@ void Control::saveDescriptions(const Common::StringArray &list) {
outf = _saveFileMan->openForSaving("SKY-VM.SAV");
bool ioFailed = true;
- if (outf) {
+ if (outf != nullptr) {
for (uint16 cnt = 0; cnt < MAX_SAVE_GAMES; cnt++) {
outf->write(list[cnt].c_str(), list[cnt].size() + 1);
}
@@ -1162,7 +1162,7 @@ uint16 Control::saveGameToFile(bool fromControlPanel, const char *filename, bool
Common::OutSaveFile *outf;
outf = _saveFileMan->openForSaving(filename);
- if (outf == NULL)
+ if (outf == nullptr)
return NO_DISK_SPACE;
if (!fromControlPanel) {
diff --git a/engines/sky/detection.cpp b/engines/sky/detection.cpp
index 16275cfe26..60224e2d0a 100644
--- a/engines/sky/detection.cpp
+++ b/engines/sky/detection.cpp
@@ -385,6 +385,13 @@ Common::Error SkyEngine::loadGameState(int slot) {
}
Common::Error SkyEngine::saveGameState(int slot, const Common::String &desc, bool isAutosave) {
+ // prevent writing to autosave slot when user selects it manually
+ // ie. from the ScummVM in-game menu Save panel
+ // This also secures _selectedGame which is unsigned integer (uint16)
+ // from overflowing in the subtraction below
+ if (!isAutosave && slot <= 0) {
+ return Common::kWritePermissionDenied;
+ }
// Set the save slot and save the game
_skyControl->_selectedGame = isAutosave ? 0 : slot - 1;
if (_skyControl->saveGameToFile(false, nullptr, isAutosave) != GAME_SAVED)
diff --git a/engines/sky/sky.cpp b/engines/sky/sky.cpp
index 7e86ee7a5c..d8fc9c4b02 100644
--- a/engines/sky/sky.cpp
+++ b/engines/sky/sky.cpp
@@ -171,7 +171,7 @@ Common::Error SkyEngine::go() {
uint16 result = 0;
if (ConfMan.hasKey("save_slot")) {
int saveSlot = ConfMan.getInt("save_slot");
- if (saveSlot >= 0 && saveSlot <= 999)
+ if (saveSlot >= 0 && saveSlot <= MAX_SAVE_GAMES)
result = _skyControl->quickXRestore(ConfMan.getInt("save_slot"));
}
More information about the Scummvm-git-logs
mailing list