#include "dns-type.h"
#include "escape.h"
#include "hexdecoct.h"
+#include "memory-util.h"
#include "resolved-dns-dnssec.h"
#include "resolved-dns-packet.h"
#include "resolved-dns-rr.h"
return 0;
}
- r = dns_name_concat(dns_resource_key_name(key), name, &joined);
+ r = dns_name_concat(dns_resource_key_name(key), name, 0, &joined);
if (r < 0)
return r;
if (search_domain) {
_cleanup_free_ char *joined = NULL;
- r = dns_name_concat(dns_resource_key_name(key), search_domain, &joined);
+ r = dns_name_concat(dns_resource_key_name(key), search_domain, 0, &joined);
if (r < 0)
return r;
if (search_domain) {
_cleanup_free_ char *joined = NULL;
- r = dns_name_concat(dns_resource_key_name(key), search_domain, &joined);
+ r = dns_name_concat(dns_resource_key_name(key), search_domain, 0, &joined);
if (r < 0)
return r;
#define FIELD_EQUAL(a, b, field) \
((a).field ## _size == (b).field ## _size && \
- memcmp((a).field, (b).field, (a).field ## _size) == 0)
+ memcmp_safe((a).field, (b).field, (a).field ## _size) == 0)
-int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecord *b) {
+int dns_resource_record_payload_equal(const DnsResourceRecord *a, const DnsResourceRecord *b) {
int r;
- assert(a);
- assert(b);
-
- if (a == b)
- return 1;
-
- r = dns_resource_key_equal(a->key, b->key);
- if (r <= 0)
- return r;
+ /* Check if a and b are the same, but don't look at their keys */
if (a->unparseable != b->unparseable)
return 0;
}
}
+int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecord *b) {
+ int r;
+
+ assert(a);
+ assert(b);
+
+ if (a == b)
+ return 1;
+
+ r = dns_resource_key_equal(a->key, b->key);
+ if (r <= 0)
+ return r;
+
+ return dns_resource_record_payload_equal(a, b);
+}
+
static char* format_location(uint32_t latitude, uint32_t longitude, uint32_t altitude,
uint8_t size, uint8_t horiz_pre, uint8_t vert_pre) {
char *s;
case DNS_TYPE_DNSKEY: {
_cleanup_free_ char *alg = NULL;
char *ss;
- int n;
uint16_t key_tag;
key_tag = dnssec_keytag(rr, true);
if (r < 0)
return NULL;
- r = asprintf(&s, "%s %u %u %s %n",
+ r = asprintf(&s, "%s %u %u %s",
k,
rr->dnskey.flags,
rr->dnskey.protocol,
- alg,
- &n);
+ alg);
if (r < 0)
return NULL;
- r = base64_append(&s, n,
+ r = base64_append(&s, r,
rr->dnskey.key, rr->dnskey.key_size,
8, columns());
if (r < 0)
_cleanup_free_ char *alg = NULL;
char expiration[STRLEN("YYYYMMDDHHmmSS") + 1], inception[STRLEN("YYYYMMDDHHmmSS") + 1];
const char *type;
- int n;
type = dns_type_to_string(rr->rrsig.type_covered);
/* TYPE?? follows
* http://tools.ietf.org/html/rfc3597#section-5 */
- r = asprintf(&s, "%s %s%.*u %s %u %u %s %s %u %s %n",
+ r = asprintf(&s, "%s %s%.*u %s %u %u %s %s %u %s",
k,
type ?: "TYPE",
type ? 0 : 1, type ? 0u : (unsigned) rr->rrsig.type_covered,
expiration,
inception,
rr->rrsig.key_tag,
- rr->rrsig.signer,
- &n);
+ rr->rrsig.signer);
if (r < 0)
return NULL;
- r = base64_append(&s, n,
+ r = base64_append(&s, r,
rr->rrsig.signature, rr->rrsig.signature_size,
8, columns());
if (r < 0)
}
case DNS_TYPE_OPENPGPKEY: {
- int n;
-
- r = asprintf(&s, "%s %n",
- k,
- &n);
+ r = asprintf(&s, "%s", k);
if (r < 0)
return NULL;
- r = base64_append(&s, n,
+ r = base64_append(&s, r,
rr->generic.data, rr->generic.data_size,
8, columns());
if (r < 0)