X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fctf.c;h=717f48d4cf1bbdd81bc8e676c1e325e02fa9c83b;hp=08834e9744318e944ae97ad006c43f8ca79b8bb0;hb=546293fa85416f739f1cfc125c5c4bcd25075a5d;hpb=5385cf15115d777de4a220a164c101da0e4c3bac diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 08834e97..717f48d4 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -448,6 +448,21 @@ int create_stream_packet_index(struct ctf_trace *td, /* Use content size if non-zero, else file size */ packet_index.packet_size = packet_index.content_size ? : filestats.st_size * CHAR_BIT; } + + /* Validate content size and packet size values */ + if (packet_index.content_size > packet_index.packet_size) { + fprintf(stdout, "[error] Content size (%zu bits) is larger than packet size (%zu bits).\n", + packet_index.content_size, packet_index.packet_size); + 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); + return -EINVAL; + } + + /* Save position after header and context */ packet_index.data_offset = pos->offset;