From 0f8e720711532d60200211ab7c6dce80e023b68f Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 31 May 2018 16:47:42 +0200 Subject: [PATCH] [NTDLL_APITEST][LIB_RTL] Add a test for RtlQueryTimeZoneInformation and fix the bug in RtlpQueryRegistryDirect In working on some problems with Time Zone adjustments in ReactOS I found that the RtlQueryTimeZoneInformation function is partially broken and wrote an apitest to capture the failures. Patch by Doug Lyons. CORE-14658 --- .../rostests/apitests/ntdll/CMakeLists.txt | 1 + modules/rostests/apitests/ntdll/testlist.c | 2 ++ sdk/lib/rtl/registry.c | 26 ++++++++++++------- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt b/modules/rostests/apitests/ntdll/CMakeLists.txt index 3e9756c7f35..a7fdc5a2cd9 100644 --- a/modules/rostests/apitests/ntdll/CMakeLists.txt +++ b/modules/rostests/apitests/ntdll/CMakeLists.txt @@ -49,6 +49,7 @@ list(APPEND SOURCE RtlMemoryStream.c RtlNtPathNameToDosPathName.c RtlpEnsureBufferSize.c + RtlQueryTimeZoneInfo.c RtlReAllocateHeap.c RtlUnicodeStringToAnsiString.c RtlUpcaseUnicodeStringToCountedOemString.c diff --git a/modules/rostests/apitests/ntdll/testlist.c b/modules/rostests/apitests/ntdll/testlist.c index f17f87267cc..c6afd1d3425 100644 --- a/modules/rostests/apitests/ntdll/testlist.c +++ b/modules/rostests/apitests/ntdll/testlist.c @@ -53,6 +53,7 @@ extern void func_RtlIsNameLegalDOS8Dot3(void); extern void func_RtlMemoryStream(void); extern void func_RtlNtPathNameToDosPathName(void); extern void func_RtlpEnsureBufferSize(void); +extern void func_RtlQueryTimeZoneInformation(void); extern void func_RtlReAllocateHeap(void); extern void func_RtlUnicodeStringToAnsiString(void); extern void func_RtlUpcaseUnicodeStringToCountedOemString(void); @@ -111,6 +112,7 @@ const struct test winetest_testlist[] = { "RtlMemoryStream", func_RtlMemoryStream }, { "RtlNtPathNameToDosPathName", func_RtlNtPathNameToDosPathName }, { "RtlpEnsureBufferSize", func_RtlpEnsureBufferSize }, + { "RtlQueryTimeZoneInformation", func_RtlQueryTimeZoneInformation }, { "RtlReAllocateHeap", func_RtlReAllocateHeap }, { "RtlUnicodeStringToAnsiString", func_RtlUnicodeStringToAnsiString }, { "RtlUpcaseUnicodeStringToCountedOemString", func_RtlUpcaseUnicodeStringToCountedOemString }, diff --git a/sdk/lib/rtl/registry.c b/sdk/lib/rtl/registry.c index 02361efc486..bc69d4d0b33 100644 --- a/sdk/lib/rtl/registry.c +++ b/sdk/lib/rtl/registry.c @@ -96,17 +96,25 @@ RtlpQueryRegistryDirect(IN ULONG ValueType, } else { - /* Check if there's space for the length and type, plus data */ - if (*Length < (2 * sizeof(ULONG) + ValueLength)) + if (ValueType != REG_BINARY) { - /* Nope, fail */ - return STATUS_BUFFER_TOO_SMALL; - } + /* Check if there's space for the length and type, plus data */ + if (*Length < (2 * sizeof(ULONG) + ValueLength)) + { + /* Nope, fail */ + return STATUS_BUFFER_TOO_SMALL; + } - /* Return the data */ - *Length++ = ValueLength; - *Length++ = ValueType; - RtlCopyMemory(Length, ValueData, ValueLength); + /* Return the data */ + *Length++ = ValueLength; + *Length++ = ValueType; + RtlCopyMemory(Length, ValueData, ValueLength); + } + else + { + /* Return the REG_BINARY data */ + RtlCopyMemory(Length, ValueData, ValueLength); + } } } -- 2.17.1