diff options
author | Neel Chauhan <neel@neelc.org> | 2018-11-04 20:08:57 -0500 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-04-24 17:28:38 +1000 |
commit | b65f8c419a4eb2608beecbf31af0b5bdc6cc38ec (patch) | |
tree | 73f0a49ba7bb80cc23f802b8a79e7136c9dd7bc7 /src/core/or/policies.c | |
parent | 26183476575abf0f8daccc2f4ca8be4ba0e2a5de (diff) | |
download | tor-b65f8c419a4eb2608beecbf31af0b5bdc6cc38ec.tar.gz tor-b65f8c419a4eb2608beecbf31af0b5bdc6cc38ec.zip |
Add firewall_choose_address_ls() and hs_get_extend_info_from_lspecs() tests
Diffstat (limited to 'src/core/or/policies.c')
-rw-r--r-- | src/core/or/policies.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/or/policies.c b/src/core/or/policies.c index b58a5c9cb6..83d9a53fc0 100644 --- a/src/core/or/policies.c +++ b/src/core/or/policies.c @@ -1031,6 +1031,15 @@ fascist_firewall_choose_address_ls(const smartlist_t *lspecs, tor_assert(ap); + if (lspecs == NULL) { + log_warn(LD_BUG, "Unknown or missing link specifiers"); + return; + } + if (smartlist_len(lspecs) == 0) { + log_warn(LD_PROTOCOL, "Link specifiers are empty"); + return; + } + tor_addr_make_null(&ap->addr, AF_UNSPEC); ap->port = 0; @@ -1062,6 +1071,16 @@ fascist_firewall_choose_address_ls(const smartlist_t *lspecs, } } SMARTLIST_FOREACH_END(ls); + /* If we don't have IPv4 or IPv6 in link specifiers, log a bug and return. */ + if (!have_v4 && !have_v6) { + if (!have_v6) { + log_warn(LD_PROTOCOL, "None of our link specifiers have IPv4 or IPv6"); + } else { + log_warn(LD_PROTOCOL, "None of our link specifiers have IPv4"); + } + return; + } + /* Here, don't check for DirPorts as link specifiers are only used for * ORPorts. */ const or_options_t *options = get_options(); |