[advapi32 2/3] Add a input parameter check to ClearEventLog

View: New views
1 Messages — Rating Filter:   Alert me  

[advapi32 2/3] Add a input parameter check to ClearEventLog

by Paul Vriens-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Add one simple parameter check. Most of the removals of the todo_wine's
is due to the fact that OpenBackupEventLogA doesn't give us a handle on
Wine yet.

Changelog
   Add a input parameter check to ClearEventLog

--
Cheers,

Paul.



>From c67e1dfd8d4dcf2c13295b8755495177a5d940fe Mon Sep 17 00:00:00 2001
From: Paul Vriens <Paul.Vriens.Wine@...>
Date: Wed, 4 Nov 2009 08:00:58 +0100
Subject: [PATCH 3/4] Add a input parameter check to ClearEventLog

---
 dlls/advapi32/eventlog.c       |   23 ++++++++++++++++++-----
 dlls/advapi32/tests/eventlog.c |   12 ------------
 2 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/dlls/advapi32/eventlog.c b/dlls/advapi32/eventlog.c
index 4990112..af377ee 100644
--- a/dlls/advapi32/eventlog.c
+++ b/dlls/advapi32/eventlog.c
@@ -107,7 +107,7 @@ BOOL WINAPI BackupEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
 /******************************************************************************
  * ClearEventLogA [ADVAPI32.@]
  *
- * Clears the event log and/or saves the log to a backup file.
+ * Clears the event log and optionally saves the log to a backup file.
  *
  * PARAMS
  *  hEvenLog         [I] Handle to event log to clear.
@@ -121,8 +121,14 @@ BOOL WINAPI BackupEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
  */
 BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
 {
- FIXME("(%p,%s) stub\n", hEventLog, debugstr_a(lpBackupFileName));
- return TRUE;
+    LPWSTR backupW;
+    BOOL ret;
+
+    backupW = SERV_dup(lpBackupFileName);
+    ret = ClearEventLogW(hEventLog, backupW);
+    HeapFree(GetProcessHeap(), 0, backupW);
+
+    return ret;
 }
 
 /******************************************************************************
@@ -132,8 +138,15 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
  */
 BOOL WINAPI ClearEventLogW( HANDLE hEventLog, LPCWSTR lpBackupFileName )
 {
- FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
- return TRUE;
+    FIXME("(%p,%s) stub\n", hEventLog, debugstr_w(lpBackupFileName));
+
+    if (!hEventLog)
+    {
+        SetLastError(ERROR_INVALID_HANDLE);
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 /******************************************************************************
diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c
index 99990a2..6bc9a24 100644
--- a/dlls/advapi32/tests/eventlog.c
+++ b/dlls/advapi32/tests/eventlog.c
@@ -508,22 +508,16 @@ static void test_clear(void)
 
     SetLastError(0xdeadbeef);
     ret = ClearEventLogA(NULL, NULL);
-    todo_wine
-    {
     ok(!ret, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
-    }
 
     /* Make a backup eventlog to work with */
     create_backup(backup);
 
     SetLastError(0xdeadbeef);
     ret = ClearEventLogA(NULL, backup);
-    todo_wine
-    {
     ok(!ret, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
-    }
 
     handle = OpenBackupEventLogA(NULL, backup);
     todo_wine
@@ -532,20 +526,14 @@ static void test_clear(void)
     /* A real eventlog would fail with ERROR_ALREADY_EXISTS */
     SetLastError(0xdeadbeef);
     ret = ClearEventLogA(handle, backup);
-    todo_wine
-    {
     ok(!ret, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
-    }
 
     /* Show that ClearEventLog only works for real eventlogs. */
     SetLastError(0xdeadbeef);
     ret = ClearEventLogA(handle, NULL);
-    todo_wine
-    {
     ok(!ret, "Expected failure\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
-    }
 
     CloseEventLog(handle);
     DeleteFileA(backup);
--
1.6.2.5