advapi32/tests: Fix a buffer overflow when calling GetEventLogInformation.
This commit is contained in:
parent
d1749b548b
commit
d6cc12d139
|
@ -130,7 +130,8 @@ static void test_info(void)
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
DWORD needed;
|
DWORD needed;
|
||||||
EVENTLOG_FULL_INFORMATION efi;
|
BYTE buffer[2 * sizeof(EVENTLOG_FULL_INFORMATION)];
|
||||||
|
EVENTLOG_FULL_INFORMATION *efi = (void *)buffer;
|
||||||
|
|
||||||
if (!pGetEventLogInformation)
|
if (!pGetEventLogInformation)
|
||||||
{
|
{
|
||||||
|
@ -161,26 +162,26 @@ static void test_info(void)
|
||||||
ok(GetLastError() == RPC_X_NULL_REF_POINTER, "Expected RPC_X_NULL_REF_POINTER, got %d\n", GetLastError());
|
ok(GetLastError() == RPC_X_NULL_REF_POINTER, "Expected RPC_X_NULL_REF_POINTER, got %d\n", GetLastError());
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, (LPVOID)&efi, 0, NULL);
|
ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, efi, 0, NULL);
|
||||||
ok(!ret, "Expected failure\n");
|
ok(!ret, "Expected failure\n");
|
||||||
ok(GetLastError() == RPC_X_NULL_REF_POINTER, "Expected RPC_X_NULL_REF_POINTER, got %d\n", GetLastError());
|
ok(GetLastError() == RPC_X_NULL_REF_POINTER, "Expected RPC_X_NULL_REF_POINTER, got %d\n", GetLastError());
|
||||||
|
|
||||||
SetLastError(0xdeadbeef);
|
SetLastError(0xdeadbeef);
|
||||||
needed = 0xdeadbeef;
|
needed = 0xdeadbeef;
|
||||||
efi.dwFull = 0xdeadbeef;
|
efi->dwFull = 0xdeadbeef;
|
||||||
ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, (LPVOID)&efi, 0, &needed);
|
ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, efi, 0, &needed);
|
||||||
ok(!ret, "Expected failure\n");
|
ok(!ret, "Expected failure\n");
|
||||||
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
|
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
|
||||||
ok(needed == sizeof(EVENTLOG_FULL_INFORMATION), "Expected sizeof(EVENTLOG_FULL_INFORMATION), got %d\n", needed);
|
ok(needed == sizeof(EVENTLOG_FULL_INFORMATION), "Expected sizeof(EVENTLOG_FULL_INFORMATION), got %d\n", needed);
|
||||||
ok(efi.dwFull == 0xdeadbeef, "Expected no change to the dwFull member\n");
|
ok(efi->dwFull == 0xdeadbeef, "Expected no change to the dwFull member\n");
|
||||||
|
|
||||||
/* Not that we care, but on success last error is set to ERROR_IO_PENDING */
|
/* Not that we care, but on success last error is set to ERROR_IO_PENDING */
|
||||||
efi.dwFull = 0xdeadbeef;
|
efi->dwFull = 0xdeadbeef;
|
||||||
needed *= 2;
|
needed = sizeof(buffer);
|
||||||
ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, (LPVOID)&efi, needed, &needed);
|
ret = pGetEventLogInformation(handle, EVENTLOG_FULL_INFO, efi, needed, &needed);
|
||||||
ok(ret, "Expected success\n");
|
ok(ret, "Expected success\n");
|
||||||
ok(needed == sizeof(EVENTLOG_FULL_INFORMATION), "Expected sizeof(EVENTLOG_FULL_INFORMATION), got %d\n", needed);
|
ok(needed == sizeof(EVENTLOG_FULL_INFORMATION), "Expected sizeof(EVENTLOG_FULL_INFORMATION), got %d\n", needed);
|
||||||
ok(efi.dwFull == 0 || efi.dwFull == 1, "Expected 0 (not full) or 1 (full), got %d\n", efi.dwFull);
|
ok(efi->dwFull == 0 || efi->dwFull == 1, "Expected 0 (not full) or 1 (full), got %d\n", efi->dwFull);
|
||||||
|
|
||||||
CloseEventLog(handle);
|
CloseEventLog(handle);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue