From: Lennart Poettering Date: Thu, 19 Jun 2025 16:28:16 +0000 (+0200) Subject: resolved: make bypass tests work X-Git-Tag: v258-rc1~285^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F37902%2Fhead;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/resolve/test-dns-query.c b/src/resolve/test-dns-query.c index 083cc6d7005..3bcb6e0e78e 100644 --- a/src/resolve/test-dns-query.c +++ b/src/resolve/test-dns-query.c @@ -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);