Skip to content

Commit

Permalink
Check return value from setsockopt().
Browse files Browse the repository at this point in the history
coverity: 1449508, 1449522.
  • Loading branch information
Linus Nordberg committed Aug 1, 2017
1 parent 8aef6cf commit 633e4b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions radsecproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -2014,13 +2014,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");
Expand Down
6 changes: 4 additions & 2 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 633e4b8

Please sign in to comment.