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:19:13 +0200 |
commit | 1e695906e679d6a4be772ea67ce8164da665ec12 (patch) | |
tree | ff2aeb9a6c6edc5543a59cf00a51902a60f7aabd | |
parent | 844ec06079f5276e15271eb66bc89d6d5acf04e2 (diff) |
Check return value from setsockopt().
coverity: 1449508, 1449522.
-rw-r--r-- | radsecproxy.c | 6 | ||||
-rw-r--r-- | util.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/radsecproxy.c b/radsecproxy.c index 5bd7642..e3a3814 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -1929,13 +1929,15 @@ void createlistener(uint8_t type, char *arg) { debugerrno(errno, DBG_WARN, "createlistener: socket failed"); continue; } - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) + debugerrno(errno, DBG_WARN, "createlistener: SO_REUSEADDR"); disable_DF_bit(s, res); #ifdef IPV6_V6ONLY if (res->ai_family == AF_INET6) - setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)); + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) == -1) + debugerrno(errno, DBG_WARN, "createlistener: IPV6_V6ONLY"); #endif if (bind(s, res->ai_addr, res->ai_addrlen)) { debugerrno(errno, DBG_WARN, "createlistener: bind failed"); @@ -139,10 +139,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; |