]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
APPS: Allow non-option parameters appear anywhere in list, marking them OPT_PARAM
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Sat, 3 Apr 2021 14:03:21 +0000 (16:03 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Thu, 20 May 2021 14:31:22 +0000 (16:31 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15126)

apps/include/opt.h
apps/lib/opt.c

index 5d85877301a27ae7017d6633defe7b211b75d701..213e41b83b8ba9d640848f84a94d46baaddaab7d 100644 (file)
@@ -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
index 4b75b46681aad5a874228d045e15f64ac744503b..b0ec265aa905b023940abaea6863a02a1d009626 100644 (file)
@@ -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;