diff options
author | teor (Tim Wilson-Brown) <teor2345@gmail.com> | 2016-01-22 17:43:24 +1100 |
---|---|---|
committer | teor (Tim Wilson-Brown) <teor2345@gmail.com> | 2016-01-29 07:16:32 +1100 |
commit | 1401117ff2bc5fc90df51d19c3c0d7abc439c34e (patch) | |
tree | 52cabe50fe0e4cf65666de7c3324968f767a2db7 /src/or/control.c | |
parent | 77a9de0d48e61e6762e65f6099c9a424544eb0ad (diff) | |
download | tor-1401117ff2bc5fc90df51d19c3c0d7abc439c34e.tar.gz tor-1401117ff2bc5fc90df51d19c3c0d7abc439c34e.zip |
Return NULL from extend_info_from_node if the node has no allowed address
Modify callers to correctly handle these new NULL returns:
* fix assert in onion_extend_cpath
* warn and discard circuit in circuit_get_open_circ_or_launch
* warn, discard circuit, and tell controller in handle_control_extendcircuit
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/or/control.c b/src/or/control.c index 66182fe2a4..2c0209ed85 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -2864,12 +2864,26 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len, } /* now circ refers to something that is ready to be extended */ + int first_node = zero_circ; SMARTLIST_FOREACH(nodes, const node_t *, node, { - extend_info_t *info = extend_info_from_node(node, 0); - tor_assert(info); /* True, since node_has_descriptor(node) == true */ + extend_info_t *info = extend_info_from_node(node, first_node); + if (first_node && !info) { + log_warn(LD_CONTROL, + "controller tried to connect to a node that doesn't have any " + "addresses that are allowed by the firewall configuration; " + "circuit marked for closing."); + circuit_mark_for_close(TO_CIRCUIT(circ), -END_CIRC_REASON_CONNECTFAILED); + connection_write_str_to_buf("551 Couldn't start circuit\r\n", conn); + goto done; + } else { + /* True, since node_has_descriptor(node) == true and we are extending + * to the node's primary address */ + tor_assert(info); + } circuit_append_new_exit(circ, info); extend_info_free(info); + first_node = 0; }); /* now that we've populated the cpath, start extending */ |