aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-03-27 15:31:29 -0400
committerNick Mathewson <nickm@torproject.org>2014-03-27 15:31:29 -0400
commit9c0a1adfa21f12e6682fa26d43fbf91bab4e6fc3 (patch)
tree4854edff8e71379627e00cd23c8e3e0db63abc6e /src/common
parenta83abcf5ee5cb8fe245bc97e089e082f62921194 (diff)
downloadtor-9c0a1adfa21f12e6682fa26d43fbf91bab4e6fc3.tar
tor-9c0a1adfa21f12e6682fa26d43fbf91bab4e6fc3.tar.gz
Don't do a DNS lookup on a bridge line address
Fixes bug 10801; bugfix on 07bf274d in 0.2.0.1-alpha.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/address.c16
-rw-r--r--src/common/address.h3
2 files changed, 14 insertions, 5 deletions
diff --git a/src/common/address.c b/src/common/address.c
index 14a7b6bc9..3e898611d 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1439,12 +1439,16 @@ is_internal_IP(uint32_t ip, int for_listening)
* to the port.
*
* Don't do DNS lookups and don't allow domain names in the <ip> field.
- * Don't accept <b>addrport</b> of the form "<ip>" or "<ip>:0".
+ *
+ * If <b>default_port</b> is less than 0, don't accept <b>addrport</b> of the
+ * form "<ip>" or "<ip>:0". Otherwise, accept those forms, and set
+ * *<b>port_out</b> to <b>default_port</b>.
*
* Return 0 on success, -1 on failure. */
int
tor_addr_port_parse(int severity, const char *addrport,
- tor_addr_t *address_out, uint16_t *port_out)
+ tor_addr_t *address_out, uint16_t *port_out,
+ int default_port)
{
int retval = -1;
int r;
@@ -1458,8 +1462,12 @@ tor_addr_port_parse(int severity, const char *addrport,
if (r < 0)
goto done;
- if (!*port_out)
- goto done;
+ if (!*port_out) {
+ if (default_port >= 0)
+ *port_out = default_port;
+ else
+ goto done;
+ }
/* make sure that address_out is an IP address */
if (tor_addr_parse(address_out, addr_tmp) < 0)
diff --git a/src/common/address.h b/src/common/address.h
index 77e585534..7afcb0d92 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -209,7 +209,8 @@ int tor_addr_port_split(int severity, const char *addrport,
char **address_out, uint16_t *port_out);
int tor_addr_port_parse(int severity, const char *addrport,
- tor_addr_t *address_out, uint16_t *port_out);
+ tor_addr_t *address_out, uint16_t *port_out,
+ int default_port);
int tor_addr_hostname_is_local(const char *name);