[tor-commits] [tor/master] Clean up ugly constants in connection_dir_download_cert_failed(), and fix a broken one

andrea at torproject.org andrea at torproject.org
Sat May 11 04:08:16 UTC 2013


commit c0d96bae666c1dc0c16b4df69190fa126131aa65
Author: Andrea Shepard <andrea at torproject.org>
Date:   Thu May 9 08:23:53 2013 -0700

    Clean up ugly constants in connection_dir_download_cert_failed(), and fix a broken one
---
 src/or/directory.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/or/directory.c b/src/or/directory.c
index 8dd5a7c..f65ac87 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -803,6 +803,8 @@ connection_dir_bridge_routerdesc_failed(dir_connection_t *conn)
 static void
 connection_dir_download_cert_failed(dir_connection_t *conn, int status)
 {
+  const char *fp_pfx = "fp/";
+  const char *fpsk_pfx = "fp-sk/";
   smartlist_t *failed;
   tor_assert(conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE);
 
@@ -814,19 +816,20 @@ connection_dir_download_cert_failed(dir_connection_t *conn, int status)
    * with "fp/") or download by fingerprint/signing key pair
    * (resource starts with "fp-sk/").
    */
-  if (!strcmpstart(conn->requested_resource, "fp/")) {
+  if (!strcmpstart(conn->requested_resource, fp_pfx)) {
     /* Download by fingerprint case */
-    dir_split_resource_into_fingerprints(conn->requested_resource + 3,
+    dir_split_resource_into_fingerprints(conn->requested_resource +
+                                         strlen(fp_pfx),
                                          failed, NULL, DSR_HEX);
     SMARTLIST_FOREACH_BEGIN(failed, char *, cp) {
       /* Null signing key digest indicates download by fp only */
       authority_cert_dl_failed(cp, NULL, status);
       tor_free(cp);
     } SMARTLIST_FOREACH_END(cp);
-  } else if (!strcmpstart(conn->requested_resource, "fp-sk/")) {
+  } else if (!strcmpstart(conn->requested_resource, fpsk_pfx)) {
     /* Download by (fp,sk) pairs */
-    dir_split_resource_into_fingerprint_pairs(conn->requested_resource + 5,
-                                              failed);
+    dir_split_resource_into_fingerprint_pairs(conn->requested_resource +
+                                              strlen(fpsk_pfx), failed);
     SMARTLIST_FOREACH_BEGIN(failed, fp_pair_t *, cp) {
       authority_cert_dl_failed(cp->first, cp->second, status);
       tor_free(cp);





More information about the tor-commits mailing list