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

[or-cvs] r10220: Fix a groovy memory corruption bug in routerlist_replace. (in tor/trunk: . src/or)



Author: nickm
Date: 2007-05-19 14:31:04 -0400 (Sat, 19 May 2007)
New Revision: 10220

Modified:
   tor/trunk/
   tor/trunk/src/or/routerlist.c
Log:
 r12805@catbus:  nickm | 2007-05-19 14:31:00 -0400
 Fix a groovy memory corruption bug in routerlist_replace.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12805] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2007-05-19 18:31:02 UTC (rev 10219)
+++ tor/trunk/src/or/routerlist.c	2007-05-19 18:31:04 UTC (rev 10220)
@@ -15,6 +15,8 @@
 
 #include "or.h"
 
+// #define DEBUG_ROUTERLIST
+
 /****************************************************************************/
 
 /* static function prototypes */
@@ -1764,7 +1766,9 @@
   smartlist_add(rl->routers, ri);
   ri->routerlist_index = smartlist_len(rl->routers) - 1;
   router_dir_info_changed();
-  // routerlist_assert_ok(rl);
+#ifdef DEBUG_ROUTERLIST
+  routerlist_assert_ok(rl);
+#endif
   routerlist_check_bug_417();
 }
 
@@ -1810,6 +1814,9 @@
     extrainfo_free(ei_tmp);
 
  done:
+#ifdef DEBUG_ROUTERLIST
+  routerlist_assert_ok(rl);
+#endif
   routerlist_check_bug_417();
   return r;
 }
@@ -1838,7 +1845,9 @@
   } else {
     routerinfo_free(ri);
   }
-  // routerlist_assert_ok(rl);
+#ifdef DEBUG_ROUTERLIST
+  routerlist_assert_ok(rl);
+#endif
   routerlist_check_bug_417();
 }
 
@@ -1892,7 +1901,9 @@
       digestmap_remove(rl->desc_by_eid_map, ri->cache_info.extra_info_digest);
     routerinfo_free(ri);
   }
-  // routerlist_assert_ok(rl);
+#ifdef DEBUG_ROUTERLIST
+  routerlist_assert_ok(rl);
+#endif
   routerlist_check_bug_417();
 }
 
@@ -1924,7 +1935,9 @@
 
   signed_descriptor_free(sd);
   routerlist_check_bug_417();
-  // routerlist_assert_ok(rl);
+#ifdef DEBUG_ROUTERLIST
+  routerlist_assert_ok(rl);
+#endif
 }
 
 /** Remove <b>ri_old</b> from the routerlist <b>rl</b>, and replace it with
@@ -1970,11 +1983,17 @@
   digestmap_set(rl->desc_digest_map,
           ri_new->cache_info.signed_descriptor_digest, &(ri_new->cache_info));
 
+  if (!tor_digest_is_zero(ri_new->cache_info.signed_descriptor_digest))
+    digestmap_set(rl->desc_by_eid_map, ri_new->cache_info.extra_info_digest,
+                  ri_new);
+
   if (make_old && get_options()->DirPort &&
       ri_old->purpose == ROUTER_PURPOSE_GENERAL) {
     signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri_old);
     smartlist_add(rl->old_routers, sd);
     digestmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
+    if (!tor_digest_is_zero(sd->extra_info_digest))
+      digestmap_set(rl->desc_by_eid_map, sd->extra_info_digest, sd);
   } else {
     if (memcmp(ri_old->cache_info.signed_descriptor_digest,
                ri_new->cache_info.signed_descriptor_digest,
@@ -1997,7 +2016,9 @@
                        ri_old->cache_info.extra_info_digest);
     routerinfo_free(ri_old);
   }
-  // routerlist_assert_ok(rl);
+#ifdef DEBUG_ROUTERLIST
+  routerlist_assert_ok(rl);
+#endif
   routerlist_check_bug_417();
 }