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 50ffee7a8 examples: Fix network echo receive terminators
50ffee7a8 is described below

commit 50ffee7a85659a14ff6367191d560395beeae4ad
Author: Old-Ding <[email protected]>
AuthorDate: Mon Jul 6 04:23:04 2026 +0800

    examples: Fix network echo receive terminators
    
    The netloop and poll TCP echo examples receive up to IOBUFFER_SIZE bytes 
and then append a NUL terminator before logging the data. A full-size receive 
can therefore write one byte past the input buffer.
    
    Reserve one extra byte in the buffers that are terminated after recv(). 
Keep the receive limit and echo length capped at IOBUFFER_SIZE so the data path 
is unchanged.
    
    Signed-off-by: Old-Ding <[email protected]>
---
 examples/netloop/lo_listener.c | 2 +-
 examples/netloop/lo_main.c     | 2 +-
 examples/poll/host.c           | 2 +-
 examples/poll/net_listener.c   | 2 +-
 examples/poll/net_reader.c     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/examples/netloop/lo_listener.c b/examples/netloop/lo_listener.c
index 20f72ad9c..57362cec8 100644
--- a/examples/netloop/lo_listener.c
+++ b/examples/netloop/lo_listener.c
@@ -64,7 +64,7 @@ struct net_listener_s
   struct sockaddr_in addr;
   fd_set          master;
   fd_set          working;
-  char            buffer[IOBUFFER_SIZE];
+  char            buffer[IOBUFFER_SIZE + 1];
   int             listensd;
   int             mxsd;
 };
diff --git a/examples/netloop/lo_main.c b/examples/netloop/lo_main.c
index 513278b08..3c6a0c72f 100644
--- a/examples/netloop/lo_main.c
+++ b/examples/netloop/lo_main.c
@@ -63,7 +63,7 @@ static int lo_client(void)
 {
   struct sockaddr_in myaddr;
   char outbuf[IOBUFFER_SIZE];
-  char inbuf[IOBUFFER_SIZE];
+  char inbuf[IOBUFFER_SIZE + 1];
   int sockfd;
   int len;
   int nbytessent;
diff --git a/examples/poll/host.c b/examples/poll/host.c
index 740bccb22..8d42dd997 100644
--- a/examples/poll/host.c
+++ b/examples/poll/host.c
@@ -64,7 +64,7 @@ int main(int argc, char **argv, char **envp)
 {
   struct sockaddr_in myaddr;
   char outbuf[IOBUFFER_SIZE];
-  char inbuf[IOBUFFER_SIZE];
+  char inbuf[IOBUFFER_SIZE + 1];
   int sockfd;
   int len;
   int nbytessent;
diff --git a/examples/poll/net_listener.c b/examples/poll/net_listener.c
index e20306d6c..3c72e16e3 100644
--- a/examples/poll/net_listener.c
+++ b/examples/poll/net_listener.c
@@ -64,7 +64,7 @@ struct net_listener_s
   struct sockaddr_in addr;
   fd_set          master;
   fd_set          working;
-  char            buffer[IOBUFFER_SIZE];
+  char            buffer[IOBUFFER_SIZE + 1];
   int             listensd;
   int             mxsd;
 };
diff --git a/examples/poll/net_reader.c b/examples/poll/net_reader.c
index 288179763..191f39875 100644
--- a/examples/poll/net_reader.c
+++ b/examples/poll/net_reader.c
@@ -121,7 +121,7 @@ static void net_configure(void)
 static void net_receive(int sd)
 {
   struct timeval timeout;
-  char buffer[IOBUFFER_SIZE];
+  char buffer[IOBUFFER_SIZE + 1];
   char *ptr;
   fd_set readset;
   int nbytes;

Reply via email to