- strncmp should compare up to and _include_ the \0 (was off by one).
Instead of 2 for "-h", it should be 3. Use "sizeof("-h")" instead of
hardcoding 3.
- strncmp logic was reversed for the --list-options check.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
int i;
for (i = 0; i < argc; i++) {
- if ((strncmp(argv[i], "-h", 2) == 0) ||
- strncmp(argv[i], "--h", 3) == 0 ||
- strncmp(argv[i], "--list-options", 14)) {
+ if ((strncmp(argv[i], "-h", sizeof("-h")) == 0) ||
+ strncmp(argv[i], "--h", sizeof("--h")) == 0 ||
+ strncmp(argv[i], "--list-options", sizeof("--list-options")) == 0) {
return 1;
}
}