summaryrefslogtreecommitdiff
path: root/monitor/sdp.c
diff options
context:
space:
mode:
authorMatias Karhumaa <matias.karhumaa@gmail.com>2018-10-16 23:25:08 +0300
committerJohan Hedberg <johan.hedberg@intel.com>2018-10-18 19:10:36 +0300
commit3ebf246be6e9fbfe8262473f60f42ce08892c0f9 (patch)
treeb201e812ce7a18103813b72bdcdc305a24d5a693 /monitor/sdp.c
parent800257a5aae104ba73c5d299cd350643610998b0 (diff)
downloadbluez-3ebf246be6e9fbfe8262473f60f42ce08892c0f9.tar.gz
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.
Diffstat (limited to 'monitor/sdp.c')
-rw-r--r--monitor/sdp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/monitor/sdp.c b/monitor/sdp.c
index 13a8807c7..36708f426 100644
--- a/monitor/sdp.c
+++ b/monitor/sdp.c
@@ -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);