From 4d72eb8421dee62ee0d7941386de5ff4f2365a25 Mon Sep 17 00:00:00 2001 From: Alan Carvalho de Assis Date: Sun, 3 May 2026 09:14:52 -0300 Subject: [PATCH] net/icmpv6: Discard Neighbor Discovery packet if optlen is 0 This commit make ICMPv6 on NuttX compliant with RFC4861 ignoring a Neighbor Discovery packet when its optlen is 0. Signed-off-by: Alan C. Assis --- net/icmpv6/icmpv6_input.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index c3521917d65..28792be0ca1 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -428,6 +428,15 @@ void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen) FAR struct icmpv6_generic_s *opt = (FAR struct icmpv6_generic_s *)&options[ndx]; + /* RFC 4861 4.6: "The value 0 is invalid. Nodes MUST silently + * discard a packet that contains an option with length zero." + */ + + if (opt->optlen == 0) + { + goto icmpv6_drop_packet; + } + switch (opt->opttype) { case ICMPv6_OPT_SRCLLADDR: