nuttx/wireless/bluetooth
Alan Carvalho de Assis 5ec51ae6d5 wireless/bluetooth: Validate lengths when parsing advertising reports.
le_adv_report() took the report count and each report's data length from
the event and used them without checking either against the data that was
actually received:

  - the declared data length indexes the RSSI octet, so a length larger
    than the event reads past the end of the buffer;
  - the loop was bounded only by the report count, so a count larger than
    the payload walks off the end of it;
  - bt_buf_consume() only checks its bound with DEBUGASSERT(), so on a
    build without assertions the buffer length underflows rather than
    reporting the problem.

Check that the event is long enough for the count, then check each report
against the remaining length before reading its data or its RSSI, and
stop parsing when a report does not fit.

While here, include the RSSI octet when advancing to the next report.
sizeof() of the report structure does not account for it, because the
data member is a zero-length array, so every report after the first
started one octet early.

Ref: Core v6.0, Vol 4, Part E, 7.7.65.2 (LE Advertising Report event)
Testing: builds for sim:bluetooth with Make; every commit in this series
verified to build individually.  Not yet exercised at runtime - the
scriptable controller that can inject a malformed report is added
separately.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Assisted-by: Claude Code Opus 5
2026-09-19 18:30:43 -03: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 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03: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 inverted MTU cap in bt_conn_send() 2026-08-30 10:48:18 -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 lengths when parsing advertising reports. 2026-09-19 18:30:43 -03:00
bt_hcicore.h
bt_ioctl.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03: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 bt_atomic: use atomic macro to replace wireless/bluetooth/bt_atomic.c 2024-12-04 13:54:45 +08:00
Kconfig Bluetooth SMP: added support for Legacy pairing (MITM) with passkey 2025-05-28 21:49:08 +08:00
Make.defs bt_atomic: use atomic macro to replace wireless/bluetooth/bt_atomic.c 2024-12-04 13:54:45 +08:00