From: Mathieu Desnoyers Date: Sat, 7 May 2011 14:18:32 +0000 (-0400) Subject: fix packet vs file size check X-Git-Tag: v0.1~83 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=58b0b8835f84f2a028328e02eb5044640880d1e5;hp=df752f351b1ba0f8cd0b70ba328afa8d36bc31a9 fix packet vs file size check Signed-off-by: Mathieu Desnoyers --- 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; }