From b8179871a6dd5e225f0fef26d12b1eb38e8a6da7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 7 Feb 2008 16:10:36 +0000 Subject: [PATCH] r17964@catbus: nickm | 2008-02-07 10:45:02 -0500 Fix bug in last patch that made secret_to_key crash. svn:r13415 --- src/common/crypto.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/common/crypto.c b/src/common/crypto.c index ea68e3cfdf..6f640b2843 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -2093,7 +2093,7 @@ secret_to_key(char *key_out, size_t key_out_len, const char *secret, { crypto_digest_env_t *d; uint8_t c; - size_t count; + size_t count, tmplen; char *tmp; tor_assert(key_out_len < SIZE_T_CEILING); @@ -2105,7 +2105,8 @@ secret_to_key(char *key_out, size_t key_out_len, const char *secret, tor_assert(key_out_len <= DIGEST_LEN); d = crypto_new_digest_env(); - tmp = tor_malloc(8+secret_len); + tmplen = 8+secret_len; + tmp = tor_malloc(tmplen); memcpy(tmp,s2k_specifier,8); memcpy(tmp+8,secret,secret_len); secret_len += 8; @@ -2119,7 +2120,7 @@ secret_to_key(char *key_out, size_t key_out_len, const char *secret, } } crypto_digest_get_digest(d, key_out, key_out_len); - memset(tmp, 0, 8+secret_len); + memset(tmp, 0, tmplen); tor_free(tmp); crypto_free_digest_env(d); }