summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>2021-04-12 19:00:00 +0200
committerDr. David von Oheimb <dev@ddvo.net>2021-05-20 16:31:22 +0200
commit56c4f6fe724e4aa54498188873d84e5694b02984 (patch)
treea5e9eda34894414eb4e394189bff97c87eee9965 /apps
parent601fe8e0d78d4344445cbfa83dbe9bc4ad1287f1 (diff)
APPS: Allow duplicate entries in options list, marking them OPT_DUP
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15126)
Diffstat (limited to 'apps')
-rw-r--r--apps/include/opt.h1
-rw-r--r--apps/lib/opt.c11
2 files changed, 9 insertions, 3 deletions
diff --git a/apps/include/opt.h b/apps/include/opt.h
index 213e41b83b..951557974b 100644
--- a/apps/include/opt.h
+++ b/apps/include/opt.h
@@ -318,6 +318,7 @@ typedef struct options_st {
} OPTIONS;
/* Special retval values: */
#define OPT_PARAM 0 /* same as OPT_EOF usually defined in apps */
+#define OPT_DUP -2 /* marks duplicate occurrence of option in help output */
/*
* 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 b0ec265aa9..0f08da2df4 100644
--- a/apps/lib/opt.c
+++ b/apps/lib/opt.c
@@ -187,7 +187,7 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
if (o->valtype == '.')
OPENSSL_assert(o->retval == OPT_PARAM);
else
- OPENSSL_assert(o->retval > OPT_PARAM);
+ OPENSSL_assert(o->retval == OPT_DUP || o->retval > OPT_PARAM);
switch (i) {
case 0: case '-': case '.':
case '/': case '<': case '>': case 'E': case 'F':
@@ -203,8 +203,13 @@ char *opt_init(int ac, char **av, const OPTIONS *o)
/*
* Some compilers inline strcmp and the assert string is too long.
*/
- duplicated = strcmp(o->name, next->name) == 0;
- OPENSSL_assert(!duplicated);
+ duplicated = next->retval != OPT_DUP
+ && strcmp(o->name, next->name) == 0;
+ if (duplicated) {
+ opt_printf_stderr("%s: Internal error: duplicate option %s\n",
+ prog, o->name);
+ OPENSSL_assert(!duplicated);
+ }
}
#endif
if (o->name[0] == '\0') {