]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Coverity 1522032: use after free
authorPauli <pauli@openssl.org>
Fri, 17 Mar 2023 01:11:16 +0000 (12:11 +1100)
committerPauli <pauli@openssl.org>
Mon, 20 Mar 2023 22:00:36 +0000 (09:00 +1100)
Fix use after free error.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/20528)

providers/implementations/kdfs/argon2.c

index 89947472c05a91c3c543b72d870a39b58065128a..cb9e69a7a35554f83fe7592799cd133109a9d19c 100644 (file)
@@ -1033,10 +1033,11 @@ static int kdf_argon2_derive(void *vctx, unsigned char *out, size_t outlen,
 
     ctx->md = EVP_MD_fetch(ctx->libctx, "blake2b512", ctx->propq);
     if (ctx->md == NULL) {
+        EVP_MAC_free(ctx->mac);
         OPENSSL_free(ctx);
         ERR_raise_data(ERR_LIB_PROV, PROV_R_MISSING_MESSAGE_DIGEST,
                        "canot fetch blake2b512");
-        goto fail1;
+        return 0;
     }
 
     if (ctx->salt == NULL || ctx->saltlen == 0) {
@@ -1135,7 +1136,6 @@ fail3:
 
 fail2:
     EVP_MD_free(ctx->md);
-fail1:
     EVP_MAC_free(ctx->mac);
 
     return 0;