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.
This commit is contained in:
Willem Toorop 2015-12-16 12:02:53 +01:00
parent 2c2359af61
commit d09e892285
2 changed files with 9 additions and 7 deletions

View File

@ -2777,7 +2777,7 @@ static int chain_head_validate_with_ta(struct mem_funcs *mf,
if ((s = chain_node_get_trusted_keys( if ((s = chain_node_get_trusted_keys(
mf, now, skew, head->parent, ta, &keys)) != GETDNS_DNSSEC_SECURE) mf, now, skew, head->parent, ta, &keys)) != GETDNS_DNSSEC_SECURE)
return s; return s;
if (rrset_has_rrs(&head->rrset)) { if (rrset_has_rrs(&head->rrset)) {
if ((keytag = a_key_signed_rrset( if ((keytag = a_key_signed_rrset(

View File

@ -762,11 +762,11 @@ _getdns_rr_dict2wire(getdns_dict *rr_dict, gldns_buffer *buf)
assert(buf); assert(buf);
if ((r = getdns_dict_get_bindata(rr_dict, "name", &name))) if ((r = getdns_dict_get_bindata(rr_dict, "name", &name)))
goto error; return r;
gldns_buffer_write(buf, name->data, name->size); gldns_buffer_write(buf, name->data, name->size);
if ((r = getdns_dict_get_int(rr_dict, "type", &rr_type))) if ((r = getdns_dict_get_int(rr_dict, "type", &rr_type)))
goto error; return r;
gldns_buffer_write_u16(buf, (uint16_t)rr_type); gldns_buffer_write_u16(buf, (uint16_t)rr_type);
(void) getdns_dict_get_int(rr_dict, "class", &rr_class); (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; break;
} }
if ((r = getdns_dict_get_dict(rr_dict, "rdata", &rdata))) if ((r = getdns_dict_get_dict(rr_dict, "rdata", &rdata))) {
goto error; 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))) { (r = getdns_dict_get_bindata(rdata, "rdata_raw", &rdata_raw))) {
gldns_buffer_write_u16(buf, (uint16_t)rdata_raw->size); 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, gldns_buffer_write_u16_at(buf, rdata_size_mark,
(uint16_t)(gldns_buffer_position(buf)-rdata_size_mark-2)); (uint16_t)(gldns_buffer_position(buf)-rdata_size_mark-2));
} }
error:
return r; return r;
} }