]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: make bypass tests work 37902/head
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Jun 2025 16:28:16 +0000 (18:28 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 19 Jun 2025 16:30:06 +0000 (18:30 +0200)
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.

src/resolve/test-dns-query.c

index 083cc6d7005e9ca0781d8ab3b9f0ca5290761aab..3bcb6e0e78e20441c0de3711da837e05a1618aa1 100644 (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);