]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ecparam: process -list_curves before reading input
authorTomas Mraz <tomas@openssl.org>
Wed, 22 Jan 2025 18:48:05 +0000 (19:48 +0100)
committerTomas Mraz <tomas@openssl.org>
Thu, 13 Feb 2025 10:19:02 +0000 (11:19 +0100)
Fixes #26519

This is a regression from commit 1dbb67c4

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26525)

apps/ecparam.c

index bbd3c9e633ccd21323a7e7969c1fe8dbe5be941c..9c9b3e050636a26d1043fee7bca7f55b833dad4e 100644 (file)
@@ -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");