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:
@@ -1454,7 +1454,7 @@ nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
|
|||||||
nxt_conf_value_t *value)
|
nxt_conf_value_t *value)
|
||||||
{
|
{
|
||||||
nxt_str_t pattern;
|
nxt_str_t pattern;
|
||||||
nxt_uint_t i, first;
|
nxt_uint_t i, first, last;
|
||||||
|
|
||||||
if (nxt_conf_type(value) != NXT_CONF_STRING) {
|
if (nxt_conf_type(value) != NXT_CONF_STRING) {
|
||||||
return nxt_conf_vldt_error(vldt, "The \"match\" patterns for \"host\", "
|
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] == '!');
|
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] == '*') {
|
if (pattern.start[i] == '*' && pattern.start[i + 1] == '*') {
|
||||||
return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
|
return nxt_conf_vldt_error(vldt, "The \"match\" pattern must "
|
||||||
"not contain double \"*\" markers.");
|
"not contain double \"*\" markers.");
|
||||||
|
|||||||
Reference in New Issue
Block a user