This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 22bc92453b836379c004d1c913895c7c9c387348 Author: gaohedong <[email protected]> AuthorDate: Sat Sep 20 21:12:38 2025 +0800 net/arp: Add checks on hardware/protocol type. RFC 826 requires the receiver to check the hardware type and the protocol type of an ARP packet. Drop ARP packets whose hardware type is not Ethernet or whose protocol type is not IPv4. Signed-off-by: gaohedong <[email protected]> --- net/arp/arp_input.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/arp/arp_input.c b/net/arp/arp_input.c index 89d52765362..ef22a92e375 100644 --- a/net/arp/arp_input.c +++ b/net/arp/arp_input.c @@ -102,6 +102,13 @@ static int arp_in(FAR struct net_driver_s *dev) dev->d_len = 0; + if (arp->ah_hwtype != HTONS(ARP_HWTYPE_ETH) || + arp->ah_protocol != HTONS(ETHTYPE_IP)) + { + nerr("ERROR: Invalid hardware type or protocol type\n"); + return -EINVAL; + } + ipaddr = net_ip4addr_conv32(arp->ah_dipaddr); #ifdef CONFIG_NET_ARP_GRATUITOUS sipaddr = net_ip4addr_conv32(arp->ah_sipaddr);
