Bug 34981 - suspicion of wrong argument passed to Windows API function
suspicion of wrong argument passed to Windows API function
Status: RESOLVED FIXED
Product: Log4j
Classification: Unclassified
Component: Appender
1.2
Other Windows XP
: P2 minor
: ---
Assigned To: log4j-dev
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-05-20 10:45 UTC by Tom
Modified: 2005-08-22 23:29 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom 2005-05-20 10:45:10 UTC
I was enhancing the nteventlog.cpp file, the source of the native library
NTEventLogAppender.dll. I noticed following call in function regSetString:

RegSetValueEx(hkey, name, 0, REG_SZ, (LPBYTE)value, lstrlen(value));

Though it doesn't produce any error (for the present :-), it is IMHO in
contradiction with MSDN documentation, where following is said:

"If the data is of type REG_SZ, REG_EXPAND_SZ, or REG_MULTI_SZ, cbData must
include the size of the terminating null character or characters."
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/regsetvalueex.asp)

So the correct call should be
RegSetValueEx(hkey, name, 0, REG_SZ, (LPBYTE)value, lstrlen(value) + 1);

Thanks
Comment 1 Curt Arnold 2005-08-22 00:43:58 UTC
Since TCHAR can be either char or wchar_t (but likely char) in this instance, it should be

RegSetValueEx(hkey, name, 0, REG_SZ, (LPBYTE)value, lstrlen(value) + sizeof(TCHAR));
Comment 2 Mark Womack 2005-08-23 07:29:17 UTC
Applied Curt's change.  It will be in the v1.2.12rc5 build.