diff options
Diffstat (limited to 'src/or/microdesc.c')
-rw-r--r-- | src/or/microdesc.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/or/microdesc.c b/src/or/microdesc.c index ba4532ef64..1b0c333dae 100644 --- a/src/or/microdesc.c +++ b/src/or/microdesc.c @@ -55,7 +55,7 @@ _microdesc_hash(microdesc_t *md) static INLINE int _microdesc_eq(microdesc_t *a, microdesc_t *b) { - return !memcmp(a->digest, b->digest, DIGEST256_LEN); + return tor_memeq(a->digest, b->digest, DIGEST256_LEN); } HT_PROTOTYPE(microdesc_map, microdesc_t, node, @@ -452,10 +452,11 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force) smartlist_add(wrote, md); } - finish_writing_to_file(open_file); /*XXX Check me.*/ - if (cache->cache_content) tor_munmap_file(cache->cache_content); + + finish_writing_to_file(open_file); /*XXX Check me.*/ + cache->cache_content = tor_mmap_file(cache->cache_fname); if (!cache->cache_content && smartlist_len(wrote)) { @@ -468,7 +469,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force) tor_assert(md->saved_location == SAVED_IN_CACHE); md->body = (char*)cache->cache_content->data + md->off; if (PREDICT_UNLIKELY( - md->bodylen < 9 || memcmp(md->body, "onion-key", 9) != 0)) { + md->bodylen < 9 || fast_memneq(md->body, "onion-key", 9) != 0)) { /* XXXX023 once bug 2022 is solved, we can kill this block and turn it * into just the tor_assert(!memcmp) */ off_t avail = cache->cache_content->size - md->off; @@ -480,7 +481,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force) " with \"onion-key\". Instead I got %s.", (int)md->off, escaped(bad_str)); tor_free(bad_str); - tor_assert(!memcmp(md->body, "onion-key", 9)); + tor_assert(fast_memeq(md->body, "onion-key", 9)); } } SMARTLIST_FOREACH_END(md); @@ -633,7 +634,7 @@ microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache, void update_microdesc_downloads(time_t now) { - or_options_t *options = get_options(); + const or_options_t *options = get_options(); networkstatus_t *consensus; smartlist_t *missing; digestmap_t *pending; @@ -692,7 +693,7 @@ update_microdescs_from_networkstatus(time_t now) /** Return true iff we should prefer to use microdescriptors rather than * routerdescs for building circuits. */ int -we_use_microdescriptors_for_circuits(or_options_t *options) +we_use_microdescriptors_for_circuits(const or_options_t *options) { int ret = options->UseMicrodescriptors; if (ret == -1) { @@ -711,7 +712,7 @@ we_use_microdescriptors_for_circuits(or_options_t *options) /** Return true iff we should try to download microdescriptors at all. */ int -we_fetch_microdescriptors(or_options_t *options) +we_fetch_microdescriptors(const or_options_t *options) { if (directory_caches_dir_info(options)) return 1; @@ -720,7 +721,7 @@ we_fetch_microdescriptors(or_options_t *options) /** Return true iff we should try to download router descriptors at all. */ int -we_fetch_router_descriptors(or_options_t *options) +we_fetch_router_descriptors(const or_options_t *options) { if (directory_caches_dir_info(options)) return 1; |