]> git.puffer.fish Git - matthieu/frr.git/commitdiff
nhrpd: fix coverity warning about os_socket()
authorMark Stapp <mjs@voltanet.io>
Wed, 14 Apr 2021 13:57:41 +0000 (09:57 -0400)
committerMark Stapp <mjs@voltanet.io>
Wed, 14 Apr 2021 13:57:41 +0000 (09:57 -0400)
Ensure we don't try to use an invalid fd in nhrpd, reported
by coverity.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
nhrpd/linux.c

index bcf97f030a8624500b68288b4143a71b7dfbef43..f697311d4955e865235fab61bd768c9d91a860d7 100644 (file)
@@ -60,7 +60,7 @@ int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr,
                .msg_iov = &iov,
                .msg_iovlen = 1,
        };
-       int status;
+       int status, fd;
 
        if (addrlen > sizeof(lladdr.sll_addr))
                return -1;
@@ -72,7 +72,11 @@ int os_sendmsg(const uint8_t *buf, size_t len, int ifindex, const uint8_t *addr,
        lladdr.sll_halen = addrlen;
        memcpy(lladdr.sll_addr, addr, addrlen);
 
-       status = sendmsg(os_socket(), &msg, 0);
+       fd = os_socket();
+       if (fd < 0)
+               return -1;
+
+       status = sendmsg(fd, &msg, 0);
        if (status < 0)
                return -errno;