From bbdb0ab6a8a576fb9da0f57908d9e725c4925849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 19 Apr 2020 18:50:00 +0200 Subject: [PATCH] [TZLIB] QueryTimeZoneData(): Don't fail if the optional values "Display", "Std", "Dlt" are missing (or too long to be captured). However fail if the timezone information is missing. --- sdk/lib/tzlib/tzlib.c | 52 +++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/sdk/lib/tzlib/tzlib.c b/sdk/lib/tzlib/tzlib.c index 93c33a3fb3a..1dc0cbe7f76 100644 --- a/sdk/lib/tzlib/tzlib.c +++ b/sdk/lib/tzlib/tzlib.c @@ -152,6 +152,30 @@ QueryTimeZoneData( LONG lError; DWORD dwValueSize; + if (Index) + { + dwValueSize = sizeof(*Index); + lError = RegQueryValueExW(hZoneKey, + L"Index", + NULL, + NULL, + (LPBYTE)Index, + &dwValueSize); + if (lError != ERROR_SUCCESS) + *Index = 0; + } + + /* The time zone information structure is mandatory for a valid time zone */ + dwValueSize = sizeof(*TimeZoneInfo); + lError = RegQueryValueExW(hZoneKey, + L"TZI", + NULL, + NULL, + (LPBYTE)TimeZoneInfo, + &dwValueSize); + if (lError != ERROR_SUCCESS) + return lError; + if (Description && DescriptionSize && *DescriptionSize > 0) { lError = RegQueryValueExW(hZoneKey, @@ -161,7 +185,7 @@ QueryTimeZoneData( (LPBYTE)Description, DescriptionSize); if (lError != ERROR_SUCCESS) - return lError; + *Description = 0; } if (StandardName && StandardNameSize && *StandardNameSize > 0) @@ -173,7 +197,7 @@ QueryTimeZoneData( (LPBYTE)StandardName, StandardNameSize); if (lError != ERROR_SUCCESS) - return lError; + *StandardName = 0; } if (DaylightName && DaylightNameSize && *DaylightNameSize > 0) @@ -185,30 +209,10 @@ QueryTimeZoneData( (LPBYTE)DaylightName, DaylightNameSize); if (lError != ERROR_SUCCESS) - return lError; + *DaylightName = 0; } - if (Index) - { - dwValueSize = sizeof(*Index); - lError = RegQueryValueExW(hZoneKey, - L"Index", - NULL, - NULL, - (LPBYTE)Index, - &dwValueSize); - if (lError != ERROR_SUCCESS) - return lError; - } - - dwValueSize = sizeof(*TimeZoneInfo); - lError = RegQueryValueExW(hZoneKey, - L"TZI", - NULL, - NULL, - (LPBYTE)TimeZoneInfo, - &dwValueSize); - return lError; + return ERROR_SUCCESS; } //