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 559c6855f34 net/ipv4: Drop ipv4 packet total length bigger than the 
actual transmitted data
559c6855f34 is described below

commit 559c6855f34373c91d8f868f63e7413a7f252f62
Author: wenquan1 <[email protected]>
AuthorDate: Thu Jul 24 10:38:44 2025 +0800

    net/ipv4: Drop ipv4 packet total length bigger than the actual transmitted 
data
    
    Derived from RFC 791 s3.1 p13 Internet Header Format.
    
    Signed-off-by: wenquan1 <[email protected]>
---
 net/devif/ipv4_input.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c
index c97a3b5ec63..5ea71232e6b 100644
--- a/net/devif/ipv4_input.c
+++ b/net/devif/ipv4_input.c
@@ -187,6 +187,8 @@ static int ipv4_in(FAR struct net_driver_s *dev)
 
   /* Get the size of the packet minus the size of link layer header */
 
+  dev->d_len -= NET_LL_HDRLEN(dev);
+
   if (IPv4_HDRLEN > dev->d_len)
     {
       nwarn("WARNING: Packet shorter than IPv4 header\n");
@@ -214,6 +216,9 @@ static int ipv4_in(FAR struct net_driver_s *dev)
     }
   else if (totlen > dev->d_len)
     {
+#ifdef CONFIG_NET_STATISTICS
+      g_netstats.ipv4.drop++;
+#endif
       nwarn("WARNING: IP packet shorter than length in IP header\n");
       goto drop;
     }

Reply via email to