Configuration: fixed buffer over-read in pattern validation.

There was an undefined behavior in the validation function, caused by testing
one character after the string if a wildcard was at the end.
This commit is contained in:
Axel Duch
2020-07-28 14:51:33 +01:00
parent f1e445bdef
commit c3e6901f53

View File

@@ -1454,7 +1454,7 @@ nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value)
{
nxt_str_t pattern;
nxt_uint_t i, first;
nxt_uint_t i, first, last;
if (nxt_conf_type(value) != NXT_CONF_STRING) {
return nxt_conf_vldt_error(vldt, "The \"match\" patterns for \"host\", "
@@ -1468,8 +1468,9 @@ nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
}
first = (pattern.start[0] == '!');
last = pattern.length - 1;
for (i = first; i < pattern.length; i++) {
for (i = first; i < last; i++) {
if (pattern.start[i] == '*' && pattern.start[i + 1] == '*') {
return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
"not contain double \"*\" markers.");