]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix incomplete error check on BIO_set_md()
authorndossche <niels.dossche@ugent.be>
Thu, 2 Feb 2023 15:11:16 +0000 (16:11 +0100)
committerTodd Short <todd.short@me.com>
Wed, 8 Feb 2023 15:34:49 +0000 (10:34 -0500)
BIO_set_md() can return an error value <= 0 according to my analysis
tool and the documentation. But only an error value == 0 is currently
checked. Fix it by changing the check condition.

CLA: trivial

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/20195)

crypto/cms/cms_lib.c

index a9e659b23dd2d99d70d82cb0ff90d8571ef47ce9..b5a4b315a3a18464a71048c3f1ca3123fd716eeb 100644 (file)
@@ -437,7 +437,7 @@ BIO *ossl_cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm,
     (void)ERR_pop_to_mark();
 
     mdbio = BIO_new(BIO_f_md());
-    if (mdbio == NULL || !BIO_set_md(mdbio, digest)) {
+    if (mdbio == NULL || BIO_set_md(mdbio, digest) <= 0) {
         ERR_raise(ERR_LIB_CMS, CMS_R_MD_BIO_INIT_ERROR);
         goto err;
     }