From: Pauli Date: Tue, 7 May 2019 00:26:32 +0000 (+1000) Subject: Coverity CID 1444961: Integer handling issues X-Git-Tag: openssl-3.0.0-alpha1~2093 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea053ec99e985a3d76762bc54ccce23e12d08999;p=thirdparty%2Fopenssl.git Coverity CID 1444961: Integer handling issues Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/8888) --- diff --git a/crypto/evp/p5_crpt2.c b/crypto/evp/p5_crpt2.c index ac5b974e545..c231a32c050 100644 --- a/crypto/evp/p5_crpt2.c +++ b/crypto/evp/p5_crpt2.c @@ -134,7 +134,7 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, const EVP_CIPHER *c, const EVP_MD *md, int en_de) { unsigned char *salt, key[EVP_MAX_KEY_LENGTH]; - int saltlen, iter; + int saltlen, iter, t; int rv = 0; unsigned int keylen = 0; int prf_nid, hmac_md_nid; @@ -157,7 +157,12 @@ int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, goto err; } - keylen = EVP_CIPHER_CTX_key_length(ctx); + t = EVP_CIPHER_CTX_key_length(ctx); + if (t < 0) { + EVPerr(EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN, EVP_R_INVALID_KEY_LENGTH); + goto err; + } + keylen = t; /* Now check the parameters of the kdf */