summaryrefslogtreecommitdiff
path: root/src/feature/rend/rendcache.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-01-17 13:32:19 -0500
committerNick Mathewson <nickm@torproject.org>2019-01-17 13:32:19 -0500
commitf632335feb27b45a3ee5eb64690826bda52467bd (patch)
treea60fca8562c6beafcaae1de678fcefaecbeeb26d /src/feature/rend/rendcache.c
parent22c5ad682cdd2e6a9a2124585302b2335361ab80 (diff)
downloadtor-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/rendcache.c')
-rw-r--r--src/feature/rend/rendcache.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/feature/rend/rendcache.c b/src/feature/rend/rendcache.c
index ecd85e4a5a..699b5a4a48 100644
--- a/src/feature/rend/rendcache.c
+++ b/src/feature/rend/rendcache.c
@@ -593,10 +593,10 @@ rend_cache_lookup_v2_desc_as_dir(const char *desc_id, const char **desc)
char desc_id_digest[DIGEST_LEN];
tor_assert(rend_cache_v2_dir);
if (base32_decode(desc_id_digest, DIGEST_LEN,
- desc_id, REND_DESC_ID_V2_LEN_BASE32) < 0) {
+ desc_id, REND_DESC_ID_V2_LEN_BASE32) != DIGEST_LEN) {
log_fn(LOG_PROTOCOL_WARN, LD_REND,
"Rejecting v2 rendezvous descriptor request -- descriptor ID "
- "contains illegal characters: %s",
+ "has wrong length or illegal characters: %s",
safe_str(desc_id));
return -1;
}
@@ -854,7 +854,8 @@ rend_cache_store_v2_desc_as_client(const char *desc,
*entry = NULL;
}
if (base32_decode(want_desc_id, sizeof(want_desc_id),
- desc_id_base32, strlen(desc_id_base32)) < 0) {
+ desc_id_base32, strlen(desc_id_base32)) !=
+ sizeof(want_desc_id)) {
log_warn(LD_BUG, "Couldn't decode base32 %s for descriptor id.",
escaped_safe_str_client(desc_id_base32));
goto err;