Skip to contentSkip to conversation

libtraceevent: Fix uninitialized variable in eval_num_arg()

PATCH In review Steven Rostedt 2 participants 2 messages Sep 23, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libtraceevent: Fix uninitialized variable in eval_num_arg()

From: "Steven Rostedt (Google)" <[email protected]>

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")
---
 src/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/event-parse.c +1 -1
index 980e980985ad..a0458e548765 100644
@@ -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;
 		}
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Steven Rostedt

From: "Steven Rostedt (Google)" <[email protected]>

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.

Quoted 6 lines

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")