exit(2) on unsupported positional arguments on command line

Change-Id: I6d4efa6ddef41607aecd5ceee78e400db821292f
This commit is contained in:
Harald Welte 2019-12-03 22:14:20 +01:00
parent 50595fb9b5
commit cbf23b6465
2 changed files with 10 additions and 0 deletions

View File

@ -123,6 +123,11 @@ static void handle_options(int argc, char **argv)
break;
}
}
if (argc > optind) {
fprintf(stderr, "Unsupported positional arguments on command line\n");
exit(2);
}
}
int main(int argc, char **argv)

View File

@ -275,6 +275,11 @@ int main(int argc, char **argv)
exit(2);
}
if (argc > optind+1) {
fprintf(stderr, "Unsupported positional arguments on command line\n");
exit(2);
}
f = osmo_e1cap_open(NULL, argv[optind++]);
if (!f) {
fprintf(stderr, "Unable to open input file\n");