GH124: Possible buffer overrun in EventLogChannel

This commit is contained in:
aleks-f 2013-03-12 23:13:02 -05:00
parent daef0aa403
commit ad66c4aac4
2 changed files with 6 additions and 4 deletions

View File

@ -22,6 +22,7 @@ Release 1.5.2 (2013-03-??)
- added Recursive and SortedDirectoryIterator (Marian Krivos) - added Recursive and SortedDirectoryIterator (Marian Krivos)
- added ListMap (map-like container with preserving insertion order) - added ListMap (map-like container with preserving insertion order)
- MailMessage: attachments saving support and consistent read/write - MailMessage: attachments saving support and consistent read/write
- fixed GH #124: Possibile buffer overrun in Foundation/EventLogChannel
Release 1.5.1 (2013-01-11) Release 1.5.1 (2013-01-11)
========================== ==========================

View File

@ -56,9 +56,10 @@ EventLogChannel::EventLogChannel():
_logFile("Application"), _logFile("Application"),
_h(0) _h(0)
{ {
static const int length = 256;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
wchar_t name[256]; wchar_t name[length];
int n = GetModuleFileNameW(NULL, name, sizeof(name)); int n = GetModuleFileNameW(NULL, name, length);
if (n > 0) if (n > 0)
{ {
wchar_t* end = name + n - 1; wchar_t* end = name + n - 1;
@ -68,8 +69,8 @@ EventLogChannel::EventLogChannel():
UnicodeConverter::toUTF8(uname, _name); UnicodeConverter::toUTF8(uname, _name);
} }
#else #else
char name[256]; char name[length];
int n = GetModuleFileNameA(NULL, name, sizeof(name)); int n = GetModuleFileNameA(NULL, name, length);
if (n > 0) if (n > 0)
{ {
char* end = name + n - 1; char* end = name + n - 1;