Skip to contentSkip to conversation

btmon: fix segfault caused by buffer over-read

PATCH In review Matias Karhumaa 1 participant 1 message Oct 16, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 12/12 btmon: fix segfault caused by buffer over-read

Fix segfault caused by buffer over-read in service_rsp function of monitor/sdp.c.

This bug can be triggered locally reading malformed btmon capture file and also over the air by sending specifically crafted SDP Search Attribute response to device running btmon.

Bug was found by fuzzing btmon with AFL.

---
 monitor/sdp.c | 4 ++++
 1 file changed, 4 insertions(+)
monitor/sdp.c +4 -0
index 13a8807c7..36708f426 100644
@@ -585,6 +585,10 @@ static void service_rsp(const struct l2cap_frame *frame, struct tid_data *tid)
 	}
 
 	count = get_be16(frame->data + 2);
+	if (count * 4 > frame->size) {
+		print_text(COLOR_ERROR, "invalid record count");
+                return;
+	}
 
 	print_field("Total record count: %d", get_be16(frame->data));
 	print_field("Current record count: %d", count);
Signature · 1 line
2.17.1