Module: wine Branch: master Commit: e94c1ce3aea2f3ccf7468a2ea5aed82df17b013b URL: http://source.winehq.org/git/wine.git/?a=commit;h=e94c1ce3aea2f3ccf7468a2ea5...
Author: Paul Vriens Paul.Vriens.Wine@gmail.com Date: Mon Nov 2 10:31:17 2009 +0100
advapi32: Add some input parameter checks to OpenBackupEventLog.
---
dlls/advapi32/eventlog.c | 36 ++++++++++++++++++++++++++++++++---- dlls/advapi32/tests/eventlog.c | 12 ------------ 2 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/dlls/advapi32/eventlog.c b/dlls/advapi32/eventlog.c index f72dba9..4990112 100644 --- a/dlls/advapi32/eventlog.c +++ b/dlls/advapi32/eventlog.c @@ -378,8 +378,16 @@ BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent ) */ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) { - FIXME("(%s,%s) stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpFileName)); - return (HANDLE)0xcafe4242; + LPWSTR uncnameW, filenameW; + HANDLE handle; + + uncnameW = SERV_dup(lpUNCServerName); + filenameW = SERV_dup(lpFileName); + handle = OpenBackupEventLogW(uncnameW, filenameW); + HeapFree(GetProcessHeap(), 0, uncnameW); + HeapFree(GetProcessHeap(), 0, filenameW); + + return handle; }
/****************************************************************************** @@ -389,8 +397,28 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) */ HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName ) { - FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName)); - return (HANDLE)0xcafe4242; + FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName)); + + if (!lpFileName) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + if (lpUNCServerName && lpUNCServerName[0]) + { + FIXME("Remote server not supported\n"); + SetLastError(RPC_S_SERVER_UNAVAILABLE); + return NULL; + } + + if (GetFileAttributesW(lpFileName) == INVALID_FILE_ATTRIBUTES) + { + SetLastError(ERROR_FILE_NOT_FOUND); + return NULL; + } + + return (HANDLE)0xcafe4242; }
/****************************************************************************** diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c index 56df6d9..8a96c69 100644 --- a/dlls/advapi32/tests/eventlog.c +++ b/dlls/advapi32/tests/eventlog.c @@ -413,37 +413,25 @@ static void test_openbackup(void)
SetLastError(0xdeadbeef); handle = OpenBackupEventLogA(NULL, NULL); - todo_wine - { ok(handle == NULL, "Didn't expect a handle\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - }
SetLastError(0xdeadbeef); handle = OpenBackupEventLogA(NULL, "idontexist.evt"); - todo_wine - { ok(handle == NULL, "Didn't expect a handle\n"); ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); - }
SetLastError(0xdeadbeef); handle = OpenBackupEventLogA("IDontExist", NULL); - todo_wine - { ok(handle == NULL, "Didn't expect a handle\n"); ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); - }
SetLastError(0xdeadbeef); handle = OpenBackupEventLogA("IDontExist", "idontexist.evt"); - todo_wine - { ok(handle == NULL, "Didn't expect a handle\n"); ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE || GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */ "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError()); - }
/* Make a backup eventlog to work with */ DeleteFileA(backup);