From d25ce46c56d352d6194955b874928bf3a2d2a4cb Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 7 Feb 2020 13:58:31 -0700 Subject: [PATCH] Check localtime() return value; coverity CID 208156 --- plugins/sample_approval/sample_approval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/sample_approval/sample_approval.c b/plugins/sample_approval/sample_approval.c index e1f1d83aa..12a999e5b 100644 --- a/plugins/sample_approval/sample_approval.c +++ b/plugins/sample_approval/sample_approval.c @@ -138,8 +138,8 @@ approval_check(unsigned int version, sudo_conv_t conversation, * which are 9am - 5pm local time. Does not check holidays. */ ret = 0; - time(&now); - tm = localtime(&now); + if (time(&now) == -1 || (tm = localtime(&now)) == NULL) + goto bad; if (tm->tm_wday < 1 || tm->tm_wday > 5) { /* bad weekday */ goto bad; @@ -164,7 +164,7 @@ bad: } done: - while ((debug_file = TAILQ_FIRST(&debug_files))) { + while ((debug_file = TAILQ_FIRST(&debug_files)) != NULL) { TAILQ_REMOVE(&debug_files, debug_file, entries); free(debug_file->debug_file); free(debug_file->debug_flags);