This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 7fa0767e3 examples: nrf24l01_term: reserve RX terminator
7fa0767e3 is described below

commit 7fa0767e30843634e37df2d10adb6b73b6292bbd
Author: Old-Ding <[email protected]>
AuthorDate: Mon Jul 6 05:58:51 2026 +0800

    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 <[email protected]>
---
 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");

Reply via email to