diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-05-17 01:52:26 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-05-17 01:52:26 +0000 |
commit | 836328be2e9a8ede43b075bae73426ce4ffcb60c (patch) | |
tree | 8108a2ae756036291aea791e9397577c34689bd0 | |
parent | b4bd9f772ccc9e1570116a690c8bb99242b7a14a (diff) | |
download | tor-836328be2e9a8ede43b075bae73426ce4ffcb60c.tar.gz tor-836328be2e9a8ede43b075bae73426ce4ffcb60c.zip |
r12777@catbus: nickm | 2007-05-16 21:52:23 -0400
Fix dumb bug introduced in r10199
svn:r10202
-rw-r--r-- | src/common/crypto.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 4bb58f2d76..40cb5fafae 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1494,12 +1494,14 @@ crypto_expand_key_material(const char *key_in, size_t key_in_len, tor_assert(key_out_len <= DIGEST_LEN*256); memcpy(tmp, key_in, key_in_len); - for (cp = key_out, i=0; key_out_len >= DIGEST_LEN; + for (cp = key_out, i=0; key_out_len; ++i, cp += DIGEST_LEN, key_out_len -= DIGEST_LEN) { tmp[key_in_len] = i; if (crypto_digest(digest, tmp, key_in_len+1)) goto err; memcpy(cp, digest, MIN(DIGEST_LEN, key_out_len)); + if (key_out_len < DIGEST_LEN) + break; } memset(tmp, 0, key_in_len+1); tor_free(tmp); |