From 14e3d1f343f035fc9ec9eafc746de5cffffd4d81 Mon Sep 17 00:00:00 2001 From: Le Philousophe Date: Sun, 23 Oct 2022 15:20:48 +0200 Subject: [PATCH] CGE: Don't use unsafe sprintf and vsprintf --- engines/cge/cge_main.cpp | 4 ++-- engines/cge/sound.cpp | 4 ++-- engines/cge/text.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp index 1463afd8bcd..5e4dc3559ec 100644 --- a/engines/cge/cge_main.cpp +++ b/engines/cge/cge_main.cpp @@ -547,7 +547,7 @@ void CGEEngine::setMapBrick(int x, int z) { Square *s = new Square(this); char n[6]; s->gotoxy(x * kMapGridX, kMapTop + z * kMapGridZ); - sprintf(n, "%02d:%02d", x, z); + Common::sprintf_s(n, "%02d:%02d", x, z); _clusterMap[z][x] = 1; s->setName(n); _vga->_showQ->insert(s, _vga->_showQ->first()); @@ -1448,7 +1448,7 @@ void CGEEngine::movie(const char *ext) { return; char fn[12]; - sprintf(fn, "CGE.%s", (*ext == '.') ? ext +1 : ext); + Common::sprintf_s(fn, "CGE.%s", (*ext == '.') ? ext +1 : ext); if (_resman->exist(fn)) { loadScript(fn); diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 866ab8d86f3..4a17b40c033 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -151,7 +151,7 @@ void Fx::preload(int ref0) { char filename[12]; for (int ref = ref0; ref < ref0 + 10; ref++) { - sprintf(filename, "FX%05d.WAV", ref); + Common::sprintf_s(filename, "FX%05d.WAV", ref); EncryptedStream file(_vm->_resman, filename); DataCk *wav = loadWave(&file); if (wav) { @@ -171,7 +171,7 @@ void Fx::preload(int ref0) { DataCk *Fx::load(int idx, int ref) { char filename[12]; - sprintf(filename, "FX%05d.WAV", ref); + Common::sprintf_s(filename, "FX%05d.WAV", ref); EncryptedStream file(_vm->_resman, filename); DataCk *wav = loadWave(&file); diff --git a/engines/cge/text.cpp b/engines/cge/text.cpp index fe4d534fe22..f40912a0e96 100644 --- a/engines/cge/text.cpp +++ b/engines/cge/text.cpp @@ -209,7 +209,7 @@ void Text::sayTime(Sprite *spr) { _vm->_system->getTimeAndDate(curTime); char t[6]; - sprintf(t, "%d:%02d", curTime.tm_hour, curTime.tm_min); + Common::sprintf_s(t, "%d:%02d", curTime.tm_hour, curTime.tm_min); say(t, spr); }