Skip to content

Commit

Permalink
Fix incomplete error check on BIO_set_md()
Browse files Browse the repository at this point in the history
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 #20195)

(cherry picked from commit abf6546)
  • Loading branch information
nielsdos authored and tmshort committed Feb 8, 2023
1 parent e80518d commit 9b77bd9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/cms/cms_lib.c
Expand Up @@ -431,7 +431,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;
}
Expand Down

0 comments on commit 9b77bd9

Please sign in to comment.