diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-01-17 17:06:51 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2015-01-17 17:06:51 +0100 |
commit | 9f1a5ab5614976e10c4cfaeb055b6c0058b8ba20 (patch) | |
tree | 9e97f4105840cc67ca3f14e7b385a593346f9207 /src | |
parent | 3b63a7218f3b5f7cfcec86ef1f2e0ad514d477fb (diff) | |
download | fastd-9f1a5ab5614976e10c4cfaeb055b6c0058b8ba20.tar fastd-9f1a5ab5614976e10c4cfaeb055b6c0058b8ba20.zip |
Never create sockets for an address family without matching binds
Diffstat (limited to 'src')
-rw-r--r-- | src/socket.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/socket.c b/src/socket.c index c84d2d1..d464b6e 100644 --- a/src/socket.c +++ b/src/socket.c @@ -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) |