[or-cvs] r15149: you can't strcasecmp on 20-byte digests what if they contain (tor/trunk/src/or)

arma at seul.org arma at seul.org
Wed Jun 11 22:46:31 UTC 2008


Author: arma
Date: 2008-06-11 18:46:31 -0400 (Wed, 11 Jun 2008)
New Revision: 15149

Modified:
   tor/trunk/src/or/rendservice.c
Log:
you can't strcasecmp on 20-byte digests
what if they contain nuls?
(worse, what if they *don't* contain nuls? ;)


Modified: tor/trunk/src/or/rendservice.c
===================================================================
--- tor/trunk/src/or/rendservice.c	2008-06-11 22:44:43 UTC (rev 15148)
+++ tor/trunk/src/or/rendservice.c	2008-06-11 22:46:31 UTC (rev 15149)
@@ -1026,8 +1026,8 @@
   tor_assert(intro);
   while ((circ = circuit_get_next_by_pk_and_purpose(circ,pk_digest,
                                                   CIRCUIT_PURPOSE_S_INTRO))) {
-    if (!strcasecmp(circ->build_state->chosen_exit->identity_digest,
-                    intro->extend_info->identity_digest) &&
+    if (!memcmp(circ->build_state->chosen_exit->identity_digest,
+                intro->extend_info->identity_digest, DIGEST_LEN) &&
         circ->rend_desc_version == desc_version) {
       return circ;
     }
@@ -1036,8 +1036,8 @@
   circ = NULL;
   while ((circ = circuit_get_next_by_pk_and_purpose(circ,pk_digest,
                                         CIRCUIT_PURPOSE_S_ESTABLISH_INTRO))) {
-    if (!strcasecmp(circ->build_state->chosen_exit->identity_digest,
-                    intro->extend_info->identity_digest) &&
+    if (!memcmp(circ->build_state->chosen_exit->identity_digest,
+                intro->extend_info->identity_digest, DIGEST_LEN) &&
         circ->rend_desc_version == desc_version) {
       return circ;
     }



More information about the tor-commits mailing list