Author: mjmartin Date: Sun May 17 15:31:58 2009 New Revision: 40953
URL: http://svn.reactos.org/svn/reactos?rev=40953&view=rev Log: - ReadEventLogA/ReadEventLogW: Check for lpBuffer for NULL and if so set nNumberOfBytesToRead to zero so that rpcrt4 does not access a NULL buffer. Set pnBytesRead and pnMinNumberOfBytesNeeded variables prior to checking for failure and returning FALSE. In preparation for implementation of EventLog.
Modified: trunk/reactos/dll/win32/advapi32/service/eventlog.c
Modified: trunk/reactos/dll/win32/advapi32/service/eventlog.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service/... ============================================================================== --- trunk/reactos/dll/win32/advapi32/service/eventlog.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/eventlog.c [iso-8859-1] Sun May 17 15:31:58 2009 @@ -632,6 +632,13 @@ hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
+ /* If buffer is NULL set nNumberOfBytesToRead to 0 to prevent rpcrt4 from + trying to access a null pointer */ + if (!lpBuffer) + { + nNumberOfBytesToRead = 0; + } + RpcTryExcept { Status = ElfrReadELA(hEventLog, @@ -648,14 +655,14 @@ } RpcEndExcept;
- if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - *pnBytesRead = (DWORD)bytesRead; *pnMinNumberOfBytesNeeded = (DWORD)minNumberOfBytesNeeded; + + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + }
return TRUE; } @@ -689,6 +696,13 @@ hEventLog, dwReadFlags, dwRecordOffset, lpBuffer, nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
+ /* If buffer is NULL set nNumberOfBytesToRead to 0 to prevent rpcrt4 from + trying to access a null pointer */ + if (!lpBuffer) + { + nNumberOfBytesToRead = 0; + } + RpcTryExcept { Status = ElfrReadELW(hEventLog, @@ -705,14 +719,14 @@ } RpcEndExcept;
- if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return FALSE; - } - *pnBytesRead = (DWORD)bytesRead; *pnMinNumberOfBytesNeeded = (DWORD)minNumberOfBytesNeeded; + + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return FALSE; + }
return TRUE; }