aboutsummaryrefslogtreecommitdiff
path: root/src/common/util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-12-22 12:56:35 -0500
committerNick Mathewson <nickm@torproject.org>2014-12-22 12:56:35 -0500
commit47760c7ba5f1c87c945f4a018e3b3da6d127a8b9 (patch)
treefce7d4a6cd8b7865786574b34065fd8158ecb103 /src/common/util.c
parent137982f955b297b41a89086d672baf761825c152 (diff)
downloadtor-47760c7ba5f1c87c945f4a018e3b3da6d127a8b9.tar.gz
tor-47760c7ba5f1c87c945f4a018e3b3da6d127a8b9.zip
When decoding a base-{16,32,64} value, clear the target buffer first
This is a good idea in case the caller stupidly doesn't check the return value from baseX_decode(), and as a workaround for the current inconsistent API of base16_decode. Prevents any fallout from bug 14013.
Diffstat (limited to 'src/common/util.c')
-rw-r--r--src/common/util.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 5eb0f9a69b..036fd2542c 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1076,6 +1076,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);