From e83ce12aec89eb2aea94e892e66ba451f281acbd Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 24 Feb 2014 13:34:01 -0500 Subject: [PATCH] Fix: missing little endian conversion for one index field Locked-step with lttng-tools commit : Fix: missing big endian conversion for one index field Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- formats/ctf/ctf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index c503eca1..19ecfdc2 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -1818,6 +1818,7 @@ int import_stream_packet_index(struct ctf_trace *td, struct ctf_packet_index *ctf_index = NULL; struct ctf_packet_index_file_hdr index_hdr; struct packet_index index; + uint32_t packet_index_len; int ret = 0; int first_packet = 1; size_t len; @@ -1845,7 +1846,8 @@ int import_stream_packet_index(struct ctf_trace *td, ret = -1; goto error; } - if (index_hdr.packet_index_len == 0) { + packet_index_len = be32toh(index_hdr.packet_index_len); + if (packet_index_len == 0) { fprintf(stderr, "[error] Packet index length cannot be 0.\n"); ret = -1; goto error; @@ -1854,8 +1856,8 @@ int import_stream_packet_index(struct ctf_trace *td, * Allocate the index length found in header, not internal * representation. */ - ctf_index = g_malloc0(index_hdr.packet_index_len); - while (fread(ctf_index, index_hdr.packet_index_len, 1, + ctf_index = g_malloc0(packet_index_len); + while (fread(ctf_index, packet_index_len, 1, pos->index_fp) == 1) { uint64_t stream_id; struct ctf_stream_declaration *stream = NULL; -- 2.34.1