mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
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
This commit is contained in:
parent
7643c5254c
commit
267af9ecf9
@ -1667,10 +1667,13 @@ dir_split_resource_into_fingerprints(const char *resource,
|
|||||||
smartlist_t *fp_out, int *compressed_out,
|
smartlist_t *fp_out, int *compressed_out,
|
||||||
int decode_hex)
|
int decode_hex)
|
||||||
{
|
{
|
||||||
|
int old_len;
|
||||||
|
tor_assert(fp_out);
|
||||||
|
old_len = smartlist_len(fp_out);
|
||||||
smartlist_split_string(fp_out, resource, "+", 0, 0);
|
smartlist_split_string(fp_out, resource, "+", 0, 0);
|
||||||
if (compressed_out)
|
if (compressed_out)
|
||||||
*compressed_out = 0;
|
*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);
|
char *last = smartlist_get(fp_out,smartlist_len(fp_out)-1);
|
||||||
size_t last_len = strlen(last);
|
size_t last_len = strlen(last);
|
||||||
if (last_len > 2 && !strcmp(last+last_len-2, ".z")) {
|
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) {
|
if (decode_hex) {
|
||||||
int i;
|
int i;
|
||||||
char *cp, *d = NULL;
|
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);
|
cp = smartlist_get(fp_out, i);
|
||||||
if (strlen(cp) != HEX_DIGEST_LEN) {
|
if (strlen(cp) != HEX_DIGEST_LEN) {
|
||||||
|
info(LD_DIR, "Skipping digest \"%s\" with non-standard length.", cp);
|
||||||
smartlist_del(fp_out, i--);
|
smartlist_del(fp_out, i--);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
d = tor_malloc_zero(DIGEST_LEN);
|
d = tor_malloc_zero(DIGEST_LEN);
|
||||||
if (base16_decode(d, DIGEST_LEN, cp, HEX_DIGEST_LEN)<0) {
|
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--);
|
smartlist_del(fp_out, i--);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user