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

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


The following commit(s) were added to refs/heads/master by this push:
     new 719191ac72 net/local: Return an error when write the too big packet.
719191ac72 is described below

commit 719191ac7265ac0ff9224e1fc970ce624c6f2153
Author: liqinhui <[email protected]>
AuthorDate: Mon Aug 7 17:03:31 2023 +0800

    net/local: Return an error when write the too big packet.
    
    Verification:
      Write a packet, the length is bigger than CONFIG_DEV_FIFO_SIZE.
      The return value should be -1, and the errno is EMSGSIZE.
    Signed-off-by: liqinhui <[email protected]>
---
 net/local/local_sendpacket.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/local/local_sendpacket.c b/net/local/local_sendpacket.c
index 1c75d3c24a..f941dc0de0 100644
--- a/net/local/local_sendpacket.c
+++ b/net/local/local_sendpacket.c
@@ -130,6 +130,12 @@ int local_send_packet(FAR struct file *filep, FAR const 
struct iovec *buf,
           len16 += iov->iov_len;
         }
 
+      if (len16 > CONFIG_DEV_FIFO_SIZE - sizeof(uint16_t))
+        {
+          nerr("ERROR: Packet is too big: %d\n", len16);
+          return -EMSGSIZE;
+        }
+
       ret = local_fifo_write(filep, (FAR const uint8_t *)&len16,
                              sizeof(uint16_t));
       if (ret != sizeof(uint16_t))

Reply via email to