examples: nrf24l01_term: reserve RX terminator

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>
This commit is contained in:
Old-Ding 2026-07-06 05:58:51 +08:00 committed by Xiang Xiao
parent fd525988f8
commit 7fa0767e30

View file

@ -221,7 +221,7 @@ int read_pkt(int wl_fd)
int ret;
uint32_t pipeno;
ret = read(wl_fd, buff, sizeof(buff));
ret = read(wl_fd, buff, sizeof(buff) - 1);
if (ret < 0)
{
perror("Error reading packet\n");