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') {