]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: tests for dns_packet_extract(); check handling of self-referential compress...
authorJames Coglan <james@neighbourhood.ie>
Mon, 10 Jun 2024 13:46:55 +0000 (14:46 +0100)
committerJames Coglan <james@neighbourhood.ie>
Mon, 22 Jul 2024 08:53:17 +0000 (09:53 +0100)
src/resolve/test-dns-packet-extract.c

index 0b7f9e45a4603b46ea27d59940467f2bbc24f7dd..14de04b806a05770eb119d889b1b41e4a2bbe0b3 100644 (file)
@@ -935,6 +935,30 @@ TEST(packet_query_bad_compression_5) {
         ASSERT_EQ(dns_answer_size(packet->answer), 0u);
 }
 
+TEST(packet_query_bad_compression_6) {
+        _cleanup_(dns_packet_unrefp) DnsPacket *packet = NULL;
+
+        ASSERT_OK(dns_packet_new(&packet, DNS_PROTOCOL_DNS, 0, DNS_PACKET_SIZE_MAX));
+        ASSERT_NOT_NULL(packet);
+        dns_packet_truncate(packet, 0);
+
+        const uint8_t data[] = {
+                        0x00, 0x2a,     0x01, 0x00,
+                        0x00, 0x01,     0x00, 0x00,     0x00, 0x00,     0x00, 0x00,
+
+        /* name */      0x03, 'w', 'w', 'w',
+                        0xc0, 0x0c,     /* points at the current name */
+        /* A */         0x00, 0x01,
+        /* IN */        0x00, 0x01
+        };
+
+        ASSERT_OK(dns_packet_append_blob(packet, data, sizeof(data), NULL));
+
+        ASSERT_ERROR(dns_packet_extract(packet), EBADMSG);
+        ASSERT_EQ(dns_question_size(packet->question), 0u);
+        ASSERT_EQ(dns_answer_size(packet->answer), 0u);
+}
+
 /* ================================================================
  * reply: A
  * ================================================================ */