diff options
author | Rich Salz <rsalz@akamai.com> | 2020-11-28 16:12:58 -0500 |
---|---|---|
committer | Tomas Mraz <tmraz@fedoraproject.org> | 2020-12-15 11:47:17 +0100 |
commit | 021410ea3fc3876538830839d16b67e610d12785 (patch) | |
tree | 7178c87097f1083bc285a77f8ec179ceba343464 /apps/s_client.c | |
parent | c678f68a19638c1e2bbfee6a7a1d8d728976ce66 (diff) |
Check non-option arguments
Make sure all commands check to see if there are any "extra" arguments
after the options, and print an error if so.
Made all error messages consistent (which is to say, minimal).
Fixes: #13527
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13563)
Diffstat (limited to 'apps/s_client.c')
-rw-r--r-- | apps/s_client.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/apps/s_client.c b/apps/s_client.c index 98f034f112..56444baeca 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -1572,6 +1572,24 @@ int s_client_main(int argc, char **argv) } } + /* Optional argument is connect string if -connect not used. */ + argc = opt_num_rest(); + if (argc == 1) { + /* + * Don't allow -connect and a separate argument. + */ + if (connectstr != NULL) { + BIO_printf(bio_err, + "%s: cannot provide both -connect option and target parameter\n", + prog); + goto opthelp; + } + connect_type = use_inet; + freeandcopy(&connectstr, *opt_rest()); + } else if (argc != 0) { + goto opthelp; + } + if (count4or6 >= 2) { BIO_printf(bio_err, "%s: Can't use both -4 and -6\n", prog); goto opthelp; @@ -1590,23 +1608,6 @@ int s_client_main(int argc, char **argv) goto opthelp; } } - argc = opt_num_rest(); - if (argc == 1) { - /* If there's a positional argument, it's the equivalent of - * OPT_CONNECT. - * Don't allow -connect and a separate argument. - */ - if (connectstr != NULL) { - BIO_printf(bio_err, - "%s: must not provide both -connect option and target parameter\n", - prog); - goto opthelp; - } - connect_type = use_inet; - freeandcopy(&connectstr, *opt_rest()); - } else if (argc != 0) { - goto opthelp; - } #ifndef OPENSSL_NO_NEXTPROTONEG if (min_version == TLS1_3_VERSION && next_proto_neg_in != NULL) { |