diff options
author | Colin Snover | 2017-09-03 16:33:22 -0500 |
---|---|---|
committer | Colin Snover | 2017-09-03 20:00:23 -0500 |
commit | d2b4e16ab2bd28ce8b39a6330683228bd48950c2 (patch) | |
tree | 6ebb5bfa62c02ec418a2d76d0fe0c484ab01dc0f /backends/graphics | |
parent | a2b05b5c6302e8755448de66124fb9be81eee942 (diff) | |
download | scummvm-rg350-d2b4e16ab2bd28ce8b39a6330683228bd48950c2.tar.gz scummvm-rg350-d2b4e16ab2bd28ce8b39a6330683228bd48950c2.tar.bz2 scummvm-rg350-d2b4e16ab2bd28ce8b39a6330683228bd48950c2.zip |
SDL: Fix unsafe sprintf usage
Translation strings come from external data sources and can cause
a stack buffer overflow here just by accidentally (or maliciously)
being too long.
Diffstat (limited to 'backends/graphics')
-rw-r--r-- | backends/graphics/surfacesdl/surfacesdl-graphics.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index 180ab421cf..f84c09f535 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -2446,20 +2446,20 @@ bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { setFeatureState(OSystem::kFeatureAspectRatioCorrection, !_videoMode.aspectRatioCorrection); endGFXTransaction(); #ifdef USE_OSD - char buffer[128]; + Common::String message; if (_videoMode.aspectRatioCorrection) - sprintf(buffer, "%s\n%d x %d -> %d x %d", + message = Common::String::format("%s\n%d x %d -> %d x %d", _("Enabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h ); else - sprintf(buffer, "%s\n%d x %d -> %d x %d", + message = Common::String::format("%s\n%d x %d -> %d x %d", _("Disabled aspect ratio correction"), _videoMode.screenWidth, _videoMode.screenHeight, _hwscreen->w, _hwscreen->h ); - displayMessageOnOSD(buffer); + displayMessageOnOSD(message.c_str()); #endif internUpdateScreen(); return true; @@ -2526,14 +2526,13 @@ bool SurfaceSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) { g++; } if (newScalerName) { - char buffer[128]; - sprintf(buffer, "%s %s\n%d x %d -> %d x %d", + const Common::String message = Common::String::format( + "%s %s\n%d x %d -> %d x %d", _("Active graphics filter:"), newScalerName, _videoMode.screenWidth, _videoMode.screenHeight, - _hwscreen->w, _hwscreen->h - ); - displayMessageOnOSD(buffer); + _hwscreen->w, _hwscreen->h); + displayMessageOnOSD(message.c_str()); } #endif internUpdateScreen(); |