From 8f604dddedfdb9801d8bb24781f7a08eb802e45d Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Wed, 9 Oct 2019 02:14:52 +0300 Subject: [PATCH] Fix log format misuse Harden log channel methods against non-constant string. --- Utilities/Log.h | 4 ++-- rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp | 4 ++-- rpcs3/Emu/Cell/Modules/cellPngDec.cpp | 4 ++-- rpcs3/Emu/GDB.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Utilities/Log.h b/Utilities/Log.h index b5d1b3eb39..7752149166 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -72,8 +72,8 @@ namespace logs #define GEN_LOG_METHOD(_sev)\ const message msg_##_sev{this, level::_sev};\ - template \ - void _sev(const char* fmt, const Args&... args)\ + template \ + void _sev(const char(&fmt)[N], const Args&... args)\ {\ if (UNLIKELY(level::_sev <= enabled))\ {\ diff --git a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp index 21fa881b7f..7ecc385d49 100644 --- a/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp @@ -209,11 +209,11 @@ error_code cellMsgDialogOpen2(u32 type, vm::cptr msgString, vm::ptrget()) diff --git a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp index 7f9e235f51..98e8ae905d 100644 --- a/rpcs3/Emu/Cell/Modules/cellPngDec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPngDec.cpp @@ -149,7 +149,7 @@ void pngDecEndCallback(png_structp png_ptr, png_infop info) // Custom error handler for libpng void pngDecError(png_structp png_ptr, png_const_charp error_message) { - cellPngDec.error(error_message); + cellPngDec.error("%s", error_message); // we can't return here or libpng blows up throw LibPngCustomException("Fatal Error in libpng"); } @@ -157,7 +157,7 @@ void pngDecError(png_structp png_ptr, png_const_charp error_message) // Custom warning handler for libpng void pngDecWarning(png_structp png_ptr, png_const_charp error_message) { - cellPngDec.warning(error_message); + cellPngDec.warning("%s", error_message); } // Get the chunk information of the PNG file. IDAT is marked as existing, only after decoding or reading the header. diff --git a/rpcs3/Emu/GDB.cpp b/rpcs3/Emu/GDB.cpp index ea7c743670..edd6f2d5e6 100644 --- a/rpcs3/Emu/GDB.cpp +++ b/rpcs3/Emu/GDB.cpp @@ -257,7 +257,7 @@ bool gdb_thread::read_cmd(gdb_cmd& out_cmd) } catch (const std::runtime_error& e) { - gdbDebugServer.error(e.what()); + gdbDebugServer.error("%s", e.what()); return false; } } @@ -855,7 +855,7 @@ void gdb_thread::operator()() client_socket = -1; } - gdbDebugServer.error(e.what()); + gdbDebugServer.error("%s", e.what()); } } }