Module: wine Branch: master Commit: 84d689bd5838f786c35549f6af67b4bdde28aa42 URL: http://source.winehq.org/git/wine.git/?a=commit;h=84d689bd5838f786c35549f6af...
Author: Paul Vriens Paul.Vriens.Wine@gmail.com Date: Tue Oct 27 09:33:55 2009 +0100
advapi32/tests: Add some input parameter checks.
---
dlls/advapi32/eventlog.c | 44 ++++++++++++++++++++++++++++++++++++--- dlls/advapi32/tests/eventlog.c | 9 -------- 2 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/dlls/advapi32/eventlog.c b/dlls/advapi32/eventlog.c index 118bd11..82bff01 100644 --- a/dlls/advapi32/eventlog.c +++ b/dlls/advapi32/eventlog.c @@ -29,11 +29,25 @@ #include "wmistr.h" #include "evntrace.h"
+#include "wine/unicode.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(advapi); WINE_DECLARE_DEBUG_CHANNEL(eventlog);
+static inline LPWSTR SERV_dup( LPCSTR str ) +{ + UINT len; + LPWSTR wstr; + + if( !str ) + return NULL; + len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 ); + wstr = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, str, -1, wstr, len ); + return wstr; +} + /****************************************************************************** * BackupEventLogA [ADVAPI32.@] * @@ -283,8 +297,16 @@ HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName ) */ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source ) { - FIXME("(%s,%s) stub\n", debugstr_a(uncname), debugstr_a(source)); - return (HANDLE)0xcafe4242; + LPWSTR uncnameW, sourceW; + HANDLE handle; + + uncnameW = SERV_dup(uncname); + sourceW = SERV_dup(source); + handle = OpenEventLogW(uncnameW, sourceW); + HeapFree(GetProcessHeap(), 0, uncnameW); + HeapFree(GetProcessHeap(), 0, sourceW); + + return handle; }
/****************************************************************************** @@ -294,8 +316,22 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source ) */ HANDLE WINAPI OpenEventLogW( LPCWSTR uncname, LPCWSTR source ) { - FIXME("(%s,%s) stub\n", debugstr_w(uncname), debugstr_w(source)); - return (HANDLE)0xcafe4242; + FIXME("(%s,%s) stub\n", debugstr_w(uncname), debugstr_w(source)); + + if (!source) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + if (uncname) + { + FIXME("Remote server not supported\n"); + SetLastError(RPC_S_SERVER_UNAVAILABLE); + return NULL; + } + + return (HANDLE)0xcafe4242; }
/****************************************************************************** diff --git a/dlls/advapi32/tests/eventlog.c b/dlls/advapi32/tests/eventlog.c index 244a805..3567a8c 100644 --- a/dlls/advapi32/tests/eventlog.c +++ b/dlls/advapi32/tests/eventlog.c @@ -44,29 +44,20 @@ static void test_open_close(void)
SetLastError(0xdeadbeef); handle = OpenEventLogA(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 = OpenEventLogA("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 = OpenEventLogA("IDontExist", "deadbeef"); - 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()); - }
/* This one opens the Application log */ handle = OpenEventLogA(NULL, "deadbeef");