diff options
author | MrSquanchee <usuraj35@gmail.com> | 2020-03-20 23:57:40 +0530 |
---|---|---|
committer | MrSquanchee <usuraj35@gmail.com> | 2020-04-07 23:11:17 +0530 |
commit | cbd3f88831f4a0f6cd9450621e50d8ba062f76ef (patch) | |
tree | 3b7511a1d295ed3f75a75126529891a6981c0dec /src/lib/net | |
parent | 065ccda4f67023c752162227c77b0e1319e30b85 (diff) | |
download | tor-cbd3f88831f4a0f6cd9450621e50d8ba062f76ef.tar.gz tor-cbd3f88831f4a0f6cd9450621e50d8ba062f76ef.zip |
Added tests for tor_addr_is_null/valid()
Added tests for tor_addr_is_valid(),
and added tests for tor_addr_is_null(),
which is not modfied.
Ticket 33679
Diffstat (limited to 'src/lib/net')
-rw-r--r-- | src/lib/net/address.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c index e968d8a7f7..7b24e406a4 100644 --- a/src/lib/net/address.c +++ b/src/lib/net/address.c @@ -817,7 +817,8 @@ tor_addr_is_loopback(const tor_addr_t *addr) /* Is addr valid? * Checks that addr is non-NULL and not tor_addr_is_null(). - * If for_listening is true, IPv4 addr 0.0.0.0 is allowed. + * If for_listening is true, addr is allowed in either case if + * addr is 0.0.0.0 (for IPv4) or :: (for IPv6). * It means "bind to all addresses on the local machine". */ int tor_addr_is_valid(const tor_addr_t *addr, int for_listening) @@ -833,6 +834,10 @@ tor_addr_is_valid(const tor_addr_t *addr, int for_listening) return 1; } + if (for_listening && addr->family == AF_INET6) { + return 1; + } + /* Otherwise, the address is valid if it's not tor_addr_is_null() */ return !tor_addr_is_null(addr); } |