[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.

This commit is contained in:
Hermès Bélusca-Maïto 2020-04-19 18:50:00 +02:00
parent 7c3e96a26a
commit bbdb0ab6a8
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -152,6 +152,30 @@ QueryTimeZoneData(
LONG lError; LONG lError;
DWORD dwValueSize; 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) if (Description && DescriptionSize && *DescriptionSize > 0)
{ {
lError = RegQueryValueExW(hZoneKey, lError = RegQueryValueExW(hZoneKey,
@ -161,7 +185,7 @@ QueryTimeZoneData(
(LPBYTE)Description, (LPBYTE)Description,
DescriptionSize); DescriptionSize);
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
return lError; *Description = 0;
} }
if (StandardName && StandardNameSize && *StandardNameSize > 0) if (StandardName && StandardNameSize && *StandardNameSize > 0)
@ -173,7 +197,7 @@ QueryTimeZoneData(
(LPBYTE)StandardName, (LPBYTE)StandardName,
StandardNameSize); StandardNameSize);
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
return lError; *StandardName = 0;
} }
if (DaylightName && DaylightNameSize && *DaylightNameSize > 0) if (DaylightName && DaylightNameSize && *DaylightNameSize > 0)
@ -185,30 +209,10 @@ QueryTimeZoneData(
(LPBYTE)DaylightName, (LPBYTE)DaylightName,
DaylightNameSize); DaylightNameSize);
if (lError != ERROR_SUCCESS) if (lError != ERROR_SUCCESS)
return lError; *DaylightName = 0;
} }
if (Index) return ERROR_SUCCESS;
{
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;
} }
// //