From: Mark Andrews Date: Wed, 11 Mar 2020 02:55:14 +0000 (+1100) Subject: Report opcode mismatch X-Git-Tag: v9.11.18~28^2~1 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=b81b37b64546b18d8b975d3cee3ddab2859c434f;p=thirdparty%2Fbind9.git Report opcode mismatch (cherry picked from commit bb7576cc9bbb98c75f3783dbb6f47bdba2516c20) --- diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 77a17c88c05..61b00b00768 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -4017,6 +4018,33 @@ recv_done(isc_task_t *task, isc_event_t *event) { UNLOCK_LOOKUP; return; } + if (msg->opcode != l->opcode) { + isc_buffer_t bb; + char expect[20] = { 0 }, got[20] = { 0 }; + + isc_buffer_init(&bb, &expect, sizeof(expect)); + result = dns_opcode_totext(l->opcode, &bb); + check_result(result, "dns_opcode_totext"); + + isc_buffer_init(&bb, &got, sizeof(got)); + result = dns_opcode_totext(msg->opcode, &bb); + check_result(result, "dns_opcode_totext"); + + printf(";; 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) { match = true; for (result = dns_message_firstname(msg, DNS_SECTION_QUESTION);