[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Try to always dtrt if routerlist==NULL



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv8352/src/or

Modified Files:
	circuitbuild.c directory.c router.c routerlist.c 
Log Message:
Try to always dtrt if routerlist==NULL

Index: circuitbuild.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuitbuild.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- circuitbuild.c	14 Oct 2004 02:47:08 -0000	1.37
+++ circuitbuild.c	14 Oct 2004 03:44:45 -0000	1.38
@@ -989,6 +989,8 @@
   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;

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- directory.c	14 Oct 2004 03:18:14 -0000	1.143
+++ directory.c	14 Oct 2004 03:44:45 -0000	1.144
@@ -554,7 +554,8 @@
       return -1;
     }
     router_get_routerlist(&rl);
-    routerlist_update_from_runningrouters(rl,rrs);
+    if (rl)
+      routerlist_update_from_runningrouters(rl,rrs);
     running_routers_free(rrs);
   }
 

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.95
retrieving revision 1.96
diff -u -d -r1.95 -r1.96
--- router.c	14 Oct 2004 03:18:14 -0000	1.95
+++ router.c	14 Oct 2004 03:44:45 -0000	1.96
@@ -386,6 +386,7 @@
   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))

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -d -r1.155 -r1.156
--- routerlist.c	14 Oct 2004 03:31:40 -0000	1.155
+++ routerlist.c	14 Oct 2004 03:44:45 -0000	1.156
@@ -59,7 +59,7 @@
       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 @@
   int i;
   routerinfo_t *router;
 
-  tor_assert(routerlist);
+  if (!routerlist)
+    return NULL;
 
   for(i=0;i<smartlist_len(routerlist->routers);i++) {
     router = smartlist_get(routerlist->routers, i);
@@ -653,6 +654,7 @@
   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_exit_policy_all_routers_reject(uint32_t addr, uint16_t port) {
   int i;
   routerinfo_t *router;
+  if (!routerlist) return 1;
 
   for (i=0;i<smartlist_len(routerlist->routers);i++) {
     router = smartlist_get(routerlist->routers, i);