]> granicus.if.org Git - sudo/commitdiff
Check for gmtime() or localtime() returning NULL and just use a
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 20 Feb 2017 23:44:02 +0000 (16:44 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 20 Feb 2017 23:44:02 +0000 (16:44 -0700)
zero offset in that case.  Should not be possible.

plugins/sudoers/gmtoff.c

index ccd4567ce384c0311024c2bbb7417adcf5cc24b9..7e01773fcfa3bb7e78d1ebaafff3c6abfd1f4797 100644 (file)
@@ -42,11 +42,14 @@ get_gmtoff(time_t *clock)
 long
 get_gmtoff(time_t *clock)
 {
-       struct tm gmt, *local;
+       struct tm *gm, gmt, *local;
        long offset;
 
-       gmt = *gmtime(clock);
-       local = localtime(clock);
+       if ((gm = gmtime(clock)) == NULL)
+           return 0;
+       gmt = *gm;
+       if ((local = localtime(clock)) == NULL)
+           return 0;
 
        offset = (local->tm_sec - gmt.tm_sec) +
            ((local->tm_min - gmt.tm_min) * 60) +