Skip to content

examples: nrf24l01_term: reserve RX terminator#3604

Open
Old-Ding wants to merge 1 commit into
apache:masterfrom
Old-Ding:codex/nrf24l01-term-rx-terminator
Open

examples: nrf24l01_term: reserve RX terminator#3604
Old-Ding wants to merge 1 commit into
apache:masterfrom
Old-Ding:codex/nrf24l01-term-rx-terminator

Conversation

@Old-Ding

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

Copy link
Copy Markdown
Contributor

Summary

  • Limit nrf24l01_term RX reads to sizeof(buff) - 1.
  • Keep the trailing byte available for the buff[ret] = '\0' terminator.

Root cause

buff is declared as NRF24L01_MAX_PAYLOAD_LEN + 1, but read_pkt() requested sizeof(buff) bytes before appending a NUL terminator. A full-length read could write the terminator one byte past buff.

Testing

  • git diff --check
  • git show --stat --check --format=fuller HEAD

Not run: local compile, because this environment does not have make, cmake, gcc, clang, or cc available.

@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 add git commit message and valid email signature :-)

read_pkt() terminates the received payload with buff[ret], but a full-size read can leave no room for that trailing NUL byte.

Limit the read length to one byte less than the buffer size so the received payload remains safely terminated before it is printed.

Signed-off-by: Old-Ding <ai.neo.ae86@gmail.com>
@Old-Ding Old-Ding force-pushed the codex/nrf24l01-term-rx-terminator branch from c6724c8 to d9c3d5c Compare July 8, 2026 01:47
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