]> git.proxmox.com Git - pve-firewall.git/commitdiff
Fix #1492: logger: print timestamps only if we have one
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 4 Sep 2017 08:56:59 +0000 (10:56 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 4 Sep 2017 10:39:27 +0000 (12:39 +0200)
There's no guarantee that there's a timestamp in an skb, so
nflog_get_timestamp can fail.

src/pvefw-logger.c

index 3dc40eb527701f7dc76432c3c1fada9f2507ec24..12ada772c3e51db5fe20b1798d8b21ee67c39922 100644 (file)
@@ -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);