aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-02-07 16:10:36 +0000
committerNick Mathewson <nickm@torproject.org>2008-02-07 16:10:36 +0000
commitb8179871a6dd5e225f0fef26d12b1eb38e8a6da7 (patch)
treed6bbd87f19a90331998059ff7bb82d869bdcb905
parenteecc44dab8ad98246b2c4dbedf977113f1874f77 (diff)
downloadtor-b8179871a6dd5e225f0fef26d12b1eb38e8a6da7.tar
tor-b8179871a6dd5e225f0fef26d12b1eb38e8a6da7.tar.gz
r17964@catbus: nickm | 2008-02-07 10:45:02 -0500
Fix bug in last patch that made secret_to_key crash. svn:r13415
-rw-r--r--src/common/crypto.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index ea68e3cfd..6f640b284 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);
}