fix packet vs file size check
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 14:18:32 +0000 (10:18 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 7 May 2011 14:18:32 +0000 (10:18 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/ctf.c

index f57d086efcef1ff235aeb7140388e5be17fb2665..a418a6d507d4f1f33051495bdd3c95ada513f5ae 100644 (file)
@@ -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;
                }
 
This page took 0.026001 seconds and 4 git commands to generate.