From de72f40580f35eed0abf8ee081bc8b833d0fbe0f Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Wed, 28 Oct 2009 19:37:06 +0100 Subject: [PATCH] advapi32: Add some input parameter checks to GetNumberOfEventLogRecords. --- dlls/advapi32/eventlog.c | 13 ++++++++++++- dlls/advapi32/tests/eventlog.c | 5 ----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/dlls/advapi32/eventlog.c b/dlls/advapi32/eventlog.c index e5c7bd7a58a..6812cdd66e5 100644 --- a/dlls/advapi32/eventlog.c +++ b/dlls/advapi32/eventlog.c @@ -265,7 +265,18 @@ BOOL WINAPI GetNumberOfEventLogRecords( HANDLE hEventLog, PDWORD NumberOfRecords { FIXME("(%p,%p) stub\n", hEventLog, NumberOfRecords); - if (!NumberOfRecords) return FALSE; + if (!NumberOfRecords) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (!hEventLog) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + *NumberOfRecords = 0; return TRUE; diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c index 4840ec5caf2..d3940128151 100644 --- a/dlls/advapi32/tests/eventlog.c +++ b/dlls/advapi32/tests/eventlog.c @@ -158,25 +158,20 @@ static void test_count(void) SetLastError(0xdeadbeef); ret = GetNumberOfEventLogRecords(NULL, NULL); ok(!ret, "Expected failure\n"); - todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); SetLastError(0xdeadbeef); count = 0xdeadbeef; ret = GetNumberOfEventLogRecords(NULL, &count); - todo_wine - { ok(!ret, "Expected failure\n"); ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); ok(count == 0xdeadbeef, "Expected count to stay unchanged\n"); - } handle = OpenEventLogA(NULL, "Application"); SetLastError(0xdeadbeef); ret = GetNumberOfEventLogRecords(handle, NULL); ok(!ret, "Expected failure\n"); - todo_wine ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); count = 0xdeadbeef;