2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Report opcode mismatch

This commit is contained in:
Mark Andrews 2020-03-11 13:55:14 +11:00
parent 4a7b9dba61
commit bb7576cc9b

View File

@ -64,6 +64,7 @@
#include <dns/log.h> #include <dns/log.h>
#include <dns/message.h> #include <dns/message.h>
#include <dns/name.h> #include <dns/name.h>
#include <dns/opcode.h>
#include <dns/rcode.h> #include <dns/rcode.h>
#include <dns/rdata.h> #include <dns/rdata.h>
#include <dns/rdataclass.h> #include <dns/rdataclass.h>
@ -3815,6 +3816,32 @@ recv_done(isc_task_t *task, isc_event_t *event) {
UNLOCK_LOOKUP; UNLOCK_LOOKUP;
return; return;
} }
if (msg->opcode != l->opcode) {
char expect[20] = { 0 }, got[20] = { 0 };
isc_buffer_init(&b, &expect, sizeof(expect));
result = dns_opcode_totext(l->opcode, &b);
check_result(result, "dns_opcode_totext");
isc_buffer_init(&b, &got, sizeof(got));
result = dns_opcode_totext(msg->opcode, &b);
check_result(result, "dns_opcode_totext");
dighost_warning("Warning: Opcode mismatch: expected %s, got %s",
expect, got);
dns_message_destroy(&msg);
if (l->tcp_mode) {
isc_event_free(&event);
clear_query(query);
cancel_lookup(l);
check_next_lookup(l);
UNLOCK_LOOKUP;
return;
} else {
goto udp_mismatch;
}
}
if (msg->counts[DNS_SECTION_QUESTION] != 0) { if (msg->counts[DNS_SECTION_QUESTION] != 0) {
match = true; match = true;
for (result = dns_message_firstname(msg, DNS_SECTION_QUESTION); for (result = dns_message_firstname(msg, DNS_SECTION_QUESTION);