diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-01-27 08:12:14 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-01-27 08:12:14 -0500 |
commit | 795582169aa9a710739fbb7f3f651e337032df4a (patch) | |
tree | fb4cd43db99faca9907797b9969a6a4e9420bd8d /src/or/connection.c | |
parent | 782c52658c1f0e2a0a49b4ba990b0b420dd129c1 (diff) | |
download | tor-795582169aa9a710739fbb7f3f651e337032df4a.tar.gz tor-795582169aa9a710739fbb7f3f651e337032df4a.zip |
Bulletproof conn_get_outbound_address() a little.
Diffstat (limited to 'src/or/connection.c')
-rw-r--r-- | src/or/connection.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 4421534b7f..188276026f 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1902,10 +1902,18 @@ conn_get_outbound_address(sa_family_t family, { const tor_addr_t *ext_addr = NULL; - int fam_index=0; - if (family==AF_INET6) { - fam_index=1; + int fam_index; + switch (family) { + case AF_INET: + fam_index = 0; + break; + case AF_INET6: + fam_index = 1; + break; + default: + return NULL; } + // If an exit connection, use the exit address (if present) if (conn_type == CONN_TYPE_EXIT) { if (!tor_addr_is_null( |