resolved: make bypass tests work

It's not sufficient to append a DNS key to a packet, we must also update
the qdcount too. We got this right in most tests but didn#t here.
Moreover, we must extract the packet then to actually have a DnsQuestion
properly filled in.

Fix that. Without this the tests didn't test anything reasonable.
This commit is contained in:
Lennart Poettering
2025-06-19 18:30:06 +02:00
parent 576a2bc79b
commit 884fb39f33
+4
View File
@@ -128,6 +128,8 @@ TEST(dns_query_new_bypass_ok) {
ASSERT_NOT_NULL(question);
ASSERT_OK(dns_packet_append_question(packet, question));
DNS_PACKET_HEADER(packet)->qdcount = htobe16(dns_question_size(question));
ASSERT_OK(dns_packet_extract(packet));
ASSERT_OK(dns_query_new(&manager, &query, NULL, NULL, packet, 1, 0));
ASSERT_NOT_NULL(query);
@@ -146,6 +148,8 @@ TEST(dns_query_new_bypass_conflict) {
ASSERT_NOT_NULL(question);
ASSERT_OK(dns_packet_append_question(packet, question));
DNS_PACKET_HEADER(packet)->qdcount = htobe16(dns_question_size(question));
ASSERT_OK(dns_packet_extract(packet));
ASSERT_OK(dns_question_new_address(&extra_q, AF_INET, "www.example.com", false));
ASSERT_NOT_NULL(extra_q);