]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
[apps/genpkey] exit status should not be 0 on output errors
authorNicola Tuveri <nic.tuv@gmail.com>
Fri, 26 Jun 2020 22:42:49 +0000 (01:42 +0300)
committerNicola Tuveri <nic.tuv@gmail.com>
Tue, 7 Jul 2020 08:57:57 +0000 (11:57 +0300)
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)

apps/genpkey.c

index 39fa73c91cf4ddc418260b7dd3b0392365666d24..e74c74a7a82c1a1f6fba3a581e11d2897ca4a6e0 100644 (file)
@@ -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);