[Scummvm-git-logs] scummvm master -> 801266eca5bd909c0a3d6215112ed1a1e2e07ba5

sev- noreply at scummvm.org
Mon Dec 20 23:22:16 UTC 2021


This automated email contains information about 9 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5596dcd6f8 SCUMM: IMUSE: Fix incorrect string copy
9804ae380d STARTREK: Fix loading of MIDI music
913d943a09 SCI: Use safer string copying
20b55693f3 TWINE: Use safer string copying
6d101d2113 GLK: LEVEL9: Use safer operations for storing ramsaves
eac751624c GLK: JACL: Avoid potential non-null-terminated string
1a312c252d GLK: HUGO: Use safer string copying
c947d71925 GLK: AGT: Use safer string copying
801266eca5 AGS: Use safer string copying


Commit: 5596dcd6f81e2af6b3087138f8de3f7d6c1f29c2
    https://github.com/scummvm/scummvm/commit/5596dcd6f81e2af6b3087138f8de3f7d6c1f29c2
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:53+01:00

Commit Message:
SCUMM: IMUSE: Fix incorrect string copy

Changed paths:
    engines/scumm/imuse_digi/dimuse_triggers.cpp


diff --git a/engines/scumm/imuse_digi/dimuse_triggers.cpp b/engines/scumm/imuse_digi/dimuse_triggers.cpp
index 2b21e72cd7..5723f3ab41 100644
--- a/engines/scumm/imuse_digi/dimuse_triggers.cpp
+++ b/engines/scumm/imuse_digi/dimuse_triggers.cpp
@@ -167,7 +167,7 @@ void IMuseDigiTriggersHandler::processTriggers(int soundId, char *marker) {
 		return;
 	}
 
