]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Avoid freeing context on error
authorPauli <pauli@openssl.org>
Sun, 19 Mar 2023 22:02:34 +0000 (09:02 +1100)
committerPauli <pauli@openssl.org>
Mon, 20 Mar 2023 22:00:43 +0000 (09:00 +1100)
Freeing the allocated KDF context seems wrong when derive errors.

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 cb9e69a7a35554f83fe7592799cd133109a9d19c..768dcfe1bff66cb1d7e02435359adbb8f6f1967f 100644 (file)
@@ -1025,7 +1025,6 @@ static int kdf_argon2_derive(void *vctx, unsigned char *out, size_t outlen,
 
     ctx->mac = EVP_MAC_fetch(ctx->libctx, "blake2bmac", ctx->propq);
     if (ctx->mac == NULL) {
-        OPENSSL_free(ctx);
         ERR_raise_data(ERR_LIB_PROV, PROV_R_MISSING_MAC,
                        "cannot fetch blake2bmac");
         return 0;
@@ -1034,7 +1033,6 @@ 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");
         return 0;