mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
CRUISE: Don't use unsafe strcat and strcpy
This commit is contained in:
parent
c618b7fe91
commit
f2ddbbea91
@ -138,7 +138,7 @@ backgroundIncrustStruct *addBackgroundIncrust(int16 overlayIdx, int16 objectIdx,
|
||||
newElement->frame = params.fileIdx;
|
||||
newElement->spriteId = filesDatabase[params.fileIdx].subData.index;
|
||||
newElement->ptr = nullptr;
|
||||
strcpy(newElement->name, filesDatabase[params.fileIdx].subData.name);
|
||||
Common::strcpy_s(newElement->name, filesDatabase[params.fileIdx].subData.name);
|
||||
|
||||
if (filesDatabase[params.fileIdx].subData.resourceType == OBJ_TYPE_SPRITE) {
|
||||
// sprite
|
||||
|
@ -309,18 +309,18 @@ void printInfoBlackBox(const char *string) {
|
||||
void waitForPlayerInput() {
|
||||
}
|
||||
|
||||
void getFileExtention(const char *name, char *buffer) {
|
||||
void getFileExtention(const char *name, char *buffer, size_t ln) {
|
||||
while (*name != '.' && *name) {
|
||||
name++;
|
||||
}
|
||||
|
||||
strcpy(buffer, name);
|
||||
Common::strcpy_s(buffer, ln, name);
|
||||
}
|
||||
|
||||
void removeExtention(const char *name, char *buffer) { // not like in original
|
||||
void removeExtention(const char *name, char *buffer, size_t ln) { // not like in original
|
||||
char *ptr;
|
||||
|
||||
strcpy(buffer, name);
|
||||
Common::strcpy_s(buffer, ln, name);
|
||||
|
||||
ptr = strchr(buffer, '.');
|
||||
|
||||
@ -344,19 +344,19 @@ int loadFileSub1(uint8 **ptr, const char *name, uint8 *ptr2) {
|
||||
}
|
||||
}
|
||||
|
||||
getFileExtention(name, buffer);
|
||||
getFileExtention(name, buffer, sizeof(buffer));
|
||||
|
||||
if (!strcmp(buffer, ".SPL")) {
|
||||
removeExtention(name, buffer);
|
||||
removeExtention(name, buffer, sizeof(buffer));
|
||||
|
||||
/* if (useH32)
|
||||
*{
|
||||
* strcat(buffer, ".H32");
|
||||
* Common::strcat_s(buffer,".H32");
|
||||
*}
|
||||
* else
|
||||
* if (useAdLib)
|
||||
* { */
|
||||
strcat(buffer,".ADL");
|
||||
Common::strcat_s(buffer,".ADL");
|
||||
/* }
|
||||
* else
|
||||
* {
|
||||
@ -563,7 +563,7 @@ void CruiseEngine::initAllData() {
|
||||
scriptFunc2(bootOverlayNumber, &procHead, 1, 0);
|
||||
}
|
||||
|
||||
strcpy(lastOverlay, "AUTO00");
|
||||
Common::strcpy_s(lastOverlay, "AUTO00");
|
||||
|
||||
_gameSpeed = GAME_FRAME_DELAY_1;
|
||||
_speedFlag = false;
|
||||
@ -1622,9 +1622,9 @@ int CruiseEngine::processInput() {
|
||||
changeCursor(CURSOR_NORMAL);
|
||||
} else { // else create the message for the linked relation
|
||||
char text[80];
|
||||
strcpy(text, menuTable[0]->stringPtr);
|
||||
strcat(text, ":");
|
||||
strcat(text, currentMenuElement->string);
|
||||
Common::strcpy_s(text, menuTable[0]->stringPtr);
|
||||
Common::strcat_s(text, ":");
|
||||
Common::strcat_s(text, currentMenuElement->string);
|
||||
linkedMsgList = renderText(320, (const char *)text);
|
||||
changeCursor(CURSOR_CROSS);
|
||||
}
|
||||
@ -1761,9 +1761,9 @@ void CruiseEngine::mainLoop() {
|
||||
|
||||
int enableUser = 0;
|
||||
|
||||
strcpy(nextOverlay, "");
|
||||
strcpy(lastOverlay, "");
|
||||
strcpy(cmdLine, "");
|
||||
nextOverlay[0] = '\0';
|
||||
lastOverlay[0] = '\0';
|
||||
cmdLine[0] = '\0';
|
||||
|
||||
currentActiveMenu = -1;
|
||||
autoMsg = -1;
|
||||
|
@ -94,9 +94,9 @@ void resetFileEntryRange(int param1, int param2);
|
||||
int getProcParam(int overlayIdx, int param2, const char * name);
|
||||
void changeScriptParamInList(int param1, int param2, scriptInstanceStruct * pScriptInstance, int newValue, int param3);
|
||||
uint8 *getDataFromData3(ovlData3Struct * ptr, int param);
|
||||
void removeExtention(const char *name, char *buffer);
|
||||
void removeExtention(const char *name, char *buffer, size_t ln);
|
||||
void resetPtr2(scriptInstanceStruct * ptr);
|
||||
void getFileExtention(const char *name, char *buffer);
|
||||
void getFileExtention(const char *name, char *buffer, size_t ln);
|
||||
void *allocAndZero(int size);
|
||||
void freeStuff2();
|
||||
void mainLoop();
|
||||
|
@ -216,7 +216,7 @@ fileTypeEnum getFileType(const char *name) {
|
||||
|
||||
fileTypeEnum newFileType = type_UNK;
|
||||
|
||||
getFileExtention(name, extentionBuffer);
|
||||
getFileExtention(name, extentionBuffer, sizeof(extentionBuffer));
|
||||
|
||||
if (!strcmp(extentionBuffer, ".SPL")) {
|
||||
newFileType = type_SPL;
|
||||
|
@ -297,12 +297,13 @@ void addDecomp(char *string, ...) {
|
||||
|
||||
void resolveVarName(char *ovlIdxString, int varType, char *varIdxString,
|
||||
char *outputName) {
|
||||
// outputName is 256 length
|
||||
int varIdx = atoi(varIdxString);
|
||||
|
||||
strcpy(outputName, "");
|
||||
outputName[0] = '\0';
|
||||
|
||||
if (varType == 2) {
|
||||
strcpy(outputName, getStringNameFromIdx(varType,
|
||||
Common::strlcpy(outputName, 256, getStringNameFromIdx(varType,
|
||||
varIdxString));
|
||||
return;
|
||||
}
|
||||
@ -333,7 +334,7 @@ void resolveVarName(char *ovlIdxString, int varType, char *varIdxString,
|
||||
sprintf(outputName, "ovl(%s).[%d][%s]", ovlIdxString, varType,
|
||||
varIdxString);
|
||||
} else {
|
||||
strcpy(outputName, ovlIdxString);
|
||||
Common::strcpy_s(outputName, 256, ovlIdxString);
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,7 +452,7 @@ int decompSaveVar() {
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
strcpy(decompSaveOpcodeVar, popDecomp());
|
||||
Common::strcpy_s(decompSaveOpcodeVar, popDecomp());
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
@ -685,8 +686,8 @@ int decompSwapStack() {
|
||||
stack1 = popDecomp();
|
||||
stack2 = popDecomp();
|
||||
|
||||
strcpy(buffer1, stack1);
|
||||
strcpy(buffer2, stack2);
|
||||
Common::strcpy_s(buffer1, stack1);
|
||||
Common::strcpy_s(buffer2, stack2);
|
||||
|
||||
pushDecomp(buffer1);
|
||||
pushDecomp(buffer2);
|
||||
@ -722,7 +723,7 @@ int decompFunction() {
|
||||
|
||||
case 0x6: {
|
||||
unsigned long int numArg = atoi(popDecomp());
|
||||
char functionName[100];
|
||||
char functionName[256];
|
||||
|
||||
char *idxStr = popDecomp();
|
||||
char *ovlStr = popDecomp();
|
||||
|
@ -146,7 +146,7 @@ void initSystem() {
|
||||
subColor = 10;
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
strcpy(preloadData[i].name, "");
|
||||
preloadData[i].name[0] = '\0';
|
||||
preloadData[i].ptr = nullptr;
|
||||
preloadData[i].nofree = 0;
|
||||
}
|
||||
@ -161,7 +161,7 @@ void initSystem() {
|
||||
changeCursor(CURSOR_NORMAL);
|
||||
mouseOn();
|
||||
|
||||
strcpy(cmdLine, "");
|
||||
cmdLine[0] = '\0';
|
||||
|
||||
loadFNT("system.fnt");
|
||||
}
|
||||
|
@ -19,6 +19,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// For Op_BgName
|
||||
#define FORBIDDEN_SYMBOL_EXCEPTION_strcpy
|
||||
|
||||
#include "cruise/cruise.h"
|
||||
#include "cruise/cruise_main.h"
|
||||
#include "cruise/cell.h"
|
||||
@ -46,7 +49,7 @@ int16 Op_LoadOverlay() {
|
||||
if (strlen(pOverlayName) == 0)
|
||||
return 0;
|
||||
|
||||
strcpy(overlayName, pOverlayName);
|
||||
Common::strcpy_s(overlayName, pOverlayName);
|
||||
strToUpper(overlayName);
|
||||
|
||||
//gfxModuleData.field_84();
|
||||
@ -790,7 +793,7 @@ int16 Op_ClearScreen() {
|
||||
if ((bgIdx >= 0) && (bgIdx < NBSCREENS) && (backgroundScreens[bgIdx])) {
|
||||
memset(backgroundScreens[bgIdx], 0, 320 * 200);
|
||||
backgroundChanged[bgIdx] = true;
|
||||
strcpy(backgroundTable[0].name, "");
|
||||
backgroundTable[0].name[0] = '\0';
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -944,9 +947,9 @@ int16 Op_RemoveBackground() {
|
||||
backgroundChanged[0] = true;
|
||||
}
|
||||
|
||||
strcpy(backgroundTable[backgroundIdx].name, "");
|
||||
backgroundTable[backgroundIdx].name[0] = '\0';
|
||||
} else {
|
||||
strcpy(backgroundTable[0].name, "");
|
||||
backgroundTable[0].name[0] = '\0';
|
||||
}
|
||||
|
||||
return (0);
|
||||
@ -1524,11 +1527,9 @@ int16 Op_Itoa() {
|
||||
sprintf(txt, "%d", val);
|
||||
else {
|
||||
char format[30];
|
||||
char nbf[20];
|
||||
strcpy(format, "%");
|
||||
sprintf(nbf, "%d", param[0]);
|
||||
strcat(format, nbf);
|
||||
strcat(format, "d");
|
||||
format[0] = '%';
|
||||
sprintf(&format[1], "%d", param[0]);
|
||||
Common::strcat_s(format, "d");
|
||||
sprintf(txt, format, val);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ exportEntryStruct *parseExport(int *out1, int *pExportedFuncionIdx, char *buffer
|
||||
Common::strlcpy(functionName, dotPtr + 1, sizeof(functionName));
|
||||
*dotPtr = 0;
|
||||
|
||||
strcpy(overlayName, localBuffer);
|
||||
Common::strcpy_s(overlayName, localBuffer);
|
||||
} else {
|
||||
overlayName[0] = 0;
|
||||
|
||||
|
@ -51,7 +51,7 @@ void freeCTP() {
|
||||
ctpVar17 = nullptr;
|
||||
_vm->_polyStruct = nullptr;
|
||||
|
||||
strcpy((char *)currentCtpName, "");
|
||||
currentCtpName[0] = '\0';
|
||||
}
|
||||
|
||||
int pathVar0;
|
||||
|
@ -71,7 +71,7 @@ WARN_UNUSED_RESULT bool readSavegameHeader(Common::InSaveFile *in, CruiseSavegam
|
||||
void writeSavegameHeader(Common::OutSaveFile *out, CruiseSavegameHeader &header) {
|
||||
// Write out a savegame header
|
||||
char saveIdentBuffer[6];
|
||||
strcpy(saveIdentBuffer, "SVMCR");
|
||||
Common::strcpy_s(saveIdentBuffer, "SVMCR");
|
||||
out->write(saveIdentBuffer, 6);
|
||||
|
||||
out->writeByte(CRUISE_SAVEGAME_VERSION);
|
||||
@ -645,7 +645,7 @@ void resetPreload() {
|
||||
MemFree(preloadData[i].ptr);
|
||||
preloadData[i].ptr = nullptr;
|
||||
}
|
||||
strcpy(preloadData[i].name, "");
|
||||
preloadData[i].name[0] = '\0';
|
||||
preloadData[i].nofree = 0;
|
||||
}
|
||||
}
|
||||
@ -654,7 +654,7 @@ void resetPreload() {
|
||||
void unloadOverlay(const char*name, int overlayNumber) {
|
||||
releaseOverlay(name);
|
||||
|
||||
strcpy(overlayTable[overlayNumber].overlayName, "");
|
||||
overlayTable[overlayNumber].overlayName[0] = '\0';
|
||||
overlayTable[overlayNumber].ovlData = nullptr;
|
||||
overlayTable[overlayNumber].alreadyLoaded = 0;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ int closeBase() {
|
||||
|
||||
MemFree(volumePtrToFileDescriptor);
|
||||
|
||||
strcpy(currentBaseName, "");
|
||||
currentBaseName[0] = '\0';
|
||||
}
|
||||
|
||||
if (_vm->_PAL_file.isOpen()) {
|
||||
@ -91,7 +91,7 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
|
||||
|
||||
askDisk(-1);
|
||||
|
||||
strcpy(buffer, entry->ident);
|
||||
Common::strcpy_s(buffer, entry->ident);
|
||||
|
||||
_vm->_currentVolumeFile.open(buffer);
|
||||
|
||||
@ -125,7 +125,7 @@ int getVolumeDataEntry(volumeDataStruct *entry) {
|
||||
volumePtrToFileDescriptor[i].unk3 = _vm->_currentVolumeFile.readSint32BE();
|
||||
}
|
||||
|
||||
strcpy(currentBaseName, entry->ident);
|
||||
Common::strcpy_s(currentBaseName, entry->ident);
|
||||
|
||||
loadPal(entry);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user