[posix] address coverity warning: argument cannot be negative (#9453)

Added validation to check for the negative value of sMLDMonitorFd, as
setsockopt parameter cannot be negative.
This commit is contained in:
hastigondaliya
2023-09-27 11:09:57 -07:00
committed by GitHub
parent 09a0fbe9c6
commit 50487a647d
+3 -1
View File
@@ -1724,7 +1724,9 @@ static void mldListenerInit(void)
{
struct ipv6_mreq mreq6;
sMLDMonitorFd = SocketWithCloseExec(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6, kSocketNonBlock);
sMLDMonitorFd = SocketWithCloseExec(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6, kSocketNonBlock);
VerifyOrDie(sMLDMonitorFd != -1, OT_EXIT_FAILURE);
mreq6.ipv6mr_interface = gNetifIndex;
memcpy(&mreq6.ipv6mr_multiaddr, kMLDv2MulticastAddress.mFields.m8, sizeof(kMLDv2MulticastAddress.mFields.m8));