From 8f416ba9b0c21cac62ce55ee2797b7b75c000575 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Wed, 22 Jan 2025 19:48:05 +0100 Subject: [PATCH] ecparam: process -list_curves before reading input Fixes #26519 This is a regression from commit 1dbb67c4 Reviewed-by: Dmitry Belyavskiy Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/26525) --- apps/ecparam.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/ecparam.c b/apps/ecparam.c index bbd3c9e633c..9c9b3e05063 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -192,6 +192,16 @@ int ecparam_main(int argc, char **argv) if (!app_RAND_load()) goto end; + if (list_curves) { + out = bio_open_owner(outfile, outformat, private); + if (out == NULL) + goto end; + + if (list_builtin_curves(out)) + ret = 0; + goto end; + } + private = genkey ? 1 : 0; if (curve_name != NULL) { @@ -270,12 +280,6 @@ int ecparam_main(int argc, char **argv) if (out == NULL) goto end; - if (list_curves) { - if (list_builtin_curves(out)) - ret = 0; - goto end; - } - if (text && EVP_PKEY_print_params(out, params_key, 0, NULL) <= 0) { BIO_printf(bio_err, "unable to print params\n"); -- 2.47.2