From 58b0b8835f84f2a028328e02eb5044640880d1e5 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sat, 7 May 2011 10:18:32 -0400 Subject: [PATCH 1/1] fix packet vs file size check Signed-off-by: Mathieu Desnoyers --- formats/ctf/ctf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index f57d086e..a418a6d5 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -458,9 +458,9 @@ int create_stream_packet_index(struct ctf_trace *td, return -EINVAL; } - if (packet_index.packet_size > filestats.st_size * CHAR_BIT) { - fprintf(stdout, "[error] Packet size (%zu bits) is larger than file size (%zu bits).\n", - packet_index.content_size, filestats.st_size * CHAR_BIT); + if (packet_index.packet_size > (filestats.st_size - packet_index.offset) * CHAR_BIT) { + fprintf(stdout, "[error] Packet size (%zu bits) is larger than remaining file size (%zu bits).\n", + packet_index.content_size, (filestats.st_size - packet_index.offset) * CHAR_BIT); return -EINVAL; } -- 2.34.1