]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check the return value of HMAC in crypto.c and assert on error
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>
Mon, 23 Nov 2015 09:53:59 +0000 (20:53 +1100)
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>
Wed, 25 Nov 2015 23:46:36 +0000 (10:46 +1100)
Fixes bug #17658; bugfix on commit in fdbb9cdf746b (11 Oct 2011)
in tor version 0.2.3.5-alpha-dev.

changes/check-crypto-errors [new file with mode: 0644]
src/common/crypto.c

diff --git a/changes/check-crypto-errors b/changes/check-crypto-errors
new file mode 100644 (file)
index 0000000..e41862c
--- /dev/null
@@ -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".
index 913d1c26c9076e8dabc10ba6fa9d2cc578ccfe73..86357b0a439753b5357acd166e7b821db903a82e 100644 (file)
@@ -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 */