Router: fixed crash when matching an empty address pattern array.
A crash would occur when the router tried to match an
against an empty address pattern array.
The following configuration was used to reproduce the
issue:
{
"listeners": {
"127.0.0.1:8082": {
"pass": "routes"
}
},
"routes": [
{
"match": {
"source": []
},
"action": {
"return": 200
}
}
]
}
This commit is contained in:
@@ -99,6 +99,13 @@ or "upstreams" using a variable "pass" option.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
<change type="bugfix">
|
||||
<para>
|
||||
the router process crashed while matching a request to an empty array of
|
||||
source or destination address patterns.
|
||||
</para>
|
||||
</change>
|
||||
|
||||
</changes>
|
||||
|
||||
|
||||
|
||||
@@ -1936,6 +1936,11 @@ nxt_http_route_addr_rule(nxt_http_request_t *r,
|
||||
nxt_http_route_addr_pattern_t *p;
|
||||
|
||||
n = addr_rule->items;
|
||||
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
p = &addr_rule->addr_pattern[0] - 1;
|
||||
|
||||
do {
|
||||
|
||||
@@ -1751,6 +1751,10 @@ class TestRouting(TestApplicationProto):
|
||||
self.route_match_invalid({"source": "*:1-a"})
|
||||
self.route_match_invalid({"source": "*:65536"})
|
||||
|
||||
def test_routes_match_source_none(self):
|
||||
self.route_match({"source": []})
|
||||
assert self.get()['status'] == 404, 'source none'
|
||||
|
||||
def test_routes_match_destination(self):
|
||||
assert 'success' in self.conf(
|
||||
{"*:7080": {"pass": "routes"}, "*:7081": {"pass": "routes"}},
|
||||
|
||||
Reference in New Issue
Block a user