From: Nick Mathewson Date: Fri, 19 Nov 2010 21:48:13 +0000 (-0500) Subject: Merge branch 'fix2183', remote branch 'rransom/fix2195-v2' into maint-0.2.2 X-Git-Tag: tor-0.2.2.19-alpha~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=54551f3148d3fbd66b49f2f9d201c4e86d69d65b;p=thirdparty%2Ftor.git Merge branch 'fix2183', remote branch 'rransom/fix2195-v2' into maint-0.2.2 --- 54551f3148d3fbd66b49f2f9d201c4e86d69d65b diff --cc src/or/router.c index af248c6554,9b80247f19,e82945e64c..3d4ee70399 --- a/src/or/router.c +++ b/src/or/router.c @@@@ -1486,25 -1485,22 -1486,30 +1485,27 @@@@ router_rebuild_descriptor(int force ei->cache_info.published_on = ri->cache_info.published_on; memcpy(ei->cache_info.identity_digest, ri->cache_info.identity_digest, DIGEST_LEN); - - ei_size = options->ExtraInfoStatistics ? MAX_EXTRAINFO_UPLOAD_SIZE : 8192; - - ei->cache_info.signed_descriptor_body = tor_malloc(ei_size); - - if (extrainfo_dump_to_string(ei->cache_info.signed_descriptor_body, - - ei_size, ei, - - get_server_identity_key()) < 0) { + + if (extrainfo_dump_to_string(&ei->cache_info.signed_descriptor_body, + + 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) {