aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/kyra/gui_lok.cpp3
-rw-r--r--engines/kyra/kyra_mr.cpp1
-rw-r--r--engines/kyra/sequences_lol.cpp2
-rw-r--r--engines/kyra/sound_digital.cpp1
-rw-r--r--engines/kyra/text_lok.cpp1
-rw-r--r--engines/kyra/text_mr.cpp6
6 files changed, 10 insertions, 4 deletions
diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp
index 2f79bb1d46..afc2c0bc47 100644
--- a/engines/kyra/gui_lok.cpp
+++ b/engines/kyra/gui_lok.cpp
@@ -749,6 +749,7 @@ int GUI_LoK::saveGame(Button *button) {
for (int i = 0; i < 5; i++) {
if (_menu[2].item[i].saveSlot == _vm->_gameToLoad) {
strncpy(_savegameName, _menu[2].item[i].itemString, 31);
+ _savegameName[30] = 0;
break;
}
}
@@ -757,7 +758,7 @@ int GUI_LoK::saveGame(Button *button) {
_screen->setFont(cf);
- while (_displaySubMenu && !_vm->shouldQuit()) {
+ while (_displaySubMenu && !_vm->shouldQuit()) {
checkTextfieldInput();
cf = _screen->setFont(Screen::FID_8_FNT);
updateSavegameString();
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index 78db980dee..a450c14c29 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -1319,6 +1319,7 @@ int KyraEngine_MR::loadLanguageFile(const char *file, uint8 *&buffer) {
uint32 size = 0;
char nBuf[32];
strncpy(nBuf, file, 32);
+ nBuf[31] = 0;
buffer = _res->fileData(appendLanguage(nBuf, _lang, sizeof(nBuf)), &size);
return buffer ? size : 0 ;
diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp
index ca5c09acb7..236a559816 100644
--- a/engines/kyra/sequences_lol.cpp
+++ b/engines/kyra/sequences_lol.cpp
@@ -772,7 +772,7 @@ void HistoryPlayer::play() {
char tempWsaFilename[16];
char voiceFilename[13];
// the 'a' *has* to be lowercase
- strncpy(voiceFilename, "PS_1a", sizeof(voiceFilename));
+ strcpy(voiceFilename, "PS_1a");
int part = 0;
Sound *sound = _vm->sound();
diff --git a/engines/kyra/sound_digital.cpp b/engines/kyra/sound_digital.cpp
index 314d45299a..7f659e914e 100644
--- a/engines/kyra/sound_digital.cpp
+++ b/engines/kyra/sound_digital.cpp
@@ -459,6 +459,7 @@ int SoundDigital::playSound(const char *filename, uint8 priority, Audio::Mixer::
}
strncpy(use->filename, filename, sizeof(use->filename));
+ use->filename[sizeof(use->filename) - 1] = 0;
use->priority = priority;
Audio::SeekableAudioStream *audioStream = _supportedCodecs[usedCodec].streamFunc(stream, DisposeAfterUse::YES);
if (!audioStream) {
diff --git a/engines/kyra/text_lok.cpp b/engines/kyra/text_lok.cpp
index 266553cdea..874ce387e9 100644
--- a/engines/kyra/text_lok.cpp
+++ b/engines/kyra/text_lok.cpp
@@ -349,6 +349,7 @@ void KyraEngine_LoK::drawSentenceCommand(const char *sentence, int color) {
void KyraEngine_LoK::updateSentenceCommand(const char *str1, const char *str2, int color) {
char sentenceCommand[500];
strncpy(sentenceCommand, str1, 500);
+ sentenceCommand[499] = 0;
if (str2)
strncat(sentenceCommand, str2, 500 - strlen(sentenceCommand));
diff --git a/engines/kyra/text_mr.cpp b/engines/kyra/text_mr.cpp
index 57b1d83137..ea2dc48031 100644
--- a/engines/kyra/text_mr.cpp
+++ b/engines/kyra/text_mr.cpp
@@ -34,8 +34,10 @@ TextDisplayer_MR::TextDisplayer_MR(KyraEngine_MR *vm, Screen_MR *screen)
}
char *TextDisplayer_MR::preprocessString(const char *str) {
- if (_talkBuffer != str)
- strncpy(_talkBuffer, str, sizeof(_talkBuffer));
+ if (_talkBuffer != str) {
+ assert(strlen(str) < sizeof(_talkBuffer) - 1);
+ strcpy(_talkBuffer, str);
+ }
char *p = _talkBuffer;
while (*p) {