Skip to content

Commit

Permalink
Fix coverity-1604666
Browse files Browse the repository at this point in the history
Coverity recently flaged an error in which the return value for
EVP_MD_get_size wasn't checked for negative values prior to use, which
can cause underflow later in the function.

Just add the check and error out if get_size returns an error.

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Tomas Mraz <[email protected]>
(Merged from openssl#24896)

(cherry picked from commit 22e08c7)
  • Loading branch information
nhorman authored and t8m committed Jul 17, 2024
1 parent 05590a9 commit 79ab705
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/rsa/rsa_oaep.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen,

mdlen = EVP_MD_get_size(md);

if (tlen <= 0 || flen <= 0)
if (tlen <= 0 || flen <= 0 || mdlen <= 0)
return -1;
/*
* |num| is the length of the modulus; |flen| is the length of the
Expand Down

0 comments on commit 79ab705

Please sign in to comment.