mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-29 01:03:26 +01:00
Hand-tune the new tor_memcmp instances in 0.2.3
This commit is contained in:
parent
7267647bd7
commit
9e16a418f9
@ -465,7 +465,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
|
|||||||
tor_assert(md->saved_location == SAVED_IN_CACHE);
|
tor_assert(md->saved_location == SAVED_IN_CACHE);
|
||||||
md->body = (char*)cache->cache_content->data + md->off;
|
md->body = (char*)cache->cache_content->data + md->off;
|
||||||
if (PREDICT_UNLIKELY(
|
if (PREDICT_UNLIKELY(
|
||||||
md->bodylen < 9 || tor_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
|
/* XXXX023 once bug 2022 is solved, we can kill this block and turn it
|
||||||
* into just the tor_assert(!memcmp) */
|
* into just the tor_assert(!memcmp) */
|
||||||
off_t avail = cache->cache_content->size - md->off;
|
off_t avail = cache->cache_content->size - md->off;
|
||||||
|
@ -352,7 +352,7 @@ nodelist_assert_ok(void)
|
|||||||
SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, ri) {
|
SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, ri) {
|
||||||
const node_t *node = node_get_by_id(ri->cache_info.identity_digest);
|
const node_t *node = node_get_by_id(ri->cache_info.identity_digest);
|
||||||
tor_assert(node && node->ri == ri);
|
tor_assert(node && node->ri == ri);
|
||||||
tor_assert(tor_memeq(ri->cache_info.identity_digest,
|
tor_assert(fast_memeq(ri->cache_info.identity_digest,
|
||||||
node->identity, DIGEST_LEN));
|
node->identity, DIGEST_LEN));
|
||||||
tor_assert(! digestmap_get(dm, node->identity));
|
tor_assert(! digestmap_get(dm, node->identity));
|
||||||
digestmap_set(dm, node->identity, (void*)node);
|
digestmap_set(dm, node->identity, (void*)node);
|
||||||
@ -364,7 +364,7 @@ nodelist_assert_ok(void)
|
|||||||
SMARTLIST_FOREACH_BEGIN(ns->routerstatus_list, routerstatus_t *, rs) {
|
SMARTLIST_FOREACH_BEGIN(ns->routerstatus_list, routerstatus_t *, rs) {
|
||||||
const node_t *node = node_get_by_id(rs->identity_digest);
|
const node_t *node = node_get_by_id(rs->identity_digest);
|
||||||
tor_assert(node && node->rs == rs);
|
tor_assert(node && node->rs == rs);
|
||||||
tor_assert(tor_memeq(rs->identity_digest, node->identity, DIGEST_LEN));
|
tor_assert(fast_memeq(rs->identity_digest, node->identity, DIGEST_LEN));
|
||||||
digestmap_set(dm, node->identity, (void*)node);
|
digestmap_set(dm, node->identity, (void*)node);
|
||||||
if (ns->flavor == FLAV_MICRODESC) {
|
if (ns->flavor == FLAV_MICRODESC) {
|
||||||
/* If it's a microdesc consensus, every entry that has a
|
/* If it's a microdesc consensus, every entry that has a
|
||||||
@ -422,7 +422,7 @@ node_get_by_hex_id(const char *hex_id)
|
|||||||
if (nn_char == '=') {
|
if (nn_char == '=') {
|
||||||
const char *named_id =
|
const char *named_id =
|
||||||
networkstatus_get_router_digest_by_nickname(nn_buf);
|
networkstatus_get_router_digest_by_nickname(nn_buf);
|
||||||
if (!named_id || tor_memcmp(named_id, digest_buf, DIGEST_LEN))
|
if (!named_id || tor_memneq(named_id, digest_buf, DIGEST_LEN))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user