[or-cvs] Fix a fun bug that was probably causing unnecessary downloa...

Nick Mathewson nickm at seul.org
Thu Oct 27 23:16:11 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv23619

Modified Files:
	directory.c 
Log Message:
Fix a fun bug that was probably causing unnecessary downloads, and that coupld possibly have caused some segfaults: When post-processing a split fingerprint URL, we were trying to base16_decode() entries already in the fingerprint list, failing, and removing them.  Ow.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.315
retrieving revision 1.316
diff -u -d -r1.315 -r1.316
--- directory.c	25 Oct 2005 18:01:01 -0000	1.315
+++ directory.c	27 Oct 2005 23:16:08 -0000	1.316
@@ -1667,10 +1667,13 @@
                                      smartlist_t *fp_out, int *compressed_out,
                                      int decode_hex)
 {
+  int old_len;
+  tor_assert(fp_out);
+  old_len = smartlist_len(fp_out);
   smartlist_split_string(fp_out, resource, "+", 0, 0);
   if (compressed_out)
     *compressed_out = 0;
-  if (smartlist_len(fp_out)) {
+  if (smartlist_len(fp_out) > old_len) {
     char *last = smartlist_get(fp_out,smartlist_len(fp_out)-1);
     size_t last_len = strlen(last);
     if (last_len > 2 && !strcmp(last+last_len-2, ".z")) {
@@ -1682,14 +1685,16 @@
   if (decode_hex) {
     int i;
     char *cp, *d = NULL;
-    for (i = 0; i < smartlist_len(fp_out); ++i) {
+    for (i = old_len; i < smartlist_len(fp_out); ++i) {
       cp = smartlist_get(fp_out, i);
       if (strlen(cp) != HEX_DIGEST_LEN) {
+        info(LD_DIR, "Skipping digest \"%s\" with non-standard length.", cp);
         smartlist_del(fp_out, i--);
         goto again;
       }
       d = tor_malloc_zero(DIGEST_LEN);
       if (base16_decode(d, DIGEST_LEN, cp, HEX_DIGEST_LEN)<0) {
+        info(LD_DIR, "Skipping non-decodable digest \"%s\"", cp);
         smartlist_del(fp_out, i--);
         goto again;
       }



More information about the tor-commits mailing list