Unverified Commit 8c928be4 by Patrick Steinhardt Committed by GitHub

Merge pull request #4406 from yoney/clar

Fix clar to verify command line arguments before execute
parents 1d7c15ad 32758631
...@@ -313,11 +313,18 @@ clar_parse_args(int argc, char **argv) ...@@ -313,11 +313,18 @@ clar_parse_args(int argc, char **argv)
{ {
int i; int i;
/* Verify options before execute */
for (i = 1; i < argc; ++i) { for (i = 1; i < argc; ++i) {
char *argument = argv[i]; char *argument = argv[i];
if (argument[0] != '-') if (argument[0] != '-' || argument[1] == '\0'
|| strchr("sixvqQl", argument[1]) == NULL) {
clar_usage(argv[0]); clar_usage(argv[0]);
}
}
for (i = 1; i < argc; ++i) {
char *argument = argv[i];
switch (argument[1]) { switch (argument[1]) {
case 's': case 's':
...@@ -391,7 +398,7 @@ clar_parse_args(int argc, char **argv) ...@@ -391,7 +398,7 @@ clar_parse_args(int argc, char **argv)
break; break;
default: default:
clar_usage(argv[0]); assert(!"Unexpected commandline argument!");
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment