aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/file.cpp4
-rw-r--r--engines/sci/engine/file.h2
-rw-r--r--engines/sci/engine/kfile.cpp6
3 files changed, 8 insertions, 4 deletions
diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index 2128433b90..7e218bc81c 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -371,7 +371,9 @@ bool fillSavegameDesc(const Common::String &filename, SavegameDesc *desc) {
if (meta.name.lastChar() == '\n')
meta.name.deleteLastChar();
- Common::strlcpy(desc->name, meta.name.c_str(), SCI_MAX_SAVENAME_LENGTH);
+ // At least Phant2 requires use of strncpy, since it creates save game
+ // names of exactly SCI_MAX_SAVENAME_LENGTH
+ strncpy(desc->name, meta.name.c_str(), SCI_MAX_SAVENAME_LENGTH);
return desc;
}
diff --git a/engines/sci/engine/file.h b/engines/sci/engine/file.h
index fee628aad5..1657dd3c7c 100644
--- a/engines/sci/engine/file.h
+++ b/engines/sci/engine/file.h
@@ -35,7 +35,7 @@ enum kFileOpenMode {
};
enum {
- SCI_MAX_SAVENAME_LENGTH = 36, ///< Maximum length of a savegame name (including terminator character).
+ SCI_MAX_SAVENAME_LENGTH = 36, ///< Maximum length of a savegame name (including optional terminator character).
MAX_SAVEGAME_NR = 20 ///< Maximum number of savegames
};
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 1a6695f882..eb6cacbe19 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -426,7 +426,7 @@ reg_t kFileIOOpen(EngineState *s, int argc, reg_t *argv) {
byte *out = buffer;
for (uint i = 0; i < numSaves; ++i) {
WRITE_UINT16(out, saves[i].id - kSaveIdShift);
- Common::strlcpy((char *)out + sizeof(int16), saves[i].name, SCI_MAX_SAVENAME_LENGTH);
+ strncpy((char *)out + sizeof(int16), saves[i].name, SCI_MAX_SAVENAME_LENGTH);
out += recordSize;
}
WRITE_UINT16(out, 0xFFFF);
@@ -1372,7 +1372,9 @@ reg_t kGetSaveFiles32(EngineState *s, int argc, reg_t *argv) {
for (uint i = 0; i < saves.size(); ++i) {
const SavegameDesc &save = saves[i];
char *target = &descriptions.charAt(SCI_MAX_SAVENAME_LENGTH * i);
- Common::strlcpy(target, save.name, SCI_MAX_SAVENAME_LENGTH);
+ // At least Phant2 requires use of strncpy, since it creates save game
+ // names of exactly SCI_MAX_SAVENAME_LENGTH
+ strncpy(target, save.name, SCI_MAX_SAVENAME_LENGTH);
saveIds.setFromInt16(i, save.id - kSaveIdShift);
}