From: Nicola Tuveri Date: Fri, 26 Jun 2020 22:42:49 +0000 (+0300) Subject: [apps/genpkey] exit status should not be 0 on output errors X-Git-Tag: openssl-3.0.0-alpha5~64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=466d30c0d7fa861a5fcbaebd2e2010a8c2aea322;p=thirdparty%2Fopenssl.git [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 (Merged from https://github.com/openssl/openssl/pull/12305) --- diff --git a/apps/genpkey.c b/apps/genpkey.c index 8954ef19c75..4a4a83fd40a 100644 --- a/apps/genpkey.c +++ b/apps/genpkey.c @@ -189,9 +189,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) { @@ -203,11 +206,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);