diff options
author | Dr. David von Oheimb <dev@ddvo.net> | 2024-09-27 07:58:20 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-10-04 12:09:33 +0200 |
commit | 1dbb67c4f1a3aec7f4026e43257b33ffad665ba5 (patch) | |
tree | 07426178cfc48f5f2481a23cd51863c1bccabb01 /apps | |
parent | APPS/dsaparam: fix case where infile and outfile are the same (diff) | |
download | openssl-1dbb67c4f1a3aec7f4026e43257b33ffad665ba5.tar.xz openssl-1dbb67c4f1a3aec7f4026e43257b33ffad665ba5.zip |
APPS/{ecparam,pkeyparam}: fix case where infile and outfile are the same
Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25552)
Diffstat (limited to 'apps')
-rw-r--r-- | apps/ecparam.c | 20 | ||||
-rw-r--r-- | apps/pkeyparam.c | 6 |
2 files changed, 13 insertions, 13 deletions
diff --git a/apps/ecparam.c b/apps/ecparam.c index 71f93c4ca5..35899522d2 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -194,16 +194,6 @@ int ecparam_main(int argc, char **argv) private = genkey ? 1 : 0; - out = bio_open_owner(outfile, outformat, private); - if (out == NULL) - goto end; - - if (list_curves) { - if (list_builtin_curves(out)) - ret = 0; - goto end; - } - if (curve_name != NULL) { OSSL_PARAM params[4]; OSSL_PARAM *p = params; @@ -276,6 +266,16 @@ int ecparam_main(int argc, char **argv) goto end; } + out = bio_open_owner(outfile, outformat, private); + 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)) { BIO_printf(bio_err, "unable to print params\n"); diff --git a/apps/pkeyparam.c b/apps/pkeyparam.c index 4fefe69e6b..fd8de0e02f 100644 --- a/apps/pkeyparam.c +++ b/apps/pkeyparam.c @@ -97,9 +97,6 @@ int pkeyparam_main(int argc, char **argv) in = bio_open_default(infile, 'r', FORMAT_PEM); if (in == NULL) goto end; - out = bio_open_default(outfile, 'w', FORMAT_PEM); - if (out == NULL) - goto end; pkey = PEM_read_bio_Parameters_ex(in, NULL, app_get0_libctx(), app_get0_propq()); if (pkey == NULL) { @@ -107,6 +104,9 @@ int pkeyparam_main(int argc, char **argv) ERR_print_errors(bio_err); goto end; } + out = bio_open_default(outfile, 'w', FORMAT_PEM); + if (out == NULL) + goto end; if (check) { if (e == NULL) |