Skip to content

examples: nrf24l01_btle: Fix RX terminator bounds#3596

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Old-Ding:codex/nrf24l01-btle-rx-terminator
Jul 9, 2026
Merged

examples: nrf24l01_btle: Fix RX terminator bounds#3596
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Old-Ding:codex/nrf24l01-btle-rx-terminator

Conversation

@Old-Ding

@Old-Ding Old-Ding commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reserve one extra byte for the RX buffer terminator
  • keep the nRF24L01 read length capped at NRF24L01_MAX_PAYLOAD_LEN
  • dump only the bytes actually received in the debug path

Why

nrf24_read() appends a NUL terminator after reading a packet. The local buffer was exactly 32 bytes, which is the nRF24L01 maximum payload length. A full-size payload can therefore return 32 and make rbuf[ret] = '\0' write one byte past the buffer.

Testing

  • git diff --check origin/master..HEAD
  • git show --check --stat --oneline HEAD
  • local compile/checkpatch not run: this Windows environment has no usable gcc/clang/make or WSL/bash shell

@cederom cederom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @Old-Ding, looks good, please update git commit signature to valid email :-)

@Old-Ding Old-Ding force-pushed the codex/nrf24l01-btle-rx-terminator branch from 1a2b1be to 7e653fe Compare July 8, 2026 03:02
nrf24_read() reads up to the nRF24L01 maximum payload length and then appends a NUL terminator for the receive buffer. A full 32-byte payload can therefore write one byte past the local rbuf[32].

Reserve one extra byte for the terminator while keeping the read length capped at NRF24L01_MAX_PAYLOAD_LEN. Dump the number of bytes actually received in the debug path.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
@Old-Ding Old-Ding force-pushed the codex/nrf24l01-btle-rx-terminator branch from 7e653fe to 2e75b07 Compare July 8, 2026 13:50
@xiaoxiang781216 xiaoxiang781216 merged commit 13f04f6 into apache:master Jul 9, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants