Module: wine Branch: master Commit: 3e3ca7dd2880749afea498c386ce8b3194a9323d URL: https://gitlab.winehq.org/wine/wine/-/commit/3e3ca7dd2880749afea498c386ce8b3...
Author: Paul Gofman pgofman@codeweavers.com Date: Thu May 25 21:11:41 2023 -0600
ntdll: Validate flags in NtUnmapViewOfSectionEx().
---
dlls/kernelbase/tests/process.c | 4 ++-- dlls/ntdll/unix/virtual.c | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/kernelbase/tests/process.c b/dlls/kernelbase/tests/process.c index 7c6544f6dd9..2e5bb7ca458 100644 --- a/dlls/kernelbase/tests/process.c +++ b/dlls/kernelbase/tests/process.c @@ -242,9 +242,9 @@ static void test_VirtualAlloc2(void) ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError());
ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER); - todo_wine ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, "Got ret %d, error %lu.\n", ret, GetLastError()); ret = pUnmapViewOfFile2(GetCurrentProcess(), view1, MEM_PRESERVE_PLACEHOLDER); - todo_wine ok(ret, "Got error %lu.\n", GetLastError()); + ok(ret, "Got error %lu.\n", GetLastError());
memset(&info, 0, sizeof(info)); VirtualQuery(placeholder1, &info, sizeof(info)); diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index c701ce4fc03..40fe2c9b282 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -5298,7 +5298,14 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr ) */ NTSTATUS WINAPI NtUnmapViewOfSectionEx( HANDLE process, PVOID addr, ULONG flags ) { - if (flags) FIXME("Ignoring flags %#x.\n", (int)flags); + static const ULONG type_mask = MEM_UNMAP_WITH_TRANSIENT_BOOST | MEM_PRESERVE_PLACEHOLDER; + + if (flags & ~type_mask) + { + WARN( "Unsupported flags %#x.\n", (int)flags ); + return STATUS_INVALID_PARAMETER; + } + if (flags) FIXME( "Ignoring flags %#x.\n", (int)flags ); return unmap_view_of_section( process, addr ); }