Menu

#718 curl_getdate() fails to parse UTC +1300

closed-fixed
libcurl (356)
5
2015-02-07
2008-01-03
No

There are areas of New Zealand currently under Daylight Saving Time at UTC +1300. For reference, see for example <http://en.wikipedia.org/wiki/Time_zone>. However, the function curl_getdate() fails to parse these dates, because it has an erroneous, hard-coded limit that only allows values less than +1300. So curl_getdate() returns -1 for "Tue, 01 Jan 2008 00:00:01 +1300" but correctly parses "Tue, 01 Jan 2008 00:00:01 +1200".

This bug still exists as of the daily snapshot on Jan 3, 2008. The problematic code is in the function parsedate() at lib/parsedate.c:292.

if((tzoff == -1) &&
((end - date) == 4) &&
(val < 1300) &&
(indate< date) &&
((date[-1] == '+' || date[-1] == '-'))) {
/* four digits and a value less than 1300 and it is preceeded with
a plus or minus. This is a time zone indication. */
found = TRUE;
tzoff = (val/100 * 60 + val%100)*60;

/* the + and - prefix indicates the local time compared to GMT,
this we need ther reversed math to get what we want */
tzoff = date[-1]=='+'?-tzoff:tzoff;
}

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2008-01-05

    Logged In: YES
    user_id=1110
    Originator: NO

    so a simple <= 1300 will be fine then?

     
  • Anonymous

    Anonymous - 2008-01-05

    Logged In: YES
    user_id=993558
    Originator: YES

    It should be at least < 1400. An even higher limit might be advisable, to 'future proof' the code. Locales can do crazy things with DST.

     
  • Daniel Stenberg

    Daniel Stenberg - 2008-01-06

    Logged In: YES
    user_id=1110
    Originator: NO

    Thanks a lot for your report and feedback, I committed a fix that now accepts -1400 to +1400 offsets, as I found a resource on the net that mentioned them being delimiters a time zone parser should expect, so until we find something that indicates even larger offsets I think these will be fine.

    Case closed!

     
  • Daniel Stenberg

    Daniel Stenberg - 2008-01-06
    • status: open --> closed-fixed
     
  • Anonymous

    Anonymous - 2008-01-06

    Logged In: YES
    user_id=993558
    Originator: YES

    Thanks, Daniel!