summaryrefslogtreecommitdiffstats
path: root/apps/srp.c
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2017-08-20 23:10:48 +0200
committerRich Salz <rsalz@openssl.org>2017-08-21 16:58:49 +0200
commitc27363f566274a65067d7559f9669f300f957183 (patch)
tree8f6f6166011fdf04e168c4582212554874a20e98 /apps/srp.c
parentAdd PKEY_CTX setter tests for TLS1-PRF (diff)
downloadopenssl-c27363f566274a65067d7559f9669f300f957183.tar.xz
openssl-c27363f566274a65067d7559f9669f300f957183.zip
Check # of arguments for remaining commands.
Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/4201)
Diffstat (limited to 'apps/srp.c')
-rw-r--r--apps/srp.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/apps/srp.c b/apps/srp.c
index c5002188a5..ceb0640c2f 100644
--- a/apps/srp.c
+++ b/apps/srp.c
@@ -297,11 +297,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 != NULL || passoutarg != NULL) && argc != 1) {
BIO_printf(bio_err,
@@ -390,10 +391,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)
@@ -554,9 +552,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;
}