MINOR: dns: update dns response buffer reading pointer due to SRV record
authorBaptiste Assmann <bedis9@gmail.com>
Fri, 11 Aug 2017 08:37:20 +0000 (10:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Aug 2017 09:24:57 +0000 (11:24 +0200)
commit63a28110771ecb18b84409dab4fa1b7a17253e52
tree12386f6bb1713cb0b58f71eceed2051bb7b604ac
parentddc8ce6d29eb131bcb8f864b5bda46b78e4e42e6
MINOR: dns: update dns response buffer reading pointer due to SRV record

DNS SRV records uses "dns name compression" to store the target name.
"dns compression" principle is simple. Let's take the name below:
  3336633266663038.red.default.svc.cluster.local.
It can be stored "as is" in the response or it can be compressed like
this:
  3336633266663038<POINTER>
and <POINTER> would point to the string
'.red.default.svc.cluster.local.' availble in the question section for
example.
This mechanism allows storing much more data in a single DNS response.

This means the flag "record->data_len" which stores the size of the
record (hence the whole string, uncompressed) can't be used to move the
pointer forward when reading responses. We must use the "offset" integer
which means the real number of bytes occupied by the target name.

If we don't do that, we can properly read the first SRV record, then we
loose alignment and we start reading unrelated data (still in the
response) leading to a false negative error treated as an "invalid"
response...
src/dns.c