]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Free fetched digest in show_digests
authorMarc Brooks <IDisposable@gmail.com>
Tue, 30 Jul 2024 20:29:34 +0000 (15:29 -0500)
committerTomas Mraz <tomas@openssl.org>
Thu, 1 Aug 2024 09:38:17 +0000 (11:38 +0200)
Fixes #24892

Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25046)

(cherry picked from commit 871c534d39efecc2087da0fd24ff72e2712031a4)

apps/dgst.c

index 3f02af0d5738ab72dfc23bdef59cd01a626b3ed2..d15ad65ef82fa8bc772ed390558d3e93077ccb5c 100644 (file)
@@ -478,7 +478,7 @@ int dgst_main(int argc, char **argv)
 static void show_digests(const OBJ_NAME *name, void *arg)
 {
     struct doall_dgst_digests *dec = (struct doall_dgst_digests *)arg;
-    const EVP_MD *md = NULL;
+    EVP_MD *md = NULL;
 
     /* Filter out signed digests (a.k.a signature algorithms) */
     if (strstr(name->name, "rsa") != NULL || strstr(name->name, "RSA") != NULL)
@@ -490,8 +490,7 @@ static void show_digests(const OBJ_NAME *name, void *arg)
     /* Filter out message digests that we cannot use */
     md = EVP_MD_fetch(app_get0_libctx(), name->name, app_get0_propq());
     if (md == NULL) {
-        md = EVP_get_digestbyname(name->name);
-        if (md == NULL)
+        if (EVP_get_digestbyname(name->name) == NULL)
             return;
     }
 
@@ -502,6 +501,8 @@ static void show_digests(const OBJ_NAME *name, void *arg)
     } else {
         BIO_printf(dec->bio, " ");
     }
+
+    EVP_MD_free(md);
 }
 
 /*