# HG changeset patch # User Maxim Dounin # Date 1621945061 -10800 # Node ID a45b6a206cfccf42d20e552e44afb3a13bbc9ed1 # Parent 5d561a77502e2b9570906f12e0d085721b558997 Resolver: fixed label types handling in ngx_resolver_copy(). Previously, anything with any of the two high bits set were interpreted as compression pointers. This is incorrect, as RFC 1035 clearly states that "The 10 and 01 combinations are reserved for future use". Further, the 01 combination is actually allocated for EDNS extended label type (see RFC 2671 and RFC 6891), not really used though. Fix is to reject unrecognized label types rather than misinterpreting them as compression pointers. diff --git a/src/core/ngx_resolver.c b/src/core/ngx_resolver.c --- a/src/core/ngx_resolver.c +++ b/src/core/ngx_resolver.c @@ -3958,6 +3958,11 @@ ngx_resolver_copy(ngx_resolver_t *r, ngx } if (n & 0xc0) { + if ((n & 0xc0) != 0xc0) { + err = "invalid label type in DNS response"; + goto invalid; + } + if (p >= last) { err = "name is out of DNS response"; goto invalid;