Module: wine Branch: stable Commit: 0e18a08ca9d986c7bef4841e39b012e4bd82f6aa URL: https://source.winehq.org/git/wine.git/?a=commit;h=0e18a08ca9d986c7bef4841e3...
Author: Stefan Leichter sle85276@gmx.de Date: Mon Mar 12 00:14:55 2018 +0100
ntdll: Fix RtlCheckRegistryKey when called with empty path.
Signed-off-by: Stefan Leichter sle85276@gmx.de Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit f07e8ca8f01106b6d41a933f0ac393b30d505bad) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/ntdll/reg.c | 4 +++- dlls/ntdll/tests/reg.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/reg.c b/dlls/ntdll/reg.c index 2dd75be..a34c863 100644 --- a/dlls/ntdll/reg.c +++ b/dlls/ntdll/reg.c @@ -1401,10 +1401,12 @@ NTSTATUS WINAPI RtlCheckRegistryKey(IN ULONG RelativeTo, IN PWSTR Path)
TRACE("(%d, %s)\n", RelativeTo, debugstr_w(Path));
- if((!RelativeTo) && Path == NULL) + if(!RelativeTo && (Path == NULL || Path[0] == 0)) return STATUS_OBJECT_PATH_SYNTAX_BAD; if(RelativeTo & RTL_REGISTRY_HANDLE) return STATUS_SUCCESS; + if((RelativeTo <= RTL_REGISTRY_USER) && (Path == NULL || Path[0] == 0)) + return STATUS_SUCCESS;
status = RTL_GetKeyHandle(RelativeTo, Path, &handle); if (handle) NtClose(handle); diff --git a/dlls/ntdll/tests/reg.c b/dlls/ntdll/tests/reg.c index 7d2e566..ddd400e 100644 --- a/dlls/ntdll/tests/reg.c +++ b/dlls/ntdll/tests/reg.c @@ -671,6 +671,7 @@ static void test_RtlOpenCurrentUser(void)
static void test_RtlCheckRegistryKey(void) { + static WCHAR empty[] = {0}; NTSTATUS status;
status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, winetestpath.Buffer); @@ -678,6 +679,18 @@ static void test_RtlCheckRegistryKey(void)
status = pRtlCheckRegistryKey((RTL_REGISTRY_ABSOLUTE | RTL_REGISTRY_OPTIONAL), winetestpath.Buffer); ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and RTL_REGISTRY_OPTIONAL: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, NULL); + ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and Path being NULL: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_ABSOLUTE, empty); + ok(status == STATUS_OBJECT_PATH_SYNTAX_BAD, "RtlCheckRegistryKey with RTL_REGISTRY_ABSOLUTE and Path being empty: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_USER, NULL); + ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_USER and Path being NULL: 0x%08x\n", status); + + status = pRtlCheckRegistryKey(RTL_REGISTRY_USER, empty); + ok(status == STATUS_SUCCESS, "RtlCheckRegistryKey with RTL_REGISTRY_USER and Path being empty: 0x%08x\n", status); }
static void test_NtFlushKey(void)