libtraceevent: Handle case of unknown operator
PATCH 1/1 libtraceevent: Handle case of unknown operator
From: "Steven Rostedt (Google)" <[email protected]>
The m68k architecture had a trace event with "m68k_memory[0].addr >> 13" in it. The parsing after the ']' and before the '.' checked the priority of the '.' but because it does not handle '.' as an operator it returned a negative number. But process_op() did not check for an error and continued processing. This caused a segfault.
Return immediately if the operator is not handled by get_op_prio().
--- src/event-parse.c | 4 ++++ 1 file changed, 4 insertions(+)
src/event-parse.c +4 -0
@@ -2498,6 +2498,10 @@ process_op(struct tep_event *event, struct tep_print_arg *arg, char **tok)/* higher prios need to be closer to the root */ prio =get_op_prio (*tok); +if (prio <0 ) { + token = *tok; + goto out_free; + }if (prio > arg->op.prio)return process_op (event, arg, tok);
Signature · 1 line
2.45.2
Hello Steve,
Quoted 8 lines · Steven Rostedt
From: "Steven Rostedt (Google)" <[email protected]>
The m68k architecture had a trace event with "m68k_memory[0].addr >> 13" in it. The parsing after the ']' and before the '.' checked the priority of the '.' but because it does not handle '.' as an operator it returned a negative number. But
process_op()did not check for an error and continued processing. This caused a segfault.
Quoted 7 lines
Return immediately if the operator is not handled by
get_op_prio().Reported-by Jean-Michel Hautbois <[email protected]>Fixes 6582b0aea1cc ("tools/events: Add files to create libtraceevent.a")Signed-off-by Steven Rostedt (Google) <[email protected]>
Thank you for your patch !
Quoted 19 lines
--- src/event-parse.c | 4 ++++ 1 file changed, 4 insertions(+)src/event-parse.c +4
-0@@ -2498,6 +2498,10 @@ process_op(struct tep_event *event, struct tep_print_arg *arg, char **tok)/* higher prios need to be closer to the root */ prio =get_op_prio (*tok); +if (prio <0 ) { + token = *tok; + goto out_free; + }if (prio > arg->op.prio)return process_op (event, arg, tok);