summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-12-22 15:58:49 -0500
committerNick Mathewson <nickm@torproject.org>2014-12-22 15:58:49 -0500
commit6d728ba8801031b27937436cbcad033f4406a8b5 (patch)
tree46d2743671c256069ce9587164acf42659083c70 /src
parent5b55778c86b88329725521d2c93829a9c9ad3501 (diff)
parent47760c7ba5f1c87c945f4a018e3b3da6d127a8b9 (diff)
downloadtor-6d728ba8801031b27937436cbcad033f4406a8b5.tar.gz
tor-6d728ba8801031b27937436cbcad033f4406a8b5.zip
Merge remote-tracking branch 'public/bug14013_024' into maint-0.2.5
Diffstat (limited to 'src')
-rw-r--r--src/common/crypto.c6
-rw-r--r--src/common/util.c3
2 files changed, 9 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index a247a87d48..f4e86683d9 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -2756,6 +2756,8 @@ base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
if (destlen > SIZE_T_CEILING)
return -1;
+ memset(dest, 0, destlen);
+
EVP_DecodeInit(&ctx);
EVP_DecodeUpdate(&ctx, (unsigned char*)dest, &len,
(unsigned char*)src, srclen);
@@ -2777,6 +2779,8 @@ base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
if (destlen > SIZE_T_CEILING)
return -1;
+ memset(dest, 0, destlen);
+
/* Iterate over all the bytes in src. Each one will add 0 or 6 bits to the
* value we're decoding. Accumulate bits in <b>n</b>, and whenever we have
* 24 bits, batch them into 3 bytes and flush those bytes to dest.
@@ -2956,6 +2960,8 @@ base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
tor_assert((nbits/8) <= destlen); /* We need enough space. */
tor_assert(destlen < SIZE_T_CEILING);
+ memset(dest, 0, destlen);
+
/* Convert base32 encoded chars to the 5-bit values that they represent. */
tmp = tor_malloc_zero(srclen);
for (j = 0; j < srclen; ++j) {
diff --git a/src/common/util.c b/src/common/util.c
index 2d7893b38a..04cc6b12c6 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1129,6 +1129,9 @@ base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
return -1;
if (destlen < srclen/2 || destlen > SIZE_T_CEILING)
return -1;
+
+ memset(dest, 0, destlen);
+
end = src+srclen;
while (src<end) {
v1 = hex_decode_digit_(*src);