[tor-commits] [tor/master] Correct the bulletproofing of routerlist_insert()

nickm at torproject.org nickm at torproject.org
Wed May 16 15:14:11 UTC 2012


commit 3ed4c5dc05a1954a8c68d0f7e9fb802f3155d308
Author: Nick Mathewson <nickm at torproject.org>
Date:   Wed May 16 10:51:02 2012 -0400

    Correct the bulletproofing of routerlist_insert()
    
    The original code updated some variables, but forgot to remove a
    replaced old-routerdesc from rl->old_routers.
    
    Related to bug 1776.
---
 changes/routerlist_ins_replace |    5 +++++
 src/or/routerlist.c            |    7 +++++++
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/changes/routerlist_ins_replace b/changes/routerlist_ins_replace
new file mode 100644
index 0000000..7b442a2
--- /dev/null
+++ b/changes/routerlist_ins_replace
@@ -0,0 +1,5 @@
+  o Minor bugfixes:
+    - If we hit the error case where routerlist_insert() replaces an
+      existing (old) server descriptor, make sure to remove that
+      server descriptor from the old_routers list. Fix related to bug
+      1776. Bugfix on 0.2.2.18-alpha.
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 86cdb83..d21b40c 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2815,6 +2815,13 @@ routerlist_insert(routerlist_t *rl, routerinfo_t *ri)
                      ri->cache_info.signed_descriptor_digest,
                      &(ri->cache_info));
   if (sd_old) {
+    int idx = sd_old->routerlist_index;
+    sd_old->routerlist_index = -1;
+    smartlist_del(rl->old_routers, idx);
+    if (idx < smartlist_len(rl->old_routers)) {
+       signed_descriptor_t *d = smartlist_get(rl->old_routers, idx);
+       d->routerlist_index = idx;
+    }
     rl->desc_store.bytes_dropped += sd_old->signed_descriptor_len;
     sdmap_remove(rl->desc_by_eid_map, sd_old->extra_info_digest);
     signed_descriptor_free(sd_old);





More information about the tor-commits mailing list