From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx> If a dynamic string happens to not have any length, which means that it does not even have a null pointer, but the parsing code will still look at the offset, and read the string at that location. If there's another dynamic string after it, it will mistakenly report that next string as the current one. This can be confusing, as the string being printed is not the string expected. Discovered this when playing with kprobes and exec arguments. Fixes: ("tools/events: Add files to create libtraceevent.a") Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx> --- src/event-parse.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/event-parse.c b/src/event-parse.c index 1217491..7a75e9b 100644 --- a/src/event-parse.c +++ b/src/event-parse.c @@ -4392,6 +4392,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, break; case TEP_PRINT_STRING: { int str_offset; + int len; if (arg->string.offset == -1) { struct tep_format_field *f; @@ -4400,6 +4401,10 @@ static void print_str_arg(struct trace_seq *s, void *data, int size, arg->string.offset = f->offset; } str_offset = data2host4(tep, *(unsigned int *)(data + arg->string.offset)); + len = (str_offset >> 16) & 0xffff; + /* Do not attempt to save zero length dynamic strings */ + if (!len) + break; str_offset &= 0xffff; print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset); break; -- 2.29.2