All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bluez PATCH v1] monitor: Fix possible crash of rfcomm packet
@ 2021-05-11  7:28 Howard Chung
  2021-05-11  7:57 ` [Bluez,v1] " bluez.test.bot
  2021-05-11 18:04 ` [Bluez PATCH v1] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 4+ messages in thread
From: Howard Chung @ 2021-05-11  7:28 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz
  Cc: chromeos-bluetooth-upstreaming, Yun-Hao Chung, apusaka

From: Yun-Hao Chung <howardchung@chromium.org>

When RFCOMM_TEST_EA returns false, btmon assumes packet data has at
least 5 bytes long. If that assumption fails, btmon could crash when
trying to read the next byte.
This patch fix it by checking the remaining size before reading the last
byte.

Reviewed-by: apusaka@chromium.org
---

 monitor/rfcomm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index 9b88a3440e31..76b1123bb23d 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -452,6 +452,9 @@ void rfcomm_packet(const struct l2cap_frame *frame)
 		hdr.length = GET_LEN16(hdr.length);
 	}
 
+	if (l2cap_frame->size == 0)
+		goto fail;
+
 	l2cap_frame_pull(&tmp_frame, l2cap_frame, l2cap_frame->size-1);
 
 	if (!l2cap_frame_get_u8(&tmp_frame, &hdr.fcs))
-- 
2.31.1.607.g51e8a6a459-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-12  2:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11  7:28 [Bluez PATCH v1] monitor: Fix possible crash of rfcomm packet Howard Chung
2021-05-11  7:57 ` [Bluez,v1] " bluez.test.bot
2021-05-11 18:04 ` [Bluez PATCH v1] " Luiz Augusto von Dentz
2021-05-12  2:22   ` Yun-hao Chung

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.