summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-20 13:40:09 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-20 13:40:09 -0400
commite05ddf3e18a019b7db833448c666cbf056444d0d (patch)
tree7437b2a44dad794e78b4c161ceceb691a604cfa9 /src/or
parent6fa99ab32feda0e7866b9439fc6644693c56f134 (diff)
downloadtor-e05ddf3e18a019b7db833448c666cbf056444d0d.tar.gz
tor-e05ddf3e18a019b7db833448c666cbf056444d0d.zip
Check for port config before addr config in client port options
Otherwise, we'll fail, since "9050" looks like a perfectly fine address.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 7a96304e18..96d50954ba 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -5039,20 +5039,23 @@ parse_client_port_config(smartlist_t *out,
tor_free(addrtmp);
goto err;
}
- } else if (tor_addr_port_parse(addrport, &addr, &ptmp) == 0) {
- if (ptmp == 0) {
- log_warn(LD_CONFIG, "%sPort line has address but no port", portname);
- goto err;
- }
- port = ptmp;
} else {
+ /* Try parsing integer port before address, because, who knows?
+ "9050" might be a valid address. */
port = (int) tor_parse_long(addrport, 10, 0, 65535, &ok, NULL);
- if (!ok) {
+ if (ok) {
+ tor_addr_from_str(&addr, defaultaddr);
+ } else if (tor_addr_port_parse(addrport, &addr, &ptmp) == 0) {
+ if (ptmp == 0) {
+ log_warn(LD_CONFIG, "%sPort line has address but no port", portname);
+ goto err;
+ }
+ port = ptmp;
+ } else {
log_warn(LD_CONFIG, "Couldn't parse address '%s' for %sPort",
escaped(addrport), portname);
goto err;
}
- tor_addr_from_str(&addr, defaultaddr);
}
/* Now parse the rest of the options, if any. */