[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r10755: Backport r1075[2-4]: Fix a crash bug in directory authoritie (in tor/branches/tor-0_1_2-patches: . src/or)
Author: weasel
Date: 2007-07-06 20:20:52 -0400 (Fri, 06 Jul 2007)
New Revision: 10755
Modified:
tor/branches/tor-0_1_2-patches/ChangeLog
tor/branches/tor-0_1_2-patches/src/or/routerlist.c
Log:
Backport r1075[2-4]: Fix a crash bug in directory authorities when we re-number the routerlist while inserting a new router.
Modified: tor/branches/tor-0_1_2-patches/ChangeLog
===================================================================
--- tor/branches/tor-0_1_2-patches/ChangeLog 2007-07-06 21:21:09 UTC (rev 10754)
+++ tor/branches/tor-0_1_2-patches/ChangeLog 2007-07-07 00:20:52 UTC (rev 10755)
@@ -5,8 +5,9 @@
an mmap(). (Bug reported by lodger)
- Count the number of authorities that recommend each version
correctly. Previously, we were under-counting by 1.
+ - Fix a crash bug in directory authorities when we re-number the
+ routerlist while inserting a new router.
-
Changes in version 0.1.2.14 - 2007-05-25
o Directory authority changes:
- Two directory authorities (moria1 and moria2) just moved to new
Modified: tor/branches/tor-0_1_2-patches/src/or/routerlist.c
===================================================================
--- tor/branches/tor-0_1_2-patches/src/or/routerlist.c 2007-07-06 21:21:09 UTC (rev 10754)
+++ tor/branches/tor-0_1_2-patches/src/or/routerlist.c 2007-07-07 00:20:52 UTC (rev 10755)
@@ -1692,15 +1692,19 @@
* index as ri_old, if possible. ri is freed as appropriate. */
static void
routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
- routerinfo_t *ri_new, int idx, int make_old)
+ routerinfo_t *ri_new)
{
+ int idx;
{
/* XXXX remove this code once bug 404 is fixed. */
routerinfo_t *ri_generated = router_get_my_routerinfo();
tor_assert(ri_generated != ri_new);
}
tor_assert(ri_old != ri_new);
- idx = _routerlist_find_elt(rl->routers, ri_old, idx);
+ idx = ri_old->routerlist_index;
+ tor_assert(0 <= idx && idx < smartlist_len(rl->routers));
+ tor_assert(smartlist_get(rl->routers, idx) == ri_old);
+
router_dir_info_changed();
if (idx >= 0) {
smartlist_set(rl->routers, idx, ri_new);
@@ -1720,7 +1724,7 @@
digestmap_set(rl->desc_digest_map,
ri_new->cache_info.signed_descriptor_digest, &(ri_new->cache_info));
- if (make_old && get_options()->DirPort) {
+ if (get_options()->DirPort) {
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);
@@ -1898,6 +1902,8 @@
int authdir = get_options()->AuthoritativeDir;
int authdir_believes_valid = 0;
routerinfo_t *old_router;
+ /* This has side effects, so do it before we start the real work */
+ int have_dir_info = router_have_minimum_dir_info();
tor_assert(msg);
@@ -1965,9 +1971,6 @@
old_router = digestmap_get(routerlist->identity_map,
router->cache_info.identity_digest);
if (old_router) {
- int pos = old_router->routerlist_index;
- tor_assert(smartlist_get(routerlist->routers, pos) == old_router);
-
if (router->cache_info.published_on <=
old_router->cache_info.published_on) {
/* Same key, but old */
@@ -1994,9 +1997,8 @@
old_router->num_unreachable_notifications;
}
if (authdir && !from_cache && !from_fetch &&
- router_have_minimum_dir_info() &&
- dirserv_thinks_router_is_blatantly_unreachable(router,
- time(NULL))) {
+ have_dir_info &&
+ dirserv_thinks_router_is_blatantly_unreachable(router, time(NULL))) {
if (router->num_unreachable_notifications >= 3) {
unreachable = 1;
log_notice(LD_DIR, "Notifying server '%s' that it's unreachable. "
@@ -2011,7 +2013,7 @@
router->num_unreachable_notifications++;
}
}
- routerlist_replace(routerlist, old_router, router, pos, 1);
+ routerlist_replace(routerlist, old_router, router);
if (!from_cache) {
router_append_to_journal(&router->cache_info);
}