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

[tor-commits] [tor/master] fix naked memcmps



commit b750a77e3fc16cc670d89be1d1ed4d278d4ca989
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Jun 30 15:34:16 2016 -0400

    fix naked memcmps
---
 src/or/dirserv.c     | 4 ++--
 src/or/entrynodes.c  | 2 +-
 src/or/routerparse.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index e616373..64ebde6 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2062,8 +2062,8 @@ routers_make_ed_keys_unique(smartlist_t *routers)
       const time_t ri2_pub = ri2->cache_info.published_on;
       if (ri2_pub < ri_pub ||
           (ri2_pub == ri_pub &&
-           memcmp(ri->cache_info.signed_descriptor_digest,
-                  ri2->cache_info.signed_descriptor_digest,DIGEST_LEN)<0)) {
+           fast_memcmp(ri->cache_info.signed_descriptor_digest,
+                     ri2->cache_info.signed_descriptor_digest,DIGEST_LEN)<0)) {
         digest256map_set(by_ed_key, pk, ri);
         ri2->omit_from_vote = 1;
       } else {
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 17507fe..6990bcd 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -2452,7 +2452,7 @@ get_bridge_dl_status_by_id, (const char *digest))
 
   if (digest && get_options()->UseBridges && bridge_list) {
     SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, b) {
-      if (memcmp(digest, b->identity, DIGEST_LEN) == 0) {
+      if (tor_memeq(digest, b->identity, DIGEST_LEN)) {
         dl = &(b->fetch_status);
         break;
       }
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 13ffaf9..63397b5 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -773,7 +773,7 @@ dump_desc_fifo_bump_hash(const uint8_t *digest_sha256)
     /* Find a match if one exists */
     SMARTLIST_FOREACH_BEGIN(descs_dumped, dumped_desc_t *, ent) {
       if (ent &&
-          memcmp(ent->digest_sha256, digest_sha256, DIGEST256_LEN) == 0) {
+          tor_memeq(ent->digest_sha256, digest_sha256, DIGEST256_LEN)) {
         /*
          * Save a pointer to the match and remove it from its current
          * position.
@@ -919,7 +919,7 @@ dump_desc_populate_one_file, (const char *dirname, const char *f))
   }
 
   /* Compare the digests */
-  if (memcmp(digest, content_digest, DIGEST256_LEN) != 0) {
+  if (tor_memneq(digest, content_digest, DIGEST256_LEN)) {
     /* No match */
     log_info(LD_DIR,
              "Hash of %s from unparseable descriptors directory didn't "



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