From: Todd C. Miller Date: Mon, 20 Feb 2017 23:44:02 +0000 (-0700) Subject: Check for gmtime() or localtime() returning NULL and just use a X-Git-Tag: SUDO_1_8_20^2~97 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00b76afe46de2a7e43076061b8212898a8d76966;p=sudo Check for gmtime() or localtime() returning NULL and just use a zero offset in that case. Should not be possible. --- diff --git a/plugins/sudoers/gmtoff.c b/plugins/sudoers/gmtoff.c index ccd4567ce..7e01773fc 100644 --- a/plugins/sudoers/gmtoff.c +++ b/plugins/sudoers/gmtoff.c @@ -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) +