diff options
author | Linus Nordberg <linus@nordu.net> | 2017-07-30 22:09:55 +0200 |
---|---|---|
committer | Linus Nordberg <linus@nordu.net> | 2017-08-01 18:25:36 +0200 |
commit | 633e4b83029f4cf213c986404e28ecbd9cd8d26d (patch) | |
tree | 88b818320d2cfc91fdf247da0618dd426a5f223c /util.c | |
parent | 8aef6cf8292b805db7a8b118fb584058cdfab97e (diff) |
Check return value from setsockopt().
coverity: 1449508, 1449522.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -150,10 +150,12 @@ int bindtoaddr(struct addrinfo *addrinfo, int family, int reuse, int v6only) { disable_DF_bit(s,res); if (reuse) - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) + debugerrno(errno, DBG_WARN, "Failed to set SO_REUSEADDR"); #ifdef IPV6_V6ONLY if (v6only) - setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)); + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1) + debugerrno(errno, DBG_WARN, "Failed to set IPV6_V6ONLY"); #endif if (!bind(s, res->ai_addr, res->ai_addrlen)) return s; |