From 2388cab121beef58bb20b6b2275379304c6de737 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 4 Sep 2017 10:56:59 +0200 Subject: [PATCH] Fix #1492: logger: print timestamps only if we have one There's no guarantee that there's a timestamp in an skb, so nflog_get_timestamp can fail. --- src/pvefw-logger.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pvefw-logger.c b/src/pvefw-logger.c index 3dc40eb..12ada77 100644 --- a/src/pvefw-logger.c +++ b/src/pvefw-logger.c @@ -753,9 +753,11 @@ static int print_pkt(struct log_entry *le, struct nflog_data *ldata, u_int8_t fa LEPRINTF("%s ", chain_name); struct timeval ts; - nflog_get_timestamp(ldata, &ts); - - LEPRINTTIME(ts.tv_sec); + if (nflog_get_timestamp(ldata, &ts) == 0) { + LEPRINTTIME(ts.tv_sec); + } else { + LEPRINTTIME(time(NULL)); + } if (prefix != NULL) { LEPRINTF("%s", prefix); -- 2.39.2