Skip to contentSkip to conversation

tools/hcidump: fix a out-of-bounds read in le_meta_ev_dump()

PATCH New zefang han 1 participant 1 message Aug 30, 2020 Bluetooth drivers

lore
Share & tools
lore

zefang han

author
#0 lore raw

PATCH 1/1 tools/hcidump: fix a out-of-bounds read in le_meta_ev_dump()

Check whether the subevent code of le meta event is bigger than the size of ev_le_meta_str.

---
 tools/parser/hci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/parser/hci.c +6 -1
index 41f6fe087..acd41be83 100644
@@ -3668,7 +3668,12 @@ 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("Unknown\n");
+	} else {
+		printf("%s\n", ev_le_meta_str[subevent]);
+	}
 
 	switch (mevt->subevent) {
 	case EVT_LE_CONN_COMPLETE:
Signature · 1 line
2.17.1