be sure that the RFC1123StrToTime method is run in a LANG=C environment
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 9 Jun 2010 16:23:23 +0000 (18:23 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 9 Jun 2010 16:23:23 +0000 (18:23 +0200)
apt-pkg/contrib/strutl.cc

index 1604503..ace74cb 100644 (file)
@@ -861,12 +861,16 @@ static time_t timegm(struct tm *t)
 bool RFC1123StrToTime(const char* const str,time_t &time)
 {
    struct tm Tm;
+   setlocale (LC_ALL,"C");
+   bool const invalid =
    // Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
-   if (strptime(str, "%a, %d %b %Y %H:%M:%S %Z", &Tm) == NULL &&
+      (strptime(str, "%a, %d %b %Y %H:%M:%S %Z", &Tm) == NULL &&
    // Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
        strptime(str, "%A, %d-%b-%y %H:%M:%S %Z", &Tm) == NULL &&
    // Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() format
-       strptime(str, "%a %b %d %H:%M:%S %Y", &Tm) == NULL)
+       strptime(str, "%a %b %d %H:%M:%S %Y", &Tm) == NULL);
+   setlocale (LC_ALL,"");
+   if (invalid == true)
       return false;
 
    time = timegm(&Tm);