mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
Hand-tune the new tor_memcmp instances in 0.2.2
This commit is contained in:
parent
0cbcbc3412
commit
8fb38331c3
@ -2087,7 +2087,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
|||||||
/* This assert can fire for the control port, because
|
/* This assert can fire for the control port, because
|
||||||
* it can request NS documents before all descriptors
|
* it can request NS documents before all descriptors
|
||||||
* have been fetched. */
|
* have been fetched. */
|
||||||
if (tor_memcmp(desc->cache_info.signed_descriptor_digest,
|
if (tor_memneq(desc->cache_info.signed_descriptor_digest,
|
||||||
rs->descriptor_digest,
|
rs->descriptor_digest,
|
||||||
DIGEST_LEN)) {
|
DIGEST_LEN)) {
|
||||||
char rl_d[HEX_DIGEST_LEN+1];
|
char rl_d[HEX_DIGEST_LEN+1];
|
||||||
|
@ -2211,7 +2211,7 @@ networkstatus_add_detached_signatures(networkstatus_t *target,
|
|||||||
}
|
}
|
||||||
for (alg = DIGEST_SHA1; alg < N_DIGEST_ALGORITHMS; ++alg) {
|
for (alg = DIGEST_SHA1; alg < N_DIGEST_ALGORITHMS; ++alg) {
|
||||||
if (!tor_mem_is_zero(digests->d[alg], DIGEST256_LEN)) {
|
if (!tor_mem_is_zero(digests->d[alg], DIGEST256_LEN)) {
|
||||||
if (tor_memeq(target->digests.d[alg], digests->d[alg], DIGEST256_LEN)) {
|
if (fast_memeq(target->digests.d[alg], digests->d[alg], DIGEST256_LEN)) {
|
||||||
++n_matches;
|
++n_matches;
|
||||||
} else {
|
} else {
|
||||||
*msg_out = "Mismatched digest.";
|
*msg_out = "Mismatched digest.";
|
||||||
@ -3615,7 +3615,7 @@ vote_routerstatus_find_microdesc_hash(char *digest256_out,
|
|||||||
* the first part. */
|
* the first part. */
|
||||||
while (1) {
|
while (1) {
|
||||||
num_len = strspn(cp, "1234567890");
|
num_len = strspn(cp, "1234567890");
|
||||||
if (num_len == mlen && tor_memeq(mstr, cp, mlen)) {
|
if (num_len == mlen && fast_memeq(mstr, cp, mlen)) {
|
||||||
/* This is the line. */
|
/* This is the line. */
|
||||||
char buf[BASE64_DIGEST256_LEN+1];
|
char buf[BASE64_DIGEST256_LEN+1];
|
||||||
/* XXXX ignores extraneous stuff if the digest is too long. This
|
/* XXXX ignores extraneous stuff if the digest is too long. This
|
||||||
|
@ -2253,7 +2253,7 @@ sockaddr_is_loopback(const struct sockaddr *addr)
|
|||||||
return (ntohl(sin->sin_addr.s_addr) & 0xff000000) == 0x7f000000;
|
return (ntohl(sin->sin_addr.s_addr) & 0xff000000) == 0x7f000000;
|
||||||
} else if (addr->sa_family == AF_INET6) {
|
} else if (addr->sa_family == AF_INET6) {
|
||||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
|
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
|
||||||
return tor_memeq(sin6->sin6_addr.s6_addr, LOOPBACK_S6, 16);
|
return fast_memeq(sin6->sin6_addr.s6_addr, LOOPBACK_S6, 16);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
|
|||||||
SMARTLIST_FOREACH_BEGIN(wrote, microdesc_t *, md) {
|
SMARTLIST_FOREACH_BEGIN(wrote, microdesc_t *, md) {
|
||||||
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;
|
||||||
tor_assert(tor_memeq(md->body, "onion-key", 9));
|
tor_assert(fast_memeq(md->body, "onion-key", 9));
|
||||||
} SMARTLIST_FOREACH_END(md);
|
} SMARTLIST_FOREACH_END(md);
|
||||||
|
|
||||||
smartlist_free(wrote);
|
smartlist_free(wrote);
|
||||||
|
@ -3105,7 +3105,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
|||||||
sdmap_remove(rl->desc_digest_map,
|
sdmap_remove(rl->desc_digest_map,
|
||||||
ri_old->cache_info.signed_descriptor_digest);
|
ri_old->cache_info.signed_descriptor_digest);
|
||||||
|
|
||||||
if (tor_memcmp(ri_old->cache_info.extra_info_digest,
|
if (tor_memneq(ri_old->cache_info.extra_info_digest,
|
||||||
ri_new->cache_info.extra_info_digest, DIGEST_LEN)) {
|
ri_new->cache_info.extra_info_digest, DIGEST_LEN)) {
|
||||||
ei_tmp = eimap_remove(rl->extra_info_map,
|
ei_tmp = eimap_remove(rl->extra_info_map,
|
||||||
ri_old->cache_info.extra_info_digest);
|
ri_old->cache_info.extra_info_digest);
|
||||||
|
@ -4538,7 +4538,7 @@ tor_version_compare(tor_version_t *a, tor_version_t *b)
|
|||||||
else if ((i = a->git_tag_len - b->git_tag_len))
|
else if ((i = a->git_tag_len - b->git_tag_len))
|
||||||
return i;
|
return i;
|
||||||
else if (a->git_tag_len)
|
else if (a->git_tag_len)
|
||||||
return tor_memcmp(a->git_tag, b->git_tag, a->git_tag_len);
|
return fast_memcmp(a->git_tag, b->git_tag, a->git_tag_len);
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user