From 7fa0767e30843634e37df2d10adb6b73b6292bbd Mon Sep 17 00:00:00 2001 From: Old-Ding Date: Mon, 6 Jul 2026 05:58:51 +0800 Subject: [PATCH] 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 --- examples/nrf24l01_term/nrf24l01_term.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/nrf24l01_term/nrf24l01_term.c b/examples/nrf24l01_term/nrf24l01_term.c index c120cafc1..e8c41e8c3 100644 --- a/examples/nrf24l01_term/nrf24l01_term.c +++ b/examples/nrf24l01_term/nrf24l01_term.c @@ -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");