Corrected 'cms' exit status when key or certificate cannot be opened
authorKonstantin Shemyak <konstantin@shemyak.com>
Thu, 28 Dec 2017 21:12:59 +0000 (23:12 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Sat, 6 Jan 2018 14:37:05 +0000 (15:37 +0100)
Fixes #4996.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4997)

apps/cms.c

index 1457cab..6900ddf 100644 (file)
@@ -921,11 +921,15 @@ int cms_main(int argc, char **argv)
             keyfile = sk_OPENSSL_STRING_value(skkeys, i);
 
             signer = load_cert(signerfile, FORMAT_PEM, "signer certificate");
-            if (signer == NULL)
+            if (signer == NULL) {
+                ret = 2;
                 goto end;
+            }
             key = load_key(keyfile, keyform, 0, passin, e, "signing key file");
-            if (key == NULL)
+            if (key == NULL) {
+                ret = 2;
                 goto end;
+            }
             for (kparam = key_first; kparam; kparam = kparam->next) {
                 if (kparam->idx == i) {
                     tflags |= CMS_KEY_PARAM;