]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: make bypass tests work
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Jun 2025 16:28:16 +0000 (18:28 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 25 Jun 2025 12:36:10 +0000 (13:36 +0100)
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.

(cherry picked from commit 884fb39f33d098e15fad7647bbeef0a5569402cb)

src/resolve/test-dns-query.c

index 53c45884744a7c91cc32a6db20deb05f6dcc2ad4..fac00b8073b7499905e9e9f659e7c3ddd4fb130d 100644 (file)
@@ -122,6 +122,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);
@@ -140,6 +142,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);