Ensure HMAC_size() handles errors correctly
authorMatt Caswell <matt@openssl.org>
Wed, 19 Oct 2016 15:29:01 +0000 (16:29 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 4 Nov 2016 12:09:46 +0000 (12:09 +0000)
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/hmac/hmac.c

index 3374105cbb941209f89e01cc5ef028e57ab7526d..a2c9dd9845c1e8900caff5d69740a3cd60514ffd 100644 (file)
@@ -118,7 +118,10 @@ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len)
 
 size_t HMAC_size(const HMAC_CTX *ctx)
 {
-    return EVP_MD_size((ctx)->md);
+    int size = EVP_MD_size((ctx)->md);
+    if (size < 0)
+        return 0;
+    return size;
 }
 
 HMAC_CTX *HMAC_CTX_new(void)