mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
pipe: check if command line arguments are malformed
This commit is contained in:
parent
ce4fabb537
commit
f7cf76d4d3
1 changed files with 8 additions and 2 deletions
10
src/pipe.c
10
src/pipe.c
|
@ -200,13 +200,19 @@ int main(int argc, char *argv[])
|
|||
sendd.enabled = false; // receive only
|
||||
break;
|
||||
case 'd':
|
||||
level = atoi(optarg);
|
||||
break;
|
||||
level = strtoul(optarg, &endptr, 10);
|
||||
goto check;
|
||||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(c == '?' ? EXIT_FAILURE : EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
check: if (optarg == endptr)
|
||||
error("Failed to parse parse option argument '-%c %s'", c, optarg);
|
||||
|
||||
}
|
||||
|
||||
if (argc != optind + 2) {
|
||||
|
|
Loading…
Add table
Reference in a new issue