Skip to content

Commit

Permalink
Merge pull request systemd#33523 from neighbourhoodie/fix/dns-opt-ext…
Browse files Browse the repository at this point in the history
…ended-rcode

Fix DNS OPT extended rcode parsing
  • Loading branch information
bluca authored Jul 1, 2024
2 parents ba490e2 + c40f371 commit aedc4f7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/resolve/resolved-dns-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1804,9 +1804,9 @@ int dns_packet_read_rr(
if (r < 0)
return r;

/* RFC 2181, Section 8, suggests to
* treat a TTL with the MSB set as a zero TTL. */
if (rr->ttl & UINT32_C(0x80000000))
/* RFC 2181, Section 8, suggests to treat a TTL with the MSB set as a zero TTL. We avoid doing this
* for OPT records so that all 8 bits of the extended RCODE may be used .*/
if (key->type != DNS_TYPE_OPT && rr->ttl & UINT32_C(0x80000000))
rr->ttl = 0;

r = dns_packet_read_uint16(p, &rdlength, NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/resolve/resolved-dns-packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static inline uint16_t DNS_PACKET_RCODE(DnsPacket *p) {
uint16_t rcode;

if (p->opt)
rcode = (uint16_t) (p->opt->ttl >> 24);
rcode = (uint16_t) ((p->opt->ttl >> 20) & 0xFF0);
else
rcode = 0;

Expand Down

0 comments on commit aedc4f7

Please sign in to comment.