mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 13:43:47 +01:00
fixup! Refactor initiate_descriptor_downloads() to be safer
Calculate digest_len correctly. Also, refactor setting of initial variables to look a little nicer.
This commit is contained in:
parent
55b21b366c
commit
0fdfdae7e3
@ -4299,18 +4299,23 @@ MOCK_IMPL(STATIC void, initiate_descriptor_downloads,
|
|||||||
int lo, int hi, int pds_flags))
|
int lo, int hi, int pds_flags))
|
||||||
{
|
{
|
||||||
char *resource, *cp;
|
char *resource, *cp;
|
||||||
int digest_len = DIGEST_LEN, enc_digest_len = HEX_DIGEST_LEN;
|
int digest_len, enc_digest_len;
|
||||||
const char *sep = "+";
|
const char *sep;
|
||||||
int b64_256 = 0;
|
int b64_256;
|
||||||
smartlist_t *tmp;
|
smartlist_t *tmp;
|
||||||
|
|
||||||
if (purpose == DIR_PURPOSE_FETCH_MICRODESC) {
|
if (purpose == DIR_PURPOSE_FETCH_MICRODESC) {
|
||||||
/* Microdescriptors are downloaded by "-"-separated base64-encoded
|
/* Microdescriptors are downloaded by "-"-separated base64-encoded
|
||||||
* 256-bit digests. */
|
* 256-bit digests. */
|
||||||
digest_len = DIGEST256_LEN;
|
digest_len = DIGEST256_LEN;
|
||||||
enc_digest_len = BASE64_DIGEST256_LEN;
|
enc_digest_len = BASE64_DIGEST256_LEN + 1;
|
||||||
sep = "-";
|
sep = "-";
|
||||||
b64_256 = 1;
|
b64_256 = 1;
|
||||||
|
} else {
|
||||||
|
digest_len = DIGEST_LEN;
|
||||||
|
enc_digest_len = HEX_DIGEST_LEN + 1;
|
||||||
|
sep = "+";
|
||||||
|
b64_256 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lo < 0)
|
if (lo < 0)
|
||||||
@ -4321,7 +4326,6 @@ MOCK_IMPL(STATIC void, initiate_descriptor_downloads,
|
|||||||
if (hi-lo <= 0)
|
if (hi-lo <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
digest_len += 1; // for the NULL
|
|
||||||
tmp = smartlist_new();
|
tmp = smartlist_new();
|
||||||
|
|
||||||
for (; lo < hi; ++lo) {
|
for (; lo < hi; ++lo) {
|
||||||
|
Loading…
Reference in New Issue
Block a user