diff options
author | Roger Dingledine <arma@torproject.org> | 2005-05-14 05:01:41 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2005-05-14 05:01:41 +0000 |
commit | 07230a698c0ab072d04fc5a85d359acd8ae2f261 (patch) | |
tree | c429383410d456ff9f2d9990f9ed628830aab44f /src | |
parent | b92a77b1d221a8f060696b9567f9386841db2174 (diff) | |
download | tor-07230a698c0ab072d04fc5a85d359acd8ae2f261.tar.gz tor-07230a698c0ab072d04fc5a85d359acd8ae2f261.zip |
if router_resolve fails on the descriptor the controller
gives us, we shouldn't leave the routerinfo in the list.
svn:r4205
Diffstat (limited to 'src')
-rw-r--r-- | src/or/routerlist.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 1e5e9e8bce..a9cf703f54 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -796,7 +796,7 @@ void router_mark_as_down(const char *digest) { /** Add <b>router</b> to the routerlist, if we don't already have it. Replace * older entries (if any) with the same name. Note: Callers should not hold - * their pointers to <b>router</b> after invoking this function; <b>router</b> + * their pointers to <b>router</b> if this function fails; <b>router</b> * will either be inserted into the routerlist or freed. Returns 0 if the * router was added; -1 if it was not. * @@ -914,6 +914,18 @@ router_load_single_router(const char *s, const char **msg) if (msg) *msg = "Couldn't parse router descriptor"; return -1; } + if (router_is_me(ri)) { + log_fn(LOG_WARN, "Router's identity key matches mine; dropping."); + if (msg && !*msg) *msg = "Router's identity key matches mine."; + routerinfo_free(ri); + return 0; + } + if (router_resolve(ri)<0) { + log_fn(LOG_WARN, "Couldn't resolve router address; dropping."); + if (msg && !*msg) *msg = "Couldn't resolve router address."; + routerinfo_free(ri); + return 0; + } if (routerlist && routerlist->running_routers) { running_routers_t *rr = routerlist->running_routers; router_update_status_from_smartlist(ri, @@ -923,6 +935,7 @@ router_load_single_router(const char *s, const char **msg) if (router_add_to_routerlist(ri, msg)<0) { log_fn(LOG_WARN, "Couldn't add router to list; dropping."); if (msg && !*msg) *msg = "Couldn't add router to list."; + /* ri is already freed */ return 0; } else { smartlist_t *changed = smartlist_create(); @@ -931,11 +944,6 @@ router_load_single_router(const char *s, const char **msg) smartlist_free(changed); } - if (router_resolve(ri)<0) { - if (msg && !*msg) *msg = "Couldn't resolve router address."; - return 0; - } - log_fn(LOG_DEBUG, "Added router to list"); return 1; } |