Skip to contentSkip to conversation

tools/lib/traceevent: Sanity check of is_timestamp_in_us()

PATCH In review Tzvetomir Stoyanov 2 participants 3 messages Nov 29, 2018 – Dec 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/lib/traceevent: Sanity check of is_timestamp_in_us()

This patch adds a sanity check of is_timestamp_in_us() input parameter trace_clock. It avoids a potential segfailt in this function in case trace_clock is NULL.

---
 tools/lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
index 854b68ef2e4e..12449c308853 100644
@@ -5454,7 +5454,7 @@ void tep_event_info(struct trace_seq *s, struct tep_event *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")
Signature · 1 line
2.19.1
#1 lore raw
Quoted 5 lines · On Wed, 28 Nov 2018 14:40:49 +0000 Tzvetomir Stoyanov <[email protected]>…

This patch adds a sanity check of is_timestamp_in_us() input parameter trace_clock. It avoids a potential segfailt in this function in case trace_clock is NULL.

Thanks Tzvetomir!

I'm going to add a:

to this patch.

-- Steve

Quoted 17 lines
---
 tools/lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
index 854b68ef2e4e..12449c308853 100644
@@ -5454,7 +5454,7 @@ void tep_event_info(struct trace_seq *s, struct tep_event *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 lore raw
In reply to Tzvetomir Stoyanov
Quoted 3 lines · On Wed, 28 Nov 2018 14:40:49 +0000 Tzvetomir Stoyanov <[email protected]>…

This patch adds a sanity check of is_timestamp_in_us() input parameter trace_clock. It avoids a potential segfailt in this function in case trace_clock is NULL.

FYI, I applied this to trace-cmd as well.

-- Steve

Quoted 19 lines
---
 tools/lib/traceevent/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +1 -1
index 854b68ef2e4e..12449c308853 100644
@@ -5454,7 +5454,7 @@ void tep_event_info(struct trace_seq *s, struct tep_event *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")