From 42025f92ff4da26a97019d8b98eb0d9143a88724 Mon Sep 17 00:00:00 2001 From: Florian Obser Date: Sun, 28 Apr 2024 16:43:44 +0000 Subject: gmtime(3) / locatime(3) can fail when timestamps are way off. Add missing error checks to all calls under sbin/ Input & OK millert --- sbin/unwind/libunbound/util/log.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sbin/unwind') diff --git a/sbin/unwind/libunbound/util/log.c b/sbin/unwind/libunbound/util/log.c index a15ee920c0f..86a3acee43c 100644 --- a/sbin/unwind/libunbound/util/log.c +++ b/sbin/unwind/libunbound/util/log.c @@ -271,8 +271,8 @@ log_vmsg(int pri, const char* type, } now = (time_t)time(NULL); #if defined(HAVE_STRFTIME) && defined(HAVE_LOCALTIME_R) - if(log_time_asc && strftime(tmbuf, sizeof(tmbuf), "%b %d %H:%M:%S", - localtime_r(&now, &tm))%(sizeof(tmbuf)) != 0) { + if(log_time_asc && localtime_r(&now, &tm) && strftime(tmbuf, + sizeof(tmbuf), "%b %d %H:%M:%S", &tm)%(sizeof(tmbuf)) != 0) { /* %sizeof buf!=0 because old strftime returned max on error */ fprintf(logfile, "%s %s[%d:%x] %s: %s\n", tmbuf, ident, (int)getpid(), tid?*tid:0, type, message); -- cgit v1.2.3