mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
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 <wenquan1@xiaomi.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user