aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 07:10:30 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commit22ed4467a413961816f317c641e436ca627d06d2 (patch)
tree137ea525b0dee2f196e43faa1eeff585746fce2b /util.c
parent6a3f6df865cc8b9626181c87b33b4f7723852a2f (diff)
downloadpasst-22ed4467a413961816f317c641e436ca627d06d2.tar
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.gz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.bz2
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.lz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.xz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.zst
passt-22ed4467a413961816f317c641e436ca627d06d2.zip
treewide: Unchecked return value from library, CWE-252
All instances were harmless, but it might be useful to have some debug messages here and there. Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'util.c')
-rw-r--r--util.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/util.c b/util.c
index 81cf744..c3475d6 100644
--- a/util.c
+++ b/util.c
@@ -154,7 +154,8 @@ void passt_vsyslog(int pri, const char *format, va_list ap)
if (log_opt & LOG_PERROR)
fprintf(stderr, "%s", buf + sizeof("<0>"));
- send(log_sock, buf, n, 0);
+ if (send(log_sock, buf, n, 0) != n)
+ fprintf(stderr, "Failed to send %i bytes to syslog\n", n);
}
#define IPV6_NH_OPT(nh) \
@@ -239,7 +240,7 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto, uint16_t port,
};
const struct sockaddr *sa;
struct epoll_event ev;
- int fd, sl, one = 1;
+ int fd, sl, y = 1;
if (proto != IPPROTO_TCP && proto != IPPROTO_UDP &&
proto != IPPROTO_ICMP && proto != IPPROTO_ICMPV6)
@@ -287,10 +288,12 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto, uint16_t port,
sa = (const struct sockaddr *)&addr6;
sl = sizeof(addr6);
- setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));
+ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &y, sizeof(y)))
+ debug("Failed to set IPV6_V6ONLY on socket %i", fd);
}
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &y, sizeof(y)))
+ debug("Failed to set IPV6_V6ONLY on socket %i", fd);
if (bind(fd, sa, sl) < 0) {
/* We'll fail to bind to low ports if we don't have enough