summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicola Tuveri <nic.tuv@gmail.com>2020-06-27 01:42:49 +0300
committerNicola Tuveri <nic.tuv@gmail.com>2020-07-07 11:57:57 +0300
commit1940c092a52afd8bc919b8faa5f3d51004503f3a (patch)
treedb74d76257ee0bd45a076ee99a04e2dc17b93f2a
parent2797fea7608063f54cf45763d1a7ae60a67dae65 (diff)
[apps/genpkey] exit status should not be 0 on output errors
If the key is to be serialized or printed as text and the framework returns an error, the app should signal the failure to the user using a non-zero exit status. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12305) (cherry picked from commit 466d30c0d7fa861a5fcbaebd2e2010a8c2aea322)
-rw-r--r--apps/genpkey.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/apps/genpkey.c b/apps/genpkey.c
index 39fa73c91c..e74c74a7a8 100644
--- a/apps/genpkey.c
+++ b/apps/genpkey.c
@@ -177,9 +177,12 @@ int genpkey_main(int argc, char **argv)
goto end;
}
+ ret = 0;
+
if (rv <= 0) {
BIO_puts(bio_err, "Error writing key\n");
ERR_print_errors(bio_err);
+ ret = 1;
}
if (text) {
@@ -191,11 +194,10 @@ int genpkey_main(int argc, char **argv)
if (rv <= 0) {
BIO_puts(bio_err, "Error printing key\n");
ERR_print_errors(bio_err);
+ ret = 1;
}
}
- ret = 0;
-
end:
EVP_PKEY_free(pkey);
EVP_PKEY_CTX_free(ctx);