Skip to content

Commit

Permalink
Never create sockets for an address family without matching binds
Browse files Browse the repository at this point in the history
  • Loading branch information
neocturne committed Jan 17, 2015
1 parent 3b63a72 commit 9f1a5ab
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,19 @@ fastd_socket_t * fastd_socket_open(fastd_peer_t *peer, int af) {

const fastd_bind_address_t *bind_address;

if (af == AF_INET && conf.bind_addr_default_v4)
if (af == AF_INET && conf.bind_addr_default_v4) {
bind_address = conf.bind_addr_default_v4;
else if (af == AF_INET6 && conf.bind_addr_default_v6)
}
else if (af == AF_INET6 && conf.bind_addr_default_v6) {
bind_address = conf.bind_addr_default_v6;
else
}
else if (!conf.bind_addr_default_v4 && !conf.bind_addr_default_v6) {
bind_address = &any_address;
}
else {
pr_debug("not opening an %s socket for peer %P (no bind address with matching address family)", (af == AF_INET6) ? "IPv6" : "IPv4", peer);
return NULL;
}

int fd = bind_socket(bind_address, true);
if (fd < 0)
Expand Down

0 comments on commit 9f1a5ab

Please sign in to comment.