Skip to content

Commit d0129dd

Browse files
committed
resolved: refuse doing queries for known-obsolete RR types
Given how fragile DNS servers are with some DNS types, and given that we really should avoid confusing them with known-weird lookups, refuse doing lookups for known-obsolete RR types.
1 parent 274b874 commit d0129dd

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

src/resolve/dns-type.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,33 @@ bool dns_type_is_dnssec(uint16_t type) {
124124
DNS_TYPE_NSEC3PARAM);
125125
}
126126

127+
bool dns_type_is_obsolete(uint16_t type) {
128+
return IN_SET(type,
129+
/* Obsoleted by RFC 973 */
130+
DNS_TYPE_MD,
131+
DNS_TYPE_MF,
132+
DNS_TYPE_MAILA,
133+
134+
/* Kinda obsoleted by RFC 2505 */
135+
DNS_TYPE_MB,
136+
DNS_TYPE_MG,
137+
DNS_TYPE_MR,
138+
DNS_TYPE_MINFO,
139+
DNS_TYPE_MAILB,
140+
141+
/* RFC1127 kinda obsoleted this by recommending against its use */
142+
DNS_TYPE_WKS,
143+
144+
/* Declared historical by RFC 6563 */
145+
DNS_TYPE_A6,
146+
147+
/* Obsoleted by DNSSEC-bis */
148+
DNS_TYPE_NXT,
149+
150+
/* RFC 1035 removed support for concepts that needed this from RFC 883 */
151+
DNS_TYPE_NULL);
152+
}
153+
127154
const char *dns_class_to_string(uint16_t class) {
128155

129156
switch (class) {

src/resolve/dns-type.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ bool dns_type_is_valid_query(uint16_t type);
130130
bool dns_type_is_valid_rr(uint16_t type);
131131
bool dns_type_may_redirect(uint16_t type);
132132
bool dns_type_is_dnssec(uint16_t type);
133+
bool dns_type_is_obsolete(uint16_t type);
133134

134135
bool dns_class_is_pseudo(uint16_t class);
135136
bool dns_class_is_valid_rr(uint16_t class);

src/resolve/resolved-bus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,8 @@ static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd
563563

564564
if (!dns_type_is_valid_query(type))
565565
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid RR type for query %" PRIu16, type);
566+
if (dns_type_is_obsolete(type))
567+
return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, "Specified DNS RR type %" PRIu16 " is obsolete.", type);
566568

567569
r = check_ifindex_flags(ifindex, &flags, 0, error);
568570
if (r < 0)

src/resolve/resolved-dns-transaction.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key)
138138
/* Don't allow looking up invalid or pseudo RRs */
139139
if (!dns_type_is_valid_query(key->type))
140140
return -EINVAL;
141+
if (dns_type_is_obsolete(key->type))
142+
return -EOPNOTSUPP;
141143

142144
/* We only support the IN class */
143145
if (key->class != DNS_CLASS_IN && key->class != DNS_CLASS_ANY)

0 commit comments

Comments
 (0)