Merge branch 'master' of ssh://efficios.com/home/efficios/git/babeltrace
[babeltrace.git] / formats / ctf / ctf.c
index 2b2e15185275b68699467ea62f07aa8ef35bca1b..098b7eb15d7d4589880243ed7d0ecdc66c7b4152 100644 (file)
@@ -475,7 +475,7 @@ int ctf_open_trace_metadata_packet_read(struct ctf_trace *td, FILE *in,
 {
        struct metadata_packet_header header;
        size_t readlen, writelen, toread;
-       char buf[4096];
+       char buf[4096 + 1];     /* + 1 for debug-mode \0 */
        int ret = 0;
 
        readlen = fread(&header, header_sizeof(header), 1, in);
@@ -516,12 +516,13 @@ int ctf_open_trace_metadata_packet_read(struct ctf_trace *td, FILE *in,
        toread = (header.content_size / CHAR_BIT) - header_sizeof(header);
 
        for (;;) {
-               readlen = fread(buf, sizeof(char), min(sizeof(buf), toread), in);
+               readlen = fread(buf, sizeof(char), min(sizeof(buf) - 1, toread), in);
                if (ferror(in)) {
                        ret = -EINVAL;
                        break;
                }
                if (babeltrace_debug) {
+                       buf[readlen] = '\0';
                        fprintf(stdout, "[debug] metadata packet read: %s\n",
                                buf);
                }
@@ -907,13 +908,12 @@ int create_stream_packet_index(struct ctf_trace *td,
                                return -EINVAL;
                        }
                        file_stream->parent.stream_class = stream;
+                       ret = create_stream_definitions(td, &file_stream->parent);
+                       if (ret)
+                               return ret;
                }
                first_packet = 0;
 
-               ret = create_stream_definitions(td, &file_stream->parent);
-               if (ret)
-                       return ret;
-
                if (file_stream->parent.stream_packet_context) {
                        /* Read packet context */
                        ret = generic_rw(&pos->parent, &file_stream->parent.stream_packet_context->p);
This page took 0.031136 seconds and 4 git commands to generate.