Commit 87df0eb
committed
Fix option parsing for unknown flags
mcd segfaulted on any unrecognised option (e.g. -V) because usage()
called strlen(pid_file) before compose_paths() had initialised it.
Fix by moving compose_paths() into usage() itself.
mctl silently showed help and exited 0 for unknown options because
'?' is also in the option string as a -? help alias, masking the
error. Split case '?' to check optopt and add a default branch so
unrecognised options exit with code 1.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>1 parent 37a54d8 commit 87df0eb
2 files changed
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
| 52 | + | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
| |||
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
125 | | - | |
126 | 127 | | |
127 | 128 | | |
128 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
641 | 641 | | |
642 | 642 | | |
643 | 643 | | |
644 | | - | |
645 | 644 | | |
646 | 645 | | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
647 | 650 | | |
648 | 651 | | |
649 | 652 | | |
| |||
666 | 669 | | |
667 | 670 | | |
668 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
669 | 675 | | |
670 | 676 | | |
671 | 677 | | |
| |||
0 commit comments