From bd10bf4b5bbe022f85bbf8d56e6afa50ad76bf60 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 14 Oct 2004 03:44:45 +0000 Subject: [PATCH] Try to always dtrt if routerlist==NULL svn:r2489 --- src/or/circuitbuild.c | 2 ++ src/or/directory.c | 3 ++- src/or/router.c | 1 + src/or/routerlist.c | 7 +++++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 56949da5de..b52f90dbae 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -989,6 +989,8 @@ onion_new_cpath_build_state(uint8_t purpose, const char *exit_digest) cpath_build_state_t *info; routerinfo_t *exit; router_get_routerlist(&rl); + if (!rl) + return NULL; r = new_route_len(options.PathlenCoinWeight, purpose, rl->routers); if (r < 1) /* must be at least 1 */ return NULL; diff --git a/src/or/directory.c b/src/or/directory.c index ad33330352..e0ddcc37e9 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -554,7 +554,8 @@ connection_dir_client_reached_eof(connection_t *conn) return -1; } router_get_routerlist(&rl); - routerlist_update_from_runningrouters(rl,rrs); + if (rl) + routerlist_update_from_runningrouters(rl,rrs); running_routers_free(rrs); } diff --git a/src/or/router.c b/src/or/router.c index cf018efb04..5374631072 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -386,6 +386,7 @@ void router_retry_connections(void) { tor_assert(server_mode()); router_get_routerlist(&rl); + if (!rl) return; for (i=0;i < smartlist_len(rl->routers);i++) { router = smartlist_get(rl->routers, i); if(router_is_me(router)) diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 7ca2e903ac..f3670a51a7 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -59,7 +59,7 @@ int router_reload_router_list(void) if (router_load_routerlist_from_directory(s, NULL, 0) < 0) { log_fn(LOG_WARN, "Cached directory '%s' was unparseable; ignoring.", filename); } - if( routerlist && routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2) { + if(routerlist && routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2) { /* XXX use new onion key lifetime when 0.0.8 servers are obsolete */ directory_has_arrived(); /* do things we've been waiting to do */ } @@ -448,7 +448,8 @@ routerinfo_t *router_get_by_addr_port(uint32_t addr, uint16_t port) { int i; routerinfo_t *router; - tor_assert(routerlist); + if (!routerlist) + return NULL; for(i=0;irouters);i++) { router = smartlist_get(routerlist->routers, i); @@ -653,6 +654,7 @@ int router_add_to_routerlist(routerinfo_t *router) { routerinfo_t *r; char id_digest[DIGEST_LEN]; + tor_assert(routerlist); crypto_pk_get_digest(router->identity_pkey, id_digest); /* If we have a router with this name, and the identity key is the same, @@ -989,6 +991,7 @@ int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port, int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port) { int i; routerinfo_t *router; + if (!routerlist) return 1; for (i=0;irouters);i++) { router = smartlist_get(routerlist->routers, i);