diff mbox series

libtraceevent: Fix uninitialized variable in eval_num_arg()

Message ID 20220923123014.489e0e39@gandalf.local.home (mailing list archive)
State Accepted
Commit 7190a0111b4c7e2e767915a8830a197282a9f9d5
Headers show
Series libtraceevent: Fix uninitialized variable in eval_num_arg() | expand

Commit Message

Steven Rostedt Sept. 23, 2022, 4:30 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

It appears that my compiler version did not notice that "field_size"
passed to check_data_offset_size() in the TEP_PRINT_DYNAMIC_ARRAY case was
not initialized. But other compilers do.

Since this case we just want to make sure the offset is not passed the end
of the event data, we can simply pass in zero.

Fixes: efd32896dd5db ("libtraceevent: Add warnings if fields are outside the event")
Reported-by: Ross Zwisler <zwisler@google.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ross Zwisler Sept. 23, 2022, 8:59 p.m. UTC | #1
On Fri, Sep 23, 2022 at 12:30:14PM -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
> 
> It appears that my compiler version did not notice that "field_size"
> passed to check_data_offset_size() in the TEP_PRINT_DYNAMIC_ARRAY case was
> not initialized. But other compilers do.
> 
> Since this case we just want to make sure the offset is not passed the end
> of the event data, we can simply pass in zero.
> 
> Fixes: efd32896dd5db ("libtraceevent: Add warnings if fields are outside the event")
> Reported-by: Ross Zwisler <zwisler@google.com>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Reviewed-by: Ross Zwisler <zwisler@google.com>
diff mbox series

Patch

diff --git a/src/event-parse.c b/src/event-parse.c
index 980e980985ad..a0458e548765 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -4310,7 +4310,7 @@  eval_num_arg(void *data, int size, struct tep_event *event, struct tep_print_arg
 		dynamic_offset_field(tep, arg->dynarray.field, data, size,
 				     &offset, NULL);
 		if (check_data_offset_size(event, arg->field.name, size,
-					   offset, field_size)) {
+					   offset, 0)) {
 			val = (unsigned long)data;
 			break;
 		}