diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2010-11-15 01:36:08 -0800 |
---|---|---|
committer | Robert Ransom <rransom.8774@gmail.com> | 2010-11-17 08:33:48 -0800 |
commit | 780b8f4287432c51e822b72952f097a1dbb5e0d2 (patch) | |
tree | c2a17740d8e5d86232ac8834b140ddd92f0b49e4 /src | |
parent | 213bcb3c4022ef3535a50f2d9375ba79eccf11b4 (diff) | |
download | tor-780b8f4287432c51e822b72952f097a1dbb5e0d2.tar.gz tor-780b8f4287432c51e822b72952f097a1dbb5e0d2.zip |
Generate a router descriptor even if generating an extra-info descriptor fails.
Fixes bug #2195.
Diffstat (limited to 'src')
-rw-r--r-- | src/or/router.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/or/router.c b/src/or/router.c index 2705a78c54..17c20eddfd 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1492,19 +1492,24 @@ router_rebuild_descriptor(int force) ei_size, ei, get_server_identity_key()) < 0) { log_warn(LD_BUG, "Couldn't generate extra-info descriptor."); - routerinfo_free(ri); extrainfo_free(ei); - return -1; + ei = NULL; + } else { + ei->cache_info.signed_descriptor_len = + strlen(ei->cache_info.signed_descriptor_body); + router_get_extrainfo_hash(ei->cache_info.signed_descriptor_body, + ei->cache_info.signed_descriptor_digest); } - ei->cache_info.signed_descriptor_len = - strlen(ei->cache_info.signed_descriptor_body); - router_get_extrainfo_hash(ei->cache_info.signed_descriptor_body, - ei->cache_info.signed_descriptor_digest); /* Now finish the router descriptor. */ - memcpy(ri->cache_info.extra_info_digest, - ei->cache_info.signed_descriptor_digest, - DIGEST_LEN); + if (ei) { + memcpy(ri->cache_info.extra_info_digest, + ei->cache_info.signed_descriptor_digest, + DIGEST_LEN); + } else { + /* ri was allocated with tor_malloc_zero, so there is no need to + * zero ri->cache_info.extra_info_digest here. */ + } ri->cache_info.signed_descriptor_body = tor_malloc(8192); if (router_dump_router_to_string(ri->cache_info.signed_descriptor_body, 8192, ri, get_server_identity_key()) < 0) { @@ -1531,7 +1536,9 @@ router_rebuild_descriptor(int force) routerinfo_set_country(ri); - tor_assert(! routerinfo_incompatible_with_extrainfo(ri, ei, NULL, NULL)); + if (ei) { + tor_assert(! routerinfo_incompatible_with_extrainfo(ri, ei, NULL, NULL)); + } routerinfo_free(desc_routerinfo); desc_routerinfo = ri; |