From 246afc1b1ba8c81557307bfffa5291c91cc2c782 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 6 Oct 2011 13:02:50 -0400 Subject: Make internal error check for unrecognized digest algorithm more robust Fixes Coverity CID 479. --- src/common/crypto.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/common/crypto.c b/src/common/crypto.c index 851f11bf3b..235bd88ffa 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1663,6 +1663,10 @@ crypto_digest_get_digest(crypto_digest_env_t *digest, SHA256_Final(r, &tmpenv.d.sha2); break; default: + log_warn(LD_BUG, "Called with unknown algorithm %d", digest->algorithm); + /* If fragile_assert is not enabled, then we should at least not + * leak anything. */ + memset(r, 0xff, sizeof(r)); tor_fragile_assert(); break; } -- cgit v1.2.3-54-g00ecf