[openssl-commits] [openssl] OpenSSL_1_1_0-stable update
Rich Salz
rsalz at openssl.org
Thu Jan 25 18:19:04 UTC 2018
The branch OpenSSL_1_1_0-stable has been updated
via 847997f98c28b3b8ceb2b95ef1751f7c7c1bfa61 (commit)
from bfef66f000937a44cb769acce313e8504a5631b8 (commit)
- Log -----------------------------------------------------------------
commit 847997f98c28b3b8ceb2b95ef1751f7c7c1bfa61
Author: Rich Salz <rsalz at openssl.org>
Date: Wed Jan 24 17:13:45 2018 -0500
Check # of arguments for remaining commands.
Backport of https://github.com/openssl/openssl/pull/4201
Reviewed-by: Bernd Edlinger <bernd.edlinger at hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/5162)
-----------------------------------------------------------------------
Summary of changes:
apps/enc.c | 4 ++++
apps/genrsa.c | 12 +++++++++---
apps/openssl.c | 11 +++++++----
apps/prime.c | 10 ++++++++--
apps/rand.c | 8 ++++++--
apps/srp.c | 21 +++++++++------------
apps/version.c | 5 +++++
7 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/apps/enc.c b/apps/enc.c
index ef65606..ab9fbc7 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -257,6 +257,10 @@ int enc_main(int argc, char **argv)
break;
}
}
+ if (opt_num_rest() != 0) {
+ BIO_printf(bio_err, "Extra arguments given.\n");
+ goto opthelp;
+ }
if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) {
BIO_printf(bio_err, "%s: AEAD ciphers not supported\n", prog);
diff --git a/apps/genrsa.c b/apps/genrsa.c
index 1ac66a9..aab2595 100644
--- a/apps/genrsa.c
+++ b/apps/genrsa.c
@@ -78,6 +78,7 @@ int genrsa_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:
@@ -110,11 +111,16 @@ int genrsa_main(int argc, char **argv)
}
argc = opt_num_rest();
argv = opt_rest();
- private = 1;
- if (argv[0] && (!opt_int(argv[0], &num) || num <= 0))
- goto end;
+ if (argc == 1) {
+ if (!opt_int(argv[0], &num) || num <= 0)
+ goto end;
+ } else if (argc > 0) {
+ BIO_printf(bio_err, "Extra arguments given.\n");
+ goto opthelp;
+ }
+ private = 1;
if (!app_passwd(NULL, passoutarg, NULL, &passout)) {
BIO_printf(bio_err, "Error getting password\n");
goto end;
diff --git a/apps/openssl.c b/apps/openssl.c
index 31962cd..c3fd30f 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -334,6 +334,7 @@ int list_main(int argc, char **argv)
switch (o) {
case OPT_EOF: /* Never hit, but suppresses warning */
case OPT_ERR:
+opthelp:
BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
return 1;
case OPT_HELP:
@@ -363,12 +364,14 @@ int list_main(int argc, char **argv)
}
done = 1;
}
-
- if (!done) {
- BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
- return 1;
+ if (opt_num_rest() != 0) {
+ BIO_printf(bio_err, "Extra arguments given.\n");
+ goto opthelp;
}
+ if (!done)
+ goto opthelp;
+
return 0;
}
diff --git a/apps/prime.c b/apps/prime.c
index b0f5969..086f08e 100644
--- a/apps/prime.c
+++ b/apps/prime.c
@@ -43,6 +43,7 @@ int prime_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:
@@ -69,9 +70,14 @@ int prime_main(int argc, char **argv)
argc = opt_num_rest();
argv = opt_rest();
- if (argc == 0 && !generate) {
+ if (generate) {
+ if (argc != 0) {
+ BIO_printf(bio_err, "Extra arguments given.\n");
+ goto opthelp;
+ }
+ } else if (argc == 0) {
BIO_printf(bio_err, "%s: No prime specified\n", prog);
- goto end;
+ goto opthelp;
}
if (generate) {
diff --git a/apps/rand.c b/apps/rand.c
index 21c9a7a..c63eb1f 100644
--- a/apps/rand.c
+++ b/apps/rand.c
@@ -76,9 +76,13 @@ int rand_main(int argc, char **argv)
}
argc = opt_num_rest();
argv = opt_rest();
-
- if (argc != 1 || !opt_int(argv[0], &num) || num < 0)
+ if (argc == 1) {
+ if (!opt_int(argv[0], &num) || num <= 0)
+ goto end;
+ } else if (argc > 0) {
+ BIO_printf(bio_err, "Extra arguments given.\n");
goto opthelp;
+ }
app_RAND_load_file(NULL, (inrand != NULL));
if (inrand != NULL)
diff --git a/apps/srp.c b/apps/srp.c
index ec35c55..823521a 100644
--- a/apps/srp.c
+++ b/apps/srp.c
@@ -293,11 +293,12 @@ int srp_main(int argc, char **argv)
"Exactly one of the options -add, -delete, -modify -list must be specified.\n");
goto opthelp;
}
- if ((mode == OPT_DELETE || mode == OPT_MODIFY || mode == OPT_ADD)
- && argc < 1) {
- BIO_printf(bio_err,
- "Need at least one user for options -add, -delete, -modify. \n");
- goto opthelp;
+ if (mode == OPT_DELETE || mode == OPT_MODIFY || mode == OPT_ADD) {
+ if (argc == 0) {
+ BIO_printf(bio_err, "Need at least one user.\n");
+ goto opthelp;
+ }
+ user = *argv++;
}
if ((passinarg || passoutarg) && argc != 1) {
BIO_printf(bio_err,
@@ -391,10 +392,7 @@ int srp_main(int argc, char **argv)
if (verbose > 1)
BIO_printf(bio_err, "Starting user processing\n");
- if (argc > 0)
- user = *(argv++);
-
- while (mode == OPT_LIST || user) {
+ while (mode == OPT_LIST || user != NULL) {
int userindex = -1;
if (user != NULL && verbose > 1)
@@ -557,9 +555,8 @@ int srp_main(int argc, char **argv)
doupdatedb = 1;
}
}
- if (--argc > 0) {
- user = *(argv++);
- } else {
+ user = *argv++;
+ if (user == NULL) {
/* no more processing in any mode if no users left */
break;
}
diff --git a/apps/version.c b/apps/version.c
index e3c8299..751cb0f 100644
--- a/apps/version.c
+++ b/apps/version.c
@@ -61,6 +61,7 @@ int version_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:
@@ -93,6 +94,10 @@ int version_main(int argc, char **argv)
break;
}
}
+ if (opt_num_rest() != 0) {
+ BIO_printf(bio_err, "Extra parameters given.\n");
+ goto opthelp;
+ }
if (!dirty)
version = 1;
More information about the openssl-commits
mailing list