From 6488b25484aeed042a72962d1b3e3b5f2074f688 Mon Sep 17 00:00:00 2001 From: Simon Lin Date: Sat, 1 Aug 2020 00:33:48 +0800 Subject: [PATCH] [netif] check address type when adding addresses (#5297) --- src/core/net/netif.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/net/netif.cpp b/src/core/net/netif.cpp index 57d1e7197..4932e4339 100644 --- a/src/core/net/netif.cpp +++ b/src/core/net/netif.cpp @@ -321,6 +321,7 @@ otError Netif::SubscribeExternalMulticast(const Address &aAddress) const_cast(kLinkLocalAllRoutersMulticastAddress)); ExternalNetifMulticastAddress *entry; + VerifyOrExit(aAddress.IsMulticast(), error = OT_ERROR_INVALID_ARGS); VerifyOrExit(!IsMulticastSubscribed(aAddress), error = OT_ERROR_ALREADY); // Check that the address is not one of the fixed addresses: @@ -420,6 +421,8 @@ otError Netif::AddExternalUnicastAddress(const NetifUnicastAddress &aAddress) NetifUnicastAddress *entry; NetifUnicastAddress *prev; + VerifyOrExit(!aAddress.GetAddress().IsMulticast(), error = OT_ERROR_INVALID_ARGS); + entry = mUnicastAddresses.FindMatching(aAddress.GetAddress(), prev); if (entry != nullptr)