nuttx/wireless/bluetooth
Alan Carvalho de Assis 843cf6d581 wireless/bluetooth: Validate Number Of Completed Packets event.
Two problems in hci_num_completed_packets().

Number_of_Handles is a single octet, but it was read with BT_LE162HOST(),
which takes the first octet of the handle that follows it as the high
byte.  A one-octet field could therefore produce a loop count of up to
65535.

The loop was then bounded only by that count and not by the data that was
actually received, so it walked past the end of the event, reading handle
and count pairs out of whatever followed it.

Read the field at its declared width, and require the pairs the event
claims to have been received before reading them.

Per-connection credit accounting, which this handler still does not do,
is a separate change.

Ref: Core v6.0, Vol 4, Part E, 7.7.19 (Number Of Completed Packets event)
Testing: builds for sim:bluetooth with Make; every commit in this series
verified to build individually.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code Opus 5
2026-09-25 10:35:51 +02:00
..
bt_atomic.h nuttx/atomic: replace atomic_fetch_xxx with atomic_xxx just like zephyr 2026-08-24 13:20:45 +08:00
bt_att.c wireless/bluetooth: Reject GATT operations on unconnected peers. 2026-09-24 09:51:44 +02:00
bt_att.h
bt_buf.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_buf.h
bt_conn.c wireless/bluetooth: Fix bad aligment 2026-09-22 10:07:09 -03:00
bt_conn.h style: Fix "the the" typo across the codebase. 2026-03-23 11:07:49 +01:00
bt_gatt.c wireless/bluetooth: Fix record stride in descriptor discovery response. 2026-09-18 11:18:36 +08:00
bt_hcicore.c wireless/bluetooth: Validate Number Of Completed Packets event. 2026-09-25 10:35:51 +02:00
bt_hcicore.h
bt_ioctl.c wireless/bluetooth: Reject GATT operations on unconnected peers. 2026-09-24 09:51:44 +02:00
bt_ioctl.h
bt_keys.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_keys.h Bluetooth SMP: added support for Legacy pairing (MITM) with passkey 2025-05-28 21:49:08 +08:00
bt_l2cap.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_l2cap.h
bt_netdev.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_queue.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_queue.h
bt_services.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_smp.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
bt_smp.h Bluetooth SMP: added support for Legacy pairing (MITM) with passkey 2025-05-28 21:49:08 +08:00
bt_uuid.c
CMakeLists.txt
Kconfig Bluetooth SMP: added support for Legacy pairing (MITM) with passkey 2025-05-28 21:49:08 +08:00
Make.defs