aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-11-02 11:20:09 -0400
committerNick Mathewson <nickm@torproject.org>2010-11-02 11:20:09 -0400
commit114a371c0ea43aae667b71b2ba1e0a7754d08ea5 (patch)
tree4dc74a5f5b4f55ff5cace870a49975a9d07daceb /src
parent213139f887edd5f366108e72d77c33bcfa3f8ba9 (diff)
downloadtor-114a371c0ea43aae667b71b2ba1e0a7754d08ea5.tar
tor-114a371c0ea43aae667b71b2ba1e0a7754d08ea5.tar.gz
Fix the assert in bug 1776
In the case where old_router == NULL but sdmap has an entry for the router, we can currently safely infer that the old_router was not a bridge. Add an assert to ensure that this remains true, and fix the logic not to die with the tor_assert(old_router) call.
Diffstat (limited to 'src')
-rw-r--r--src/or/routerlist.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 8ed9a7f5e..94f57cc39 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -2661,12 +2661,15 @@ signed_descriptor_free(signed_descriptor_t *sd)
tor_free(sd);
}
-/** Extract a signed_descriptor_t from a routerinfo, and free the routerinfo.
+/** Extract a signed_descriptor_t from a general routerinfo, and free the
+ * routerinfo.
*/
static signed_descriptor_t *
signed_descriptor_from_routerinfo(routerinfo_t *ri)
{
- signed_descriptor_t *sd = tor_malloc_zero(sizeof(signed_descriptor_t));
+ signed_descriptor_t *sd;
+ tor_assert(ri->purpose == ROUTER_PURPOSE_GENERAL);
+ sd = tor_malloc_zero(sizeof(signed_descriptor_t));
memcpy(sd, &(ri->cache_info), sizeof(signed_descriptor_t));
sd->routerlist_index = -1;
ri->cache_info.signed_descriptor_body = NULL;
@@ -3209,10 +3212,14 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
/* If we have this descriptor already and the new descriptor is a bridge
* descriptor, replace it. If we had a bridge descriptor before and the
* new one is not a bridge descriptor, don't replace it. */
- tor_assert(old_router);
+
+ /* Only members of routerlist->identity_map can be bridges; we don't
+ * put bridges in old_routers. */
+ const int was_bridge = old_router &&
+ old_router->purpose == ROUTER_PURPOSE_BRIDGE;
+
if (! (routerinfo_is_a_configured_bridge(router) &&
- (router->purpose == ROUTER_PURPOSE_BRIDGE ||
- old_router->purpose != ROUTER_PURPOSE_BRIDGE))) {
+ (router->purpose == ROUTER_PURPOSE_BRIDGE || !was_bridge))) {
log_info(LD_DIR,
"Dropping descriptor that we already have for router '%s'",
router->nickname);