diff --git a/apps/apps.h b/apps/apps.h index 319b02ef1948e3e9dd6a85109b7e85e4e141d0ff..5faf440200bd9bd31a8916104311dcb6a59f663b 100644 --- a/apps/apps.h +++ b/apps/apps.h @@ -274,6 +274,10 @@ int has_stdin_waiting(void); case OPT_S_DHPARAM: \ case OPT_S_DEBUGBROKE +#define IS_NO_PROT_FLAG(o) \ + (o == OPT_S_NOSSL3 || o == OPT_S_NOTLS1 || o == OPT_S_NOTLS1_1 \ + || o == OPT_S_NOTLS1_2) + /* * Option parsing. */ diff --git a/apps/s_client.c b/apps/s_client.c index e79cf7e496e3161124f441699c6bf24091780a0c..69e225cef63d3c3f369a9b6e66ab40ab921e2e2c 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -768,6 +768,10 @@ static const OPT_PAIR services[] = { (o == OPT_4 || o == OPT_6 || o == OPT_HOST || o == OPT_PORT || o == OPT_CONNECT) #define IS_UNIX_FLAG(o) (o == OPT_UNIX) +#define IS_PROT_FLAG(o) \ + (o == OPT_SSL3 || o == OPT_TLS1 || o == OPT_TLS1_1 || o == OPT_TLS1_2 \ + || o == OPT_DTLS || o == OPT_DTLS1 || o == OPT_DTLS1_2) + /* Free |*dest| and optionally set it to a copy of |source|. */ static void freeandcopy(char **dest, const char *source) { @@ -851,7 +855,7 @@ int s_client_main(int argc, char **argv) char *ctlog_file = NULL; int ct_validation = 0; #endif - int min_version = 0, max_version = 0; + int min_version = 0, max_version = 0, prot_opt = 0, no_prot_opt = 0; int async = 0; unsigned int split_send_fragment = 0; unsigned int max_pipelines = 0; @@ -905,6 +909,19 @@ int s_client_main(int argc, char **argv) prog); goto end; } + + if (IS_PROT_FLAG(o) && ++prot_opt > 1) { + BIO_printf(bio_err, "Cannot supply multiple protocol flags\n"); + goto end; + } + if (IS_NO_PROT_FLAG(o)) + no_prot_opt++; + if (prot_opt == 1 && no_prot_opt) { + BIO_printf(bio_err, "Cannot supply both a protocol flag and " + "\"-no_\"\n"); + goto end; + } + switch (o) { case OPT_EOF: case OPT_ERR: diff --git a/apps/s_server.c b/apps/s_server.c index 45c128d70129878f27c3f00a024ccba3ebe296f2..d545546f29d0d3bf01a75850f6278ff4f7fad014 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -910,6 +910,10 @@ OPTIONS s_server_options[] = { {NULL, OPT_EOF, 0, NULL} }; +#define IS_PROT_FLAG(o) \ + (o == OPT_SSL3 || o == OPT_TLS1 || o == OPT_TLS1_1 || o == OPT_TLS1_2 \ + || o == OPT_DTLS || o == OPT_DTLS1 || o == OPT_DTLS1_2) + int s_server_main(int argc, char *argv[]) { ENGINE *engine = NULL; @@ -970,7 +974,7 @@ int s_server_main(int argc, char *argv[]) char *srpuserseed = NULL; char *srp_verifier_file = NULL; #endif - int min_version = 0, max_version = 0; + int min_version = 0, max_version = 0, prot_opt = 0, no_prot_opt = 0; local_argc = argc; local_argv = argv; @@ -984,6 +988,17 @@ int s_server_main(int argc, char *argv[]) prog = opt_init(argc, argv, s_server_options); while ((o = opt_next()) != OPT_EOF) { + if (IS_PROT_FLAG(o) && ++prot_opt > 1) { + BIO_printf(bio_err, "Cannot supply multiple protocol flags\n"); + goto end; + } + if (IS_NO_PROT_FLAG(o)) + no_prot_opt++; + if (prot_opt == 1 && no_prot_opt) { + BIO_printf(bio_err, "Cannot supply both a protocol flag and " + "\"-no_\"\n"); + goto end; + } switch (o) { case OPT_EOF: case OPT_ERR: