Hi,
First Bug
Description
When the return answer type in the answer section dose not match the query class type, (for example, the query class type is 0x0001 and the return answer type is 0xdf01), the answer packet is forwarded to the client and the RCODE of the unbound return packet is 0.
Expected/Actual behavior
Bind and Pdns return the response packet with a RCODE of 2.
Steps to reproduce
1、Turn on a fake name server and return a specific payload.
The details of the response packet(response1) from the fake server are as follows:
+ HEADER
+ transaction, flags, questions, answers, authority, additional:
+ 38 CB 81 80 00 01 00 01 00 02 00 01
+
+ QUESTION
+ 06 63 65 72 74 30 31 07 65 78 61 6D 70 6C 65 00 00 25 00 01
+
+ ANSWER
+ C0 0C 00 25 DF 01 00 00 00 00 00 55
+ FF FE FF FF FE 33 11 5C 6F 2F 64 FF 2B DE 74 C7
+ D0 80 AC E1 1F 97 AB D0 CB BF BC 82 F3 E3 92 24
+ B2 47 1E 14 68 22 58 29 FF 1B 11 E1 6A 2E 95 02
+ E1 C0 A0 D5 33 E1 8A 14 D6 D5 5F 48 24 AA 41 89
+ FA FF FD 75 53 A3 65 77 CD 23 11 E0 BC 69 3A CE
+ F8 A2 A6 09 A6
+
+ AUTHORITY
+ C0 13 00 02 00 01 00 00 00 00 00 06
+ 03 6E 73 34 C0 13
+ C0 13 00 02 00 01 00 00 00 00 00 06
+ 03 6E 73 32 C0 13
+
+ ADDITIONAL
+ 00 00 29 10 00 00 00 00 00 00 00
https://643684107.oss-cn-beijing.aliyuncs.com/unbound-test2/dns_server.py
https://643684107.oss-cn-beijing.aliyuncs.com/unbound-test2/response1
Download them and run this script like so:
python3 dns_server.py response1
2、start unbound. The configuration options are as follows:
server:
verbosity: 1
num-threads: 2
interface: 0.0.0.0
interface: ::0
port: 5357
do-not-query-localhost: no
access-control: 127.0.0.1/8 allow
access-control: ::0/0 allow
username: "root"
forward-zone:
name: '.'
forward-addr: 127.0.0.1
3、Send the corresponding dns request.
https://643684107.oss-cn-beijing.aliyuncs.com/unbound-test2/dns_request.py
https://643684107.oss-cn-beijing.aliyuncs.com/unbound-test2/request1
The details of the request packet(request1) from client are as follows:
```
+ HEADER
+ transaction, flags, questions, answers, authority, additional:
+ 31 32 01 00 00 01 00 00 00 00 00 00