From 534001610478cebc0c10ec71fa9dfb407925aad4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 8 Nov 2018 06:37:46 -0600 Subject: [PATCH] net/mld: Very that the address of the group that we join is a valid IPv6 multicast address. --- net/mld/mld_join.c | 7 +++++++ net/mld/mld_report.c | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/net/mld/mld_join.c b/net/mld/mld_join.c index d8bb5d9f5f..f8a022c548 100644 --- a/net/mld/mld_join.c +++ b/net/mld/mld_join.c @@ -132,6 +132,13 @@ int mld_joingroup(FAR const struct ipv6_mreq *mrec) DEBUGASSERT(mrec != NULL); + /* Assure that the group address is an IPv6 multicast address */ + + if (!net_is_addr_mcast(mrec->ipv6mr_multiaddr.s6_addr16)) + { + return -EINVAL; + } + /* Get the device from the interface index. Use the default network device * if an interface index of 0 is provided. */ diff --git a/net/mld/mld_report.c b/net/mld/mld_report.c index 3c133a6c75..85e1407059 100644 --- a/net/mld/mld_report.c +++ b/net/mld/mld_report.c @@ -74,12 +74,15 @@ int mld_report(FAR struct net_driver_s *dev, FAR const net_ipv6addr_t grpaddr) grpaddr[0], grpaddr[1], grpaddr[2], grpaddr[3], grpaddr[4], grpaddr[5], grpaddr[6], grpaddr[7]); - /* Find the group (or create a new one) using the incoming IP address. - * If we are not a router (and I assume we are not), then can ignore - * reports from groups that we are not a member of. - */ - #ifdef CONFIG_NET_MLD_ROUTER + /* Assure that the group address is an IPv6 multicast address */ + + if (!net_is_addr_mcast(mrec->ipv6mr_multiaddr.s6_addr16)) + { + return -EINVAL; + } + + group = mld_grpallocfind(dev, grpaddr); if (group == NULL) { @@ -88,6 +91,10 @@ int mld_report(FAR struct net_driver_s *dev, FAR const net_ipv6addr_t grpaddr) } #else + /* Find the group using the incoming IP address. If we are not a router, + * then can ignore reports from groups that we are not a member of. + */ + group = mld_grpfind(dev, grpaddr); if (group == NULL) {