Skip to content

Commit

Permalink
Resolver: explicit check for compression pointers in question.
Browse files Browse the repository at this point in the history
Since nginx always uses exactly one entry in the question section of
a DNS query, and never uses compression pointers in this entry, parsing
of a DNS response in ngx_resolver_process_response() does not expect
compression pointers to appear in the question section of the DNS
response.  Indeed, compression pointers in the first name of a DNS response
hardly make sense, do not seem to be allowed by RFC 1035 (which says
"a pointer to a prior occurance of the same name", note "prior"), and
were never observed in practice.

Added an explicit check to ngx_resolver_process_response()'s parsing
of the question section to properly report an error if compression pointers
nevertheless appear in the question section.
  • Loading branch information
mdounin committed May 25, 2021
1 parent f85d701 commit e860ecc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/core/ngx_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,12 @@ ngx_resolver_process_response(ngx_resolver_t *r, u_char *buf, size_t n,
i = sizeof(ngx_resolver_hdr_t);

while (i < (ngx_uint_t) n) {

if (buf[i] & 0xc0) {
err = "unexpected compression pointer in DNS response";
goto done;
}

if (buf[i] == '\0') {
goto found;
}
Expand Down

0 comments on commit e860ecc

Please sign in to comment.