Skip to content

Commit

Permalink
ctf: check version of LTTng trace index
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
simark authored and jgalar committed Nov 14, 2019
1 parent 2428e03 commit 2068d50
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plugins/ctf/fs-src/data-stream-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2068d50

Please sign in to comment.