]> granicus.if.org Git - file/commitdiff
fix for broken ctime/asctime.
authorChristos Zoulas <christos@zoulas.com>
Wed, 18 Nov 2009 23:35:14 +0000 (23:35 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 18 Nov 2009 23:35:14 +0000 (23:35 +0000)
ChangeLog
src/print.c

index c0d5b8073eed5277095fd491168aebf9a3accd79..44ce2bc9ad66b2d29538f978ae631fd4f82def00 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-11-17  18:35  Christos Zoulas <christos@zoulas.com<
+
+       * ctime/asctime can return NULL on some OS's although
+         they should not (Toshit Antani)
+
 2009-09-14  13:49  Christos Zoulas <christos@zoulas.com<
 
        * Centralize magic path handling routines and remove the
index 7c6932a9a8c2a723a7d97f0e94fd6fc762916fc1..18dc203f8105fe05c5343b33bc918182df8166f2 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: print.c,v 1.66 2009/02/03 20:27:51 christos Exp $")
+FILE_RCSID("@(#)$File: print.c,v 1.67 2009/10/19 13:10:20 christos Exp $")
 #endif  /* lint */
 
 #include <string.h>
@@ -218,7 +218,7 @@ file_fmttime(uint32_t v, int local)
                        (void)time(&now);
                        tm1 = localtime(&now);
                        if (tm1 == NULL)
-                               return "*Invalid time*";
+                               goto out;
                        daylight = tm1->tm_isdst;
                }
 #endif /* HAVE_TM_ISDST */
@@ -227,10 +227,14 @@ file_fmttime(uint32_t v, int local)
                        t += 3600;
                tm = gmtime(&t);
                if (tm == NULL)
-                       return "*Invalid time*";
+                       goto out;
                pp = asctime(tm);
        }
 
+       if (pp == NULL)
+               goto out;
        pp[strcspn(pp, "\n")] = '\0';
        return pp;
+out:
+       return "*Invalid time*";
 }