archive mirror
 help / color / mirror / Atom feed
* [PATCH] libtraceevent: Do not print zero length dynamic strings
@ 2021-06-16  2:55 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2021-06-16  2:55 UTC (permalink / raw)
  To: Linux Trace Devel

From: "Steven Rostedt (VMware)" <>

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) <>
 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,
 		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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-16  2:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16  2:55 [PATCH] libtraceevent: Do not print zero length dynamic strings Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).