summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/resolve/dns-type.h15
-rw-r--r--src/resolve/resolved-dns-cache.c20
-rw-r--r--src/resolve/resolved-dns-packet.c2
-rw-r--r--src/resolve/resolved-dns-zone.c4
4 files changed, 23 insertions, 18 deletions
diff --git a/src/resolve/dns-type.h b/src/resolve/dns-type.h
index deb89e9b7e..bea0adaa16 100644
--- a/src/resolve/dns-type.h
+++ b/src/resolve/dns-type.h
@@ -23,13 +23,6 @@
#include "macro.h"
-const char *dns_type_to_string(int type);
-int dns_type_from_string(const char *s);
-
-bool dns_type_is_pseudo(uint16_t type);
-bool dns_type_is_valid_query(uint16_t type);
-bool dns_type_is_valid_rr(uint16_t type);
-
/* DNS record types, taken from
* http://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml.
*/
@@ -127,12 +120,20 @@ assert_cc(DNS_TYPE_ANY == 255);
enum {
DNS_CLASS_IN = 0x01,
DNS_CLASS_ANY = 0xFF,
+
_DNS_CLASS_MAX,
_DNS_CLASS_INVALID = -1
};
+bool dns_type_is_pseudo(uint16_t type);
+bool dns_type_is_valid_query(uint16_t type);
+bool dns_type_is_valid_rr(uint16_t type);
+
bool dns_class_is_pseudo(uint16_t class);
bool dns_class_is_valid_rr(uint16_t class);
+const char *dns_type_to_string(int type);
+int dns_type_from_string(const char *s);
+
const char *dns_class_to_string(uint16_t type);
int dns_class_from_string(const char *name);
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index a8d612794c..9ad3c0e82b 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -282,6 +282,12 @@ static int dns_cache_put_positive(
assert(rr);
assert(owner_address);
+ /* Never cache pseudo RRs */
+ if (dns_class_is_pseudo(rr->key->class))
+ return 0;
+ if (dns_type_is_pseudo(rr->key->type))
+ return 0;
+
/* New TTL is 0? Delete the entry... */
if (rr->ttl <= 0) {
k = dns_cache_remove(c, rr->key);
@@ -300,11 +306,6 @@ static int dns_cache_put_positive(
return 0;
}
- if (rr->key->class == DNS_CLASS_ANY)
- return 0;
- if (dns_type_is_pseudo(rr->key->type))
- return 0;
-
/* Entry exists already? Update TTL and timestamp */
existing = dns_cache_get(c, rr);
if (existing) {
@@ -368,12 +369,15 @@ static int dns_cache_put_negative(
dns_cache_remove(c, key);
- if (key->class == DNS_CLASS_ANY)
+ /* Never cache pseudo RR keys */
+ if (dns_class_is_pseudo(key->class))
return 0;
if (dns_type_is_pseudo(key->type))
- /* ANY is particularly important to filter out as we
- * use this as a pseudo-type for NXDOMAIN entries */
+ /* DNS_TYPE_ANY is particularly important to filter
+ * out as we use this as a pseudo-type for NXDOMAIN
+ * entries */
return 0;
+
if (soa_ttl <= 0) {
if (log_get_max_level() >= LOG_DEBUG) {
r = dns_resource_key_to_string(key, &key_str);
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index e8f570555b..bb299462a7 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -1531,7 +1531,7 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
if (r < 0)
goto fail;
- if (key->class == DNS_CLASS_ANY ||
+ if (!dns_class_is_valid_rr(key->class)||
!dns_type_is_valid_rr(key->type)) {
r = -EBADMSG;
goto fail;
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
index 0ddf2be8b3..20c8a4da90 100644
--- a/src/resolve/resolved-dns-zone.c
+++ b/src/resolve/resolved-dns-zone.c
@@ -223,9 +223,9 @@ int dns_zone_put(DnsZone *z, DnsScope *s, DnsResourceRecord *rr, bool probe) {
assert(s);
assert(rr);
- if (rr->key->class == DNS_CLASS_ANY)
+ if (dns_class_is_pseudo(rr->key->class))
return -EINVAL;
- if (rr->key->type == DNS_TYPE_ANY)
+ if (dns_type_is_pseudo(rr->key->type))
return -EINVAL;
existing = dns_zone_get(z, rr);