ctf: check version of LTTng trace index
authorSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Nov 2019 17:08:53 +0000 (12:08 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Mon, 4 Nov 2019 20:27:19 +0000 (15:27 -0500)
If LTTng was to start producing trace index files with major version 2,
it would presumably be because the format has become
backwards-incompatible.  Babeltrace would currently try to parse it like
it parses version 1.x index files, and that would likely not give good
results.

This patch makes Babeltrace check the major version of LTTng trace index
files before parsing them, and ignore them if the major version is not 1.

Change-Id: Ieb4a795a3fce1f5196a2b4ab44575da1b4fc1364
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2325
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/plugins/ctf/fs-src/data-stream-file.c

index b9c3ae9e8f99b7fa20ea2d847055867b4bd7efbf..70f419022f9b4c91dfc4b2284f51ff59b5c1a70f 100644 (file)
@@ -303,6 +303,7 @@ struct ctf_fs_ds_index *build_index_from_idx_file(
        size_t i;
        struct ctf_stream_class *sc;
        struct ctf_msg_iter_packet_properties props;
+       uint32_t version_major, version_minor;
 
        BT_COMP_LOGI("Building index from .idx file of stream file %s",
                        ds_file->file->path->str);
@@ -373,6 +374,16 @@ struct ctf_fs_ds_index *build_index_from_idx_file(
                goto error;
        }
 
+       version_major = be32toh(header->index_major);
+       version_minor = be32toh(header->index_minor);
+       if (version_major != 1) {
+               BT_COMP_LOGW(
+                       "Unknown LTTng trace index version: "
+                       "major=%" PRIu32 ", minor=%" PRIu32,
+                       version_major, version_minor);
+               goto error;
+       }
+
        file_index_entry_size = be32toh(header->packet_index_len);
        file_entry_count = (filesize - sizeof(*header)) / file_index_entry_size;
        if ((filesize - sizeof(*header)) % file_index_entry_size) {
This page took 0.026114 seconds and 4 git commands to generate.