diff mbox series

[BlueZ,1/1] hcidump:fix array boundary issue le_meta_ev_dump()

Message ID 20230112232112.212021-2-jqian@calamp.com
State New
Headers show
Series *** hcidump: fix array boundary issue le_meta_ev_dump *** | expand

Commit Message

Jing Qian Jan. 12, 2023, 11:21 p.m. UTC
le_meta_ev_dump() print array content without checking index boundary.
hcidump would crash if the event index is out-of-boundary
---
 tools/parser/hci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/parser/hci.c b/tools/parser/hci.c
index db7d32c011b9..30feafaed36c 100644
--- a/tools/parser/hci.c
+++ b/tools/parser/hci.c
@@ -3657,7 +3657,11 @@  static inline void le_meta_ev_dump(int level, struct frame *frm)
 	frm->len -= EVT_LE_META_EVENT_SIZE;
 
 	p_indent(level, frm);
-	printf("%s\n", ev_le_meta_str[subevent]);
+	if (subevent <= LE_EV_NUM) {
+		printf("%s\n", ev_le_meta_str[subevent]);
+	} else {
+		printf("Undefined--> %d\n", subevent);
+	}
 
 	switch (mevt->subevent) {
 	case EVT_LE_CONN_COMPLETE: