From 00b76afe46de2a7e43076061b8212898a8d76966 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 20 Feb 2017 16:44:02 -0700 Subject: [PATCH] Check for gmtime() or localtime() returning NULL and just use a zero offset in that case. Should not be possible. --- plugins/sudoers/gmtoff.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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) + -- 2.40.0