]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix unsafe BIO_get_md_ctx check
authorPW Hu <jlu.hpw@foxmail.com>
Thu, 7 Oct 2021 03:50:59 +0000 (11:50 +0800)
committerTomas Mraz <tomas@openssl.org>
Fri, 8 Oct 2021 09:46:50 +0000 (11:46 +0200)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16768)

apps/dgst.c

index 36a8c6fb084b8d629fc290996d33930e053dd133..bd23b76996e7d78a977901a3c840bc08c2a6d899 100644 (file)
@@ -335,7 +335,7 @@ int dgst_main(int argc, char **argv)
         EVP_PKEY_CTX *pctx = NULL;
         int res;
 
-        if (!BIO_get_md_ctx(bmd, &mctx)) {
+        if (BIO_get_md_ctx(bmd, &mctx) <= 0) {
             BIO_printf(bio_err, "Error getting context\n");
             goto end;
         }
@@ -362,7 +362,7 @@ int dgst_main(int argc, char **argv)
     /* we use md as a filter, reading from 'in' */
     else {
         EVP_MD_CTX *mctx = NULL;
-        if (!BIO_get_md_ctx(bmd, &mctx)) {
+        if (BIO_get_md_ctx(bmd, &mctx) <= 0) {
             BIO_printf(bio_err, "Error getting context\n");
             goto end;
         }