]> git.saurik.com Git - apt.git/commitdiff
let TimeRFC1123 return an empty string if gmtime() fails
authorDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 2 Apr 2011 15:59:10 +0000 (17:59 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Sat, 2 Apr 2011 15:59:10 +0000 (17:59 +0200)
apt-pkg/contrib/strutl.cc

index ace738d7a13599ab73b1ef628387dd7f7dbfc2d8..072dda3ac3b1f74b76f403c4d79bbaffdc5fbbae 100644 (file)
@@ -692,9 +692,11 @@ int StringToBool(const string &Text,int Default)
    year 2000 complient and timezone neutral */
 string TimeRFC1123(time_t Date)
 {
-   struct tm Conv = *gmtime(&Date);
-   char Buf[300];
+   struct tm Conv;
+   if (gmtime_r(&Date, &Conv) == NULL)
+      return "";
 
+   char Buf[300];
    const char *Day[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
    const char *Month[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul",
                           "Aug","Sep","Oct","Nov","Dec"};