aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-10-27 23:16:08 +0000
committerNick Mathewson <nickm@torproject.org>2005-10-27 23:16:08 +0000
commit267af9ecf94dce7b570cc59f78aec23004981eea (patch)
treec9af10fc6773c1cb17607359f0b94efe26de7128 /src
parent7643c5254c871e326fe3033ee888f68cf2563994 (diff)
downloadtor-267af9ecf94dce7b570cc59f78aec23004981eea.tar
tor-267af9ecf94dce7b570cc59f78aec23004981eea.tar.gz
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.
svn:r5326
Diffstat (limited to 'src')
-rw-r--r--src/or/directory.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 2a45b5f16..320485ce5 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1667,10 +1667,13 @@ dir_split_resource_into_fingerprints(const char *resource,
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 @@ dir_split_resource_into_fingerprints(const char *resource,
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;
}