[Scummvm-git-logs] scummvm master -> 0b07029274bda575b9df8e9d0f615a0f3af75c20

eriktorbjorn eriktorbjorn at telia.com
Sun Aug 6 20:06:35 CEST 2017


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:
0b07029274 QUEEN: Silence GCC 7 warnings about potential buffer overflow


Commit: 0b07029274bda575b9df8e9d0f615a0f3af75c20
    https://github.com/scummvm/scummvm/commit/0b07029274bda575b9df8e9d0f615a0f3af75c20
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2017-08-06T20:06:18+02:00

Commit Message:
QUEEN: Silence GCC 7 warnings about potential buffer overflow

Use snprintf() instead of sprintf() to limit how much is written
to the buffer. Note that there are other places where it looks
like it could overflow, but they did not trigger warnings and I'm
guessing that it doesn't overflow in reality.

Changed paths:
    engines/queen/command.cpp


diff --git a/engines/queen/command.cpp b/engines/queen/command.cpp
index 2a793a5..3866f6e 100644
--- a/engines/queen/command.cpp
+++ b/engines/queen/command.cpp
@@ -61,7 +61,7 @@ void CmdText::displayTemp(InkColor color, Verb v) {
 
 void CmdText::displayTemp(InkColor color, const char *name, bool outlined) {
 	char temp[MAX_COMMAND_LEN];
-	sprintf(temp, "%s %s", _command, name);
+	snprintf(temp, MAX_COMMAND_LEN, "%s %s", _command, name);
 	display(color, temp, outlined);
 }
 
@@ -87,7 +87,7 @@ public:
 	virtual void displayTemp(InkColor color, const char *name, bool outlined) {
 		char temp[MAX_COMMAND_LEN];
 
-		sprintf(temp, "%s %s", name, _command);
+		snprintf(temp, MAX_COMMAND_LEN, "%s %s", name, _command);
 		display(color, temp, outlined);
 	}
 
@@ -119,9 +119,9 @@ public:
 		char temp[MAX_COMMAND_LEN];
 		// don't show a space after the goto and give commands in the Greek version
 		if (_command[1] != (char)-34 && !(_command[1] == (char)-2 && strlen(_command) > 5))
-			sprintf(temp, "%s %s", _command, name);
+			snprintf(temp, MAX_COMMAND_LEN, "%s %s", _command, name);
 		else
-			sprintf(temp, "%s%s", _command, name);
+			snprintf(temp, MAX_COMMAND_LEN, "%s%s", _command, name);
 		display(color, temp, outlined);
 	}
 





More information about the Scummvm-git-logs mailing list