From: atishkov Date: Mon, 17 Jul 2023 10:10:44 +0000 (+0300) Subject: apps/cms.c: Fix unreachable code in cms_main() X-Git-Tag: openssl-3.1.2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=866f43afdc46418b7e26be357f5a618e7beb1cdf;p=thirdparty%2Fopenssl.git apps/cms.c: Fix unreachable code in cms_main() Reviewed-by: Tom Cosgrove Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21474) (cherry picked from commit 8c34367e434c6b9555f21cc4fc77a18d6ef84a85) --- diff --git a/apps/cms.c b/apps/cms.c index 76c78967193..dbb5145611a 100644 --- a/apps/cms.c +++ b/apps/cms.c @@ -796,6 +796,9 @@ int cms_main(int argc, char **argv) if ((operation & SMIME_IP) == 0 && contfile != NULL) BIO_printf(bio_err, "Warning: -contfile option is ignored for the given operation\n"); + if (operation != SMIME_ENCRYPT && *argv != NULL) + BIO_printf(bio_err, + "Warning: recipient certificate file parameters ignored for operation other than -encrypt\n"); if ((flags & CMS_BINARY) != 0) { if (!(operation & SMIME_OP)) @@ -823,19 +826,13 @@ int cms_main(int argc, char **argv) goto end; } - if (*argv != NULL) { - if (operation == SMIME_ENCRYPT) { - for (; *argv != NULL; argv++) { - cert = load_cert(*argv, FORMAT_UNDEF, - "recipient certificate file"); - if (cert == NULL) - goto end; - sk_X509_push(encerts, cert); - cert = NULL; - } - } else { - BIO_printf(bio_err, "Warning: recipient certificate file parameters ignored for operation other than -encrypt\n"); - } + for (; *argv != NULL; argv++) { + cert = load_cert(*argv, FORMAT_UNDEF, + "recipient certificate file"); + if (cert == NULL) + goto end; + sk_X509_push(encerts, cert); + cert = NULL; } }