*/
if (unlikely(pos->offset == EOF))
return EOF;
+
+ if (pos->content_size == 0) {
+ /* Stream is inactive for now (live reading). */
+ return EAGAIN;
+ }
+ /* Packet only contains headers */
+ if (pos->offset == pos->content_size)
+ return EAGAIN;
+
assert(pos->offset < pos->content_size);
/* Read event header */
return -EINVAL;
}
+ if (packet_index.content_size < pos->offset) {
+ fprintf(stderr, "[error] Invalid CTF stream: content size is smaller than packet headers.\n");
+ return -EINVAL;
+ }
+
if ((packet_index.packet_size >> LOG2_CHAR_BIT) == 0) {
fprintf(stderr, "[error] Invalid CTF stream: packet size needs to be at least one byte\n");
return -EINVAL;
ret = -1;
goto error;
}
+ if (index_hdr.packet_index_len == 0) {
+ fprintf(stderr, "[error] Packet index length cannot be 0.\n");
+ ret = -1;
+ goto error;
+ }
while ((index_read = fread(&ctf_index, index_hdr.packet_index_len, 1,
pos->index_fp)) == 1) {