diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-23 12:56:16 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-23 12:56:16 -0400 |
commit | 0fdfdae7e3a88a9172a51f36ac6b536b5687d401 (patch) | |
tree | edca55d8af97e301725748ff6bf6cddc331a74d2 /src/or/routerlist.c | |
parent | 55b21b366c4a8c237dda0a967c0c499e18fb0b4c (diff) | |
download | tor-0fdfdae7e3a88a9172a51f36ac6b536b5687d401.tar.gz tor-0fdfdae7e3a88a9172a51f36ac6b536b5687d401.zip |
fixup! Refactor initiate_descriptor_downloads() to be safer
Calculate digest_len correctly.
Also, refactor setting of initial variables to look a little nicer.
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index e65898636a..efa4abbac1 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -4299,18 +4299,23 @@ MOCK_IMPL(STATIC void, initiate_descriptor_downloads, int lo, int hi, int pds_flags)) { char *resource, *cp; - int digest_len = DIGEST_LEN, enc_digest_len = HEX_DIGEST_LEN; - const char *sep = "+"; - int b64_256 = 0; + int digest_len, enc_digest_len; + const char *sep; + int b64_256; smartlist_t *tmp; if (purpose == DIR_PURPOSE_FETCH_MICRODESC) { /* Microdescriptors are downloaded by "-"-separated base64-encoded * 256-bit digests. */ digest_len = DIGEST256_LEN; - enc_digest_len = BASE64_DIGEST256_LEN; + enc_digest_len = BASE64_DIGEST256_LEN + 1; sep = "-"; b64_256 = 1; + } else { + digest_len = DIGEST_LEN; + enc_digest_len = HEX_DIGEST_LEN + 1; + sep = "+"; + b64_256 = 0; } if (lo < 0) @@ -4321,7 +4326,6 @@ MOCK_IMPL(STATIC void, initiate_descriptor_downloads, if (hi-lo <= 0) return; - digest_len += 1; // for the NULL tmp = smartlist_new(); for (; lo < hi; ++lo) { |