From f154497a9f0f9b408917c07180cdf1e20a5647c6 Mon Sep 17 00:00:00 2001 From: mar-na Date: Thu, 18 Apr 2013 13:28:16 +0200 Subject: [PATCH] Possible buffer overrun in Foundation/EventLogChannel --- Foundation/src/EventLogChannel.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Foundation/src/EventLogChannel.cpp b/Foundation/src/EventLogChannel.cpp index 4572f4583..56bff1909 100644 --- a/Foundation/src/EventLogChannel.cpp +++ b/Foundation/src/EventLogChannel.cpp @@ -56,7 +56,7 @@ EventLogChannel::EventLogChannel(): _logFile("Application"), _h(0) { - static const int length = 256; + static const int length = MAX_PATH + 1; #if defined(POCO_WIN32_UTF8) wchar_t name[length]; int n = GetModuleFileNameW(NULL, name, length); @@ -289,8 +289,9 @@ std::wstring EventLogChannel::findLibrary(const wchar_t* name) HMODULE dll = LoadLibraryW(name); if (dll) { - wchar_t name[MAX_PATH + 1]; - int n = GetModuleFileNameW(dll, name, sizeof(name)); + static const int length = MAX_PATH + 1; + wchar_t name[length]; + int n = GetModuleFileNameW(dll, name, length); if (n > 0) path = name; FreeLibrary(dll); } @@ -303,8 +304,9 @@ std::string EventLogChannel::findLibrary(const char* name) HMODULE dll = LoadLibraryA(name); if (dll) { - char name[MAX_PATH + 1]; - int n = GetModuleFileNameA(dll, name, sizeof(name)); + static const int length = MAX_PATH + 1; + char name[length]; + int n = GetModuleFileNameA(dll, name, length); if (n > 0) path = name; FreeLibrary(dll); }