aboutsummaryrefslogtreecommitdiff
path: root/engines/cruise
diff options
context:
space:
mode:
authorStrangerke2014-05-31 01:34:59 +0200
committerStrangerke2014-05-31 01:35:33 +0200
commit59d072c40cd06e28e3b6e13311a9e74043fd72a4 (patch)
treed3c7dceafe79b1b8991c05f94cf1521c614586d5 /engines/cruise
parent8cbee1509606986584625c669fc992f084036b76 (diff)
downloadscummvm-rg350-59d072c40cd06e28e3b6e13311a9e74043fd72a4.tar.gz
scummvm-rg350-59d072c40cd06e28e3b6e13311a9e74043fd72a4.tar.bz2
scummvm-rg350-59d072c40cd06e28e3b6e13311a9e74043fd72a4.zip
CRUISE: Add safeguards to some more string manipulations
Diffstat (limited to 'engines/cruise')
-rw-r--r--engines/cruise/linker.cpp8
-rw-r--r--engines/cruise/overlay.cpp12
2 files changed, 9 insertions, 11 deletions
diff --git a/engines/cruise/linker.cpp b/engines/cruise/linker.cpp
index cb750b0ed2..883bad97d3 100644
--- a/engines/cruise/linker.cpp
+++ b/engines/cruise/linker.cpp
@@ -40,18 +40,18 @@ exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx, char *buffer
*out1 = 0;
*pExportedFuncionIdx = 0;
- strcpy(localBuffer, buffer);
+ Common::strlcpy(localBuffer, buffer, sizeof(localBuffer));
dotPtr = strchr(localBuffer, '.');
if (dotPtr) {
- strcpy(functionName, dotPtr + 1);
+ Common::strlcpy(functionName, dotPtr + 1, sizeof(functionName));
*dotPtr = 0;
strcpy(overlayName, localBuffer);
} else {
overlayName[0] = 0;
- strcpy(functionName, buffer);
+ Common::strlcpy(functionName, buffer, sizeof(functionName));
}
ptr2 = strchr((char *)functionName, ':');
@@ -89,7 +89,7 @@ exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx, char *buffer
char exportedName[256];
char *name = entity1Name + currentExportEntry->offsetToName;
- strcpy(exportedName, name);
+ Common::strlcpy(exportedName, name, sizeof(exportedName));
strToUpper(exportedName);
if (!strcmp(functionName, exportedName)) {
diff --git a/engines/cruise/overlay.cpp b/engines/cruise/overlay.cpp
index 61df716742..d2cc0f671b 100644
--- a/engines/cruise/overlay.cpp
+++ b/engines/cruise/overlay.cpp
@@ -159,7 +159,7 @@ int loadOverlay(const char *scriptName) {
return (-2);
if (scriptName != overlayTable[scriptIdx].overlayName)
- strcpy(overlayTable[scriptIdx].overlayName, scriptName);
+ Common::strlcpy(overlayTable[scriptIdx].overlayName, scriptName, sizeof(overlayTable[scriptIdx].overlayName));
overlayTable[scriptIdx].alreadyLoaded = 1;
@@ -167,9 +167,8 @@ int loadOverlay(const char *scriptName) {
overlayTable[scriptIdx].ovlData->scriptNumber = scriptIdx;
- strcpy(fileName, scriptName);
-
- strcat(fileName, ".OVL");
+ Common::strlcpy(fileName, scriptName, sizeof(fileName));
+ Common::strlcat(fileName, ".OVL", sizeof(fileName));
debug(1, "Attempting to load overlay file %s...", fileName);
@@ -550,9 +549,8 @@ int loadOverlay(const char *scriptName) {
//uint8 fileName[50];
//char* unpackedBuffer;
- strcpy(fileName, scriptName);
-
- strcat(fileName, ".FR");
+ Common::strlcpy(fileName, scriptName, sizeof(fileName));
+ Common::strlcat(fileName, ".FR", sizeof(fileName));
fileIdx = findFileInDisks(fileName);