From d09e892285c2f445d31b57785051e5b6dd3a905e Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Wed, 16 Dec 2015 12:02:53 +0100 Subject: [PATCH] Convert rr_dict with missing rdata to wire format In wireformat this then means no rdata. This is needed with the zonecut indicating DSes returned in the validation chain. --- src/dnssec.c | 2 +- src/rr-dict.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dnssec.c b/src/dnssec.c index b31643b6..59537391 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -2777,7 +2777,7 @@ static int chain_head_validate_with_ta(struct mem_funcs *mf, if ((s = chain_node_get_trusted_keys( mf, now, skew, head->parent, ta, &keys)) != GETDNS_DNSSEC_SECURE) - return s; + return s; if (rrset_has_rrs(&head->rrset)) { if ((keytag = a_key_signed_rrset( diff --git a/src/rr-dict.c b/src/rr-dict.c index 4fe30794..fe4af1ca 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -762,11 +762,11 @@ _getdns_rr_dict2wire(getdns_dict *rr_dict, gldns_buffer *buf) assert(buf); if ((r = getdns_dict_get_bindata(rr_dict, "name", &name))) - goto error; + return r; gldns_buffer_write(buf, name->data, name->size); if ((r = getdns_dict_get_int(rr_dict, "type", &rr_type))) - goto error; + return r; gldns_buffer_write_u16(buf, (uint16_t)rr_type); (void) getdns_dict_get_int(rr_dict, "class", &rr_class); @@ -787,10 +787,13 @@ _getdns_rr_dict2wire(getdns_dict *rr_dict, gldns_buffer *buf) break; } - if ((r = getdns_dict_get_dict(rr_dict, "rdata", &rdata))) - goto error; + if ((r = getdns_dict_get_dict(rr_dict, "rdata", &rdata))) { + if (r == GETDNS_RETURN_NO_SUCH_DICT_NAME) { + gldns_buffer_write_u16(buf, 0); + r = GETDNS_RETURN_GOOD; + } - if (n_rdata_fields == 0 && GETDNS_RETURN_GOOD == + } else if (n_rdata_fields == 0 && GETDNS_RETURN_GOOD == (r = getdns_dict_get_bindata(rdata, "rdata_raw", &rdata_raw))) { gldns_buffer_write_u16(buf, (uint16_t)rdata_raw->size); @@ -829,7 +832,6 @@ _getdns_rr_dict2wire(getdns_dict *rr_dict, gldns_buffer *buf) gldns_buffer_write_u16_at(buf, rdata_size_mark, (uint16_t)(gldns_buffer_position(buf)-rdata_size_mark-2)); } -error: return r; }