From: Kurt Roeckx Date: Sun, 14 Feb 2016 19:45:02 +0000 (+0100) Subject: argv was set but unused X-Git-Tag: OpenSSL_1_1_0-pre4~580 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=033585175485077bf7f5bbb352fd4f162d0c235f;p=thirdparty%2Fopenssl.git 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 --- diff --git a/apps/asn1pars.c b/apps/asn1pars.c index f7fa8f35313..a6cc6397fad 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 3f64cdd57a2..c6fc9e66754 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 74bb8939003..e864973b092 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 5ee97cf66bb..79c6fb29b4f 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 6f811e35c90..432e9ff5eb2 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 7889caccefb..55d71f7fd41 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 01564131a09..905eb1992f2 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 fd63bd821ba..4bc4f328288 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 502adf1ba5a..e26afe1f94b 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 2b9a08024c3..e8df4998f7e 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 1ed0b013395..ad8330d42ff 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 5db78fc216d..125bf6158ac 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 6f5ecf0ce65..122ced706cd 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 abb40d1ab29..d55adef1ca0 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 5a2827b3997..8e1177738e9 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 4900a922912..facc63967d7 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 23383d93de3..5320f38455f 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 f00c2e3ad68..08e4d5635ef 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 ca630f0a2ff..9d0b52a10f0 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 6514fb21972..fd001483f72 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 2be2692f087..f40f131e1bd 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 9cbe7fe2e8f..07f36d370d6 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 00b5e53f7c7..ee04bb5ad8b 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;