mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Re-apply the automated conversion to 0.2.2 to make handle any memcmps that snuck in
This commit is contained in:
parent
9964c314c6
commit
0cbcbc3412
@ -824,7 +824,7 @@ smartlist_uniq_digests(smartlist_t *sl)
|
||||
static int
|
||||
_compare_digests256(const void **_a, const void **_b)
|
||||
{
|
||||
return memcmp((const char*)*_a, (const char*)*_b, DIGEST256_LEN);
|
||||
return tor_memcmp((const char*)*_a, (const char*)*_b, DIGEST256_LEN);
|
||||
}
|
||||
|
||||
/** Sort the list of DIGEST256_LEN-byte digests into ascending order. */
|
||||
|
@ -748,7 +748,7 @@ connection_or_set_bad_connections(const char *digest, int force)
|
||||
return;
|
||||
|
||||
DIGESTMAP_FOREACH(orconn_identity_map, identity, or_connection_t *, conn) {
|
||||
if (!digest || !memcmp(digest, conn->identity_digest, DIGEST_LEN))
|
||||
if (!digest || tor_memeq(digest, conn->identity_digest, DIGEST_LEN))
|
||||
connection_or_group_set_badness(conn, force);
|
||||
} DIGESTMAP_FOREACH_END;
|
||||
}
|
||||
|
@ -2087,7 +2087,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
||||
/* This assert can fire for the control port, because
|
||||
* it can request NS documents before all descriptors
|
||||
* have been fetched. */
|
||||
if (memcmp(desc->cache_info.signed_descriptor_digest,
|
||||
if (tor_memcmp(desc->cache_info.signed_descriptor_digest,
|
||||
rs->descriptor_digest,
|
||||
DIGEST_LEN)) {
|
||||
char rl_d[HEX_DIGEST_LEN+1];
|
||||
@ -2103,7 +2103,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
||||
"(router %s)\n",
|
||||
rl_d, rs_d, id);
|
||||
|
||||
tor_assert(!memcmp(desc->cache_info.signed_descriptor_digest,
|
||||
tor_assert(tor_memeq(desc->cache_info.signed_descriptor_digest,
|
||||
rs->descriptor_digest,
|
||||
DIGEST_LEN));
|
||||
};
|
||||
|
@ -2211,7 +2211,7 @@ networkstatus_add_detached_signatures(networkstatus_t *target,
|
||||
}
|
||||
for (alg = DIGEST_SHA1; alg < N_DIGEST_ALGORITHMS; ++alg) {
|
||||
if (!tor_mem_is_zero(digests->d[alg], DIGEST256_LEN)) {
|
||||
if (!memcmp(target->digests.d[alg], digests->d[alg], DIGEST256_LEN)) {
|
||||
if (tor_memeq(target->digests.d[alg], digests->d[alg], DIGEST256_LEN)) {
|
||||
++n_matches;
|
||||
} else {
|
||||
*msg_out = "Mismatched digest.";
|
||||
@ -3615,7 +3615,7 @@ vote_routerstatus_find_microdesc_hash(char *digest256_out,
|
||||
* the first part. */
|
||||
while (1) {
|
||||
num_len = strspn(cp, "1234567890");
|
||||
if (num_len == mlen && !memcmp(mstr, cp, mlen)) {
|
||||
if (num_len == mlen && tor_memeq(mstr, cp, mlen)) {
|
||||
/* This is the line. */
|
||||
char buf[BASE64_DIGEST256_LEN+1];
|
||||
/* 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;
|
||||
} else if (addr->sa_family == AF_INET6) {
|
||||
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
|
||||
return !memcmp(sin6->sin6_addr.s6_addr, LOOPBACK_S6, 16);
|
||||
return tor_memeq(sin6->sin6_addr.s6_addr, LOOPBACK_S6, 16);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,7 +48,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,
|
||||
@ -414,7 +414,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
|
||||
SMARTLIST_FOREACH_BEGIN(wrote, microdesc_t *, md) {
|
||||
tor_assert(md->saved_location == SAVED_IN_CACHE);
|
||||
md->body = (char*)cache->cache_content->data + md->off;
|
||||
tor_assert(!memcmp(md->body, "onion-key", 9));
|
||||
tor_assert(tor_memeq(md->body, "onion-key", 9));
|
||||
} SMARTLIST_FOREACH_END(md);
|
||||
|
||||
smartlist_free(wrote);
|
||||
|
@ -494,7 +494,7 @@ networkstatus_check_consensus_signature(networkstatus_t *consensus,
|
||||
authority_cert_t *cert =
|
||||
authority_cert_get_by_digests(sig->identity_digest,
|
||||
sig->signing_key_digest);
|
||||
tor_assert(!memcmp(sig->identity_digest, voter->identity_digest,
|
||||
tor_assert(tor_memeq(sig->identity_digest, voter->identity_digest,
|
||||
DIGEST_LEN));
|
||||
|
||||
if (!is_v3_auth) {
|
||||
|
@ -3083,7 +3083,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
||||
&ri_new->cache_info);
|
||||
}
|
||||
|
||||
same_descriptors = ! memcmp(ri_old->cache_info.signed_descriptor_digest,
|
||||
same_descriptors = tor_memeq(ri_old->cache_info.signed_descriptor_digest,
|
||||
ri_new->cache_info.signed_descriptor_digest,
|
||||
DIGEST_LEN);
|
||||
|
||||
@ -3105,7 +3105,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
|
||||
sdmap_remove(rl->desc_digest_map,
|
||||
ri_old->cache_info.signed_descriptor_digest);
|
||||
|
||||
if (memcmp(ri_old->cache_info.extra_info_digest,
|
||||
if (tor_memcmp(ri_old->cache_info.extra_info_digest,
|
||||
ri_new->cache_info.extra_info_digest, DIGEST_LEN)) {
|
||||
ei_tmp = eimap_remove(rl->extra_info_map,
|
||||
ri_old->cache_info.extra_info_digest);
|
||||
|
@ -3499,8 +3499,8 @@ networkstatus_parse_detached_signatures(const char *s, const char *eos)
|
||||
is_duplicate = 0;
|
||||
SMARTLIST_FOREACH(siglist, document_signature_t *, s, {
|
||||
if (s->alg == alg &&
|
||||
!memcmp(id_digest, s->identity_digest, DIGEST_LEN) &&
|
||||
!memcmp(sk_digest, s->signing_key_digest, DIGEST_LEN)) {
|
||||
tor_memeq(id_digest, s->identity_digest, DIGEST_LEN) &&
|
||||
tor_memeq(sk_digest, s->signing_key_digest, DIGEST_LEN)) {
|
||||
is_duplicate = 1;
|
||||
}
|
||||
});
|
||||
@ -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))
|
||||
return i;
|
||||
else if (a->git_tag_len)
|
||||
return memcmp(a->git_tag, b->git_tag, a->git_tag_len);
|
||||
return tor_memcmp(a->git_tag, b->git_tag, a->git_tag_len);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user