]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
swanctl: Add check for conflicting short options
authorTobias Brunner <tobias@strongswan.org>
Mon, 13 Nov 2017 09:09:05 +0000 (10:09 +0100)
committerTobias Brunner <tobias@strongswan.org>
Mon, 13 Nov 2017 09:09:41 +0000 (10:09 +0100)
src/swanctl/command.c

index 7f65d2b0e34b8a1bb6bf1dfae067fb41f7d88e86..225dff61767d9a4b84a5d0cbd6536773e84c3c20 100644 (file)
@@ -147,6 +147,15 @@ void command_register(command_t command)
                                "MAX_COMMANDS\n");
                return;
        }
+       for (i = 0; i < MAX_COMMANDS && cmds[i].cmd; i++)
+       {
+               if (cmds[i].op == command.op)
+               {
+                       fprintf(stderr, "unable to register command --%s, short option "
+                                       "conflicts with --%s\n", command.cmd, cmds[i].cmd);
+                       return;
+               }
+       }
 
        cmds[registered] = command;
        /* append default options, but not to --help */