From 0dc6ea55a13dbe27af234b5328527d0a31ae68eb Mon Sep 17 00:00:00 2001 From: JiashengJiang Date: Tue, 22 Apr 2025 09:03:44 -0400 Subject: [PATCH] apps/pkeyutl.c: Add OPENSSL_free() to avoid a memory leak If EVP_PKEY_CTX_ctrl_str() fails, the code jumps to 'end' label without freeing passwd, causing a memory leak. Fixes: 9d1bf5f7de ("Add option to read pkeyopts interactively") Signed-off-by: JiashengJiang Reviewed-by: Shane Lontis Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27470) --- apps/pkeyutl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index 2d3fd631447..79ad4c6f29f 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -426,6 +426,7 @@ int pkeyutl_main(int argc, char **argv) if (EVP_PKEY_CTX_ctrl_str(ctx, opt, passwd) <= 0) { BIO_printf(bio_err, "%s: Can't set parameter \"%s\":\n", prog, opt); + OPENSSL_free(passwd); goto end; } OPENSSL_free(passwd); -- 2.47.2