Check localtime() return value; coverity CID 208156

This commit is contained in:
Todd C. Miller
2020-02-07 13:58:31 -07:00
parent a75992897c
commit d25ce46c56

View File

@@ -138,8 +138,8 @@ approval_check(unsigned int version, sudo_conv_t conversation,
* which are 9am - 5pm local time. Does not check holidays. * which are 9am - 5pm local time. Does not check holidays.
*/ */
ret = 0; ret = 0;
time(&now); if (time(&now) == -1 || (tm = localtime(&now)) == NULL)
tm = localtime(&now); goto bad;
if (tm->tm_wday < 1 || tm->tm_wday > 5) { if (tm->tm_wday < 1 || tm->tm_wday > 5) {
/* bad weekday */ /* bad weekday */
goto bad; goto bad;
@@ -164,7 +164,7 @@ bad:
} }
done: done:
while ((debug_file = TAILQ_FIRST(&debug_files))) { while ((debug_file = TAILQ_FIRST(&debug_files)) != NULL) {
TAILQ_REMOVE(&debug_files, debug_file, entries); TAILQ_REMOVE(&debug_files, debug_file, entries);
free(debug_file->debug_file); free(debug_file->debug_file);
free(debug_file->debug_flags); free(debug_file->debug_flags);