[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Reapply the automated memcmp conversion to 0.2.3 to catch newly added memcmps



commit 7267647bd75762deba5c4070e93df64d0823142e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Wed May 11 16:41:14 2011 -0400

    Reapply the automated memcmp conversion to 0.2.3 to catch newly added memcmps
---
 src/or/microdesc.c |    2 +-
 src/or/nodelist.c  |   12 ++++++------
 src/or/router.c    |    2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index f7f42a4..86a53d2 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -465,7 +465,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 || tor_memcmp(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;
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index a736dc3..ed7fe9c 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -47,7 +47,7 @@ node_id_hash(const node_t *node)
 static INLINE unsigned int
 node_id_eq(const node_t *node1, const node_t *node2)
 {
-  return 0 == memcmp(node1->identity, node2->identity, DIGEST_LEN);
+  return tor_memeq(node1->identity, node2->identity, DIGEST_LEN);
 }
 
 HT_PROTOTYPE(nodelist_map, node_t, ht_ent, node_id_hash, node_id_eq);
@@ -183,7 +183,7 @@ nodelist_set_consensus(networkstatus_t *ns)
     node->rs = rs;
     if (ns->flavor == FLAV_MICRODESC) {
       if (node->md == NULL ||
-          0!=memcmp(node->md->digest,rs->descriptor_digest,DIGEST256_LEN)) {
+          tor_memneq(node->md->digest,rs->descriptor_digest,DIGEST256_LEN)) {
         node->md = microdesc_cache_lookup_by_digest256(NULL,
                                                        rs->descriptor_digest);
       }
@@ -352,7 +352,7 @@ nodelist_assert_ok(void)
     SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, ri) {
       const node_t *node = node_get_by_id(ri->cache_info.identity_digest);
       tor_assert(node && node->ri == ri);
-      tor_assert(0 == memcmp(ri->cache_info.identity_digest,
+      tor_assert(tor_memeq(ri->cache_info.identity_digest,
                              node->identity, DIGEST_LEN));
       tor_assert(! digestmap_get(dm, node->identity));
       digestmap_set(dm, node->identity, (void*)node);
@@ -364,7 +364,7 @@ nodelist_assert_ok(void)
     SMARTLIST_FOREACH_BEGIN(ns->routerstatus_list, routerstatus_t *, rs) {
       const node_t *node = node_get_by_id(rs->identity_digest);
       tor_assert(node && node->rs == rs);
-      tor_assert(0 == memcmp(rs->identity_digest, node->identity, DIGEST_LEN));
+      tor_assert(tor_memeq(rs->identity_digest, node->identity, DIGEST_LEN));
       digestmap_set(dm, node->identity, (void*)node);
       if (ns->flavor == FLAV_MICRODESC) {
         /* 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 == '=') {
         const char *named_id =
           networkstatus_get_router_digest_by_nickname(nn_buf);
-        if (!named_id || memcmp(named_id, digest_buf, DIGEST_LEN))
+        if (!named_id || tor_memcmp(named_id, digest_buf, DIGEST_LEN))
           return NULL;
       }
     }
@@ -540,7 +540,7 @@ node_is_named(const node_t *node)
   named_id = networkstatus_get_router_digest_by_nickname(nickname);
   if (!named_id)
     return 0;
-  return !memcmp(named_id, node->identity, DIGEST_LEN);
+  return tor_memeq(named_id, node->identity, DIGEST_LEN);
 }
 
 /** Return true iff <b>node</b> appears to be a directory authority or
diff --git a/src/or/router.c b/src/or/router.c
index 42b07cb..49c2a92 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2210,7 +2210,7 @@ router_get_verbose_nickname(char *buf, const routerinfo_t *router)
 {
   const char *good_digest = networkstatus_get_router_digest_by_nickname(
                                                          router->nickname);
-  int is_named = good_digest && !memcmp(good_digest,
+  int is_named = good_digest && tor_memeq(good_digest,
                                         router->cache_info.identity_digest,
                                         DIGEST_LEN);
   buf[0] = '$';



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits