public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/5] monitor: check data size properly in evt_num_completed_packets
@ 2026-04-06 11:23 Pauli Virtanen
  2026-04-06 11:23 ` [PATCH BlueZ 2/5] emulator: Remove assigned but unused variables Pauli Virtanen
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Pauli Virtanen @ 2026-04-06 11:23 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Use util_iov_pull to check data size before dereferencing.
---
 monitor/analyze.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/monitor/analyze.c b/monitor/analyze.c
index 6c2ccca84..819d621cd 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -617,22 +617,24 @@ static void evt_le_enh_conn_complete(struct hci_dev *dev, struct timeval *tv,
 static void evt_num_completed_packets(struct hci_dev *dev, struct timeval *tv,
 					const void *data, uint16_t size)
 {
-	uint8_t num_handles = get_u8(data);
+	struct iovec iov = { .iov_base = (void *)data, .iov_len = size };
+	uint8_t num_handles;
 	int i;
 
-	data += sizeof(num_handles);
-	size -= sizeof(num_handles);
+	if (!util_iov_pull_u8(&iov, &num_handles))
+		return;
 
 	for (i = 0; i < num_handles; i++) {
-		uint16_t handle = get_le16(data);
-		uint16_t count = get_le16(data + 2);
+		uint16_t handle, count;
 		struct hci_conn *conn;
 		struct timeval res;
 		struct hci_conn_tx *last_tx;
 		int j;
 
-		data += 4;
-		size -= 4;
+		if (!util_iov_pull_le16(&iov, &handle))
+			return;
+		if (!util_iov_pull_le16(&iov, &count))
+			return;
 
 		conn = conn_lookup(dev, handle);
 		if (!conn)
-- 
2.53.0


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

end of thread, other threads:[~2026-04-06 17:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-06 11:23 [PATCH BlueZ 1/5] monitor: check data size properly in evt_num_completed_packets Pauli Virtanen
2026-04-06 11:23 ` [PATCH BlueZ 2/5] emulator: Remove assigned but unused variables Pauli Virtanen
2026-04-06 11:23 ` [PATCH BlueZ 3/5] monitor: " Pauli Virtanen
2026-04-06 11:23 ` [PATCH BlueZ 4/5] src: " Pauli Virtanen
2026-04-06 11:23 ` [PATCH BlueZ 5/5] tools: " Pauli Virtanen
2026-04-06 12:44 ` [BlueZ,1/5] monitor: check data size properly in evt_num_completed_packets bluez.test.bot
2026-04-06 17:00 ` [PATCH BlueZ 1/5] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox