shared: fix DNS RR wire cache and EFI boot option bounds checks (#42926)

Invalidate cached DNS RR wire format when
`dns_resource_record_clamp_ttl()` updates `rr->ttl` in place.
Validate each EFI `Boot####` device-path node length before reading
subtype-specific fields.
This commit is contained in:
Lennart Poettering
2026-07-09 11:00:29 +02:00
committed by GitHub
5 changed files with 42 additions and 8 deletions
+6 -1
View File
@@ -554,7 +554,12 @@ static void dnssec_fix_rrset_ttl(
/* Pick the TTL as the minimum of the RR's TTL, the
* RR's original TTL according to the RRSIG and the
* RRSIG's own TTL, see RFC 4035, Section 5.3.3 */
rr->ttl = MIN3(rr->ttl, rrsig->rrsig.original_ttl, rrsig->ttl);
uint32_t ttl = MIN3(rr->ttl, rrsig->rrsig.original_ttl, rrsig->ttl);
if (ttl != rr->ttl) {
rr->ttl = ttl;
dns_resource_record_clear_wire_format(rr);
}
rr->expiry = rrsig->rrsig.expiration * USEC_PER_SEC;
/* Copy over information about the signer and wildcard source of synthesis */
+11
View File
@@ -2467,18 +2467,29 @@ TEST(dns_resource_record_is_synthetic) {
* ================================================================ */
TEST(dns_resource_record_clamp_ttl_in_place) {
_cleanup_free_ void *wire_format = NULL;
DnsResourceRecord *rr = NULL, *orig = NULL;
size_t wire_format_size;
rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_A, "www.example.com");
ASSERT_NOT_NULL(rr);
orig = rr;
rr->ttl = 3600;
rr->a.in_addr.s_addr = htobe32(0xc0a8017f);
ASSERT_FALSE(dns_resource_record_clamp_ttl(&rr, 4800));
ASSERT_EQ(rr->ttl, 3600u);
ASSERT_OK(dns_resource_record_to_wire_format(rr, false));
ASSERT_NOT_NULL(rr->wire_format);
wire_format_size = rr->wire_format_size;
ASSERT_NOT_NULL(wire_format = memdup(rr->wire_format, wire_format_size));
ASSERT_TRUE(dns_resource_record_clamp_ttl(&rr, 2400));
ASSERT_EQ(rr->ttl, 2400u);
ASSERT_OK(dns_resource_record_to_wire_format(rr, false));
ASSERT_EQ(rr->wire_format_size, wire_format_size);
ASSERT_NE(memcmp(rr->wire_format, wire_format, wire_format_size), 0);
ASSERT_TRUE(rr == orig);