Fix babeltrace-log uninitialized memory (v2)
authorHui Zhu <teawater@gmail.com>
Fri, 7 Sep 2012 13:16:55 +0000 (09:16 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 7 Sep 2012 13:16:55 +0000 (09:16 -0400)
Got a crash with babeltrace-log.

../../../babeltrace/include/babeltrace/mmap-align.h:78 index=0, whence=0)
  at ../../../babeltrace/formats/ctf/ctf.c:623
  at ../../../babeltrace/formats/ctf/ctf.c:576 _IO_2_1_stdin_
  at ../../babeltrace/converter/babeltrace-log.c:233
../../babeltrace/converter/babeltrace-log.c:342

This issue because pos is used before it init.  This patch init it in
function ctf_init_pos.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
converter/babeltrace-log.c

index 6ac94e69236c3cb7f29d806aa0369b63bf5b2d4b..7f31d015226548969abfa515046ece454732dce9 100644 (file)
@@ -230,6 +230,7 @@ void trace_text(FILE *input, int output)
        char *line = NULL, *nl;
        size_t linesize;
 
+       memset(&pos, 0, sizeof(pos));
        ctf_init_pos(&pos, output, O_RDWR);
 
        write_packet_header(&pos, s_uuid);
This page took 0.024654 seconds and 4 git commands to generate.