BLF: Fix relative timestamp
authorGiovanni Musto <giovanni.musto@partner.italdesign.it>
Fri, 27 Oct 2023 08:56:11 +0000 (10:56 +0200)
committerPascal Quantin <pascal@wireshark.org>
Mon, 30 Oct 2023 14:25:00 +0000 (14:25 +0000)
Set timestamp of metadata objects to the start offset of the file, not 0

wiretap/blf.c

index 8b94230bc89122a373592048c756149974e0ae9a..a0b9e43a7865946598f6cb4f89b422a0c3f11346 100644 (file)
@@ -996,16 +996,25 @@ blf_init_rec(blf_params_t *params, guint32 flags, guint64 object_timestamp, int
         break;
 
     default:
-        /*
-         * XXX - report this as an error?
-         *
-         * Or provide a mechanism to allow file readers to report
-         * a warning (an error that the reader tries to work
-         * around and that the caller should report)?
-         */
-        ws_debug("I don't understand the flags 0x%x", flags);
-        params->rec->tsprec = WTAP_TSPREC_NSEC;
-        object_timestamp = 0;
+        if (flags == 0 && object_timestamp == 0) {
+            /* This is not an error, but is used for metadata at the beginning of the file. */
+            params->rec->tsprec = WTAP_TSPREC_NSEC;
+            object_timestamp = params->blf_data->start_offset_ns;
+        }
+        else {
+            /*
+             * XXX - report this as an error?
+             *
+             * Or provide a mechanism to allow file readers to report
+             * a warning (an error that the reader tries to work
+             * around and that the caller should report)?
+             *
+             * Set the timestamp to params->blf_data->start_offset_ns also here?
+             */
+            ws_debug("Unknown combination of flags and timestamp (0x%x, %" PRIu64 ")", flags, object_timestamp);
+            params->rec->tsprec = WTAP_TSPREC_NSEC;
+            object_timestamp = 0;
+        }
         break;
     }
     params->rec->ts.secs = object_timestamp / (1000 * 1000 * 1000);