aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2015-11-23 20:53:59 +1100
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>2015-11-26 10:46:36 +1100
commitb1b8f7982ebac1347a86d5eb9eee8e5f3bd3d39c (patch)
tree8ebede7292788ad83e3a7cbedc595aae0059ae30
parent289b184e112885d4feb9569c77d322995b9417c7 (diff)
downloadtor-b1b8f7982ebac1347a86d5eb9eee8e5f3bd3d39c.tar.gz
tor-b1b8f7982ebac1347a86d5eb9eee8e5f3bd3d39c.zip
Check the return value of HMAC in crypto.c and assert on error
Fixes bug #17658; bugfix on commit in fdbb9cdf746b (11 Oct 2011) in tor version 0.2.3.5-alpha-dev.
-rw-r--r--changes/check-crypto-errors5
-rw-r--r--src/common/crypto.c7
2 files changed, 10 insertions, 2 deletions
diff --git a/changes/check-crypto-errors b/changes/check-crypto-errors
new file mode 100644
index 0000000000..e41862ca13
--- /dev/null
+++ b/changes/check-crypto-errors
@@ -0,0 +1,5 @@
+ o Minor bugfix (crypto):
+ - Check the return value of HMAC and assert on failure.
+ Fixes bug #17658; bugfix on commit in fdbb9cdf746b (11 Oct 2011)
+ in tor version 0.2.3.5-alpha-dev.
+ Patch by "teor".
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 913d1c26c9..86357b0a43 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1906,11 +1906,14 @@ crypto_hmac_sha256(char *hmac_out,
const char *key, size_t key_len,
const char *msg, size_t msg_len)
{
+ unsigned char *rv = NULL;
/* If we've got OpenSSL >=0.9.8 we can use its hmac implementation. */
tor_assert(key_len < INT_MAX);
tor_assert(msg_len < INT_MAX);
- HMAC(EVP_sha256(), key, (int)key_len, (unsigned char*)msg, (int)msg_len,
- (unsigned char*)hmac_out, NULL);
+ tor_assert(hmac_out);
+ rv = HMAC(EVP_sha256(), key, (int)key_len, (unsigned char*)msg, (int)msg_len,
+ (unsigned char*)hmac_out, NULL);
+ tor_assert(rv);
}
/* DH */