From: Dr. David von Oheimb Date: Sat, 3 Apr 2021 14:03:21 +0000 (+0200) Subject: APPS: Allow non-option parameters appear anywhere in list, marking them OPT_PARAM X-Git-Tag: openssl-3.0.0-beta1~456 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=601fe8e0d78d4344445cbfa83dbe9bc4ad1287f1;p=thirdparty%2Fopenssl.git APPS: Allow non-option parameters appear anywhere in list, marking them OPT_PARAM Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15126) --- diff --git a/apps/include/opt.h b/apps/include/opt.h index 5d85877301a..213e41b83b8 100644 --- a/apps/include/opt.h +++ b/apps/include/opt.h @@ -316,6 +316,8 @@ typedef struct options_st { int valtype; const char *helpstr; } OPTIONS; +/* Special retval values: */ +#define OPT_PARAM 0 /* same as OPT_EOF usually defined in apps */ /* * A string/int pairing; widely use for option value lookup, hence the diff --git a/apps/lib/opt.c b/apps/lib/opt.c index 4b75b46681a..b0ec265aa90 100644 --- a/apps/lib/opt.c +++ b/apps/lib/opt.c @@ -184,9 +184,13 @@ char *opt_init(int ac, char **av, const OPTIONS *o) /* Make sure options are legit. */ OPENSSL_assert(o->name[0] != '-'); - OPENSSL_assert(o->retval > 0); + if (o->valtype == '.') + OPENSSL_assert(o->retval == OPT_PARAM); + else + OPENSSL_assert(o->retval > OPT_PARAM); switch (i) { - case 0: case '-': case '/': case '<': case '>': case 'E': case 'F': + case 0: case '-': case '.': + case '/': case '<': case '>': case 'E': case 'F': case 'M': case 'U': case 'f': case 'l': case 'n': case 'p': case 's': case 'u': case 'c': case ':': case 'N': break; @@ -821,6 +825,9 @@ int opt_next(void) case ':': /* Just a string. */ break; + case '.': + /* Parameters */ + break; case '/': if (opt_isdir(arg) > 0) break;