[tor-commits] [tor/release-0.2.2] Re-apply the automated conversion to 0.2.2 to make handle any memcmps that snuck in
arma at torproject.org
arma at torproject.org
Sat May 14 03:38:40 UTC 2011
commit 0cbcbc3412b667537b6ec54da0a4c9173a19d6de
Author: Nick Mathewson <nickm at torproject.org>
Date: Wed May 11 16:27:27 2011 -0400
Re-apply the automated conversion to 0.2.2 to make handle any memcmps that snuck in
---
src/common/container.c | 2 +-
src/or/connection_or.c | 2 +-
src/or/dirserv.c | 4 ++--
src/or/dirvote.c | 4 ++--
src/or/eventdns.c | 2 +-
src/or/microdesc.c | 4 ++--
src/or/networkstatus.c | 2 +-
src/or/routerlist.c | 4 ++--
src/or/routerparse.c | 6 +++---
9 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/common/container.c b/src/common/container.c
index 5476c60..09d4bb1 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -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. */
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 4ce08af..ed174c9 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -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;
}
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 1f4489a..1fd0cd2 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -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));
};
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index a95cea4..a017cfb 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -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
diff --git a/src/or/eventdns.c b/src/or/eventdns.c
index 9e3b426..33238b2 100644
--- a/src/or/eventdns.c
+++ b/src/or/eventdns.c
@@ -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;
}
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index 5740c40..139f2f8 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -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);
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index ff20566..1aa4e4a 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -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) {
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index b0909eb..c54025b 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -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);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 3b669ad..12d1dfe 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -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;
}
More information about the tor-commits
mailing list