summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-08-16 02:52:27 +0000
committerRoger Dingledine <arma@torproject.org>2005-08-16 02:52:27 +0000
commit5e76bac1dd1daa0ed400613b7f77aecbaab7faff (patch)
tree96886e03f68abf41d13020d14cd1a8838bab762a /src/or/routerparse.c
parent955a10fee0c195c189c920bd832943a54b90c18d (diff)
downloadtor-5e76bac1dd1daa0ed400613b7f77aecbaab7faff.tar.gz
tor-5e76bac1dd1daa0ed400613b7f77aecbaab7faff.zip
the tor-spec says router->address must be an IP address. so refuse
it if it's not. (this also fixes some potential security problems with people providing hostnames as their address and then preferentially resolving them and partitioning users.) svn:r4790
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index fa69c7408f..b370f245fa 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -823,6 +823,7 @@ router_parse_entry_from_string(const char *s, const char *end)
directory_token_t *tok;
int t;
int ports_set, bw_set;
+ struct in_addr in;
if (!end) {
end = s + strlen(s);
@@ -865,7 +866,11 @@ router_parse_entry_from_string(const char *s, const char *end)
goto err;
}
router->address = tor_strdup(tok->args[1]);
- router->addr = 0;
+ if (!tor_inet_aton(router->address, &in)) {
+ log_fn(LOG_WARN,"Router address is not an IP.");
+ goto err;
+ }
+ router->addr = ntohl(in.s_addr);
if (tok->n_args >= 5) {
router->or_port = (uint16_t) tor_parse_long(tok->args[2],10,0,65535,NULL,NULL);
@@ -1013,7 +1018,6 @@ router_parse_entry_from_string(const char *s, const char *end)
}
goto done;
- return router;
err:
routerinfo_free(router);