summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2021-04-14 15:57:41 +0200
committerMark Stapp <mjs@voltanet.io>2021-04-14 15:57:41 +0200
commitf5a1fb4f321d660ae213255887f0a449c91babd1 (patch)
tree36d18de7169c838dd5efd81580bb37d128fe0e10
parentMerge pull request #8320 from idryzhov/prefix-list-seqnum (diff)
downloadfrr-f5a1fb4f321d660ae213255887f0a449c91babd1.tar.xz
frr-f5a1fb4f321d660ae213255887f0a449c91babd1.zip
nhrpd: fix coverity warning about os_socket()
Ensure we don't try to use an invalid fd in nhrpd, reported by coverity. Signed-off-by: Mark Stapp <mjs@voltanet.io>
-rw-r--r--nhrpd/linux.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/nhrpd/linux.c b/nhrpd/linux.c
index bcf97f030..f697311d4 100644
--- a/nhrpd/linux.c
+++ b/nhrpd/linux.c
@@ -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;