From 708e06c55d9fee5d59e4a4f409d115423ea1fa56 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Wed, 19 Oct 2016 16:29:01 +0100 Subject: [PATCH] Ensure HMAC_size() handles errors correctly Reviewed-by: Rich Salz --- crypto/hmac/hmac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crypto/hmac/hmac.c b/crypto/hmac/hmac.c index 3374105cbb..a2c9dd9845 100644 --- a/crypto/hmac/hmac.c +++ b/crypto/hmac/hmac.c @@ -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) -- GitLab