diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-01-17 13:32:19 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-01-17 13:32:19 -0500 |
commit | f632335feb27b45a3ee5eb64690826bda52467bd (patch) | |
tree | a60fca8562c6beafcaae1de678fcefaecbeeb26d /src/feature/rend/rendparse.c | |
parent | 22c5ad682cdd2e6a9a2124585302b2335361ab80 (diff) | |
download | tor-f632335feb27b45a3ee5eb64690826bda52467bd.tar.gz tor-f632335feb27b45a3ee5eb64690826bda52467bd.zip |
Fix users of base32_decode to check for expected length in return.
Also, when we log about a failure from base32_decode(), we now
say that the length is wrong or that the characters were invalid:
previously we would just say that there were invalid characters.
Follow-up on 28913 work.
Diffstat (limited to 'src/feature/rend/rendparse.c')
-rw-r--r-- | src/feature/rend/rendparse.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/feature/rend/rendparse.c b/src/feature/rend/rendparse.c index e2378e340f..c79f861b51 100644 --- a/src/feature/rend/rendparse.c +++ b/src/feature/rend/rendparse.c @@ -143,8 +143,9 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, goto err; } if (base32_decode(desc_id_out, DIGEST_LEN, - tok->args[0], REND_DESC_ID_V2_LEN_BASE32) < 0) { - log_warn(LD_REND, "Descriptor ID contains illegal characters: %s", + tok->args[0], REND_DESC_ID_V2_LEN_BASE32) != DIGEST_LEN) { + log_warn(LD_REND, + "Descriptor ID has wrong length or illegal characters: %s", tok->args[0]); goto err; } @@ -174,8 +175,10 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, log_warn(LD_REND, "Invalid secret ID part: '%s'", tok->args[0]); goto err; } - if (base32_decode(secret_id_part, DIGEST_LEN, tok->args[0], 32) < 0) { - log_warn(LD_REND, "Secret ID part contains illegal characters: %s", + if (base32_decode(secret_id_part, DIGEST_LEN, tok->args[0], 32) != + DIGEST_LEN) { + log_warn(LD_REND, + "Secret ID part has wrong length or illegal characters: %s", tok->args[0]); goto err; } @@ -429,8 +432,10 @@ rend_parse_introduction_points(rend_service_descriptor_t *parsed, /* Parse identifier. */ tok = find_by_keyword(tokens, R_IPO_IDENTIFIER); if (base32_decode(info->identity_digest, DIGEST_LEN, - tok->args[0], REND_INTRO_POINT_ID_LEN_BASE32) < 0) { - log_warn(LD_REND, "Identity digest contains illegal characters: %s", + tok->args[0], REND_INTRO_POINT_ID_LEN_BASE32) != + DIGEST_LEN) { + log_warn(LD_REND, + "Identity digest has wrong length or illegal characters: %s", tok->args[0]); rend_intro_point_free(intro); goto err; |