mirror of https://github.com/openssl/openssl
Use opt_int_arg() to parse integers in apps/speed.c
We use opt_int_arg() to prevent malformed processing of hexadecimal input to some command line options. Updated help to mention the change. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/17585)
This commit is contained in:
parent
944f822aad
commit
78212c6472
14
apps/speed.c
14
apps/speed.c
|
@ -214,7 +214,11 @@ typedef enum OPTION_choice {
|
||||||
} OPTION_CHOICE;
|
} OPTION_CHOICE;
|
||||||
|
|
||||||
const OPTIONS speed_options[] = {
|
const OPTIONS speed_options[] = {
|
||||||
{OPT_HELP_STR, 1, '-', "Usage: %s [options] [algorithm...]\n"},
|
{OPT_HELP_STR, 1, '-',
|
||||||
|
"Usage: %s [options] [algorithm...]\n"
|
||||||
|
"All +int options consider prefix '0' as base-8 input, "
|
||||||
|
"prefix '0x'/'0X' as base-16 input.\n"
|
||||||
|
},
|
||||||
|
|
||||||
OPT_SECTION("General"),
|
OPT_SECTION("General"),
|
||||||
{"help", OPT_HELP, '-', "Display this summary"},
|
{"help", OPT_HELP, '-', "Display this summary"},
|
||||||
|
@ -1543,7 +1547,7 @@ int speed_main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case OPT_MULTI:
|
case OPT_MULTI:
|
||||||
#ifndef NO_FORK
|
#ifndef NO_FORK
|
||||||
multi = atoi(opt_arg());
|
multi = opt_int_arg();
|
||||||
if ((size_t)multi >= SIZE_MAX / sizeof(int)) {
|
if ((size_t)multi >= SIZE_MAX / sizeof(int)) {
|
||||||
BIO_printf(bio_err, "%s: multi argument too large\n", prog);
|
BIO_printf(bio_err, "%s: multi argument too large\n", prog);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1552,7 +1556,7 @@ int speed_main(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case OPT_ASYNCJOBS:
|
case OPT_ASYNCJOBS:
|
||||||
#ifndef OPENSSL_NO_ASYNC
|
#ifndef OPENSSL_NO_ASYNC
|
||||||
async_jobs = atoi(opt_arg());
|
async_jobs = opt_int_arg();
|
||||||
if (!ASYNC_is_capable()) {
|
if (!ASYNC_is_capable()) {
|
||||||
BIO_printf(bio_err,
|
BIO_printf(bio_err,
|
||||||
"%s: async_jobs specified but async not supported\n",
|
"%s: async_jobs specified but async not supported\n",
|
||||||
|
@ -1599,10 +1603,10 @@ int speed_main(int argc, char **argv)
|
||||||
case OPT_SECONDS:
|
case OPT_SECONDS:
|
||||||
seconds.sym = seconds.rsa = seconds.dsa = seconds.ecdsa
|
seconds.sym = seconds.rsa = seconds.dsa = seconds.ecdsa
|
||||||
= seconds.ecdh = seconds.eddsa
|
= seconds.ecdh = seconds.eddsa
|
||||||
= seconds.sm2 = seconds.ffdh = atoi(opt_arg());
|
= seconds.sm2 = seconds.ffdh = opt_int_arg();
|
||||||
break;
|
break;
|
||||||
case OPT_BYTES:
|
case OPT_BYTES:
|
||||||
lengths_single = atoi(opt_arg());
|
lengths_single = opt_int_arg();
|
||||||
lengths = &lengths_single;
|
lengths = &lengths_single;
|
||||||
size_num = 1;
|
size_num = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue