From: Nick Mathewson Date: Thu, 19 Apr 2012 21:13:47 +0000 (-0400) Subject: Make base64_decode in rend_parse_client_keys more foolproof X-Git-Tag: tor-0.2.3.14-alpha~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2384d5e2c25469038caa84e0dedaa5e2efca29c;p=thirdparty%2Ftor.git Make base64_decode in rend_parse_client_keys more foolproof In general, whenever we can, we should be doing base64_decode(buf, sizeof(buf), s, strlen(s)), and not base_64_decode(buf, expr1, s, expr2) where we hope that expr1 is a good name for the size of buf and expr2 is a good formula for the length of the base64 expression in s. --- diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 99b4eb0732..7cc8b965e6 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -5171,9 +5171,9 @@ rend_parse_client_keys(strmap_t *parsed_clients, const char *ckstr) /* The size of descriptor_cookie_tmp needs to be REND_DESC_COOKIE_LEN+2, * because a base64 encoding of length 24 does not fit into 16 bytes in all * cases. */ - if ((base64_decode(descriptor_cookie_tmp, REND_DESC_COOKIE_LEN+2, - tok->args[0], REND_DESC_COOKIE_LEN_BASE64+2+1) - != REND_DESC_COOKIE_LEN)) { + if (base64_decode(descriptor_cookie_tmp, sizeof(descriptor_cookie_tmp), + tok->args[0], strlen(tok->args[0])) + != REND_DESC_COOKIE_LEN) { log_warn(LD_REND, "Descriptor cookie contains illegal characters: " "%s", escaped(tok->args[0])); goto err;