From 033585175485077bf7f5bbb352fd4f162d0c235f Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Sun, 14 Feb 2016 20:45:02 +0100 Subject: [PATCH] argv was set but unused Also gives an error message when you gave it a parameter it didn't expect. Reviewed-by: Rich Salz MR: #2009 --- apps/asn1pars.c | 3 ++- apps/crl.c | 3 ++- apps/crl2p7.c | 3 ++- apps/dsa.c | 4 +++- apps/ec.c | 4 +++- apps/ecparam.c | 4 +++- apps/genpkey.c | 4 +++- apps/nseq.c | 4 +++- apps/ocsp.c | 3 ++- apps/pkcs12.c | 4 +++- apps/pkcs7.c | 3 ++- apps/pkcs8.c | 4 +++- apps/pkey.c | 4 +++- apps/pkeyparam.c | 4 +++- apps/pkeyutl.c | 3 ++- apps/req.c | 3 ++- apps/rsa.c | 4 +++- apps/rsautl.c | 3 ++- apps/s_client.c | 3 ++- apps/s_time.c | 3 ++- apps/sess_id.c | 3 ++- apps/spkac.c | 4 +++- apps/ts.c | 1 - 23 files changed, 55 insertions(+), 23 deletions(-) diff --git a/apps/asn1pars.c b/apps/asn1pars.c index f7fa8f3531..a6cc6397fa 100644 --- a/apps/asn1pars.c +++ b/apps/asn1pars.c @@ -184,7 +184,8 @@ int asn1parse_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (oidfile != NULL) { in = bio_open_default(oidfile, 'r', FORMAT_TEXT); diff --git a/apps/crl.c b/apps/crl.c index 3f64cdd57a..c6fc9e6675 100644 --- a/apps/crl.c +++ b/apps/crl.c @@ -227,7 +227,8 @@ int crl_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (!nmflag_set) nmflag = XN_FLAG_ONELINE; diff --git a/apps/crl2p7.c b/apps/crl2p7.c index 74bb893900..e864973b09 100644 --- a/apps/crl2p7.c +++ b/apps/crl2p7.c @@ -146,7 +146,8 @@ int crl2pkcs7_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (!nocrl) { in = bio_open_default(infile, 'r', informat); diff --git a/apps/dsa.c b/apps/dsa.c index 5ee97cf66b..79c6fb29b4 100644 --- a/apps/dsa.c +++ b/apps/dsa.c @@ -194,7 +194,9 @@ int dsa_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = pubin || pubout ? 0 : 1; if (text && !pubin) private = 1; diff --git a/apps/ec.c b/apps/ec.c index 6f811e35c9..432e9ff5eb 100644 --- a/apps/ec.c +++ b/apps/ec.c @@ -205,7 +205,9 @@ int ec_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = param_out || pubin || pubout ? 0 : 1; if (text && !pubin) private = 1; diff --git a/apps/ecparam.c b/apps/ecparam.c index 7889caccef..55d71f7fd4 100644 --- a/apps/ecparam.c +++ b/apps/ecparam.c @@ -220,7 +220,9 @@ int ecparam_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = genkey ? 1 : 0; in = bio_open_default(infile, 'r', informat); diff --git a/apps/genpkey.c b/apps/genpkey.c index 01564131a0..905eb1992f 100644 --- a/apps/genpkey.c +++ b/apps/genpkey.c @@ -170,7 +170,9 @@ int genpkey_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = do_param ? 0 : 1; if (ctx == NULL) diff --git a/apps/nseq.c b/apps/nseq.c index fd63bd821b..4bc4f32828 100644 --- a/apps/nseq.c +++ b/apps/nseq.c @@ -89,6 +89,7 @@ int nseq_main(int argc, char **argv) switch (o) { case OPT_EOF: case OPT_ERR: + opthelp: BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); goto end; case OPT_HELP: @@ -107,7 +108,8 @@ int nseq_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; in = bio_open_default(infile, 'r', FORMAT_PEM); if (in == NULL) diff --git a/apps/ocsp.c b/apps/ocsp.c index 502adf1ba5..e26afe1f94 100644 --- a/apps/ocsp.c +++ b/apps/ocsp.c @@ -491,7 +491,8 @@ int ocsp_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; /* Have we anything to do? */ if (!req && !reqin && !respin && !(port && ridx_filename)) diff --git a/apps/pkcs12.c b/apps/pkcs12.c index 2b9a08024c..e8df4998f7 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -325,7 +325,9 @@ int pkcs12_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = 1; if (passarg) { diff --git a/apps/pkcs7.c b/apps/pkcs7.c index 1ed0b01339..ad8330d42f 100644 --- a/apps/pkcs7.c +++ b/apps/pkcs7.c @@ -191,7 +191,8 @@ int pkcs7_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; in = bio_open_default(infile, 'r', informat); if (in == NULL) diff --git a/apps/pkcs8.c b/apps/pkcs8.c index 5db78fc216..125bf6158a 100644 --- a/apps/pkcs8.c +++ b/apps/pkcs8.c @@ -225,7 +225,9 @@ int pkcs8_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = 1; if (!app_passwd(passinarg, passoutarg, &passin, &passout)) { diff --git a/apps/pkey.c b/apps/pkey.c index 6f5ecf0ce6..122ced706c 100644 --- a/apps/pkey.c +++ b/apps/pkey.c @@ -159,7 +159,9 @@ int pkey_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = !noout && !pubout ? 1 : 0; if (text && !pubtext) private = 1; diff --git a/apps/pkeyparam.c b/apps/pkeyparam.c index abb40d1ab2..d55adef1ca 100644 --- a/apps/pkeyparam.c +++ b/apps/pkeyparam.c @@ -92,6 +92,7 @@ int pkeyparam_main(int argc, char **argv) switch (o) { case OPT_EOF: case OPT_ERR: + opthelp: BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); goto end; case OPT_HELP: @@ -116,7 +117,8 @@ int pkeyparam_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; in = bio_open_default(infile, 'r', FORMAT_PEM); if (in == NULL) diff --git a/apps/pkeyutl.c b/apps/pkeyutl.c index 5a2827b399..8e1177738e 100644 --- a/apps/pkeyutl.c +++ b/apps/pkeyutl.c @@ -225,7 +225,8 @@ int pkeyutl_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (inkey == NULL || (peerkey != NULL && pkey_op != EVP_PKEY_OP_DERIVE)) diff --git a/apps/req.c b/apps/req.c index 4900a92291..facc63967d 100644 --- a/apps/req.c +++ b/apps/req.c @@ -367,7 +367,8 @@ int req_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (!nmflag_set) nmflag = XN_FLAG_ONELINE; diff --git a/apps/rsa.c b/apps/rsa.c index 23383d93de..5320f38455 100644 --- a/apps/rsa.c +++ b/apps/rsa.c @@ -252,7 +252,9 @@ int rsa_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; + private = (text && !pubin) || (!pubout && !noout) ? 1 : 0; if (!app_passwd(passinarg, passoutarg, &passin, &passout)) { diff --git a/apps/rsautl.c b/apps/rsautl.c index f00c2e3ad6..08e4d5635e 100644 --- a/apps/rsautl.c +++ b/apps/rsautl.c @@ -205,7 +205,8 @@ int rsautl_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (need_priv && (key_type != KEY_PRIVKEY)) { BIO_printf(bio_err, "A private key is needed for this operation\n"); diff --git a/apps/s_client.c b/apps/s_client.c index ca630f0a2f..9d0b52a10f 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -1341,7 +1341,8 @@ int s_client_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (proxystr) { int res; diff --git a/apps/s_time.c b/apps/s_time.c index 6514fb2197..fd001483f7 100644 --- a/apps/s_time.c +++ b/apps/s_time.c @@ -237,7 +237,8 @@ int s_time_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (cipher == NULL) cipher = getenv("SSL_CIPHER"); diff --git a/apps/sess_id.c b/apps/sess_id.c index 2be2692f08..f40f131e1b 100644 --- a/apps/sess_id.c +++ b/apps/sess_id.c @@ -139,7 +139,8 @@ int sess_id_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; x = load_sess_id(infile, informat); if (x == NULL) { diff --git a/apps/spkac.c b/apps/spkac.c index 9cbe7fe2e8..07f36d370d 100644 --- a/apps/spkac.c +++ b/apps/spkac.c @@ -112,6 +112,7 @@ int spkac_main(int argc, char **argv) switch (o) { case OPT_EOF: case OPT_ERR: + opthelp: BIO_printf(bio_err, "%s: Use -help for summary.\n", prog); goto end; case OPT_HELP: @@ -154,7 +155,8 @@ int spkac_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); + if (argc != 0) + goto opthelp; if (!app_passwd(passinarg, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); diff --git a/apps/ts.c b/apps/ts.c index 00b5e53f7c..ee04bb5ad8 100644 --- a/apps/ts.c +++ b/apps/ts.c @@ -299,7 +299,6 @@ int ts_main(int argc, char **argv) } } argc = opt_num_rest(); - argv = opt_rest(); if (mode == OPT_ERR || argc != 0) goto opthelp; -- 2.25.1