From 52caebf8aff93333ed811fb6b1493abbaa6a43a1 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 2 Oct 2022 19:10:02 +0200 Subject: [PATCH] TINSEL: Don't use unsafe strcat and strcpy --- engines/tinsel/drives.cpp | 2 +- engines/tinsel/strres.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engines/tinsel/drives.cpp b/engines/tinsel/drives.cpp index 1ab7ef4ddde..931b2766fb3 100644 --- a/engines/tinsel/drives.cpp +++ b/engines/tinsel/drives.cpp @@ -193,7 +193,7 @@ bool TinselFile::open(const Common::String &filename) { // Form a filename without the CD number character char newFilename[50]; strncpy(newFilename, fname, p - fname); - strcpy(newFilename + (p - fname), p + 1); + Common::strcpy_s(newFilename + (p - fname), sizeof(newFilename) - (p - fname), p + 1); return openInternal(newFilename); } diff --git a/engines/tinsel/strres.cpp b/engines/tinsel/strres.cpp index 737d25060f9..dd3582dd1d1 100644 --- a/engines/tinsel/strres.cpp +++ b/engines/tinsel/strres.cpp @@ -234,7 +234,7 @@ int LoadStringResource(int id, int sub, char *pBuffer, int bufferMax) { byte *pText = FindStringBase(id); if (pText == NULL) { - strcpy(pBuffer, "!! HIGH STRING !!"); + Common::strcpy_s(pBuffer, bufferMax, "!! HIGH STRING !!"); return 0; } @@ -310,7 +310,7 @@ int LoadStringResource(int id, int sub, char *pBuffer, int bufferMax) { } // TEMPORARY DIRTY BODGE - strcpy(pBuffer, "!! NULL STRING !!"); + Common::strcpy_s(pBuffer, bufferMax, "!! NULL STRING !!"); // string does not exist return 0;