diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-05 14:41:37 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-05 14:41:37 -0400 |
commit | b3469e4207d12821993f1d2d381c5d27918a4c01 (patch) | |
tree | d95b0114a8f96ae504fc6fe49707e9cb25426939 /src/common | |
parent | eefa3ebc786fdfd3a642698822f8a0ade583996e (diff) | |
download | tor-b3469e4207d12821993f1d2d381c5d27918a4c01.tar tor-b3469e4207d12821993f1d2d381c5d27918a4c01.tar.gz |
Make tor_addr_port_parse handle portless IPv6 addresses correctly.
(Not a bugfix on any Tor release; before 10801_024, it didn't handle
portless addresses at all.)
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/address.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/address.c b/src/common/address.c index 3e898611d..84565582e 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -1488,9 +1488,18 @@ int tor_addr_port_split(int severity, const char *addrport, char **address_out, uint16_t *port_out) { + tor_addr_t a_tmp; tor_assert(addrport); tor_assert(address_out); tor_assert(port_out); + /* We need to check for IPv6 manually because addr_port_lookup() doesn't + * do a good job on IPv6 addresses that lack a port. */ + if (tor_addr_parse(&a_tmp, addrport) == AF_INET6) { + *port_out = 0; + *address_out = tor_strdup(addrport); + return 0; + } + return addr_port_lookup(severity, addrport, address_out, NULL, port_out); } |