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

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



commit c0d96bae666c1dc0c16b4df69190fa126131aa65
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxx>
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 file 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);



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