[glib] glib/gtimezone.c: Check the size of tzi.DaylightName



commit 2cb9b8f99491959e53783d127daa8c99b81e159e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jan 7 13:34:09 2014 +0800

    glib/gtimezone.c: Check the size of tzi.DaylightName
    
    We need to re-get the size of tzi.DaylightName before we call
    RegQueryValue() because the buffer might not have enough room to hold the
    value for tzi.DaylightName that would be acquired by RegQueryValueExA(),
    even though the size of tzi.DaylightName and tzi.StandardName is the same.
    
    This is a pitfall of RegQueryValue()[1] as not doing this can result in an
    ERROR_MORE_DATA (234) failure, causing the acquisition of tzi.DaylightName
    to fail.
    
    This will fix the gdatetime/equal test, amongst some other tests in
    gdatetime, at least on certain non-English version of Windows.
    
    [1]: 
http://social.msdn.microsoft.com/Forums/vstudio/en-US/84f90854-e90c-4b63-8fc1-655a0b4645fd/regqueryvalueex-returns-errormoredata
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719344

 glib/gtimezone.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index f93c825..256ac80 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -664,6 +664,9 @@ rules_from_windows_time_zone (const gchar *identifier, TimeZoneRule **rules)
   if (RegQueryValueExA (key, "Std", NULL, NULL,
                         (LPBYTE)&(tzi.StandardName), &size) != ERROR_SUCCESS)
     goto failed;
+
+  size = sizeof tzi.DaylightName;
+
   if (RegQueryValueExA (key, "Dlt", NULL, NULL,
                         (LPBYTE)&(tzi.DaylightName), &size) != ERROR_SUCCESS)
     goto failed;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]