[systemd-commits] 2 commits - src/resolve
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Jul 31 09:42:08 PDT 2014
src/resolve/resolved-dns-packet.c | 32 ++++++++++++++++++++++++++++++++
src/resolve/resolved-dns-rr.c | 33 +++++++++++++++++++++++++++++++--
src/resolve/resolved-dns-rr.h | 8 +++++++-
3 files changed, 70 insertions(+), 3 deletions(-)
New commits:
commit fd0b4602f6332c3f1660eb208c8f5c719709a009
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 31 18:41:54 2014 +0200
resolved: properly compare RRs we cannot parse
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index 04004de..6cb4ed9 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -330,7 +330,10 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor
if (r <= 0)
return r;
- switch (a->key->type) {
+ if (a->unparseable != b->unparseable)
+ return 0;
+
+ switch (a->unparseable ? _DNS_TYPE_INVALID : a->key->type) {
case DNS_TYPE_SRV:
r = dns_name_equal(a->srv.name, b->srv.name);
commit 42cc2eebb01056beb7acd3ecfe8e533558237f84
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Jul 31 18:41:41 2014 +0200
resolved: properly process SSHFP RRs
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 024ab0d..3eda803 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -617,6 +617,16 @@ int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *star
break;
case DNS_TYPE_SSHFP:
+ r = dns_packet_append_uint8(p, rr->sshfp.algorithm, NULL);
+ if (r < 0)
+ goto fail;
+ r = dns_packet_append_uint8(p, rr->sshfp.fptype, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_append_blob(p, rr->sshfp.key, rr->sshfp.key_size, NULL);
+ break;
+
case _DNS_TYPE_INVALID: /* unparseable */
default:
@@ -1100,6 +1110,28 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
}
case DNS_TYPE_SSHFP:
+
+ r = dns_packet_read_uint8(p, &rr->sshfp.algorithm, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_read_uint8(p, &rr->sshfp.fptype, NULL);
+ if (r < 0)
+ goto fail;
+
+ r = dns_packet_read(p, rdlength - 2, &d, NULL);
+ if (r < 0)
+ goto fail;
+
+ rr->sshfp.key = memdup(d, rdlength - 2);
+ if (!rr->sshfp.key) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ rr->sshfp.key_size = rdlength - 2;
+ break;
+
default:
r = dns_packet_read(p, rdlength, &d, NULL);
if (r < 0)
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index 9ef3135..04004de 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -265,6 +265,10 @@ DnsResourceRecord* dns_resource_record_unref(DnsResourceRecord *rr) {
free(rr->mx.exchange);
break;
+ case DNS_TYPE_SSHFP:
+ free(rr->sshfp.key);
+ break;
+
case DNS_TYPE_LOC:
case DNS_TYPE_A:
case DNS_TYPE_AAAA:
@@ -393,6 +397,12 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor
a->loc.longitude == b->loc.longitude &&
a->loc.altitude == b->loc.altitude;
+ case DNS_TYPE_SSHFP:
+ return a->sshfp.algorithm == b->sshfp.algorithm &&
+ a->sshfp.fptype == b->sshfp.fptype &&
+ a->sshfp.key_size == b->sshfp.key_size &&
+ memcmp(a->sshfp.key, b->sshfp.key, a->sshfp.key_size) == 0;
+
default:
return a->generic.size == b->generic.size &&
memcmp(a->generic.data, b->generic.data, a->generic.size) == 0;
@@ -430,7 +440,6 @@ static char* format_location(uint32_t latitude, uint32_t longitude, uint32_t alt
return s;
}
-
int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) {
_cleanup_free_ char *k = NULL;
char *s;
@@ -555,6 +564,23 @@ int dns_resource_record_to_string(const DnsResourceRecord *rr, char **ret) {
break;
}
+ case DNS_TYPE_SSHFP: {
+ _cleanup_free_ char *x = NULL;
+
+ x = hexmem(rr->sshfp.key, rr->sshfp.key_size);
+ if (!x)
+ return -ENOMEM;
+
+ r = asprintf(&s, "%s %u %u %s",
+ k,
+ rr->sshfp.algorithm,
+ rr->sshfp.fptype,
+ x);
+ if (r < 0)
+ return -ENOMEM;
+ break;
+ }
+
default: {
_cleanup_free_ char *x = NULL;
diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h
index a001433..61c00d5 100644
--- a/src/resolve/resolved-dns-rr.h
+++ b/src/resolve/resolved-dns-rr.h
@@ -55,7 +55,6 @@ enum {
DNS_TYPE_SRV = 0x21,
DNS_TYPE_DNAME = 0x27,
DNS_TYPE_SSHFP = 0x2C,
-
DNS_TYPE_SPF = 0x63,
/* Special records */
@@ -138,6 +137,13 @@ struct DnsResourceRecord {
uint32_t longitude;
uint32_t altitude;
} loc;
+
+ struct {
+ uint8_t algorithm;
+ uint8_t fptype;
+ void *key;
+ size_t key_size;
+ } sshfp;
};
};
More information about the systemd-commits
mailing list