BUG/MINOR: resolvers: reject DNS messages without the QR bit
resolv_validate_dns_response() checks the query ID, the RCODE, the
question and the records, but not the QR bit, which tells a response
(1) from a query (0). A message with QR=0 is thus processed as a
response: one carrying the same answer as a valid response is accepted,
and the query itself, if it comes back from the nameserver's address
(e.g. through an echo or a forwarding loop), is processed as a response
without any answer.
The sender still has to match the nameserver address, the query ID and
the question, so this does not make spoofing easier, but such a message
is not a response and should be treated as invalid, as RFC 1035 defines
the QR bit for this purpose.
This patch adds DNS_FLAG_RESPONSE and makes such messages invalid. The
new reg-test reg-tests/resolvers/response_flag.vtc uses a small DNS
fixture that sends the same A answer with and without the QR bit, and
checks that only the former resolves and that the latter is counted as
invalid.