diff mbox series

[v3,1/4] libtraceevent: Ensure print_field_raw() terminates with '\0'

Message ID 20221213165620.1034287-2-vschneid@redhat.com (mailing list archive)
State Accepted
Commit b5db86a0405b25a922147bd0dbea58ab059bf11b
Headers show
Series libtraceevent: Handling cpumask event fields | expand

Commit Message

Valentin Schneider Dec. 13, 2022, 4:56 p.m. UTC
Testing printing cpumasks reveals an issue in print_field_raw()'s handling
of arrays: its final operation is trace_seq_putc(']'), which omits a final
'\0'.

The other cases in the function invoke trace_seq_printf() which does the
right thing, only the TEP_FIELD_IS_ARRAY case has that issue. Still, to
prevent any future surprises, add a call to trace_seq_terminate() at the
end of print_field_raw().

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
 src/event-parse.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/src/event-parse.c b/src/event-parse.c
index a6e9e93..093b345 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -5681,6 +5681,7 @@  static void print_field_raw(struct trace_seq *s, void *data, int size,
 				trace_seq_printf(s, "%llu", val);
 		}
 	}
+	trace_seq_terminate(s);
 }
 
 static int print_parse_data(struct tep_print_parse *parse, struct trace_seq *s,