Commit e94c1ce3 authored by Paul Vriens's avatar Paul Vriens Committed by Alexandre Julliard

advapi32: Add some input parameter checks to OpenBackupEventLog.

parent 381533e5
...@@ -378,8 +378,16 @@ BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent ) ...@@ -378,8 +378,16 @@ BOOL WINAPI NotifyChangeEventLog( HANDLE hEventLog, HANDLE hEvent )
*/ */
HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
{ {
FIXME("(%s,%s) stub\n", debugstr_a(lpUNCServerName), debugstr_a(lpFileName)); LPWSTR uncnameW, filenameW;
return (HANDLE)0xcafe4242; 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 ) ...@@ -389,8 +397,28 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
*/ */
HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName ) HANDLE WINAPI OpenBackupEventLogW( LPCWSTR lpUNCServerName, LPCWSTR lpFileName )
{ {
FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName)); FIXME("(%s,%s) stub\n", debugstr_w(lpUNCServerName), debugstr_w(lpFileName));
return (HANDLE)0xcafe4242;
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;
} }
/****************************************************************************** /******************************************************************************
......
...@@ -413,37 +413,25 @@ static void test_openbackup(void) ...@@ -413,37 +413,25 @@ static void test_openbackup(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
handle = OpenBackupEventLogA(NULL, NULL); handle = OpenBackupEventLogA(NULL, NULL);
todo_wine
{
ok(handle == NULL, "Didn't expect a handle\n"); ok(handle == NULL, "Didn't expect a handle\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
}
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
handle = OpenBackupEventLogA(NULL, "idontexist.evt"); handle = OpenBackupEventLogA(NULL, "idontexist.evt");
todo_wine
{
ok(handle == NULL, "Didn't expect a handle\n"); ok(handle == NULL, "Didn't expect a handle\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError()); ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
}
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
handle = OpenBackupEventLogA("IDontExist", NULL); handle = OpenBackupEventLogA("IDontExist", NULL);
todo_wine
{
ok(handle == NULL, "Didn't expect a handle\n"); ok(handle == NULL, "Didn't expect a handle\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); ok(GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
}
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
handle = OpenBackupEventLogA("IDontExist", "idontexist.evt"); handle = OpenBackupEventLogA("IDontExist", "idontexist.evt");
todo_wine
{
ok(handle == NULL, "Didn't expect a handle\n"); ok(handle == NULL, "Didn't expect a handle\n");
ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE || ok(GetLastError() == RPC_S_SERVER_UNAVAILABLE ||
GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */ GetLastError() == RPC_S_INVALID_NET_ADDR, /* Some Vista and Win7 */
"Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError()); "Expected RPC_S_SERVER_UNAVAILABLE, got %d\n", GetLastError());
}
/* Make a backup eventlog to work with */ /* Make a backup eventlog to work with */
DeleteFileA(backup); DeleteFileA(backup);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment