s3/param: don't ignore unknown options
authorRalph Boehme <slow@samba.org>
Fri, 10 Sep 2021 04:56:36 +0000 (06:56 +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/param/test_lp_load.c

index b25a54798f8b353e1abb3aced8b92fd9c59407d2..2c6a5c8891b420567fb634202d677776e7998f06 100644 (file)
@@ -27,6 +27,7 @@ int main(int argc, const char **argv)
        poptContext pc;
        char *count_str = NULL;
        int i, count = 1;
+       int opt;
        bool ok;
 
        struct poptOption long_options[] = {
@@ -70,7 +71,15 @@ int main(int argc, const char **argv)
        }
        poptSetOtherOptionHelp(pc, "[OPTION...] <config-file>");
 
-       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);
+               }
+       }
 
        if (poptPeekArg(pc)) {
                config_file = poptGetArg(pc);