]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
split_tokens: don't ignore unknown options
authorRalph Boehme <slow@samba.org>
Fri, 10 Sep 2021 05:14:40 +0000 (07:14 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 10 Sep 2021 15:10:30 +0000 (15:10 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14828

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/utils/split_tokens.c

index 6693f010edf8dd39107f4f7e51bef7d87b381de2..ab48dc5c9c1e63089aeb39c95c193c8357e081b0 100644 (file)
@@ -32,6 +32,7 @@ int main(int argc, const char *argv[])
        poptContext pc;
        char *buff;
        TALLOC_CTX *ctx = talloc_stackframe();
+       int opt;
        bool ok;
 
        struct poptOption long_options[] = {
@@ -64,7 +65,15 @@ int main(int argc, const char *argv[])
 
        poptSetOtherOptionHelp(pc, "[OPTION...] <sequence-string>");
 
-       while(poptGetNextOpt(pc) != -1);
+       while((opt = poptGetNextOpt(pc)) != -1) {
+               switch (opt) {
+               case POPT_ERROR_BADOPT:
+                       fprintf(stderr, "\nInvalid option %s: %s\n\n",
+                               poptBadOption(pc, 0), poptStrerror(opt));
+                       poptPrintUsage(pc, stderr, 0);
+                       exit(1);
+               }
+       }
 
        sequence = poptGetArg(pc);