]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
evp: fix return code check.
authorPauli <pauli@openssl.org>
Mon, 10 May 2021 04:13:30 +0000 (14:13 +1000)
committerPauli <pauli@openssl.org>
Wed, 12 May 2021 01:11:53 +0000 (11:11 +1000)
The return from evp_do_md_getparams() is 0 for failure and -1 for not being
a provided algorithm.  The code in evp_md_cache_constants() failed to check
the return code properly.  In this case it was harmless but better to fix it.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/15208)

crypto/evp/digest.c

index e584bd8b2bf1a2c4e09774f19805d005ec71ddd1..25ce60985456ba3fc949fa43e1e65f040cfa1f0f 100644 (file)
@@ -882,7 +882,7 @@ static int evp_md_cache_constants(EVP_MD *md)
     params[3] = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_ALGID_ABSENT,
                                          &algid_absent);
     params[4] = OSSL_PARAM_construct_end();
-    ok = evp_do_md_getparams(md, params);
+    ok = evp_do_md_getparams(md, params) > 0;
     if (mdsize > INT_MAX || blksz > INT_MAX)
         ok = 0;
     if (ok) {