[systemd-commits] 3 commits - src/resolve
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Jul 29 17:06:39 PDT 2014
src/resolve/resolved-dns-packet.c | 6 +++
src/resolve/resolved-dns-zone.c | 75 ++++++++++++++++++++++++++++++--------
2 files changed, 67 insertions(+), 14 deletions(-)
New commits:
commit d532366133a29136ad2dd95cb9268c7bbbb4d3ee
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jul 30 02:06:09 2014 +0200
resolved: respond to ANY queries from our zone
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
index 12a8512..65dc177 100644
--- a/src/resolve/resolved-dns-zone.c
+++ b/src/resolve/resolved-dns-zone.c
@@ -194,9 +194,9 @@ int dns_zone_put(DnsZone *z, DnsResourceRecord *rr) {
int dns_zone_lookup(DnsZone *z, DnsQuestion *q, DnsAnswer **ret) {
_cleanup_(dns_answer_unrefp) DnsAnswer *answer = NULL;
- int r;
- unsigned i, n = 0;
bool has_other_rrs = false;
+ unsigned i, n = 0;
+ int r;
assert(z);
assert(q);
@@ -210,16 +210,39 @@ int dns_zone_lookup(DnsZone *z, DnsQuestion *q, DnsAnswer **ret) {
for (i = 0; i < q->n_keys; i++) {
DnsZoneItem *j;
- j = hashmap_get(z->by_key, q->keys[i]);
- if (!j) {
- if (hashmap_get(z->by_name, DNS_RESOURCE_KEY_NAME(q->keys[i])))
+ if (q->keys[i]->type == DNS_TYPE_ANY ||
+ q->keys[i]->class == DNS_CLASS_ANY) {
+ int k;
+
+ /* If this is a generic match, then we have to
+ * go through the list by the name and look
+ * for everything manually */
+
+ j = hashmap_get(z->by_name, DNS_RESOURCE_KEY_NAME(q->keys[i]));
+ LIST_FOREACH(by_name, j, j) {
has_other_rrs = true;
- continue;
- }
+ k = dns_resource_key_match_rr(q->keys[i], j->rr);
+ if (k < 0)
+ return k;
+ if (k == 0)
+ continue;
+
+ n++;
+ }
+
+ } else {
+ j = hashmap_get(z->by_key, q->keys[i]);
+ if (!j) {
+ if (hashmap_get(z->by_name, DNS_RESOURCE_KEY_NAME(q->keys[i])))
+ has_other_rrs = true;
- LIST_FOREACH(by_name, j, j)
- n++;
+ continue;
+ }
+
+ LIST_FOREACH(by_key, j, j)
+ n++;
+ }
}
if (n <= 0) {
@@ -234,11 +257,30 @@ int dns_zone_lookup(DnsZone *z, DnsQuestion *q, DnsAnswer **ret) {
for (i = 0; i < q->n_keys; i++) {
DnsZoneItem *j;
- j = hashmap_get(z->by_key, q->keys[i]);
- LIST_FOREACH(by_key, j, j) {
- r = dns_answer_add(answer, j->rr);
- if (r < 0)
- return r;
+ if (q->keys[i]->type == DNS_TYPE_ANY ||
+ q->keys[i]->class == DNS_CLASS_ANY) {
+ int k;
+
+ j = hashmap_get(z->by_name, DNS_RESOURCE_KEY_NAME(q->keys[i]));
+ LIST_FOREACH(by_name, j, j) {
+ k = dns_resource_key_match_rr(q->keys[i], j->rr);
+ if (k < 0)
+ return k;
+ if (k == 0)
+ continue;
+
+ r = dns_answer_add(answer, j->rr);
+ if (r < 0)
+ return r;
+ }
+ } else {
+
+ j = hashmap_get(z->by_key, q->keys[i]);
+ LIST_FOREACH(by_key, j, j) {
+ r = dns_answer_add(answer, j->rr);
+ if (r < 0)
+ return r;
+ }
}
}
commit 0e2bcd6a1783008a94bdef4c828c5f8e0eba1706
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jul 30 02:05:23 2014 +0200
resolved: don't accept messages with ANY RRs
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 5eaee2c..1636362 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -868,6 +868,12 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
if (r < 0)
goto fail;
+ if (key->class == DNS_CLASS_ANY ||
+ key->type == DNS_TYPE_ANY) {
+ r = -EBADMSG;
+ goto fail;
+ }
+
rr = dns_resource_record_new(key);
if (!rr) {
r = -ENOMEM;
commit 1d3b690fbd9a89491d938188582a8031d91ebbc8
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Jul 30 02:04:07 2014 +0200
resolved: don't allow adding of ANY class/type RRs to local zones
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
index 2325ddf..12a8512 100644
--- a/src/resolve/resolved-dns-zone.c
+++ b/src/resolve/resolved-dns-zone.c
@@ -165,6 +165,11 @@ int dns_zone_put(DnsZone *z, DnsResourceRecord *rr) {
assert(z);
assert(rr);
+ if (rr->key->class == DNS_CLASS_ANY)
+ return -EINVAL;
+ if (rr->key->type == DNS_TYPE_ANY)
+ return -EINVAL;
+
existing = dns_zone_get(z, rr);
if (existing)
return 0;
More information about the systemd-commits
mailing list