options: tighten validation of argc/argv
If argc/argv do no match a lot of our assumptions are invalid, hence let's check this explicitly once, instead of ignoring the issue.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
b10d3631f3
commit
bd2d2fec80
@@ -76,9 +76,11 @@ int option_parse(
|
||||
if (state->optind == 0) {
|
||||
assert(state->mode >= 0 && state->mode < _OPTION_PARSER_MODE_MAX);
|
||||
|
||||
if (state->argc < 1 || strv_isempty(state->argv))
|
||||
if (state->argc < 1)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EUCLEAN), "argv cannot be empty");
|
||||
|
||||
assert_se((size_t) state->argc == strv_length(state->argv)); /* Make sure argc/argv are consistent */
|
||||
|
||||
state->optind = state->positional_offset = 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user