From b2112004606d84db06858f9319af43eacf4757ab Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sat, 21 Feb 2009 12:56:43 +0000 Subject: [PATCH] Fix potential buffer overflow in OSD git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2336 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/Plugin_VideoOGL/Src/OnScreenDisplay.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OnScreenDisplay.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OnScreenDisplay.cpp index dd7c929297..9e59759b43 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OnScreenDisplay.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OnScreenDisplay.cpp @@ -29,7 +29,11 @@ namespace OSD struct MESSAGE { MESSAGE() {} - MESSAGE(const char* p, u32 dw) { strcpy(str, p); dwTimeStamp = dw; } + MESSAGE(const char* p, u32 dw) { + strncpy(str, p, 255); + str[255] = '\0'; + dwTimeStamp = dw; + } char str[255]; u32 dwTimeStamp; }; @@ -47,7 +51,8 @@ void DrawMessages() if (!wasEnabled) glEnable(GL_BLEND); - if (s_listMsgs.size() > 0) { + if (s_listMsgs.size() > 0) + { int left = 25, top = 15; std::list::iterator it = s_listMsgs.begin(); while (it != s_listMsgs.end()) @@ -74,7 +79,8 @@ void DrawMessages() } } - if (!wasEnabled) glDisable(GL_BLEND); + if (!wasEnabled) + glDisable(GL_BLEND); } } // namespace \ No newline at end of file