[PATCH] tools/lib/traceevent: Add sanity check to is_timestamp_in_us()

From: Steven Rostedt
Date: Wed Nov 28 2018 - 14:55:56 EST



From: Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx>

This patch adds a sanity check to is_timestamp_in_us() input
parameter trace_clock. It avoids a potential segfault in this
function for the case trace_clock is NULL.

Reported-by: Slavomir Kaslev <kaslevs@xxxxxxxxxx>
Signed-off-by: Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx>
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
tools/lib/traceevent/event-parse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 3692f29fee46..c383305510b4 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5409,7 +5409,7 @@ void tep_event_info(struct trace_seq *s, struct tep_event_format *event,

static bool is_timestamp_in_us(char *trace_clock, bool use_trace_clock)
{
- if (!use_trace_clock)
+ if (!trace_clock || !use_trace_clock)
return true;

if (!strcmp(trace_clock, "local") || !strcmp(trace_clock, "global")
--
2.19.1