diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-05-16 22:15:48 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-05-16 22:15:48 +0000 |
commit | 807adfc879ca29d068ca1161587bf4ad050e8f82 (patch) | |
tree | 34f9f9a5aba235c4d924495d9cc8f03fc5af0e5f /src/common/crypto.c | |
parent | b837191fd0e897cbc5fc33874190bab8bbb83268 (diff) | |
download | tor-807adfc879ca29d068ca1161587bf4ad050e8f82.tar.gz tor-807adfc879ca29d068ca1161587bf4ad050e8f82.zip |
r12769@catbus: nickm | 2007-05-16 17:32:01 -0400
Fix warnings from -Wunsafe-loop-optimizations, which incidentally turned up a logic bug in connection_or_flush_from_first_active_circuit that would overcount the number of cells flushed.
svn:r10199
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index adace97995..4bb58f2d76 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1494,14 +1494,12 @@ 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; ++i, cp += DIGEST_LEN) { + for (cp = key_out, i=0; key_out_len >= DIGEST_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; - key_out_len -= DIGEST_LEN; } memset(tmp, 0, key_in_len+1); tor_free(tmp); |