ntdll: Zero bits parameter must be less than 21.

Signed-off-by: Akihiro Sagawa <sagawa.aki@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Akihiro Sagawa 2017-05-31 22:48:45 +09:00 committed by Alexandre Julliard
parent 5bd58bb275
commit 1afb369380
2 changed files with 3 additions and 3 deletions

View File

@ -400,7 +400,6 @@ static void test_VirtualAlloc(void)
addr2 = NULL;
status = pNtAllocateVirtualMemory(GetCurrentProcess(), &addr2, 22, &size,
MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
todo_wine
ok(status == STATUS_INVALID_PARAMETER_3, "NtAllocateVirtualMemory returned %08x\n", status);
if (status == STATUS_SUCCESS) ok(VirtualFree(addr2, 0, MEM_RELEASE), "VirtualFree failed\n");
@ -1168,7 +1167,6 @@ static void test_NtMapViewOfSection(void)
ptr2 = NULL;
size = 0;
status = pNtMapViewOfSection( mapping, hProcess, &ptr2, 22, 0, &offset, &size, 1, 0, PAGE_READWRITE );
todo_wine
ok( status == STATUS_INVALID_PARAMETER_4, "NtMapViewOfSection returned %x\n", status );
if (status == STATUS_SUCCESS)
{

View File

@ -279,6 +279,7 @@ static inline UINT_PTR get_mask( ULONG zero_bits )
{
if (!zero_bits) return 0xffff; /* allocations are aligned to 64K by default */
if (zero_bits < page_shift) zero_bits = page_shift;
if (zero_bits > 21) return 0;
return (1 << zero_bits) - 1;
}
@ -1885,6 +1886,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
TRACE("%p %p %08lx %x %08x\n", process, *ret, size, type, protect );
if (!size) return STATUS_INVALID_PARAMETER;
if (!mask) return STATUS_INVALID_PARAMETER_3;
if (process != NtCurrentProcess())
{
@ -2550,7 +2552,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
/* Check parameters */
if (*addr_ptr && zero_bits)
if ((*addr_ptr && zero_bits) || !mask)
return STATUS_INVALID_PARAMETER_4;
#ifndef _WIN64