aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-06-12 18:50:29 +0200
committerlaforge <laforge@gnumonks.org>2019-06-13 15:34:01 +0000
commit3aef2389802b3b188ba285e8d1eed0e3256937ef (patch)
treebef89072f7290f35f9c6c1316689197ef7bf62c4
parentd1e220fb67e14115512b9020b26ad74c49daefc5 (diff)
logging: Check return error from time() call
-rw-r--r--src/logging.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/logging.c b/src/logging.c
index 73a9c52..4c86473 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -361,7 +361,8 @@ static void _output(struct log_target *target, unsigned int subsys,
} else if (target->print_timestamp) {
char *timestr;
time_t tm;
- tm = time(NULL);
+ if ((tm = time(NULL)) == (time_t) -1)
+ goto err;
timestr = ctime(&tm);
timestr[strlen(timestr)-1] = '\0';
ret = snprintf(buf + offset, rem, "%s ", timestr);