File 0008-btmon-fix-segfault-caused-by-integer-undeflow.patch of Package bluez

From 1206eee71cd475882f0af9c4ec7990ae4822ddfe Mon Sep 17 00:00:00 2001
From: Matias Karhumaa <matias.karhumaa@gmail.com>
Date: Tue, 16 Oct 2018 23:23:12 +0300
Subject: [PATCH 08/13] btmon: fix segfault caused by integer undeflow

Fix segfault caused by integer underflow. Fix is to check that
rsp->num_codecs + 3 is not bigger than size before subtracting.

Crash was found by fuzzing btmon with AFL.
---
 monitor/packet.c | 5 +++++
 1 file changed, 5 insertions(+)

Index: bluez-5.48/monitor/packet.c
===================================================================
--- bluez-5.48.orig/monitor/packet.c
+++ bluez-5.48/monitor/packet.c
@@ -5897,6 +5897,11 @@ static void read_local_codecs_rsp(const
 	const struct bt_hci_rsp_read_local_codecs *rsp = data;
 	uint8_t i, num_vnd_codecs;
 
+	if (rsp->num_codecs + 3 > size) {
+		print_field("Invalid number of codecs.");
+		return;
+	}
+
 	print_status(rsp->status);
 	print_field("Number of supported codecs: %d", rsp->num_codecs);
 
openSUSE Build Service is sponsored by