Commit d2d52717 authored by Gijs Vermeulen's avatar Gijs Vermeulen Committed by Alexandre Julliard

ntdll: Validate len in NtQueryVirtualMemory.

parent 9a6fcdf4
...@@ -2005,6 +2005,9 @@ static void test_queryvirtualmemory(void) ...@@ -2005,6 +2005,9 @@ static void test_queryvirtualmemory(void)
/* check error code when addr is higher than working set limit */ /* check error code when addr is higher than working set limit */
status = pNtQueryVirtualMemory(NtCurrentProcess(), (void *)~0, MemoryBasicInformation, &mbi, sizeof(mbi), &readcount); status = pNtQueryVirtualMemory(NtCurrentProcess(), (void *)~0, MemoryBasicInformation, &mbi, sizeof(mbi), &readcount);
ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got %08x\n", status); ok(status == STATUS_INVALID_PARAMETER, "Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
/* check error code when len is less than MEMORY_BASIC_INFORMATION size */
status = pNtQueryVirtualMemory(NtCurrentProcess(), GetProcessHeap(), MemoryBasicInformation, &mbi, sizeof(MEMORY_BASIC_INFORMATION) - 1, &readcount);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
} }
static void test_affinity(void) static void test_affinity(void)
......
...@@ -2820,6 +2820,9 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr, ...@@ -2820,6 +2820,9 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
} }
} }
if (len < sizeof(MEMORY_BASIC_INFORMATION))
return STATUS_INFO_LENGTH_MISMATCH;
if (process != NtCurrentProcess()) if (process != NtCurrentProcess())
{ {
NTSTATUS status; NTSTATUS status;
......
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