-	Common::strlcpy(_textBuffer, marker, sizeof(marker));
+	Common::strlcpy(_textBuffer, marker, strlen(marker));
 	_midProcessing++;
 	for (int l = 0; l < DIMUSE_MAX_TRIGGERS; l++) {
 		if (!_trigs[l].sound || _trigs[l].sound != soundId || (_trigs[l].text[0] && strcmp(_textBuffer, _trigs[l].text))) {


Commit: 9804ae380da7e1616fc689c74b82f5a2c709a2a4
    https://github.com/scummvm/scummvm/commit/9804ae380da7e1616fc689c74b82f5a2c709a2a4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:53+01:00

Commit Message:
STARTREK: Fix loading of MIDI music

Changed paths:
    engines/startrek/sound.cpp
    engines/startrek/sound.h


diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp
index 08b1720ceb..294e7985ac 100644
--- a/engines/startrek/sound.cpp
+++ b/engines/startrek/sound.cpp
@@ -63,7 +63,8 @@ Sound::Sound(StarTrekEngine *vm) : _vm(vm) {
 	}
 
 	_soundHandle = new Audio::SoundHandle();
-	loadedSoundData = nullptr;
+	_loadedSoundData = nullptr;
+	_loadedSoundDataSize = 0;
 
 	for (int i = 1; i < NUM_MIDI_SLOTS; i++) {
 		_midiSlotList.push_back(&_midiSlots[i]);
@@ -84,7 +85,7 @@ Sound::~Sound() {
 		delete _midiSlots[i].midiParser;
 	delete _midiDriver;
 	delete _soundHandle;
-	delete[] loadedSoundData;
+	delete[] _loadedSoundData;
 }
 
 
@@ -102,13 +103,13 @@ void Sound::playMidiTrack(int track) {
 	if (_vm->getFeatures() & GF_DEMO)
 		return;
 
-	assert(loadedSoundData != nullptr);
+	assert(_loadedSoundData != nullptr);
 
 	// Check if a midi slot for this track exists already
 	for (int i = 1; i < NUM_MIDI_SLOTS; i++) {
 		if (_midiSlots[i].track == track) {
 			debugC(6, kDebugSound, "Playing MIDI track %d (slot %d)", track, i);
-			_midiSlots[i].midiParser->loadMusic(loadedSoundData, sizeof(loadedSoundData));
+			_midiSlots[i].midiParser->loadMusic(_loadedSoundData, _loadedSoundDataSize);
 			_midiSlots[i].midiParser->setTrack(track);
 
 			// Shift this to the back (most recently used)
@@ -126,14 +127,14 @@ void Sound::playMidiTrack(int track) {
 }
 
 void Sound::playMidiTrackInSlot(int slot, int track) {
-	assert(loadedSoundData != nullptr);
+	assert(_loadedSoundData != nullptr);
 	debugC(6, kDebugSound, "Playing MIDI track %d (slot %d)", track, slot);
 
 	clearMidiSlot(slot);
 
 	if (track != -1) {
 		_midiSlots[slot].track = track;
-		_midiSlots[slot].midiParser->loadMusic(loadedSoundData, sizeof(loadedSoundData));
+		_midiSlots[slot].midiParser->loadMusic(_loadedSoundData, _loadedSoundDataSize);
 		_midiSlots[slot].midiParser->setTrack(track);
 	}
 }
@@ -419,13 +420,14 @@ void Sound::loadPCMusicFile(const Common::String &baseSoundName) {
 	debugC(5, kDebugSound, "Loading midi \'%s\'\n", soundName.c_str());
 	Common::MemoryReadStreamEndian *soundStream = _vm->_resource->loadFile(soundName.c_str());
 
-	if (loadedSoundData != nullptr)
-		delete[] loadedSoundData;
-	loadedSoundData = new byte[soundStream->size()];
-	soundStream->read(loadedSoundData, soundStream->size());
+	if (_loadedSoundData != nullptr)
+		delete[] _loadedSoundData;
+	_loadedSoundDataSize = soundStream->size();
+	_loadedSoundData = new byte[_loadedSoundDataSize];
+	soundStream->read(_loadedSoundData, _loadedSoundDataSize);
 
 	// FIXME: should music start playing when this is called?
-	//_midiSlots[0].midiParser->loadMusic(loadedSoundData, soundStream->size());
+	//_midiSlots[0].midiParser->loadMusic(_loadedSoundData, soundStream->size());
 
 	delete soundStream;
 }
diff --git a/engines/startrek/sound.h b/engines/startrek/sound.h
index 0b9ef54fd4..15314f5b24 100644
--- a/engines/startrek/sound.h
+++ b/engines/startrek/sound.h
@@ -88,7 +88,8 @@ private:
 	MidiPlaybackSlot _midiSlots[NUM_MIDI_SLOTS]; // 0 is for music; 1-7 are for sfx
 	Common::List<MidiPlaybackSlot *> _midiSlotList; // Sorts midi slots by most recently used
 
-	byte *loadedSoundData;
+	byte *_loadedSoundData;
+	int _loadedSoundDataSize;
 	uint32 _midiDevice;
 
 	// VOC-related variables


Commit: 913d943a090746cf381d7227c0e0e28f053a0cb8
    https://github.com/scummvm/scummvm/commit/913d943a090746cf381d7227c0e0e28f053a0cb8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:53+01:00

Commit Message:
SCI: Use safer string copying

Changed paths:
    engines/sci/engine/file.cpp


diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index dbb2fa234a..01016e313a 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -345,7 +345,7 @@ bool fillSavegameDesc(const Common::String &filename, SavegameDesc &desc) {
 
 	// At least Phant2 requires use of strncpy, since it creates save game
 	// names of exactly kMaxSaveNameLength
-	strncpy(desc.name, nameString.c_str(), kMaxSaveNameLength);
+	Common::strlcpy(desc.name, nameString.c_str(), kMaxSaveNameLength);
 
 	return true;
 }


Commit: 20b55693f3d1fb1955bdf879bddc0835434530e7
    https://github.com/scummvm/scummvm/commit/20b55693f3d1fb1955bdf879bddc0835434530e7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:54+01:00

Commit Message:
TWINE: Use safer string copying

Changed paths:
    engines/twine/menu/menuoptions.cpp


diff --git a/engines/twine/menu/menuoptions.cpp b/engines/twine/menu/menuoptions.cpp
index a4483e0dec..9d4dc10c3b 100644
--- a/engines/twine/menu/menuoptions.cpp
+++ b/engines/twine/menu/menuoptions.cpp
@@ -431,7 +431,7 @@ bool MenuOptions::saveGameMenu() {
 		enterText(TextId::kEnterYourNewName, buf, sizeof(buf));
 		// may not be empty
 		if (buf[0] == '\0') {
-			strncpy(buf, _engine->_gameState->_sceneName, sizeof(buf));
+			Common::strlcpy(buf, _engine->_gameState->_sceneName, sizeof(buf));
 		}
 		Common::Error state = _engine->saveGameState(slot, buf, false);
 		if (state.getCode() != Common::kNoError) {


Commit: 6d101d211310ed5311cd42f0a6dbaa2394c6cc02
    https://github.com/scummvm/scummvm/commit/6d101d211310ed5311cd42f0a6dbaa2394c6cc02
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:54+01:00

Commit Message:
GLK: LEVEL9: Use safer operations for storing ramsaves

Changed paths:
    engines/glk/level9/level9_main.cpp


diff --git a/engines/glk/level9/level9_main.cpp b/engines/glk/level9/level9_main.cpp
index 5a6a4eb4d1..c192cbad83 100644
--- a/engines/glk/level9/level9_main.cpp
+++ b/engines/glk/level9/level9_main.cpp
@@ -1196,7 +1196,8 @@ void ramsave(int i) {
 	printf("driver - ramsave %d", i);
 #endif
 
-	memmove(ramsavearea + i, workspace.vartable, sizeof(SaveStruct));
+	memmove(ramsavearea[i].vartable, workspace.vartable, sizeof(workspace.vartable));
+	memmove(ramsavearea[i].listarea, workspace.listarea, sizeof(workspace.listarea));
 }
 
 void ramload(int i) {
@@ -1204,7 +1205,8 @@ void ramload(int i) {
 	printf("driver - ramload %d", i);
 #endif
 
-	memmove(workspace.vartable, ramsavearea + i, sizeof(SaveStruct));
+	memmove(workspace.vartable, ramsavearea[i].vartable, sizeof(workspace.vartable));
+	memmove(workspace.listarea, ramsavearea[i].listarea, sizeof(workspace.listarea));
 }
 
 void calldriver() {


Commit: eac751624cf8b6b5b0640bedf9c52c234189709d
    https://github.com/scummvm/scummvm/commit/eac751624cf8b6b5b0640bedf9c52c234189709d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:54+01:00

Commit Message:
GLK: JACL: Avoid potential non-null-terminated string

Changed paths:
    engines/glk/jacl/interpreter.cpp


diff --git a/engines/glk/jacl/interpreter.cpp b/engines/glk/jacl/interpreter.cpp
index a8ae09682b..6402db2a5c 100644
--- a/engines/glk/jacl/interpreter.cpp
+++ b/engines/glk/jacl/interpreter.cpp
@@ -2660,7 +2660,7 @@ void pop_stack() {
 	/* RESTORE THE CONTENTS OF called_name */
 	//for (counter = 0; counter < 256; counter++)
 	//called_name[counter] = backup[stack].called_name[counter];
-	strncpy(called_name, backup[stack].called_name, 1024);
+	strncpy(called_name, backup[stack].called_name, 1023);
 
 	/* RESTORE THE CONTENTS OF scope_criterion */
 	//for (counter = 0; counter < 21; counter++)
@@ -2746,7 +2746,7 @@ void push_stack(int32 file_pointer) {
 			backup[stack].text_buffer[counter] = text_buffer[counter];
 
 		/* MAKE A COPY OF THE CURRENT CONTENTS OF called_name */
-		strncpy(backup[stack].called_name, called_name, 1024);
+		strncpy(backup[stack].called_name, called_name, 1023);
 
 		// MAKE A COPY OF THE CURRENT CONTENTS OF scope_criterion
 		strncpy(backup[stack].scope_criterion, scope_criterion, 20);


Commit: 1a312c252d931415e19d59e4bde83d6d750266b3
    https://github.com/scummvm/scummvm/commit/1a312c252d931415e19d59e4bde83d6d750266b3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:54+01:00

Commit Message:
GLK: HUGO: Use safer string copying

Changed paths:
    engines/glk/hugo/heset.cpp


diff --git a/engines/glk/hugo/heset.cpp b/engines/glk/hugo/heset.cpp
index 3832224588..2c8d033c77 100644
--- a/engines/glk/hugo/heset.cpp
+++ b/engines/glk/hugo/heset.cpp
@@ -406,7 +406,7 @@ GetNextPropVal:
 				{
 					if (set_value==title_caption)
 					{
-						strncpy(game_title, GetWord(newp), MAX_GAME_TITLE);
+						Common::strlcpy(game_title, GetWord(newp), MAX_GAME_TITLE);
 						hugo_setgametitle(game_title);
 					}
 					else if (set_value==needs_repaint)


Commit: c947d71925e138c458665c20b4e46b321b3c2529
    https://github.com/scummvm/scummvm/commit/c947d71925e138c458665c20b4e46b321b3c2529
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:54+01:00

Commit Message:
GLK: AGT: Use safer string copying

Changed paths:
    engines/glk/agt/gamedata.cpp


diff --git a/engines/glk/agt/gamedata.cpp b/engines/glk/agt/gamedata.cpp
index 033070d88b..6fb0472e9e 100644
--- a/engines/glk/agt/gamedata.cpp
+++ b/engines/glk/agt/gamedata.cpp
@@ -824,7 +824,7 @@ void build_verblist(void) {
 
 	verblist = (words *)rmalloc(sizeof(words) * TOTAL_VERB);
 	for (i = 0; i < TOTAL_VERB; i++)
-		strncpy(verblist[i], dict[syntbl[auxsyn[i]]], sizeof(words));
+		Common::strlcpy(verblist[i], dict[syntbl[auxsyn[i]]], sizeof(words));
 #ifdef DUMP_VLIST
 	{
 		int j;


Commit: 801266eca5bd909c0a3d6215112ed1a1e2e07ba5
    https://github.com/scummvm/scummvm/commit/801266eca5bd909c0a3d6215112ed1a1e2e07ba5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2021-12-21T00:21:54+01:00

Commit Message:
AGS: Use safer string copying

Changed paths:
    engines/ags/engine/main/engine.cpp


diff --git a/engines/ags/engine/main/engine.cpp b/engines/ags/engine/main/engine.cpp
index d1eb3d5168..a1f6d4f3da 100644
--- a/engines/ags/engine/main/engine.cpp
+++ b/engines/ags/engine/main/engine.cpp
@@ -832,7 +832,7 @@ void engine_init_game_settings() {
 
 void engine_setup_scsystem_auxiliary() {
 	// ScriptSystem::aci_version is only 10 chars long
-	strncpy(_GP(scsystem).aci_version, _G(EngineVersion).LongString.GetCStr(), 10);
+	Common::strlcpy(_GP(scsystem).aci_version, _G(EngineVersion).LongString.GetCStr(), 10);
 	if (_GP(usetup).override_script_os >= 0) {
 		_GP(scsystem).os = _GP(usetup).override_script_os;
 	} else {




More information about the Scummvm-git-logs mailing list