Author: ekohl
Date: Sat Feb 4 19:56:21 2012
New Revision: 55417
URL:
http://svn.reactos.org/svn/reactos?rev=55417&view=rev
Log:
[ADVAPI32]
Add or fix parameter checks.
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] Sat Feb 4 19:56:21
2012
@@ -452,7 +452,7 @@
TRACE("%p, %p\n", hEventLog, NumberOfRecords);
- if(!NumberOfRecords)
+ if (NumberOfRecords == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -497,7 +497,7 @@
TRACE("%p, %p\n", hEventLog, OldestRecord);
- if(!OldestRecord)
+ if (OldestRecord == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@@ -630,16 +630,15 @@
if (lpFileName == NULL)
{
- RtlInitUnicodeString(&FileNameW, NULL);
- }
- else
- {
- if (!RtlDosPathNameToNtPathName_U(lpFileName, &FileNameW,
- NULL, NULL))
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return NULL;
- }
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
+ }
+
+ if (!RtlDosPathNameToNtPathName_U(lpFileName, &FileNameW,
+ NULL, NULL))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return NULL;
}
RpcTryExcept
@@ -802,22 +801,32 @@
{
NTSTATUS Status;
DWORD bytesRead, minNumberOfBytesNeeded;
+ DWORD dwFlags;
TRACE("%p, %lu, %lu, %p, %lu, %p, %p\n",
hEventLog, dwReadFlags, dwRecordOffset, lpBuffer,
nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
- if(!pnBytesRead || !pnMinNumberOfBytesNeeded)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- /* If buffer is NULL set nNumberOfBytesToRead to 0 to prevent rpcrt4 from
- trying to access a null pointer */
- if (!lpBuffer)
- {
- nNumberOfBytesToRead = 0;
+ if (lpBuffer == NULL ||
+ pnBytesRead == NULL ||
+ pnMinNumberOfBytesNeeded == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ dwFlags = dwReadFlags & (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ);
+ if (dwFlags == (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ dwFlags = dwReadFlags & (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ);
+ if (dwFlags == (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
}
RpcTryExcept
@@ -872,22 +881,32 @@
{
NTSTATUS Status;
DWORD bytesRead, minNumberOfBytesNeeded;
+ DWORD dwFlags;
TRACE("%p, %lu, %lu, %p, %lu, %p, %p\n",
hEventLog, dwReadFlags, dwRecordOffset, lpBuffer,
nNumberOfBytesToRead, pnBytesRead, pnMinNumberOfBytesNeeded);
- if(!pnBytesRead || !pnMinNumberOfBytesNeeded)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- /* If buffer is NULL set nNumberOfBytesToRead to 0 to prevent rpcrt4 from
- trying to access a null pointer */
- if (!lpBuffer)
- {
- nNumberOfBytesToRead = 0;
+ if (lpBuffer == NULL ||
+ pnBytesRead == NULL ||
+ pnMinNumberOfBytesNeeded == NULL)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ dwFlags = dwReadFlags & (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ);
+ if (dwFlags == (EVENTLOG_SEQUENTIAL_READ | EVENTLOG_SEEK_READ))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ dwFlags = dwReadFlags & (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ);
+ if (dwFlags == (EVENTLOG_FORWARDS_READ | EVENTLOG_BACKWARDS_READ))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
}
RpcTryExcept