Skip to content

Commit

Permalink
[posix] address coverity warning: argument cannot be negative (openth…
Browse files Browse the repository at this point in the history
…read#9453)

Added validation to check for the negative value of sMLDMonitorFd, as
setsockopt parameter cannot be negative.
  • Loading branch information
hastigondaliya authored Sep 27, 2023
1 parent 09a0fbe commit 50487a6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/posix/platform/netif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 50487a6

Please sign in to comment.