From dd836b2a117cdc6a09ae39157861c0d24008f7a7 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 3 Dec 2015 14:54:38 +0100 Subject: [PATCH 01/18] Conversion functions prototypes --- src/getdns/getdns_extra.h.in | 16 ++++++++++++++++ src/libgetdns.symbols | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/getdns/getdns_extra.h.in b/src/getdns/getdns_extra.h.in index da6c35e2..793725e8 100644 --- a/src/getdns/getdns_extra.h.in +++ b/src/getdns/getdns_extra.h.in @@ -402,6 +402,22 @@ getdns_context_get_tls_authentication(getdns_context *context, #define GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN 546 #define GETDNS_TRANSPORT_STARTTLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()" +getdns_return_t +getdns_rr_dict2wire( + const getdns_dict *rr_dict, uint8_t *wire, size_t *wire_sz); + +getdns_return_t +getdns_wire2rr_dict( + const uint8_t *wire, size_t wire_sz, getdns_dict **rr_dict); + +getdns_return_t +getdns_rr_dict2str( + const getdns_dict *rr_dict, char *str, size_t *str_sz); + +getdns_return_t +getdns_str2rr_dict( + const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl); + #ifdef __cplusplus } #endif diff --git a/src/libgetdns.symbols b/src/libgetdns.symbols index dad7cc2f..2983f1fc 100644 --- a/src/libgetdns.symbols +++ b/src/libgetdns.symbols @@ -13,7 +13,6 @@ getdns_context_get_dnssec_allowed_skew getdns_context_get_dnssec_trust_anchors getdns_context_get_dns_transport getdns_context_get_dns_transport_list -getdns_context_get_tls_authentication getdns_context_get_edns_client_subnet_private getdns_context_get_edns_do_bit getdns_context_get_edns_extended_rcode @@ -27,6 +26,7 @@ getdns_context_get_num_pending_requests getdns_context_get_resolution_type getdns_context_get_suffix getdns_context_get_timeout +getdns_context_get_tls_authentication getdns_context_get_tls_query_padding_blocksize getdns_context_get_update_callback getdns_context_get_upstream_recursive_servers @@ -114,11 +114,15 @@ getdns_pretty_snprint_list getdns_print_json_dict getdns_print_json_list getdns_root_trust_anchor +getdns_rr_dict2str +getdns_rr_dict2wire getdns_service getdns_service_sync getdns_snprint_json_dict getdns_snprint_json_list +getdns_str2rr_dict getdns_strerror getdns_validate_dnssec +getdns_wire2rr_dict plain_mem_funcs_user_arg priv_getdns_context_mf From d67949d1e731b63be97ec5726cedb741507c7af5 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 7 Dec 2015 16:43:41 +0100 Subject: [PATCH 02/18] iterators go over const wireformat data --- src/context.c | 15 ++-- src/context.h | 3 +- src/dict.c | 17 +++- src/dnssec.c | 203 +++++++++++++++++++++++++------------------- src/list.c | 26 ++++-- src/rr-dict.c | 118 ++++++++++++------------- src/rr-dict.h | 10 +-- src/rr-iter.c | 49 ++++++++--- src/rr-iter.h | 33 ++++--- src/stub.c | 6 +- src/util-internal.c | 74 ++++++++-------- src/util-internal.h | 7 ++ 12 files changed, 327 insertions(+), 234 deletions(-) diff --git a/src/context.c b/src/context.c index a623cec5..b586cc2e 100644 --- a/src/context.c +++ b/src/context.c @@ -2191,7 +2191,7 @@ ub_setup_recursing(struct ub_ctx *ctx, getdns_context *context) , context->trust_anchors_len) ; rr ; rr = _getdns_rr_iter_next(rr) ) { - (void) gldns_wire2str_rr_buf(rr->pos, + (void) gldns_wire2str_rr_buf((UNCONST_UINT8_p)rr->pos, rr->nxt - rr->pos, ta_str, sizeof(ta_str)); (void) ub_ctx_add_ta(ctx, ta_str); } @@ -2379,8 +2379,7 @@ _getdns_strdup(const struct mem_funcs *mfs, const char *s) } struct getdns_bindata * -_getdns_bindata_copy(struct mem_funcs *mfs, - const struct getdns_bindata *src) +_getdns_bindata_copy(struct mem_funcs *mfs, size_t size, const uint8_t *data) { /* Don't know why, but nodata allows * empty bindatas with the python bindings @@ -2388,20 +2387,16 @@ _getdns_bindata_copy(struct mem_funcs *mfs, static uint8_t nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; struct getdns_bindata *dst; - if (!src) - return NULL; - if (!(dst = GETDNS_MALLOC(*mfs, struct getdns_bindata))) return NULL; - dst->size = src->size; - if ((dst->size = src->size)) { - dst->data = GETDNS_XMALLOC(*mfs, uint8_t, src->size); + if ((dst->size = size)) { + dst->data = GETDNS_XMALLOC(*mfs, uint8_t, size); if (!dst->data) { GETDNS_FREE(*mfs, dst); return NULL; } - (void) memcpy(dst->data, src->data, src->size); + (void) memcpy(dst->data, data, size); } else { dst->data = nodata; } diff --git a/src/context.h b/src/context.h index 1e489d2d..d888ed4d 100644 --- a/src/context.h +++ b/src/context.h @@ -240,8 +240,7 @@ getdns_return_t _getdns_context_cancel_request(struct getdns_context *context, char *_getdns_strdup(const struct mem_funcs *mfs, const char *str); struct getdns_bindata *_getdns_bindata_copy( - struct mem_funcs *mfs, - const struct getdns_bindata *src); + struct mem_funcs *mfs, size_t size, const uint8_t *data); void _getdns_bindata_destroy( struct mem_funcs *mfs, diff --git a/src/dict.c b/src/dict.c index 822d5deb..d70381b7 100644 --- a/src/dict.c +++ b/src/dict.c @@ -574,17 +574,17 @@ getdns_dict_set_list( /*---------------------------------------- getdns_dict_set_bindata */ getdns_return_t -getdns_dict_set_bindata( - getdns_dict *dict, const char *name, const getdns_bindata *child_bindata) +_getdns_dict_set_const_bindata( + getdns_dict *dict, const char *name, size_t size, const uint8_t *data) { getdns_item *item; getdns_bindata *newbindata; getdns_return_t r; - if (!dict || !name || !child_bindata) + if (!dict || !name) return GETDNS_RETURN_INVALID_PARAMETER; - if (!(newbindata = _getdns_bindata_copy(&dict->mf, child_bindata))) + if (!(newbindata = _getdns_bindata_copy(&dict->mf, size, data))) return GETDNS_RETURN_MEMORY_ERROR; if ((r = _getdns_dict_find_and_add(dict, name, &item))) { @@ -596,6 +596,15 @@ getdns_dict_set_bindata( return GETDNS_RETURN_GOOD; } /* getdns_dict_set_bindata */ +getdns_return_t +getdns_dict_set_bindata( + getdns_dict *dict, const char *name, const getdns_bindata *child_bindata) +{ + return !child_bindata ? GETDNS_RETURN_INVALID_PARAMETER + : _getdns_dict_set_const_bindata( + dict, name, child_bindata->size, child_bindata->data); +} + /*---------------------------------------- getdns_dict_set_bindata */ getdns_return_t getdns_dict_util_set_string(getdns_dict *dict, char *name, const char *value) diff --git a/src/dnssec.c b/src/dnssec.c index 3fdff91b..59de8e46 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -219,16 +219,16 @@ /******************* Frequently Used Utility Functions ********************* *****************************************************************************/ -inline static size_t _dname_len(uint8_t *name) +inline static size_t _dname_len(const uint8_t *name) { - uint8_t *p; + const uint8_t *p; for (p = name; *p; p += *p + 1) /* pass */ ; return p - name + 1; } -inline static size_t _dname_label_count(uint8_t *name) +inline static size_t _dname_label_count(const uint8_t *name) { size_t c; for (c = 0; *name; name += *name + 1, c++) @@ -267,20 +267,24 @@ static uint8_t *_dname_label_copy(uint8_t *dst, const uint8_t *src, size_t dst_l return r; } -inline static void _dname_canonicalize(uint8_t *dname) +inline void _dname_canonicalize(const uint8_t *src, uint8_t *dst) { - uint8_t *next_label; + const uint8_t *next_label; - while (*dname) { - next_label = dname + *dname + 1; - dname += 1; - while (dname < next_label) { - *dname = (uint8_t)tolower((unsigned char)*dname); - dname++; - } + while (*src) { + next_label = src + *src + 1; + *dst++ = *src++; + while (src < next_label) + *dst++ = (uint8_t)tolower((unsigned char)*src++); } } +inline void _dname_canonicalize2(uint8_t *dname) +{ + _dname_canonicalize(dname, dname); +} + + /* Fills the array pointed to by labels (of at least 128 uint8_t * pointers) * with pointers to labels in given dname in reversed order. So that * labels[0] will point to the root. @@ -294,7 +298,8 @@ inline static void _dname_canonicalize(uint8_t *dname) * labels[3] will be "www.getdnsapi.net." * The returned value will be &labels[4] */ -static uint8_t **reverse_labels(uint8_t *dname, uint8_t **labels) +static const uint8_t **reverse_labels( + const uint8_t *dname, const uint8_t **labels) { if (*dname) labels = reverse_labels(dname + *dname + 1, labels); @@ -302,10 +307,12 @@ static uint8_t **reverse_labels(uint8_t *dname, uint8_t **labels) return labels + 1; } -static uint8_t *dname_shared_parent(uint8_t *left, uint8_t *right) +static const uint8_t *dname_shared_parent( + const uint8_t *left, const uint8_t *right) { - uint8_t *llabels[128], *rlabels[128], **last_llabel, **last_rlabel, - **llabel, **rlabel, *l, *r, sz; + const uint8_t *llabels[128], *rlabels[128], **last_llabel, **last_rlabel, + **llabel, **rlabel, *l, *r; + uint8_t sz; last_llabel = reverse_labels(left, llabels); last_rlabel = reverse_labels(right, rlabels); @@ -333,10 +340,11 @@ static uint8_t *dname_shared_parent(uint8_t *left, uint8_t *right) return llabel[-1]; } -static int dname_compare(uint8_t *left, uint8_t *right) +static int dname_compare(const uint8_t *left, const uint8_t *right) { - uint8_t *llabels[128], *rlabels[128], **last_llabel, **last_rlabel, - **llabel, **rlabel, *l, *r, lsz, rsz; + const uint8_t *llabels[128], *rlabels[128], **last_llabel, **last_rlabel, + **llabel, **rlabel, *l, *r; + uint8_t lsz, rsz; last_llabel = reverse_labels(left, llabels); last_rlabel = reverse_labels(right, rlabels); @@ -373,7 +381,7 @@ static int dname_compare(uint8_t *left, uint8_t *right) static int bitmap_has_type(_getdns_rdf_iter *bitmap, uint16_t rr_type) { - uint8_t *dptr, *dend; + const uint8_t *dptr, *dend; uint8_t window = rr_type >> 8; uint8_t subtype = rr_type & 0xFF; @@ -442,9 +450,10 @@ static inline uint16_t rr_iter_class(_getdns_rr_iter *rr) { return rr->rr_type + 4 <= rr->nxt ? gldns_read_uint16(rr->rr_type + 2) : 0; } /* Utility function to compare owner name of rr with name */ -static int rr_owner_equal(_getdns_rr_iter *rr, uint8_t *name) +static int rr_owner_equal(_getdns_rr_iter *rr, const uint8_t *name) { - uint8_t owner_spc[256], *owner; + uint8_t owner_spc[256]; + const uint8_t *owner; size_t owner_len = sizeof(owner_spc); return (owner = _getdns_owner_if_or_as_decompressed(rr, owner_spc @@ -470,7 +479,7 @@ static _getdns_rr_iter *rr_iter_ansauth(_getdns_rr_iter *rr) /* Filter that only iterates over RRs with a certain name/class/type */ static _getdns_rr_iter *rr_iter_name_class_type(_getdns_rr_iter *rr, - uint8_t *name, uint16_t rr_class, uint16_t rr_type) + const uint8_t *name, uint16_t rr_class, uint16_t rr_type) { while (rr_iter_ansauth(rr) && !( rr_iter_type(rr) == rr_type && @@ -484,7 +493,7 @@ static _getdns_rr_iter *rr_iter_name_class_type(_getdns_rr_iter *rr, /* Filter that only iterates over RRs that do not have a name/class/type */ static _getdns_rr_iter *rr_iter_not_name_class_type(_getdns_rr_iter *rr, - uint8_t *name, uint16_t rr_class, uint16_t rr_type) + const uint8_t *name, uint16_t rr_class, uint16_t rr_type) { while (rr_iter_ansauth(rr) && ( rr_iter_type(rr) == GETDNS_RRTYPE_RRSIG || ( @@ -501,7 +510,7 @@ static _getdns_rr_iter *rr_iter_not_name_class_type(_getdns_rr_iter *rr, * a RRset with a certain name/class/type */ static _getdns_rr_iter *rr_iter_rrsig_covering(_getdns_rr_iter *rr, - uint8_t *name, uint16_t rr_class, uint16_t rr_type) + const uint8_t *name, uint16_t rr_class, uint16_t rr_type) { while (rr_iter_ansauth(rr) && !( rr_iter_type(rr) == GETDNS_RRTYPE_RRSIG && @@ -516,11 +525,11 @@ static _getdns_rr_iter *rr_iter_rrsig_covering(_getdns_rr_iter *rr, } typedef struct getdns_rrset { - uint8_t *name; - uint16_t rr_class; - uint16_t rr_type; - uint8_t *pkt; - size_t pkt_len; + const uint8_t *name; + uint16_t rr_class; + uint16_t rr_type; + uint8_t *pkt; + size_t pkt_len; } getdns_rrset; typedef struct rrtype_iter { @@ -764,23 +773,24 @@ struct chain_node { * to equip the chain nodes with their RR sets are done alongside construction. * Hence they need to be enumerated before the construction functions. */ -static void val_chain_sched(chain_head *head, uint8_t *dname); -static void val_chain_sched_ds(chain_head *head, uint8_t *dname); +static void val_chain_sched(chain_head *head, const uint8_t *dname); +static void val_chain_sched_ds(chain_head *head, const uint8_t *dname); static void val_chain_sched_signer(chain_head *head, rrsig_iter *rrsig); -static void val_chain_sched_soa(chain_head *head, uint8_t *dname); +static void val_chain_sched_soa(chain_head *head, const uint8_t *dname); static chain_head *add_rrset2val_chain(struct mem_funcs *mf, chain_head **chain_p, getdns_rrset *rrset, getdns_network_req *netreq) { chain_head *head; - uint8_t *labels[128], **last_label, **label; + const uint8_t *labels[128], **last_label, **label; size_t max_labels; /* max labels in common */ chain_head *max_head; chain_node *max_node; size_t dname_len, head_sz, node_count, n; - uint8_t *dname, *region; + const uint8_t *dname; + uint8_t *region; chain_node *node; last_label = reverse_labels(rrset->name, labels); @@ -906,10 +916,11 @@ static int is_synthesized_cname(getdns_rrset *cname) _getdns_rdf_iter rdf_spc, *rdf; rrtype_iter drr_spc, *drr; _getdns_rdf_iter drdf_spc, *drdf; - uint8_t cname_rdata_spc[256], *cname_rdata, - dname_rdata_spc[256], *dname_rdata, + uint8_t cname_rdata_spc[256], + dname_rdata_spc[256], synth_name[256], - *synth_name_end = synth_name + sizeof(synth_name) - 1, *s, *c; + *synth_name_end = synth_name + sizeof(synth_name) - 1, *s; + const uint8_t *cname_rdata, *dname_rdata, *c; size_t cname_rdata_len = sizeof(cname_rdata_spc), dname_rdata_len = sizeof(dname_rdata_len), cname_labels, dname_labels; @@ -1049,7 +1060,7 @@ static void add_pkt2val_chain(struct mem_funcs *mf, */ static void add_question2val_chain(struct mem_funcs *mf, chain_head **chain_p, uint8_t *pkt, size_t pkt_len, - uint8_t *qname, uint16_t qtype, uint16_t qclass, + const uint8_t *qname, uint16_t qtype, uint16_t qclass, getdns_network_req *netreq) { getdns_rrset q_rrset; @@ -1133,7 +1144,8 @@ static void val_chain_sched_soa_node(chain_node *node) context = node->chains->netreq->owner->context; loop = node->chains->netreq->owner->loop; - if (!gldns_wire2str_dname_buf(node->ds.name, 256, name, sizeof(name))) + if (!gldns_wire2str_dname_buf( + (UNCONST_UINT8_p)node->ds.name, 256, name, sizeof(name))) return; DEBUG_SEC("schedule SOA lookup for %s\n", name); @@ -1151,7 +1163,7 @@ static void val_chain_sched_soa_node(chain_node *node) * answer, then a DS/DNSKEY lookup will follow the acquire the link of the * authentication chain. */ -static void val_chain_sched_soa(chain_head *head, uint8_t *dname) +static void val_chain_sched_soa(chain_head *head, const uint8_t *dname) { chain_node *node; @@ -1180,7 +1192,8 @@ static void val_chain_sched_node(chain_node *node) context = node->chains->netreq->owner->context; loop = node->chains->netreq->owner->loop; - if (!gldns_wire2str_dname_buf(node->ds.name, 256, name, sizeof(name))) + if (!gldns_wire2str_dname_buf( + (UNCONST_UINT8_p)node->ds.name, 256, name, sizeof(name))) return; DEBUG_SEC("schedule DS & DNSKEY lookup for %s\n", name); @@ -1200,7 +1213,7 @@ static void val_chain_sched_node(chain_node *node) node->ds_req = dnsreq->netreqs[0]; } -static void val_chain_sched(chain_head *head, uint8_t *dname) +static void val_chain_sched(chain_head *head, const uint8_t *dname) { chain_node *node; @@ -1224,7 +1237,9 @@ static void val_chain_sched_ds_node(chain_node *node) context = node->chains->netreq->owner->context; loop = node->chains->netreq->owner->loop; - if (!gldns_wire2str_dname_buf(node->ds.name, 256, name, sizeof(name))) + if (!gldns_wire2str_dname_buf( + (UNCONST_UINT8_p)node->ds.name, 256, name, sizeof(name))) + return; DEBUG_SEC("schedule DS lookup for %s\n", name); @@ -1237,7 +1252,7 @@ static void val_chain_sched_ds_node(chain_node *node) node->ds_req = ds_req->netreqs[0]; } -static void val_chain_sched_ds(chain_head *head, uint8_t *dname) +static void val_chain_sched_ds(chain_head *head, const uint8_t *dname) { chain_node *node; @@ -1254,8 +1269,9 @@ static void val_chain_sched_ds(chain_head *head, uint8_t *dname) static void val_chain_sched_signer_node(chain_node *node, rrsig_iter *rrsig) { _getdns_rdf_iter rdf_spc, *rdf; - uint8_t signer_spc[256], *signer; - size_t signer_len; + uint8_t signer_spc[256]; + const uint8_t *signer; + size_t signer_len; if (!(rdf = _getdns_rdf_iter_init_at(&rdf_spc, &rrsig->rr_i, 7))) return; @@ -1369,7 +1385,8 @@ static int key_matches_signer(getdns_rrset *dnskey, getdns_rrset *rrset) rrsig_iter rrsig_spc, *rrsig; uint16_t keytag; _getdns_rdf_iter rdf_spc, *rdf; - uint8_t signer_spc[256], *signer; + uint8_t signer_spc[256]; + const uint8_t *signer; size_t signer_len = sizeof(signer_spc); assert(dnskey->rr_type == GETDNS_RRTYPE_DNSKEY); @@ -1384,8 +1401,9 @@ static int key_matches_signer(getdns_rrset *dnskey, getdns_rrset *rrset) continue; /* Then we have at least 4 bytes to calculate keytag */ - keytag = gldns_calc_keytag_raw(rr->rr_i.rr_type + 10, - rr->rr_i.nxt - rr->rr_i.rr_type - 10); + keytag = gldns_calc_keytag_raw( + (UNCONST_UINT8_p)rr->rr_i.rr_type + 10, + rr->rr_i.nxt - rr->rr_i.rr_type - 10); for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset) ; rrsig ; rrsig = rrsig_iter_next(rrsig) ) { @@ -1457,7 +1475,7 @@ typedef struct canon_rdata_iter { _getdns_rdf_iter rdf_spc; _getdns_rdf_iter *rdf; uint8_t cdname[256]; /* Canonical dname */ - uint8_t *pos; + const uint8_t *pos; size_t len; } canon_rdata_iter; @@ -1467,8 +1485,10 @@ inline static void canon_rdata_iter_field_init(canon_rdata_iter *i) if ((i->rdf->rdd_pos->type & GETDNS_RDF_N) == GETDNS_RDF_N) { i->len = sizeof(i->cdname); if ((i->pos = _getdns_rdf_if_or_as_decompressed( - i->rdf, i->cdname, &i->len))) - _dname_canonicalize(i->pos); + i->rdf, i->cdname, &i->len))) { + _dname_canonicalize(i->pos, i->cdname); + i->pos = i->cdname; + } } else { i->pos = i->rdf->pos; i->len = i->rdf->nxt - i->rdf->pos; @@ -1558,7 +1578,7 @@ static int _rr_iter_rdata_cmp(const void *a, const void *b) */ #define VAL_RRSET_SPC_SZ 1024 static int _getdns_verify_rrsig(struct mem_funcs *mf, - getdns_rrset *rrset, rrsig_iter *rrsig, rrtype_iter *key, uint8_t **nc_name) + getdns_rrset *rrset, rrsig_iter *rrsig, rrtype_iter *key, const uint8_t **nc_name) { int r; int to_skip; @@ -1568,7 +1588,8 @@ static int _getdns_verify_rrsig(struct mem_funcs *mf, size_t n_rrs, i, valbuf_sz, owner_len; _getdns_rdf_iter *signer, signer_spc, *rdf, rdf_spc; uint8_t valbuf_spc[4096], *valbuf_buf = valbuf_spc; - uint8_t cdname_spc[256], *cdname, owner[256]; + uint8_t cdname_spc[256], owner[256]; + const uint8_t *cdname; size_t cdname_len, pos; uint32_t orig_ttl; gldns_buffer valbuf; @@ -1620,12 +1641,12 @@ static int _getdns_verify_rrsig(struct mem_funcs *mf, gldns_buffer_init_frm_data(&valbuf, valbuf_buf, valbuf_sz); gldns_buffer_write(&valbuf, rrsig->rr_i.rr_type + 10, signer->nxt - rrsig->rr_i.rr_type - 10); - _dname_canonicalize(gldns_buffer_at(&valbuf, 18)); + _dname_canonicalize2(gldns_buffer_at(&valbuf, 18)); orig_ttl = gldns_read_uint32(rrsig->rr_i.rr_type + 14); (void) memcpy(owner, rrset->name, owner_len); - _dname_canonicalize(owner); + _dname_canonicalize2(owner); if (!_dnssec_rdata_to_canonicalize(rrset->rr_type)) for (i = 0; i < n_rrs; i++) { @@ -1656,7 +1677,7 @@ static int _getdns_verify_rrsig(struct mem_funcs *mf, rdf, cdname_spc, &cdname_len))) continue; gldns_buffer_write(&valbuf, cdname, cdname_len); - _dname_canonicalize( + _dname_canonicalize2( gldns_buffer_current(&valbuf) - cdname_len); } gldns_buffer_write_u16_at(&valbuf, pos, @@ -1667,8 +1688,9 @@ static int _getdns_verify_rrsig(struct mem_funcs *mf, assert(gldns_buffer_position(&valbuf) == valbuf_sz); r = _getdns_verify_canonrrset(&valbuf, key->rr_i.rr_type[13], - signer->nxt, rrsig->rr_i.nxt - signer->nxt, - key->rr_i.rr_type+14, key->rr_i.nxt - key->rr_i.rr_type-14, + (UNCONST_UINT8_p)signer->nxt, rrsig->rr_i.nxt - signer->nxt, + (UNCONST_UINT8_p)key->rr_i.rr_type+14, + key->rr_i.nxt - key->rr_i.rr_type-14, &reason); #if defined(SEC_DEBUG) && SEC_DEBUG @@ -1710,7 +1732,8 @@ static int _getdns_verify_rrsig(struct mem_funcs *mf, /* Calculates NSEC3 hash for name, and stores that into label */ static uint8_t *_getdns_nsec3_hash_label(uint8_t *label, size_t label_len, - uint8_t *name, uint8_t algorithm, uint16_t iterations, uint8_t *salt) + const uint8_t *name, uint8_t algorithm, + uint16_t iterations, const uint8_t *salt) { uint8_t buf[512], *dst, *eob; const uint8_t *src; @@ -1747,11 +1770,12 @@ static uint8_t *_getdns_nsec3_hash_label(uint8_t *label, size_t label_len, } static uint8_t *name2nsec3_label( - getdns_rrset *nsec3, uint8_t *name, uint8_t *label, size_t label_len) + getdns_rrset *nsec3, const uint8_t *name, uint8_t *label, size_t label_len) { rrsig_iter rrsig_spc, *rrsig; _getdns_rdf_iter rdf_spc, *rdf; - uint8_t signer_spc[256], *signer; + uint8_t signer_spc[256]; + const uint8_t *signer; size_t signer_len = sizeof(signer_spc); rrtype_iter rr_spc, *rr; @@ -1832,11 +1856,12 @@ static int check_dates(int32_t now, int32_t skew, int32_t exp, int32_t inc) * expansion, nc_name will point to the next closer part of the name in rrset. */ static int dnskey_signed_rrset(struct mem_funcs *mf, time_t now, uint32_t skew, - rrtype_iter *dnskey, getdns_rrset *rrset, uint8_t **nc_name) + rrtype_iter *dnskey, getdns_rrset *rrset, const uint8_t **nc_name) { rrsig_iter rrsig_spc, *rrsig; _getdns_rdf_iter rdf_spc, *rdf; - uint8_t signer_spc[256], *signer; + uint8_t signer_spc[256]; + const uint8_t *signer; size_t signer_len = sizeof(signer_spc); uint16_t keytag; @@ -1850,7 +1875,7 @@ static int dnskey_signed_rrset(struct mem_funcs *mf, time_t now, uint32_t skew, return 0; /* Then we have at least 4 bytes to calculate keytag */ - keytag = gldns_calc_keytag_raw(dnskey->rr_i.rr_type + 10, + keytag = gldns_calc_keytag_raw((UNCONST_UINT8_p)dnskey->rr_i.rr_type + 10, dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10); for ( rrsig = rrsig_iter_init(&rrsig_spc, rrset) @@ -1899,15 +1924,15 @@ static int dnskey_signed_rrset(struct mem_funcs *mf, time_t now, uint32_t skew, } static int find_nsec_covering_name( - struct mem_funcs *mf, time_t now, uint32_t skew, - getdns_rrset *dnskey, getdns_rrset *rrset, uint8_t *name, int *opt_out); + struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *dnskey, + getdns_rrset *rrset, const uint8_t *name, int *opt_out); /* Returns whether a dnskey for keyset signed rrset. */ static int a_key_signed_rrset(struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *keyset, getdns_rrset *rrset) { rrtype_iter dnskey_spc, *dnskey; - uint8_t *nc_name; + const uint8_t *nc_name; int keytag; assert(keyset->rr_type == GETDNS_RRTYPE_DNSKEY); @@ -1949,7 +1974,7 @@ static int ds_authenticates_keys(struct mem_funcs *mf, rrtype_iter dnskey_spc, *dnskey; rrtype_iter ds_spc, *ds; uint16_t keytag; - uint8_t *nc_name; + const uint8_t *nc_name; size_t valid_dsses = 0, supported_dsses = 0; uint8_t max_supported_digest = 0; int max_supported_result = 0; @@ -1972,7 +1997,7 @@ static int ds_authenticates_keys(struct mem_funcs *mf, return 0; (void) memcpy(digest_buf_spc, dnskey_set->name, dnskey_owner_len); - _dname_canonicalize(digest_buf_spc); + _dname_canonicalize2(digest_buf_spc); for ( dnskey = rrtype_iter_init(&dnskey_spc, dnskey_set) ; dnskey ; dnskey = rrtype_iter_next(dnskey)) { @@ -1981,8 +2006,9 @@ static int ds_authenticates_keys(struct mem_funcs *mf, if (dnskey->rr_i.nxt < dnskey->rr_i.rr_type + 14) continue; - keytag = gldns_calc_keytag_raw(dnskey->rr_i.rr_type + 10, - dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10); + keytag = gldns_calc_keytag_raw( + (UNCONST_UINT8_p) dnskey->rr_i.rr_type + 10, + dnskey->rr_i.nxt - dnskey->rr_i.rr_type - 10); for ( ds = rrtype_iter_init(&ds_spc, ds_set) ; ds ; ds = rrtype_iter_next(ds)) { @@ -2105,16 +2131,16 @@ static int ds_authenticates_keys(struct mem_funcs *mf, } static int nsec_covers_name( - getdns_rrset *nsec, uint8_t *name, uint8_t **ce_name) + getdns_rrset *nsec, const uint8_t *name, const uint8_t **ce_name) { - uint8_t owner_spc[256], *owner; - size_t owner_len = sizeof(owner_spc); - uint8_t next_spc[256], *next; - size_t next_len = sizeof(next_spc); + uint8_t owner_spc[256], next_spc[256]; + const uint8_t *owner, *next; + size_t owner_len = sizeof(owner_spc), next_len = sizeof(next_spc); + rrtype_iter rr_spc, *rr; _getdns_rdf_iter rdf_spc, *rdf; int nsec_cmp; - uint8_t *common1, *common2; + const uint8_t *common1, *common2; if (/* Get owner and next, nicely decompressed */ !(rr = rrtype_iter_init(&rr_spc, nsec)) @@ -2163,7 +2189,7 @@ static int nsec_covers_name( } } -static int nsec3_matches_name(getdns_rrset *nsec3, uint8_t *name) +static int nsec3_matches_name(getdns_rrset *nsec3, const uint8_t *name) { uint8_t label[64], owner[64]; @@ -2176,7 +2202,8 @@ static int nsec3_matches_name(getdns_rrset *nsec3, uint8_t *name) return 0; } -static int nsec3_covers_name(getdns_rrset *nsec3, uint8_t *name, int *opt_out) +static int nsec3_covers_name( + getdns_rrset *nsec3, const uint8_t *name, int *opt_out) { uint8_t label[65], next[65], owner[65]; rrtype_iter rr_spc, *rr; @@ -2227,8 +2254,8 @@ static int nsec3_covers_name(getdns_rrset *nsec3, uint8_t *name, int *opt_out) } static int find_nsec_covering_name( - struct mem_funcs *mf, time_t now, uint32_t skew, - getdns_rrset *dnskey, getdns_rrset *rrset, uint8_t *name, int *opt_out) + struct mem_funcs *mf, time_t now, uint32_t skew, getdns_rrset *dnskey, + getdns_rrset *rrset, const uint8_t *name, int *opt_out) { rrset_iter i_spc, *i; getdns_rrset *n; @@ -2325,7 +2352,8 @@ static int find_nsec_covering_name( static int nsec3_find_next_closer( struct mem_funcs *mf, time_t now, uint32_t skew, - getdns_rrset *dnskey, getdns_rrset *rrset, uint8_t *nc_name, int *opt_out) + getdns_rrset *dnskey, getdns_rrset *rrset, + const uint8_t *nc_name, int *opt_out) { uint8_t wc_name[256] = { 1, (uint8_t)'*' }; int my_opt_out, keytag; @@ -2382,7 +2410,7 @@ static int key_proves_nonexistance( rrtype_iter nsec_spc, *nsec_rr; _getdns_rdf_iter bitmap_spc, *bitmap; rrset_iter i_spc, *i; - uint8_t *ce_name, *nc_name; + const uint8_t *ce_name, *nc_name; uint8_t wc_name[256] = { 1, (uint8_t)'*' }; int keytag; @@ -3044,7 +3072,7 @@ static void append_empty_ds2val_chain_list( return; bindata.size = _dname_len(ds->name); - bindata.data = ds->name; + bindata.data = (UNCONST_UINT8_p)ds->name; (void) getdns_dict_set_bindata(rr_dict, "name", &bindata); (void) getdns_dict_set_int(rr_dict, "class", ds->rr_class); (void) getdns_dict_set_int(rr_dict, "type", ds->rr_type); @@ -3225,7 +3253,8 @@ static int wire_validate_dnssec(struct mem_funcs *mf, chain_head *chain, *head, *next_head; chain_node *node; - uint8_t qname_spc[256], *qname = NULL; + uint8_t qname_spc[256]; + const uint8_t *qname = NULL; size_t qname_len = sizeof(qname_spc); uint16_t qtype = 0, qclass = GETDNS_RRCLASS_IN; diff --git a/src/list.c b/src/list.c index be4886aa..660b962e 100644 --- a/src/list.c +++ b/src/list.c @@ -545,17 +545,17 @@ getdns_list_set_list( } /* getdns_list_set_list */ /*---------------------------------------- getdns_list_set_bindata */ -getdns_return_t -getdns_list_set_bindata( - getdns_list *list, size_t index, const getdns_bindata *child_bindata) +static getdns_return_t +_getdns_list_set_const_bindata( + getdns_list *list, size_t index, size_t size, const uint8_t *data) { getdns_bindata *newbindata; getdns_return_t r; - if (!list || !child_bindata) + if (!list) return GETDNS_RETURN_INVALID_PARAMETER; - if (!(newbindata = _getdns_bindata_copy(&list->mf, child_bindata))) + if (!(newbindata = _getdns_bindata_copy(&list->mf, size, data))) return GETDNS_RETURN_MEMORY_ERROR; if ((r = _getdns_list_request_index(list, index))) { @@ -567,6 +567,15 @@ getdns_list_set_bindata( return GETDNS_RETURN_GOOD; } /* getdns_list_set_bindata */ +getdns_return_t +getdns_list_set_bindata( + getdns_list *list, size_t index, const getdns_bindata *child_bindata) +{ + return !child_bindata ? GETDNS_RETURN_INVALID_PARAMETER + : _getdns_list_set_const_bindata( + list, index, child_bindata->size, child_bindata->data); +} + /*----------------------------------------- getdns_list_set_string */ static getdns_return_t getdns_list_set_string(getdns_list *list, size_t index, const char *value) @@ -631,6 +640,13 @@ _getdns_list_append_bindata(getdns_list *list, const getdns_bindata *child_binda return getdns_list_set_bindata(list, list->numinuse, child_bindata); } getdns_return_t +_getdns_list_append_const_bindata( + getdns_list *list, size_t size, const uint8_t *data) +{ + if (!list) return GETDNS_RETURN_INVALID_PARAMETER; + return _getdns_list_set_const_bindata(list, list->numinuse, size, data); +} +getdns_return_t _getdns_list_append_string(getdns_list *list, const char *value) { if (!list) return GETDNS_RETURN_INVALID_PARAMETER; diff --git a/src/rr-dict.c b/src/rr-dict.c index 4fe30794..5e616ce7 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -44,18 +44,18 @@ #define ALEN(a) (sizeof(a)/sizeof(a[0])) #define UNKNOWN_RDATA NULL -static uint8_t * -apl_n_rdf_end(uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf) +static const uint8_t * +apl_n_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { return rdf < pkt_end ? rdf + 1 : NULL; } static getdns_return_t -apl_n_dict_set_value(getdns_dict *dict, uint8_t *rdf) +apl_n_dict_set_value(getdns_dict *dict, const uint8_t *rdf) { return getdns_dict_set_int(dict, "n", (*rdf >> 7)); } static getdns_return_t -apl_n_list_append_value(getdns_list *list, uint8_t *rdf) +apl_n_list_append_value(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, (*rdf >> 7)); } @@ -63,33 +63,34 @@ static _getdns_rdf_special apl_n = { apl_n_rdf_end, apl_n_dict_set_value, apl_n_list_append_value }; -static uint8_t * -apl_afdpart_rdf_end(uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf) +static const uint8_t * +apl_afdpart_rdf_end( + const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { - uint8_t *end = rdf + (rdf[-1] & 0x7F); + const uint8_t *end = rdf + (rdf[-1] & 0x7F); return end <= pkt_end ? end : NULL; } static getdns_return_t -apl_afdpart_dict_set_value(getdns_dict *dict, uint8_t *rdf) +apl_afdpart_dict_set_value(getdns_dict *dict, const uint8_t *rdf) { - getdns_bindata bindata = { (rdf[-1] & 0x7F), rdf }; - return getdns_dict_set_bindata(dict, "afdpart", &bindata); + return _getdns_dict_set_const_bindata( + dict, "afdpart", (rdf[-1] & 0x7F), rdf); } static getdns_return_t -apl_afdpart_list_append_value(getdns_list *list, uint8_t *rdf) +apl_afdpart_list_append_value(getdns_list *list, const uint8_t *rdf) { - getdns_bindata bindata = { (rdf[-1] & 0x7F), rdf }; - return _getdns_list_append_bindata(list, &bindata); + return _getdns_list_append_const_bindata(list, (rdf[-1] & 0x7F), rdf); } static _getdns_rdf_special apl_afdpart = { apl_afdpart_rdf_end, apl_afdpart_dict_set_value, apl_afdpart_list_append_value }; -static uint8_t * -ipseckey_gateway_rdf_end(uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf) +static const uint8_t * +ipseckey_gateway_rdf_end( + const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { - uint8_t *end; + const uint8_t *end; if (rdf - 5 < pkt) return NULL; @@ -116,15 +117,16 @@ ipseckey_gateway_rdf_end(uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf) return end <= pkt_end ? end : NULL; } static getdns_return_t -ipseckey_gateway_equip_bindata(uint8_t *rdf, getdns_bindata *bindata) +ipseckey_gateway_equip_const_bindata( + const uint8_t *rdf, size_t *size, const uint8_t **data) { - bindata->data = rdf; + *data = rdf; switch (rdf[-2]) { - case 0: bindata->size = 0; + case 0: *size = 0; break; - case 1: bindata->size = 4; + case 1: *size = 4; break; - case 2: bindata->size = 16; + case 2: *size = 16; break; case 3: while (*rdf) if ((*rdf & 0xC0) == 0xC0) @@ -133,59 +135,62 @@ ipseckey_gateway_equip_bindata(uint8_t *rdf, getdns_bindata *bindata) return GETDNS_RETURN_GENERIC_ERROR; else rdf += *rdf + 1; - bindata->size = rdf + 1 - bindata->data; + *size = rdf + 1 - *data; break; default: return GETDNS_RETURN_GENERIC_ERROR; } return GETDNS_RETURN_GOOD; - } -static getdns_return_t -ipseckey_gateway_dict_set_value(getdns_dict *dict, uint8_t *rdf) -{ - getdns_bindata bindata; - if (ipseckey_gateway_equip_bindata(rdf, &bindata)) +static getdns_return_t +ipseckey_gateway_dict_set_value(getdns_dict *dict, const uint8_t *rdf) +{ + size_t size; + const uint8_t *data; + + if (ipseckey_gateway_equip_const_bindata(rdf, &size, &data)) return GETDNS_RETURN_GENERIC_ERROR; - else if (! bindata.size) + else if (! size) return GETDNS_RETURN_GOOD; else - return getdns_dict_set_bindata(dict, "gateway", &bindata); + return _getdns_dict_set_const_bindata(dict, "gateway", size, data); } static getdns_return_t -ipseckey_gateway_list_append_value(getdns_list *list, uint8_t *rdf) +ipseckey_gateway_list_append_value(getdns_list *list, const uint8_t *rdf) { - getdns_bindata bindata; + size_t size; + const uint8_t *data; - if (ipseckey_gateway_equip_bindata(rdf, &bindata)) + if (ipseckey_gateway_equip_const_bindata(rdf, &size, &data)) return GETDNS_RETURN_GENERIC_ERROR; - else if (! bindata.size) + else if (!size) return GETDNS_RETURN_GOOD; else - return _getdns_list_append_bindata(list, &bindata); + return _getdns_list_append_const_bindata(list, size, data); } static _getdns_rdf_special ipseckey_gateway = { ipseckey_gateway_rdf_end, ipseckey_gateway_dict_set_value, ipseckey_gateway_list_append_value }; -static uint8_t * -hip_pk_algorithm_rdf_end(uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf) +static const uint8_t * +hip_pk_algorithm_rdf_end( + const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { return rdf + 4 > pkt_end ? NULL : rdf + 4 + *rdf + gldns_read_uint16(rdf + 2) > pkt_end ? NULL : rdf + 1; } static getdns_return_t -hip_pk_algorithm_dict_set_value(getdns_dict *dict, uint8_t *rdf) +hip_pk_algorithm_dict_set_value(getdns_dict *dict, const uint8_t *rdf) { return getdns_dict_set_int(dict, "pk_algorithm", rdf[1]); } static getdns_return_t -hip_pk_algorithm_list_append_value(getdns_list *list, uint8_t *rdf) +hip_pk_algorithm_list_append_value(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, rdf[1]); } @@ -194,47 +199,46 @@ static _getdns_rdf_special hip_pk_algorithm = { hip_pk_algorithm_dict_set_value, hip_pk_algorithm_list_append_value }; -static uint8_t * -hip_hit_rdf_end(uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf) +static const uint8_t * +hip_hit_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { return rdf + 3 > pkt_end ? NULL : rdf + 3 + rdf[-1] + gldns_read_uint16(rdf + 1) > pkt_end ? NULL : rdf + 1; } static getdns_return_t -hip_hit_dict_set_value(getdns_dict *dict, uint8_t *rdf) +hip_hit_dict_set_value(getdns_dict *dict, const uint8_t *rdf) { - getdns_bindata bindata = { rdf[-1], rdf + 3 }; - return getdns_dict_set_bindata(dict, "hit", &bindata); + return _getdns_dict_set_const_bindata(dict, "hit", rdf[-1], rdf + 3); } static getdns_return_t -hip_hit_list_append_value(getdns_list *list, uint8_t *rdf) +hip_hit_list_append_value(getdns_list *list, const uint8_t *rdf) { - getdns_bindata bindata = { rdf[-1], rdf + 3 }; - return _getdns_list_append_bindata(list, &bindata); + return _getdns_list_append_const_bindata(list, rdf[-1], rdf + 3); } static _getdns_rdf_special hip_hit = { hip_hit_rdf_end, hip_hit_dict_set_value, hip_hit_list_append_value }; -static uint8_t * -hip_public_key_rdf_end(uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf) +static const uint8_t * +hip_public_key_rdf_end( + const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { return rdf + 2 > pkt_end ? NULL : rdf + 2 + rdf[-2] + gldns_read_uint16(rdf) > pkt_end ? NULL : rdf + 2 + rdf[-2] + gldns_read_uint16(rdf); } static getdns_return_t -hip_public_key_dict_set_value(getdns_dict *dict, uint8_t *rdf) +hip_public_key_dict_set_value(getdns_dict *dict, const uint8_t *rdf) { - getdns_bindata bindata = { gldns_read_uint16(rdf), rdf + 2 + rdf[-2] }; - return getdns_dict_set_bindata(dict, "public_key", &bindata); + return _getdns_dict_set_const_bindata( + dict, "public_key", gldns_read_uint16(rdf), rdf + 2 + rdf[-2]); } static getdns_return_t -hip_public_key_list_append_value(getdns_list *list, uint8_t *rdf) +hip_public_key_list_append_value(getdns_list *list, const uint8_t *rdf) { - getdns_bindata bindata = { gldns_read_uint16(rdf), rdf + 2 + rdf[-2] }; - return _getdns_list_append_bindata(list, &bindata); + return _getdns_list_append_const_bindata( + list, gldns_read_uint16(rdf), rdf + 2 + rdf[-2]); } static _getdns_rdf_special hip_public_key = { hip_public_key_rdf_end, @@ -742,7 +746,7 @@ _getdns_rr_type_name(int rr_type) } getdns_return_t -_getdns_rr_dict2wire(getdns_dict *rr_dict, gldns_buffer *buf) +_getdns_rr_dict2wire(const getdns_dict *rr_dict, gldns_buffer *buf) { getdns_return_t r = GETDNS_RETURN_GOOD; struct getdns_bindata *name; @@ -780,7 +784,7 @@ _getdns_rr_dict2wire(getdns_dict *rr_dict, gldns_buffer *buf) */ rr_def = _getdns_rr_def_lookup(rr_type); for ( rd_def = rr_def->rdata - , n_rdata_fields = rr_def->n_rdata_fields + , n_rdata_fields = rr_def->n_rdata_fields + 1 ; n_rdata_fields ; n_rdata_fields-- , rd_def++ ) { if (rd_def->type & GETDNS_RDF_COMPRESSED) diff --git a/src/rr-dict.h b/src/rr-dict.h index 633433c5..6d2e809b 100644 --- a/src/rr-dict.h +++ b/src/rr-dict.h @@ -36,13 +36,13 @@ #include "getdns/getdns.h" #include "gldns/gbuffer.h" -typedef uint8_t *(*_getdns_rdf_end_t)( - uint8_t *pkt, uint8_t *pkt_end, uint8_t *rdf); +typedef const uint8_t *(*_getdns_rdf_end_t)( + const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf); /* Limit checks are already done with _getdns_rdf_end_t */ typedef getdns_return_t (*_getdns_rdf_dict_set_value_t)( - getdns_dict *dict, uint8_t *rdf); + getdns_dict *dict, const uint8_t *rdf); typedef getdns_return_t (*_getdns_rdf_list_append_value_t)( - getdns_list *list, uint8_t *rdf); + getdns_list *list, const uint8_t *rdf); typedef struct _getdns_rdf_special { _getdns_rdf_end_t rdf_end; @@ -134,7 +134,7 @@ typedef struct _getdns_rr_def { const _getdns_rr_def *_getdns_rr_def_lookup(uint16_t rr_type); getdns_return_t _getdns_rr_dict2wire( - getdns_dict *rr_dict, gldns_buffer *buf); + const getdns_dict *rr_dict, gldns_buffer *buf); const char *_getdns_rr_type_name(int rr_type); diff --git a/src/rr-iter.c b/src/rr-iter.c index bfd7c7d6..7ecff8f3 100644 --- a/src/rr-iter.c +++ b/src/rr-iter.c @@ -39,6 +39,10 @@ rr_iter_find_nxt(_getdns_rr_iter *i) assert(i); assert(i->rr_type); + if (!i->pkt) { + i->nxt = i->pkt_end; + return; + } i->nxt = i->n < GLDNS_QDCOUNT(i->pkt) ? i->rr_type + 4 : i->rr_type + 10 > i->pkt_end @@ -51,13 +55,14 @@ rr_iter_find_nxt(_getdns_rr_iter *i) static _getdns_rr_iter * find_rrtype(_getdns_rr_iter *i) { - uint8_t *pos; + const uint8_t *pos; assert(i); assert(i->pos); /* Past the last RR in the pkt */ - if (GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + + if (i->pkt && + GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt) <= i->n) goto done; @@ -83,7 +88,7 @@ done: } _getdns_rr_iter * -_getdns_rr_iter_init(_getdns_rr_iter *i, uint8_t *pkt, size_t pkt_len) +_getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, size_t pkt_len) { assert(i); @@ -99,6 +104,25 @@ _getdns_rr_iter_init(_getdns_rr_iter *i, uint8_t *pkt, size_t pkt_len) return find_rrtype(i); } +_getdns_rr_iter * +_getdns_single_rr_iter_init( + _getdns_rr_iter *i, const uint8_t *wire, size_t wire_len) +{ + assert(i); + + if (!wire || wire_len < 5 /* name + type + class */) { + i->pos = NULL; + return NULL; + } + i->pkt = NULL; + i->pos = wire; + i->pkt_end = wire + wire_len; + i->n = 0; + + return find_rrtype(i); +} + + _getdns_rr_iter * _getdns_rr_iter_rewind(_getdns_rr_iter *i) { @@ -121,12 +145,13 @@ _getdns_rr_iter_next(_getdns_rr_iter *i) return find_rrtype(i); } -static uint8_t * -dname_if_or_as_decompressed(uint8_t *pkt, uint8_t *pkt_end, uint8_t *pos, - uint8_t *buf, size_t *len, size_t refs) +static const uint8_t * +dname_if_or_as_decompressed(const uint8_t *pkt, const uint8_t *pkt_end, + const uint8_t *pos, uint8_t *buf, size_t *len, size_t refs) { uint16_t offset; - uint8_t *start, *dst; + const uint8_t *start; + uint8_t *dst; assert(pkt); assert(pkt_end); @@ -138,7 +163,7 @@ dname_if_or_as_decompressed(uint8_t *pkt, uint8_t *pkt_end, uint8_t *pos, goto error; if ((*pos & 0xC0) == 0xC0) { - if (pos + 1 >= pkt_end) + if (!pkt || pos + 1 >= pkt_end) goto error; offset = gldns_read_uint16(pos) & 0x3FFF; if (pkt + offset >= pkt_end) @@ -175,7 +200,7 @@ dname_if_or_as_decompressed(uint8_t *pkt, uint8_t *pkt_end, uint8_t *pos, start = pos; } if ((*pos & 0xC0) == 0xC0) { - if (pos + 1 >= pkt_end) + if (!pkt || pos + 1 >= pkt_end) goto error; offset = gldns_read_uint16(pos) & 0x3FFF; if (pkt + offset >= pkt_end) @@ -204,7 +229,7 @@ error: return NULL; } -uint8_t * +const uint8_t * _getdns_owner_if_or_as_decompressed(_getdns_rr_iter *i, uint8_t *ff_bytes, size_t *len) { @@ -215,7 +240,7 @@ _getdns_owner_if_or_as_decompressed(_getdns_rr_iter *i, static _getdns_rdf_iter * rdf_iter_find_nxt(_getdns_rdf_iter *i) { - uint8_t *pos; + const uint8_t *pos; assert(i); assert(i->pos); @@ -334,7 +359,7 @@ _getdns_rdf_iter_init_at( return i; } -uint8_t * +const uint8_t * _getdns_rdf_if_or_as_decompressed( _getdns_rdf_iter *i, uint8_t *ff_bytes, size_t *len) { diff --git a/src/rr-iter.h b/src/rr-iter.h index b8f492e8..85f70509 100644 --- a/src/rr-iter.h +++ b/src/rr-iter.h @@ -38,8 +38,8 @@ #include "gldns/gbuffer.h" typedef struct _getdns_rr_iter { - uint8_t *pkt; - uint8_t *pkt_end; + const uint8_t *pkt; + const uint8_t *pkt_end; /* Which RR are we currently at */ size_t n; @@ -47,32 +47,37 @@ typedef struct _getdns_rr_iter { /* pos points to start of the owner name the RR. * Or is NULL when there are no RR's left. */ - uint8_t *pos; + const uint8_t *pos; /* rr_type will point to the rr_type right after the RR's owner name. * rr_type is guaranteed to have a value when pos has a value */ - uint8_t *rr_type; + const uint8_t *rr_type; /* nxt point to the owner name of the next RR or to pkt_end */ - uint8_t *nxt; + const uint8_t *nxt; } _getdns_rr_iter; _getdns_rr_iter *_getdns_rr_iter_init(_getdns_rr_iter *i, - uint8_t *pkt, size_t pkt_len); + const uint8_t *pkt, const size_t pkt_len); + +_getdns_rr_iter *_getdns_single_rr_iter_init(_getdns_rr_iter *i, + const uint8_t *wire, const size_t wire_len); _getdns_rr_iter *_getdns_rr_iter_rewind(_getdns_rr_iter *i); _getdns_rr_iter *_getdns_rr_iter_next(_getdns_rr_iter *i); -uint8_t *_getdns_owner_if_or_as_decompressed( +const uint8_t *_getdns_owner_if_or_as_decompressed( _getdns_rr_iter *i, uint8_t *ff_bytes, size_t *len); static inline gldns_pkt_section _getdns_rr_iter_section(_getdns_rr_iter *i) { - return i->n < GLDNS_QDCOUNT(i->pkt) ? GLDNS_SECTION_QUESTION + return !i->pkt ? (i->nxt - i->rr_type == 4 ? GLDNS_SECTION_QUESTION + : GLDNS_SECTION_ANSWER ) + : i->n < GLDNS_QDCOUNT(i->pkt) ? GLDNS_SECTION_QUESTION : i->n < GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) ? GLDNS_SECTION_ANSWER : i->n < GLDNS_QDCOUNT(i->pkt) @@ -86,14 +91,14 @@ _getdns_rr_iter_section(_getdns_rr_iter *i) } typedef struct piv_getdns_rdf_iter { - uint8_t *pkt; - uint8_t *pkt_end; + const uint8_t *pkt; + const uint8_t *pkt_end; const _getdns_rdata_def *rdd_pos; const _getdns_rdata_def *rdd_end; const _getdns_rdata_def *rdd_repeat; - uint8_t *pos; - uint8_t *end; - uint8_t *nxt; + const uint8_t *pos; + const uint8_t *end; + const uint8_t *nxt; } _getdns_rdf_iter; _getdns_rdf_iter *_getdns_rdf_iter_init(_getdns_rdf_iter *i, @@ -104,7 +109,7 @@ _getdns_rdf_iter *_getdns_rdf_iter_next(_getdns_rdf_iter *i); _getdns_rdf_iter *_getdns_rdf_iter_init_at(_getdns_rdf_iter *i, _getdns_rr_iter *rr, size_t pos); -uint8_t *_getdns_rdf_if_or_as_decompressed( +const uint8_t *_getdns_rdf_if_or_as_decompressed( _getdns_rdf_iter *i, uint8_t *ff_bytes, size_t *len); #endif diff --git a/src/stub.c b/src/stub.c index c0c254cc..af1250a7 100644 --- a/src/stub.c +++ b/src/stub.c @@ -187,7 +187,7 @@ match_and_process_server_cookie( getdns_upstream *upstream, uint8_t *response, size_t response_len) { _getdns_rr_iter rr_iter_storage, *rr_iter; - uint8_t *pos; + const uint8_t *pos; uint16_t rdata_len, opt_code = 0, opt_len = 0; /* Search for the OPT RR (if any) */ @@ -287,8 +287,8 @@ is_starttls_response(getdns_network_req *netreq) _getdns_rdf_iter rdf_iter_storage, *rdf_iter; uint16_t rr_type; gldns_pkt_section section; - uint8_t starttls_name_space[256], *starttls_name; - uint8_t owner_name_space[256], *owner_name; + uint8_t starttls_name_space[256], owner_name_space[256]; + const uint8_t *owner_name, *starttls_name; size_t starttls_name_len = sizeof(starttls_name_space); size_t owner_name_len = sizeof(owner_name_space);; diff --git a/src/util-internal.c b/src/util-internal.c index 07672bd7..f14425dc 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -172,7 +172,8 @@ getdns_dict * _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) { getdns_dict *rr_dict, *rdata_dict; - getdns_bindata bindata; + const uint8_t *bin_data; + size_t bin_size; uint32_t int_val = 0; getdns_data_type val_type; _getdns_rdf_iter rdf_storage, *rdf; @@ -185,8 +186,8 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) if (!(rr_dict = _getdns_dict_create_with_mf(mf))) return NULL; - bindata.data = _getdns_owner_if_or_as_decompressed( - i, ff_bytes, &bindata.size); + bin_data = _getdns_owner_if_or_as_decompressed( + i, ff_bytes, &bin_size); /* question */ if (_getdns_rr_iter_section(i) == GLDNS_SECTION_QUESTION) { @@ -197,7 +198,8 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) getdns_dict_set_int(rr_dict, "qclass", (uint32_t) gldns_read_uint16(i->rr_type + 2)) || - getdns_dict_set_bindata(rr_dict, "qname", &bindata)) { + _getdns_dict_set_const_bindata( + rr_dict, "qname", bin_size, bin_data)) { goto error; } @@ -234,7 +236,8 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) getdns_dict_set_int(rr_dict, "ttl", (uint32_t) gldns_read_uint32(i->rr_type + 4)) || - getdns_dict_set_bindata(rr_dict, "name", &bindata)) { + _getdns_dict_set_const_bindata( + rr_dict, "name", bin_size, bin_data)) { goto error; } @@ -242,9 +245,10 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) return NULL; if (i->rr_type + 10 <= i->nxt) { - bindata.size = i->nxt - (i->rr_type + 10); - bindata.data = i->rr_type + 10; - if (getdns_dict_set_bindata(rdata_dict, "rdata_raw", &bindata)) + bin_size = i->nxt - (i->rr_type + 10); + bin_data = i->rr_type + 10; + if (_getdns_dict_set_const_bindata( + rdata_dict, "rdata_raw", bin_size, bin_data)) goto rdata_error; } for ( rdf = _getdns_rdf_iter_init(&rdf_storage, i) @@ -264,28 +268,28 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) } else if (rdf->rdd_pos->type & GETDNS_RDF_DNAME) { val_type = t_bindata; - bindata.data = _getdns_rdf_if_or_as_decompressed( - rdf, ff_bytes, &bindata.size); + bin_data = _getdns_rdf_if_or_as_decompressed( + rdf, ff_bytes, &bin_size); } else if (rdf->rdd_pos->type & GETDNS_RDF_BINDATA) { val_type = t_bindata; if (rdf->rdd_pos->type & GETDNS_RDF_FIXEDSZ) { - bindata.size = rdf->rdd_pos->type - & GETDNS_RDF_FIXEDSZ; - bindata.data = rdf->pos; + bin_size = rdf->rdd_pos->type + & GETDNS_RDF_FIXEDSZ; + bin_data = rdf->pos; } else switch(rdf->rdd_pos->type & GETDNS_RDF_LEN_VAL){ case 0x100: - bindata.size = *rdf->pos; - bindata.data = rdf->pos + 1; + bin_size = *rdf->pos; + bin_data = rdf->pos + 1; break; case 0x200: - bindata.size = gldns_read_uint16(rdf->pos); - bindata.data = rdf->pos + 2; + bin_size = gldns_read_uint16(rdf->pos); + bin_data = rdf->pos + 2; break; default: - bindata.size = rdf->nxt - rdf->pos; - bindata.data = rdf->pos; + bin_size = rdf->nxt - rdf->pos; + bin_data = rdf->pos; break; } } else if (rdf->rdd_pos->type == GETDNS_RDF_SPECIAL) @@ -302,8 +306,8 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; break; case t_bindata: - if (getdns_dict_set_bindata(rdata_dict, - rdf->rdd_pos->name, &bindata)) + if (_getdns_dict_set_const_bindata(rdata_dict, + rdf->rdd_pos->name, bin_size, bin_data)) goto rdata_error; break; case t_dict: @@ -330,8 +334,8 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; break; case t_bindata: - if (_getdns_list_append_bindata(repeat_list, - &bindata)) + if (_getdns_list_append_const_bindata( + repeat_list, bin_size, bin_data)) goto rdata_error; break; case t_dict: @@ -369,8 +373,8 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; break; case t_bindata: - if (getdns_dict_set_bindata(repeat_dict, - rdf->rdd_pos->name, &bindata)) + if (_getdns_dict_set_const_bindata(repeat_dict, + rdf->rdd_pos->name, bin_size, bin_data)) goto rdata_error; break; case t_dict: @@ -497,11 +501,11 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req, getdns_dict *rr_dict = NULL; _getdns_rr_iter rr_iter_storage, *rr_iter; _getdns_rdf_iter rdf_iter_storage, *rdf_iter; - getdns_bindata bindata; + size_t bin_size; + const uint8_t *bin_data; gldns_pkt_section section; - uint8_t canonical_name_space[256], - *canonical_name = canonical_name_space; - uint8_t owner_name_space[256], *owner_name; + uint8_t canonical_name_space[256], owner_name_space[256]; + const uint8_t *canonical_name = canonical_name_space, *owner_name; size_t canonical_name_len = sizeof(canonical_name_space), owner_name_len = sizeof(owner_name_space); int new_canonical = 0; @@ -592,14 +596,15 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req, &rdf_iter_storage, rr_iter))) continue; - bindata.size = rdf_iter->nxt - rdf_iter->pos; - bindata.data = rdf_iter->pos; + bin_size = rdf_iter->nxt - rdf_iter->pos; + bin_data = rdf_iter->pos; if (!set_dict(&rr_dict, getdns_dict_create_with_context(context)) || getdns_dict_util_set_string(rr_dict, "address_type", rr_type == GETDNS_RRTYPE_A ? "IPv4" : "IPv6" ) || - getdns_dict_set_bindata(rr_dict,"address_data",&bindata) || + _getdns_dict_set_const_bindata( + rr_dict, "address_data", bin_size, bin_data) || (just_addrs && _getdns_list_append_dict(just_addrs, rr_dict))) { @@ -656,9 +661,8 @@ _getdns_create_reply_dict(getdns_context *context, getdns_network_req *req, new_canonical = 1; } } - bindata.data = canonical_name; - bindata.size = canonical_name_len; - if (getdns_dict_set_bindata(result, "canonical_name", &bindata)) + if (_getdns_dict_set_const_bindata( + result, "canonical_name", canonical_name_len, canonical_name)) goto error; goto success; diff --git a/src/util-internal.h b/src/util-internal.h index b6db818a..fece4860 100644 --- a/src/util-internal.h +++ b/src/util-internal.h @@ -42,6 +42,7 @@ #include "context.h" #include "rr-iter.h" +#define UNCONST_UINT8_p uint8_t * #ifdef S_SPLINT_S # define INLINE @@ -81,6 +82,12 @@ getdns_return_t _getdns_list_append_string(getdns_list *list, getdns_return_t _getdns_list_append_int(getdns_list *list, uint32_t child_uint32); +getdns_return_t _getdns_list_append_const_bindata(getdns_list *list, + size_t size, const uint8_t *data); + +getdns_return_t _getdns_dict_set_const_bindata(getdns_dict *dict, + const char *name, size_t size, const uint8_t *data); + /** * private function (API users should not be calling this), this uses library * routines to make a copy of the list - would be faster to make the copy directly From c53f074fdf912f18686bdc9fa2f9acbbd7299bc0 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 8 Dec 2015 09:39:28 +0100 Subject: [PATCH 03/18] Propagate consts with debugging symbols --- src/dnssec.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dnssec.c b/src/dnssec.c index 59de8e46..cfe57b90 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -405,7 +405,7 @@ inline static void debug_sec_print_rr(const char *msg, _getdns_rr_iter *rr) { char str_spc[8192], *str = str_spc; size_t str_len = sizeof(str_spc); - uint8_t *data = rr->pos; + const uint8_t *data = rr->pos; size_t data_len = rr->nxt - rr->pos; if (!rr || !rr->pos) { @@ -413,14 +413,16 @@ inline static void debug_sec_print_rr(const char *msg, _getdns_rr_iter *rr) return; } (void) gldns_wire2str_rr_scan( - &data, &data_len, &str, &str_len, rr->pkt, rr->pkt_end - rr->pkt); + (UNCONST_UINT8_p *) &data, &data_len, &str, &str_len, + (UNCONST_UINT8_p) rr->pkt, rr->pkt_end - rr->pkt); DEBUG_SEC("%s%s", msg, str_spc); } -inline static void debug_sec_print_dname(const char *msg, uint8_t *label) +inline static void debug_sec_print_dname(const char *msg, const uint8_t *label) { char str[1024]; - if (label && gldns_wire2str_dname_buf(label, 256, str, sizeof(str))) + if (label && gldns_wire2str_dname_buf( + (UNCONST_UINT8_p)label, 256, str, sizeof(str))) DEBUG_SEC("%s%s\n", msg, str); else DEBUG_SEC("%s\n", msg); @@ -599,7 +601,8 @@ static void debug_sec_print_rrset(const char *msg, getdns_rrset *rrset) return; } gldns_buffer_init_frm_data(&buf, buf_space, sizeof(buf_space)); - if (gldns_wire2str_dname_buf(rrset->name, 256, owner, sizeof(owner))) + if (gldns_wire2str_dname_buf( + (UNCONST_UINT8_p)rrset->name, 256, owner, sizeof(owner))) gldns_buffer_printf(&buf, "%s ", owner); else gldns_buffer_printf(&buf, " "); From 47dc07e940d1c79845382581af0f35c470d60bea Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Wed, 9 Dec 2015 12:04:00 +0100 Subject: [PATCH 04/18] First go at conversion to and from rr_dicts --- src/convert.c | 123 +++++++++++++++++++++++++++++++++++ src/getdns/getdns_extra.h.in | 2 +- 2 files changed, 124 insertions(+), 1 deletion(-) diff --git a/src/convert.c b/src/convert.c index 082fe7db..15e07a1c 100644 --- a/src/convert.c +++ b/src/convert.c @@ -46,6 +46,7 @@ #include "util-internal.h" #include "gldns/wire2str.h" #include "gldns/str2wire.h" +#include "dict.h" /* stuff to make it compile pedantically */ #define UNUSED_PARAM(x) ((void)(x)) @@ -219,4 +220,126 @@ getdns_strerror(getdns_return_t err, char *buf, size_t buflen) return GETDNS_RETURN_GOOD; } /* getdns_strerror */ +getdns_return_t +getdns_rr_dict2wire( + const getdns_dict *rr_dict, uint8_t *wire, size_t *wire_sz) +{ + getdns_return_t r; + gldns_buffer gbuf; + + if (!rr_dict || !wire || !wire_sz) + return GETDNS_RETURN_INVALID_PARAMETER; + + gldns_buffer_init_frm_data(&gbuf, wire, *wire_sz); + r = _getdns_rr_dict2wire(rr_dict, &gbuf); + *wire_sz = gldns_buffer_position(&gbuf); + + if (r) + return r; + + if (gldns_buffer_position(&gbuf) == 0 || + gldns_buffer_position(&gbuf) > gldns_buffer_capacity(&gbuf)) + return GETDNS_RETURN_GENERIC_ERROR; + + return GETDNS_RETURN_GOOD; +} + +getdns_return_t +getdns_wire2rr_dict( + const uint8_t *wire, size_t wire_len, getdns_dict **rr_dict) +{ + static struct mem_funcs plain_mem_funcs = { + MF_PLAIN, .mf.pln = { malloc, realloc, free } + }; + _getdns_rr_iter rr_iter_spc, *rr_iter; + + if (!wire || !rr_dict) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (!(rr_iter = _getdns_single_rr_iter_init( + &rr_iter_spc, wire, wire_len))) + return GETDNS_RETURN_GENERIC_ERROR; + + if (!(*rr_dict = _getdns_rr_iter2rr_dict(&plain_mem_funcs, rr_iter))) + return GETDNS_RETURN_MEMORY_ERROR; + + return GETDNS_RETURN_GOOD; +} + +getdns_return_t +getdns_rr_dict2str( + const getdns_dict *rr_dict, char **str) +{ + getdns_return_t r; + gldns_buffer gbuf; + uint8_t buf_spc[4096], *buf = buf_spc; + size_t sz; + + if (!rr_dict || !str) + return GETDNS_RETURN_INVALID_PARAMETER; + + gldns_buffer_init_frm_data(&gbuf, buf, sizeof(buf_spc)); + r = _getdns_rr_dict2wire(rr_dict, &gbuf); + if (gldns_buffer_position(&gbuf) > sizeof(buf_spc)) { + if (!(buf = GETDNS_XMALLOC( + rr_dict->mf, uint8_t, (sz = gldns_buffer_position(&gbuf))))) { + return GETDNS_RETURN_MEMORY_ERROR; + } + gldns_buffer_init_frm_data(&gbuf, buf, sz); + r = _getdns_rr_dict2wire(rr_dict, &gbuf); + } + if (r) { + if (buf != buf_spc) + GETDNS_FREE(rr_dict->mf, buf); + return r; + } + if (!(*str = gldns_wire2str_rr(gldns_buffer_begin(&gbuf), + gldns_buffer_position(&gbuf)))) + r = GETDNS_RETURN_MEMORY_ERROR; + + if (buf != buf_spc) + GETDNS_FREE(rr_dict->mf, buf); + return r; +} + +getdns_return_t +getdns_str2rr_dict( + const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl) +{ + uint8_t wire_spc[4096], *wire = wire_spc; + uint8_t origin_spc[256], *origin_wf; + size_t origin_len = sizeof(origin_spc), wire_len = sizeof(wire_spc); + int e; + getdns_return_t r; + + if (!str || !rr_dict) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (!origin) + origin_wf = NULL; + + else if (gldns_str2wire_dname_buf(origin, origin_spc, &origin_len)) + return GETDNS_RETURN_GENERIC_ERROR; + else + origin_wf = origin_spc; + + e = gldns_str2wire_rr_buf(str, wire, &wire_len, + NULL, default_ttl, origin_wf, origin_len, NULL, 0); + if (GLDNS_WIREPARSE_ERROR(e) == GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL) { + if (!(wire = malloc((wire_len = GLDNS_RR_BUF_SIZE)))) + return GETDNS_RETURN_MEMORY_ERROR; + e = gldns_str2wire_rr_buf(str, wire, &wire_len, + NULL, default_ttl, origin_wf, origin_len, NULL, 0); + } + if (e) { + if (wire != wire_spc) + free(wire); + return GETDNS_RETURN_GENERIC_ERROR; + } + r = getdns_wire2rr_dict(wire, wire_len, rr_dict); + if (wire != wire_spc) + free(wire); + return r; +} + /* convert.c */ diff --git a/src/getdns/getdns_extra.h.in b/src/getdns/getdns_extra.h.in index 793725e8..9a1d9759 100644 --- a/src/getdns/getdns_extra.h.in +++ b/src/getdns/getdns_extra.h.in @@ -412,7 +412,7 @@ getdns_wire2rr_dict( getdns_return_t getdns_rr_dict2str( - const getdns_dict *rr_dict, char *str, size_t *str_sz); + const getdns_dict *rr_dict, char **str); getdns_return_t getdns_str2rr_dict( From 75b0ae669a7c507748339f9326e02a92e205081d Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Sun, 13 Dec 2015 15:58:21 +0100 Subject: [PATCH 05/18] Fix rdf iter of single RR wireformat --- src/rr-iter.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/rr-iter.c b/src/rr-iter.c index 7ecff8f3..31913b20 100644 --- a/src/rr-iter.c +++ b/src/rr-iter.c @@ -153,7 +153,6 @@ dname_if_or_as_decompressed(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *start; uint8_t *dst; - assert(pkt); assert(pkt_end); assert(pos); assert(buf); @@ -304,7 +303,7 @@ _getdns_rdf_iter_init(_getdns_rdf_iter *i, _getdns_rr_iter *rr) i->end = NULL; /* rr_iter already done or in question section */ - if (!rr->pos || rr->n < GLDNS_QDCOUNT(rr->pkt)) + if (!rr->pos || _getdns_rr_iter_section(rr) == GLDNS_SECTION_QUESTION) goto done; i->pkt = rr->pkt; From 5ae854b8bf39abe0970dd7cabfc07dc9b822b97e Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Sun, 13 Dec 2015 15:58:45 +0100 Subject: [PATCH 06/18] Fix dict to wire of repeating rdata fields --- src/rr-dict.c | 103 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 21 deletions(-) diff --git a/src/rr-dict.c b/src/rr-dict.c index 5e616ce7..51f1337d 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -745,22 +745,96 @@ _getdns_rr_type_name(int rr_type) return _getdns_rr_def_lookup(rr_type)->name; } +static void +write_int_rdata(gldns_buffer *buf, _getdns_rdf_type type, uint32_t value) +{ + size_t j; + + for (j = type & GETDNS_RDF_FIXEDSZ; j; j--) + gldns_buffer_write_u8(buf, + (uint8_t)(value >> (8 * (j - 1))) & 0xff); +} + +static void +write_bindata_rdata(gldns_buffer *buf, + _getdns_rdf_type type, getdns_bindata *bindata) +{ + if (type & GETDNS_RDF_LEN_VAL) + write_int_rdata(buf, type >> 8, bindata->size); + + gldns_buffer_write(buf, bindata->data, bindata->size); +} + + +static getdns_return_t +write_rdata_field(gldns_buffer *buf, + _getdns_rdf_type type, const char *name, getdns_dict *rdata) +{ + getdns_return_t r; + getdns_list *list; + uint32_t value; + getdns_bindata *bindata; + size_t i; + + if (type & GETDNS_RDF_INTEGER) { + if (!(type & GETDNS_RDF_REPEAT)) { + if ((r = getdns_dict_get_int(rdata, name, &value))) + return r; + else + write_int_rdata(buf, type, value); + + } else if ((r = getdns_dict_get_list(rdata, name, &list))) + return r; + + else for ( i = 0 + ; GETDNS_RETURN_GOOD == + (r = getdns_list_get_int(list, i, &value)) + ; i++) + write_int_rdata(buf, type, value); + + if (r != GETDNS_RETURN_NO_SUCH_LIST_ITEM) + return r; + + } else if (type & GETDNS_RDF_BINDATA) { + if (!(type & GETDNS_RDF_REPEAT)) { + if ((r = getdns_dict_get_bindata(rdata,name,&bindata))) + return r; + else + write_bindata_rdata(buf, type, bindata); + + } else if ((r = getdns_dict_get_list(rdata, name, &list))) + return r; + + else for ( i = 0 + ; GETDNS_RETURN_GOOD == + (r = getdns_list_get_bindata(list, i, &bindata)) + ; i++) + write_bindata_rdata(buf, type, bindata); + + if (r != GETDNS_RETURN_NO_SUCH_LIST_ITEM) + return r; + + } else + /* TODO: Handle the special types */ + return GETDNS_RETURN_GENERIC_ERROR; + + return GETDNS_RETURN_GOOD; +} + getdns_return_t _getdns_rr_dict2wire(const getdns_dict *rr_dict, gldns_buffer *buf) { getdns_return_t r = GETDNS_RETURN_GOOD; struct getdns_bindata *name; struct getdns_bindata *rdata_raw; - struct getdns_bindata *bindata; struct getdns_dict *rdata; uint32_t rr_type; uint32_t rr_class = GETDNS_RRCLASS_IN; uint32_t rr_ttl = 0; - uint32_t value; const _getdns_rr_def *rr_def; const _getdns_rdata_def *rd_def; int n_rdata_fields; - size_t j, rdata_size_mark; + size_t rdata_size_mark; assert(rr_dict); assert(buf); @@ -784,7 +858,7 @@ _getdns_rr_dict2wire(const getdns_dict *rr_dict, gldns_buffer *buf) */ rr_def = _getdns_rr_def_lookup(rr_type); for ( rd_def = rr_def->rdata - , n_rdata_fields = rr_def->n_rdata_fields + 1 + , n_rdata_fields = rr_def->n_rdata_fields ; n_rdata_fields ; n_rdata_fields-- , rd_def++ ) { if (rd_def->type & GETDNS_RDF_COMPRESSED) @@ -809,26 +883,13 @@ _getdns_rr_dict2wire(const getdns_dict *rr_dict, gldns_buffer *buf) , n_rdata_fields = rr_def->n_rdata_fields ; n_rdata_fields ; n_rdata_fields-- , rd_def++ ) { - if (rd_def->type & GETDNS_RDF_BINDATA) { - if ((r = getdns_dict_get_bindata(rdata, - rd_def->name, &bindata))) - break; - gldns_buffer_write(buf, bindata->data - , bindata->size ); - continue; - } - if (!(rd_def->type & GETDNS_RDF_INTEGER)) { - r = GETDNS_RETURN_GENERIC_ERROR; + if (rd_def->type != GETDNS_RDF_REPEAT) { + if ((r = write_rdata_field( + buf, rd_def->type, rd_def->name, rdata))) break; } - if ((r = getdns_dict_get_int( - rdata, rd_def->name, &value))) - break; - - for (j = rd_def->type & GETDNS_RDF_FIXEDSZ; j; j--) - gldns_buffer_write_u8(buf, - (uint8_t)(value >> (8 * (j - 1))) & 0xff); + /* TODO: Deal with repeat blocks */ } gldns_buffer_write_u16_at(buf, rdata_size_mark, (uint16_t)(gldns_buffer_position(buf)-rdata_size_mark-2)); From aadd4dc8bbf65207e46a91c2a9a76337381121d2 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Sun, 13 Dec 2015 15:59:36 +0100 Subject: [PATCH 07/18] Add conversion functions test package --- .../260-conversion-functions.Makefile | 15 +++ .../260-conversion-functions.c | 127 ++++++++++++++++++ .../260-conversion-functions.dsc | 16 +++ .../260-conversion-functions.good | 45 +++++++ .../260-conversion-functions.help | 2 + .../260-conversion-functions.pre | 14 ++ .../260-conversion-functions.test | 7 + 7 files changed, 226 insertions(+) create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.Makefile create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.dsc create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.help create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.pre create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.Makefile b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.Makefile new file mode 100644 index 00000000..708341a1 --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.Makefile @@ -0,0 +1,15 @@ +builddir = @BUILDDIR@ +testname = @TPKG_NAME@ +LIBTOOL = $(builddir)/libtool + +CFLAGS=-I$(builddir)/src +LDLIBS=$(builddir)/src/libgetdns.la + +.SUFFIXES: .c .o .a .lo .h + +.c.lo: + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@ + +$(testname): $(testname).lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDLIBS) $(LDFLAGS) -o $@ $< + diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c new file mode 100644 index 00000000..f92541b6 --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c @@ -0,0 +1,127 @@ +#include +#include +#include +#include + +#define FAIL(...) do { \ + fprintf(stderr, "ERROR in %s:%d, ", __FILE__, __LINE__); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + exit(EXIT_FAILURE); \ + } while (0) + +#define FAIL_r(function_name) FAIL( "%s returned %d: %s", function_name \ + , (int)r, getdns_get_errorstr_by_id(r)); + +void print_dict(getdns_dict *rr_dict) +{ + char *str = getdns_pretty_print_dict(rr_dict); + printf("%s\n", str); + free(str); +} + +void print_wire(uint8_t *wire, size_t wire_len) +{ + size_t pos, i; + + for (pos = 0; pos < wire_len; pos += 16) { + printf("%.4zx", pos); + for (i = 0; i < 16; i++) { + if (i % 8 == 0) + printf(" "); + if (pos + i < wire_len) + printf(" %.2x", (int)wire[pos + i]); + else + printf(" "); + } + printf(" "); + for (i = 0; i < 16; i++) { + if (i % 8 == 0) + printf(" "); + if (pos + i < wire_len && isprint(wire[pos + i])) + printf("%c", wire[pos + i]); + else + printf("."); + } + printf("\n"); + } +} + + +int main() +{ + getdns_return_t r; + getdns_dict *rr_dict; + getdns_bindata *dns_name; + getdns_bindata address = { 4, "\xb9\x31\x8d\x25" }; + getdns_bindata nothing = { 8, "\x07nothing" }; + char *str; + uint8_t wire_buf[4096], *wire = wire_buf, *end_of_wire; + size_t wire_len = sizeof(wire_buf); + + if ((r = getdns_str2rr_dict( + "some.domain.tld. 60 CH TXT \"first string\" second \"and third\"", + &rr_dict, NULL, 3600))) + FAIL_r("getdns_str2rr_dict"); + + print_dict(rr_dict); + + if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) + FAIL_r("getdns_rr_dict2wire"); + + print_wire(wire, wire_len); + + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/rdata_raw"))) + FAIL_r("getdns_dict_remove_name"); + + print_dict(rr_dict); + + if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) + FAIL_r("getdns_rr_dict2wire"); + + print_wire(wire, wire_len); + + getdns_dict_destroy(rr_dict); + + wire += wire_len; + wire_len = sizeof(wire_buf) - (wire - wire_buf); + + if (!(rr_dict = getdns_dict_create())) + FAIL("getdns_dict_create returned NULL"); + + if ((r = getdns_convert_fqdn_to_dns_name("www.getdnsapi.net", &dns_name))) + FAIL_r("getdns_convert_fqdn_to_dns_name"); + + r = getdns_dict_set_bindata(rr_dict, "name", dns_name); + free(dns_name->data); + free(dns_name); + if (r) + FAIL_r("getdns_dict_set_bindata"); + + if ((r = getdns_dict_set_int(rr_dict, "type", GETDNS_RRTYPE_A))) + FAIL_r("getdns_dict_set_int"); + + if ((r = getdns_dict_set_bindata(rr_dict, "/rdata/ipv4_address", &address))) + FAIL_r("getdns_dict_set_int"); + + if ((r = getdns_rr_dict2str(rr_dict, &str))) + FAIL_r("getdns_rr_dict2str"); + + printf("\n%s\n", str); + + if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) + FAIL_r("getdns_rr_dict2wire"); + + getdns_dict_destroy(rr_dict); + print_wire(wire, wire_len); + + wire += wire_len; + wire_len = sizeof(wire_buf) - (wire - wire_buf); + + /* Parse over wire data, convert to string via dict, and print */ + end_of_wire = wire; + wire = wire_buf; + wire_len = end_of_wire - wire; + + exit(EXIT_SUCCESS); +} diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.dsc b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.dsc new file mode 100644 index 00000000..eb96d979 --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.dsc @@ -0,0 +1,16 @@ +BaseName: 260-conversion-functions +Version: 1.0 +Description: Test json pointers +CreationDate: vr dec 11 13:09:47 CET 2015 +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 200-stub-only-compile.tpkg +Help: 260-conversion-functions.help +Pre: 260-conversion-functions.pre +Post: +Test: 260-conversion-functions.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good new file mode 100644 index 00000000..11d4500a --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good @@ -0,0 +1,45 @@ +{ + "class": GETDNS_RRCLASS_CH, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + , + , + + ] + }, + "ttl": 60, + "type": GETDNS_RRTYPE_TXT +} +0000 04 73 6f 6d 65 06 64 6f 6d 61 69 6e 03 74 6c 64 .some.do main.tld +0010 00 00 10 00 03 00 00 00 3c 00 1e 0c 66 69 72 73 ........ <...firs +0020 74 20 73 74 72 69 6e 67 06 73 65 63 6f 6e 64 09 t string .second. +0030 61 6e 64 20 74 68 69 72 64 and thir d....... +{ + "class": GETDNS_RRCLASS_CH, + "name": , + "rdata": + { + "txt_strings": + [ + , + , + + ] + }, + "ttl": 60, + "type": GETDNS_RRTYPE_TXT +} +0000 04 73 6f 6d 65 06 64 6f 6d 61 69 6e 03 74 6c 64 .some.do main.tld +0010 00 00 10 00 03 00 00 00 3c 00 1e 0c 66 69 72 73 ........ <...firs +0020 74 20 73 74 72 69 6e 67 06 73 65 63 6f 6e 64 09 t string .second. +0030 61 6e 64 20 74 68 69 72 64 and thir d....... + +www.getdnsapi.net. 0 IN A 185.49.141.37 + +0000 03 77 77 77 09 67 65 74 64 6e 73 61 70 69 03 6e .www.get dnsapi.n +0010 65 74 00 00 01 00 01 00 00 00 00 00 04 b9 31 8d et...... ......1. +0020 25 %....... ........ diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.help b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.help new file mode 100644 index 00000000..d9deefa2 --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.help @@ -0,0 +1,2 @@ +Compile a program that setups a dict with json pointers and pretty prints the dict. +Then compare the output to the known to be good output. diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.pre b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.pre new file mode 100644 index 00000000..e9880779 --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.pre @@ -0,0 +1,14 @@ +# #-- 260-conversion-functions.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +( + grep '^CC=' "${BUILDDIR}/build-stub-only/src/Makefile" + grep '^LDFLAGS=' "${BUILDDIR}/build-stub-only/src/Makefile" + + BUILDDIR4SED=`echo "${BUILDDIR}/build-stub-only" | sed 's/\//\\\\\//g'` + sed -e "s/@BUILDDIR@/${BUILDDIR4SED}/g" \ + -e "s/@TPKG_NAME@/${TPKG_NAME}/g" "${TPKG_NAME}.Makefile" +) > Makefile diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test new file mode 100644 index 00000000..b840c1dc --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test @@ -0,0 +1,7 @@ +# #-- 260-conversion-functions.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +make && "./${TPKG_NAME}" | tee out && diff out "${TPKG_NAME}.good" From 7baec89d4c214eab2ef36225e75bce33ffeca58d Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 14 Dec 2015 12:13:06 +0100 Subject: [PATCH 08/18] Don't misuse getdns_data_type for something else --- src/util-internal.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/util-internal.c b/src/util-internal.c index f14425dc..84b294a7 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -175,7 +175,7 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) const uint8_t *bin_data; size_t bin_size; uint32_t int_val = 0; - getdns_data_type val_type; + enum wf_data_type { wf_int, wf_bindata, wf_special } val_type; _getdns_rdf_iter rdf_storage, *rdf; getdns_list *repeat_list = NULL; getdns_dict *repeat_dict = NULL; @@ -254,7 +254,7 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) for ( rdf = _getdns_rdf_iter_init(&rdf_storage, i) ; rdf; rdf = _getdns_rdf_iter_next(rdf)) { if (rdf->rdd_pos->type & GETDNS_RDF_INTEGER) { - val_type = t_int; + val_type = wf_int; switch (rdf->rdd_pos->type & GETDNS_RDF_FIXEDSZ) { case 1: int_val = *rdf->pos; break; @@ -266,13 +266,13 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; } } else if (rdf->rdd_pos->type & GETDNS_RDF_DNAME) { - val_type = t_bindata; + val_type = wf_bindata; bin_data = _getdns_rdf_if_or_as_decompressed( rdf, ff_bytes, &bin_size); } else if (rdf->rdd_pos->type & GETDNS_RDF_BINDATA) { - val_type = t_bindata; + val_type = wf_bindata; if (rdf->rdd_pos->type & GETDNS_RDF_FIXEDSZ) { bin_size = rdf->rdd_pos->type & GETDNS_RDF_FIXEDSZ; @@ -293,24 +293,23 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) break; } } else if (rdf->rdd_pos->type == GETDNS_RDF_SPECIAL) - /* Abuse t_dict for special values */ - val_type = t_dict; + val_type = wf_special; else assert(0); if (! rdf->rdd_repeat) { switch (val_type) { - case t_int: + case wf_int: if (getdns_dict_set_int(rdata_dict, rdf->rdd_pos->name, int_val)) goto rdata_error; break; - case t_bindata: + case wf_bindata: if (_getdns_dict_set_const_bindata(rdata_dict, rdf->rdd_pos->name, bin_size, bin_data)) goto rdata_error; break; - case t_dict: + case wf_special: if (rdf->rdd_pos->special->dict_set_value( rdata_dict, rdf->pos)) goto rdata_error; @@ -328,17 +327,17 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; switch (val_type) { - case t_int: + case wf_int: if (_getdns_list_append_int(repeat_list, int_val)) goto rdata_error; break; - case t_bindata: + case wf_bindata: if (_getdns_list_append_const_bindata( repeat_list, bin_size, bin_data)) goto rdata_error; break; - case t_dict: + case wf_special: if (rdf->rdd_pos->special->list_append_value( repeat_list, rdf->pos)) goto rdata_error; @@ -367,17 +366,17 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) } assert(repeat_dict); switch (val_type) { - case t_int: + case wf_int: if (getdns_dict_set_int(repeat_dict, rdf->rdd_pos->name, int_val)) goto rdata_error; break; - case t_bindata: + case wf_bindata: if (_getdns_dict_set_const_bindata(repeat_dict, rdf->rdd_pos->name, bin_size, bin_data)) goto rdata_error; break; - case t_dict: + case wf_special: if (rdf->rdd_pos->special->dict_set_value( repeat_dict, rdf->pos)) goto rdata_error; From 4ae24761c77eaa0f6de6e3f035e0b3ea70226d96 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 14 Dec 2015 12:38:25 +0100 Subject: [PATCH 09/18] Rename special wireformat parsing funcs in aticipation of the special writing to wireformat functions --- src/rr-dict.c | 36 ++++++++++++++++++------------------ src/rr-dict.h | 13 ++++++++----- src/util-internal.c | 6 +++--- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/rr-dict.c b/src/rr-dict.c index 51f1337d..41301155 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -50,17 +50,17 @@ apl_n_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) return rdf < pkt_end ? rdf + 1 : NULL; } static getdns_return_t -apl_n_dict_set_value(getdns_dict *dict, const uint8_t *rdf) +apl_n_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return getdns_dict_set_int(dict, "n", (*rdf >> 7)); } static getdns_return_t -apl_n_list_append_value(getdns_list *list, const uint8_t *rdf) +apl_n_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, (*rdf >> 7)); } static _getdns_rdf_special apl_n = { - apl_n_rdf_end, apl_n_dict_set_value, apl_n_list_append_value + apl_n_rdf_end, apl_n_wire2dict, apl_n_wire2list }; static const uint8_t * @@ -71,19 +71,19 @@ apl_afdpart_rdf_end( return end <= pkt_end ? end : NULL; } static getdns_return_t -apl_afdpart_dict_set_value(getdns_dict *dict, const uint8_t *rdf) +apl_afdpart_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return _getdns_dict_set_const_bindata( dict, "afdpart", (rdf[-1] & 0x7F), rdf); } static getdns_return_t -apl_afdpart_list_append_value(getdns_list *list, const uint8_t *rdf) +apl_afdpart_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata(list, (rdf[-1] & 0x7F), rdf); } static _getdns_rdf_special apl_afdpart = { apl_afdpart_rdf_end, - apl_afdpart_dict_set_value, apl_afdpart_list_append_value + apl_afdpart_wire2dict, apl_afdpart_wire2list }; static const uint8_t * @@ -144,7 +144,7 @@ ipseckey_gateway_equip_const_bindata( } static getdns_return_t -ipseckey_gateway_dict_set_value(getdns_dict *dict, const uint8_t *rdf) +ipseckey_gateway_wire2dict(getdns_dict *dict, const uint8_t *rdf) { size_t size; const uint8_t *data; @@ -158,7 +158,7 @@ ipseckey_gateway_dict_set_value(getdns_dict *dict, const uint8_t *rdf) return _getdns_dict_set_const_bindata(dict, "gateway", size, data); } static getdns_return_t -ipseckey_gateway_list_append_value(getdns_list *list, const uint8_t *rdf) +ipseckey_gateway_wire2list(getdns_list *list, const uint8_t *rdf) { size_t size; const uint8_t *data; @@ -173,7 +173,7 @@ ipseckey_gateway_list_append_value(getdns_list *list, const uint8_t *rdf) } static _getdns_rdf_special ipseckey_gateway = { ipseckey_gateway_rdf_end, - ipseckey_gateway_dict_set_value, ipseckey_gateway_list_append_value + ipseckey_gateway_wire2dict, ipseckey_gateway_wire2list }; static const uint8_t * @@ -185,18 +185,18 @@ hip_pk_algorithm_rdf_end( : rdf + 1; } static getdns_return_t -hip_pk_algorithm_dict_set_value(getdns_dict *dict, const uint8_t *rdf) +hip_pk_algorithm_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return getdns_dict_set_int(dict, "pk_algorithm", rdf[1]); } static getdns_return_t -hip_pk_algorithm_list_append_value(getdns_list *list, const uint8_t *rdf) +hip_pk_algorithm_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, rdf[1]); } static _getdns_rdf_special hip_pk_algorithm = { hip_pk_algorithm_rdf_end, - hip_pk_algorithm_dict_set_value, hip_pk_algorithm_list_append_value + hip_pk_algorithm_wire2dict, hip_pk_algorithm_wire2list }; static const uint8_t * @@ -207,17 +207,17 @@ hip_hit_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) : rdf + 1; } static getdns_return_t -hip_hit_dict_set_value(getdns_dict *dict, const uint8_t *rdf) +hip_hit_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return _getdns_dict_set_const_bindata(dict, "hit", rdf[-1], rdf + 3); } static getdns_return_t -hip_hit_list_append_value(getdns_list *list, const uint8_t *rdf) +hip_hit_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata(list, rdf[-1], rdf + 3); } static _getdns_rdf_special hip_hit = { - hip_hit_rdf_end, hip_hit_dict_set_value, hip_hit_list_append_value + hip_hit_rdf_end, hip_hit_wire2dict, hip_hit_wire2list }; static const uint8_t * @@ -229,20 +229,20 @@ hip_public_key_rdf_end( : rdf + 2 + rdf[-2] + gldns_read_uint16(rdf); } static getdns_return_t -hip_public_key_dict_set_value(getdns_dict *dict, const uint8_t *rdf) +hip_public_key_wire2dict(getdns_dict *dict, const uint8_t *rdf) { return _getdns_dict_set_const_bindata( dict, "public_key", gldns_read_uint16(rdf), rdf + 2 + rdf[-2]); } static getdns_return_t -hip_public_key_list_append_value(getdns_list *list, const uint8_t *rdf) +hip_public_key_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata( list, gldns_read_uint16(rdf), rdf + 2 + rdf[-2]); } static _getdns_rdf_special hip_public_key = { hip_public_key_rdf_end, - hip_public_key_dict_set_value, hip_public_key_list_append_value + hip_public_key_wire2dict, hip_public_key_wire2list }; diff --git a/src/rr-dict.h b/src/rr-dict.h index 6d2e809b..775b92e8 100644 --- a/src/rr-dict.h +++ b/src/rr-dict.h @@ -36,18 +36,21 @@ #include "getdns/getdns.h" #include "gldns/gbuffer.h" +/* rdf_end returns a pointer to the end of this rdf's data, + * i.e. where the next rdata field will start. + */ typedef const uint8_t *(*_getdns_rdf_end_t)( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf); /* Limit checks are already done with _getdns_rdf_end_t */ -typedef getdns_return_t (*_getdns_rdf_dict_set_value_t)( +typedef getdns_return_t (*_getdns_rdf_wire2dict_t)( getdns_dict *dict, const uint8_t *rdf); -typedef getdns_return_t (*_getdns_rdf_list_append_value_t)( +typedef getdns_return_t (*_getdns_rdf_wire2list_t)( getdns_list *list, const uint8_t *rdf); typedef struct _getdns_rdf_special { - _getdns_rdf_end_t rdf_end; - _getdns_rdf_dict_set_value_t dict_set_value; - _getdns_rdf_list_append_value_t list_append_value; + _getdns_rdf_end_t rdf_end; + _getdns_rdf_wire2dict_t wire2dict; + _getdns_rdf_wire2list_t wire2list; } _getdns_rdf_special; /* draft-levine-dnsextlang'ish type rr and rdata definitions */ diff --git a/src/util-internal.c b/src/util-internal.c index 84b294a7..709645dc 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -310,7 +310,7 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; break; case wf_special: - if (rdf->rdd_pos->special->dict_set_value( + if (rdf->rdd_pos->special->wire2dict( rdata_dict, rdf->pos)) goto rdata_error; default: @@ -338,7 +338,7 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; break; case wf_special: - if (rdf->rdd_pos->special->list_append_value( + if (rdf->rdd_pos->special->wire2list( repeat_list, rdf->pos)) goto rdata_error; default: @@ -377,7 +377,7 @@ _getdns_rr_iter2rr_dict(struct mem_funcs *mf, _getdns_rr_iter *i) goto rdata_error; break; case wf_special: - if (rdf->rdd_pos->special->dict_set_value( + if (rdf->rdd_pos->special->wire2dict( repeat_dict, rdf->pos)) goto rdata_error; default: From de269a4695ae70da2682271a5ebe3debe0ecf0a4 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 14 Dec 2015 15:25:37 +0100 Subject: [PATCH 10/18] Wireformat writing for special rdata fields --- src/rr-dict.c | 302 +++++++++++++++++++++++++++++++++++++++++++++++++- src/rr-dict.h | 9 ++ 2 files changed, 305 insertions(+), 6 deletions(-) diff --git a/src/rr-dict.c b/src/rr-dict.c index 41301155..4952a02a 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -59,8 +59,47 @@ apl_n_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, (*rdf >> 7)); } +static getdns_return_t +apl_n_2wire(uint32_t value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + (void)rdata; /* unused parameter */ + + if (*rdf_len < 1) { + *rdf_len = 1; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = 1; + *rdf = value ? 0x80 : 0x00; + return GETDNS_RETURN_GOOD; +} +static getdns_return_t +apl_n_dict2wire(const getdns_dict *dict, + uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + uint32_t value; + + if ((r = getdns_dict_get_int(dict, "n", &value))) + return r; + else + return apl_n_2wire(value, rdata, rdf, rdf_len); +} +static getdns_return_t +apl_n_list2wire(const getdns_list *list, size_t i, + uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + uint32_t value; + + if ((r = getdns_list_get_int(list, i, &value))) + return r; + else + return apl_n_2wire(value, rdata, rdf, rdf_len); +} static _getdns_rdf_special apl_n = { - apl_n_rdf_end, apl_n_wire2dict, apl_n_wire2list + apl_n_rdf_end, + apl_n_wire2dict, apl_n_wire2list, + apl_n_dict2wire, apl_n_list2wire }; static const uint8_t * @@ -81,9 +120,56 @@ apl_afdpart_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata(list, (rdf[-1] & 0x7F), rdf); } +static getdns_return_t +apl_afdpart_2wire( + const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + if (value->size > 0x7F) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (rdf - 1 < rdata) + return GETDNS_RETURN_GENERIC_ERROR; + + if (*rdf_len < value->size) { + *rdf_len = value->size; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = value->size; + + /* Keeping first bit is safe because value->size <= 0x7F */ + rdf[-1] |= value->size; + + (void) memcpy(rdf, value->data, value->size); + return GETDNS_RETURN_GOOD; +} +static getdns_return_t +apl_afdpart_dict2wire( + const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_dict_get_bindata(dict, "afdpart", &value))) + return r; + else + return apl_afdpart_2wire(value, rdata, rdf, rdf_len); +} +static getdns_return_t +apl_afdpart_list2wire(const getdns_list *list, + size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_list_get_bindata(list, i, &value))) + return r; + else + return apl_afdpart_2wire(value, rdata, rdf, rdf_len); +} static _getdns_rdf_special apl_afdpart = { apl_afdpart_rdf_end, - apl_afdpart_wire2dict, apl_afdpart_wire2list + apl_afdpart_wire2dict, apl_afdpart_wire2list, + apl_afdpart_dict2wire, apl_afdpart_list2wire }; static const uint8_t * @@ -171,9 +257,78 @@ ipseckey_gateway_wire2list(getdns_list *list, const uint8_t *rdf) else return _getdns_list_append_const_bindata(list, size, data); } +static getdns_return_t +ipseckey_gateway_2wire( + const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + if (rdf - 2 < rdata) + return GETDNS_RETURN_GENERIC_ERROR; + + switch (rdf[-2]) { + case 0: if (value && value->size > 0) + return GETDNS_RETURN_INVALID_PARAMETER; + break; + case 1: if (!value || value->size != 4) + return GETDNS_RETURN_INVALID_PARAMETER; + if (*rdf_len < 4) { + *rdf_len = 4; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = 4; + (void)memcpy(rdf, value->data, 4); + return GETDNS_RETURN_GOOD; + case 2: if (!value || value->size != 16) + return GETDNS_RETURN_INVALID_PARAMETER; + if (*rdf_len < 16) { + *rdf_len = 16; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = 16; + (void)memcpy(rdf, value->data, 16); + return GETDNS_RETURN_GOOD; + case 3: if (!value || value->size == 0) + return GETDNS_RETURN_INVALID_PARAMETER; + /* Assume bindata is a valid dname; garbage in, garbage out */ + if (*rdf_len < value->size) { + *rdf_len = value->size; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = value->size; + (void)memcpy(rdf, value->data, value->size); + return GETDNS_RETURN_GOOD; + default: + return GETDNS_RETURN_GENERIC_ERROR; + } + return GETDNS_RETURN_GOOD; +} +static getdns_return_t +ipseckey_gateway_dict2wire( + const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_dict_get_bindata(dict, "gateway", &value))) + return r; + else + return ipseckey_gateway_2wire(value, rdata, rdf, rdf_len); +} +static getdns_return_t +ipseckey_gateway_list2wire(const getdns_list *list, + size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_list_get_bindata(list, i, &value))) + return r; + else + return ipseckey_gateway_2wire(value, rdata, rdf, rdf_len); +} static _getdns_rdf_special ipseckey_gateway = { ipseckey_gateway_rdf_end, - ipseckey_gateway_wire2dict, ipseckey_gateway_wire2list + ipseckey_gateway_wire2dict, ipseckey_gateway_wire2list, + ipseckey_gateway_dict2wire, ipseckey_gateway_list2wire }; static const uint8_t * @@ -194,9 +349,49 @@ hip_pk_algorithm_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_int(list, rdf[1]); } +static getdns_return_t +hip_pk_algorithm_2wire(uint32_t value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + if (rdata != rdf) + return GETDNS_RETURN_GENERIC_ERROR; + if (value > 0xFF) + return GETDNS_RETURN_INVALID_PARAMETER; + if (*rdf_len < 4) { + *rdf_len = 4; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = 4; + rdata[1] = value; + return GETDNS_RETURN_GOOD; +} +static getdns_return_t +hip_pk_algorithm_dict2wire( + const getdns_dict *dict,uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + uint32_t value; + + if ((r = getdns_dict_get_int(dict, "pk_algorithm", &value))) + return r; + else + return hip_pk_algorithm_2wire(value, rdata, rdf, rdf_len); +} +static getdns_return_t +hip_pk_algorithm_list2wire(const getdns_list *list, + size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + uint32_t value; + + if ((r = getdns_list_get_int(list, i, &value))) + return r; + else + return hip_pk_algorithm_2wire(value, rdata, rdf, rdf_len); +} static _getdns_rdf_special hip_pk_algorithm = { hip_pk_algorithm_rdf_end, - hip_pk_algorithm_wire2dict, hip_pk_algorithm_wire2list + hip_pk_algorithm_wire2dict, hip_pk_algorithm_wire2list, + hip_pk_algorithm_dict2wire, hip_pk_algorithm_list2wire }; static const uint8_t * @@ -216,8 +411,56 @@ hip_hit_wire2list(getdns_list *list, const uint8_t *rdf) { return _getdns_list_append_const_bindata(list, rdf[-1], rdf + 3); } +static getdns_return_t +hip_hit_2wire( + const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + if (rdata != rdf - 4) + return GETDNS_RETURN_GENERIC_ERROR; + if (value && value->size > 0xFF) + return GETDNS_RETURN_INVALID_PARAMETER; + if (!value || value->size == 0) { + rdata[0] = 0; + *rdf_len = 0; + return GETDNS_RETURN_GOOD; + } + if (value->size > *rdf_len) { + *rdf_len = value->size; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = value->size; + rdata[0] = value->size; + (void)memcpy(rdf, value->data, value->size); + return GETDNS_RETURN_GOOD; +} +static getdns_return_t +hip_hit_dict2wire( + const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_dict_get_bindata(dict, "hit", &value))) + return r; + else + return hip_hit_2wire(value, rdata, rdf, rdf_len); +} +static getdns_return_t +hip_hit_list2wire(const getdns_list *list, + size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_list_get_bindata(list, i, &value))) + return r; + else + return hip_hit_2wire(value, rdata, rdf, rdf_len); +} static _getdns_rdf_special hip_hit = { - hip_hit_rdf_end, hip_hit_wire2dict, hip_hit_wire2list + hip_hit_rdf_end, + hip_hit_wire2dict, hip_hit_wire2list, + hip_hit_dict2wire, hip_hit_list2wire }; static const uint8_t * @@ -240,9 +483,56 @@ hip_public_key_wire2list(getdns_list *list, const uint8_t *rdf) return _getdns_list_append_const_bindata( list, gldns_read_uint16(rdf), rdf + 2 + rdf[-2]); } +static getdns_return_t +hip_public_key_2wire( + const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + if (rdata > rdf - 4 || rdata + rdata[1] != rdf) + return GETDNS_RETURN_GENERIC_ERROR; + if (value && value->size > 0xFFFF) + return GETDNS_RETURN_INVALID_PARAMETER; + if (!value || value->size == 0) { + rdata[2] = rdata[3] = 0; + *rdf_len = 0; + return GETDNS_RETURN_GOOD; + } + if (value->size > *rdf_len) { + *rdf_len = value->size; + return GETDNS_RETURN_NEED_MORE_SPACE; + } + *rdf_len = value->size; + gldns_write_uint16(rdata + 2, value->size); + (void)memcpy(rdf, value->data, value->size); + return GETDNS_RETURN_GOOD; +} +static getdns_return_t +hip_public_key_dict2wire( + const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_dict_get_bindata(dict, "public_key", &value))) + return r; + else + return hip_public_key_2wire(value, rdata, rdf, rdf_len); +} +static getdns_return_t +hip_public_key_list2wire( + const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) +{ + getdns_return_t r; + getdns_bindata *value; + + if ((r = getdns_list_get_bindata(list, i, &value))) + return r; + else + return hip_public_key_2wire(value, rdata, rdf, rdf_len); +} static _getdns_rdf_special hip_public_key = { hip_public_key_rdf_end, - hip_public_key_wire2dict, hip_public_key_wire2list + hip_public_key_wire2dict, hip_public_key_wire2list, + hip_public_key_dict2wire, hip_public_key_list2wire }; diff --git a/src/rr-dict.h b/src/rr-dict.h index 775b92e8..5faab57a 100644 --- a/src/rr-dict.h +++ b/src/rr-dict.h @@ -36,6 +36,8 @@ #include "getdns/getdns.h" #include "gldns/gbuffer.h" +#define GETDNS_RETURN_NEED_MORE_SPACE ((getdns_return_t)399) + /* rdf_end returns a pointer to the end of this rdf's data, * i.e. where the next rdata field will start. */ @@ -46,11 +48,18 @@ typedef getdns_return_t (*_getdns_rdf_wire2dict_t)( getdns_dict *dict, const uint8_t *rdf); typedef getdns_return_t (*_getdns_rdf_wire2list_t)( getdns_list *list, const uint8_t *rdf); +typedef getdns_return_t (*_getdns_rdf_dict2wire_t)( + const getdns_dict *dict, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len); +typedef getdns_return_t (*_getdns_rdf_list2wire_t)( + const getdns_list *list, size_t index, + uint8_t *rdata, uint8_t *rdf, size_t *rdf_len); typedef struct _getdns_rdf_special { _getdns_rdf_end_t rdf_end; _getdns_rdf_wire2dict_t wire2dict; _getdns_rdf_wire2list_t wire2list; + _getdns_rdf_dict2wire_t dict2wire; + _getdns_rdf_list2wire_t list2wire; } _getdns_rdf_special; /* draft-levine-dnsextlang'ish type rr and rdata definitions */ From 0433c47466080804d00afb7e091e563264d06888 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 15 Dec 2015 00:04:33 +0100 Subject: [PATCH 11/18] Fix memory leak when deleting list items --- src/list.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/list.c b/src/list.c index 660b962e..784e6715 100644 --- a/src/list.c +++ b/src/list.c @@ -107,6 +107,13 @@ _getdns_list_remove_name(getdns_list *list, const char *name) i = &list->items[index]; if (!*next) { + switch (i->dtype) { + case t_dict : getdns_dict_destroy(i->data.dict); break; + case t_list : getdns_list_destroy(i->data.list); break; + case t_bindata: _getdns_bindata_destroy( + &list->mf, i->data.bindata); + default : break; + } if (index < list->numinuse - 1) (void) memmove( i, &i[1], (list->numinuse - index) * sizeof(getdns_item)); From b0aae6b51d0aa8f092a30c8869a95d4fbb450491 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 15 Dec 2015 00:07:05 +0100 Subject: [PATCH 12/18] Repeating and special rdata field 2 wireformat --- src/rr-dict.c | 132 +++++++++++++----- src/rr-dict.h | 6 +- .../260-conversion-functions.c | 129 ++++++++++++++++- .../260-conversion-functions.good | 97 ++++++++++--- 4 files changed, 302 insertions(+), 62 deletions(-) diff --git a/src/rr-dict.c b/src/rr-dict.c index 4952a02a..cb252d98 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -487,7 +487,7 @@ static getdns_return_t hip_public_key_2wire( const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len) { - if (rdata > rdf - 4 || rdata + rdata[1] != rdf) + if (rdata > rdf - 4 || rdata + 4 + rdata[0] != rdf) return GETDNS_RETURN_GENERIC_ERROR; if (value && value->size > 0xFFFF) return GETDNS_RETURN_INVALID_PARAMETER; @@ -1057,74 +1057,109 @@ write_bindata_rdata(gldns_buffer *buf, static getdns_return_t -write_rdata_field(gldns_buffer *buf, - _getdns_rdf_type type, const char *name, getdns_dict *rdata) +write_rdata_field(gldns_buffer *buf, uint8_t *rdata_start, + const _getdns_rdata_def *rd_def, getdns_dict *rdata) { getdns_return_t r; getdns_list *list; uint32_t value; getdns_bindata *bindata; - size_t i; + size_t i, rdf_len; - if (type & GETDNS_RDF_INTEGER) { - if (!(type & GETDNS_RDF_REPEAT)) { - if ((r = getdns_dict_get_int(rdata, name, &value))) + if (rd_def->type & GETDNS_RDF_INTEGER) { + if (!(rd_def->type & GETDNS_RDF_REPEAT)) { + if ((r = getdns_dict_get_int( + rdata, rd_def->name, &value))) return r; else - write_int_rdata(buf, type, value); + write_int_rdata(buf, rd_def->type, value); - } else if ((r = getdns_dict_get_list(rdata, name, &list))) - return r; + } else if ((r = getdns_dict_get_list( + rdata, rd_def->name, &list))) + + return r == GETDNS_RETURN_NO_SUCH_DICT_NAME + ? GETDNS_RETURN_GOOD : r; else for ( i = 0 ; GETDNS_RETURN_GOOD == (r = getdns_list_get_int(list, i, &value)) ; i++) - write_int_rdata(buf, type, value); + write_int_rdata(buf, rd_def->type, value); - if (r != GETDNS_RETURN_NO_SUCH_LIST_ITEM) - return r; - - } else if (type & GETDNS_RDF_BINDATA) { - if (!(type & GETDNS_RDF_REPEAT)) { - if ((r = getdns_dict_get_bindata(rdata,name,&bindata))) + + } else if (rd_def->type & GETDNS_RDF_BINDATA) { + + + if (!(rd_def->type & GETDNS_RDF_REPEAT)) { + if ((r = getdns_dict_get_bindata( + rdata, rd_def->name, &bindata))) return r; else - write_bindata_rdata(buf, type, bindata); + write_bindata_rdata(buf, rd_def->type, bindata); - } else if ((r = getdns_dict_get_list(rdata, name, &list))) - return r; + } else if ((r = getdns_dict_get_list( + rdata, rd_def->name, &list))) + + return r == GETDNS_RETURN_NO_SUCH_DICT_NAME + ? GETDNS_RETURN_GOOD : r; else for ( i = 0 ; GETDNS_RETURN_GOOD == (r = getdns_list_get_bindata(list, i, &bindata)) ; i++) - write_bindata_rdata(buf, type, bindata); + write_bindata_rdata(buf, rd_def->type, bindata); - if (r != GETDNS_RETURN_NO_SUCH_LIST_ITEM) - return r; - } else - /* TODO: Handle the special types */ + } else if (!(rd_def->type & GETDNS_RDF_SPECIAL)) { + /* Unknown rdata type */ return GETDNS_RETURN_GENERIC_ERROR; - return GETDNS_RETURN_GOOD; + } else if (!(rd_def->type & GETDNS_RDF_REPEAT)) { + + rdf_len = gldns_buffer_remaining(buf); + r = rd_def->special->dict2wire(rdata, rdata_start, + gldns_buffer_current(buf), &rdf_len); + if (r == GETDNS_RETURN_GOOD || + r == GETDNS_RETURN_NEED_MORE_SPACE) + gldns_buffer_skip(buf, rdf_len); + if (r) + return r; + + } else if ((r = getdns_dict_get_list(rdata, rd_def->name, &list))) { + + return r == GETDNS_RETURN_NO_SUCH_DICT_NAME + ? GETDNS_RETURN_GOOD : r; + + } else for ( i = 0; r == GETDNS_RETURN_GOOD; i++ ) { + + rdf_len = gldns_buffer_remaining(buf); + r = rd_def->special->list2wire(list, i, rdata_start, + gldns_buffer_current(buf), &rdf_len); + if (r == GETDNS_RETURN_GOOD || + r == GETDNS_RETURN_NEED_MORE_SPACE) + gldns_buffer_skip(buf, rdf_len); + } + + return r != GETDNS_RETURN_NO_SUCH_LIST_ITEM ? r : GETDNS_RETURN_GOOD; } getdns_return_t _getdns_rr_dict2wire(const getdns_dict *rr_dict, gldns_buffer *buf) { getdns_return_t r = GETDNS_RETURN_GOOD; - struct getdns_bindata *name; - struct getdns_bindata *rdata_raw; - struct getdns_dict *rdata; + getdns_bindata *name; + getdns_bindata *rdata_raw; + getdns_dict *rdata; uint32_t rr_type; uint32_t rr_class = GETDNS_RRCLASS_IN; uint32_t rr_ttl = 0; const _getdns_rr_def *rr_def; - const _getdns_rdata_def *rd_def; - int n_rdata_fields; + const _getdns_rdata_def *rd_def, *rep_rd_def; + int n_rdata_fields, rep_n_rdata_fields; size_t rdata_size_mark; + uint8_t *rdata_start; + getdns_list *list; + size_t i; assert(rr_dict); assert(buf); @@ -1166,20 +1201,47 @@ _getdns_rr_dict2wire(const getdns_dict *rr_dict, gldns_buffer *buf) } else if (n_rdata_fields || r == GETDNS_RETURN_NO_SUCH_DICT_NAME) { + r = GETDNS_RETURN_GOOD; rdata_size_mark = gldns_buffer_position(buf); gldns_buffer_skip(buf, 2); + rdata_start = gldns_buffer_current(buf); for ( rd_def = rr_def->rdata , n_rdata_fields = rr_def->n_rdata_fields ; n_rdata_fields ; n_rdata_fields-- , rd_def++ ) { + if (rd_def->type == GETDNS_RDF_REPEAT) + break; - if (rd_def->type != GETDNS_RDF_REPEAT) { - if ((r = write_rdata_field( - buf, rd_def->type, rd_def->name, rdata))) + if ((r = write_rdata_field(buf, + rdata_start, rd_def, rdata))) + break; + } + if (n_rdata_fields == 0 || r) { + /* pass */; + + } else if ((r = getdns_dict_get_list( + rdata, rd_def->name, &list))) { + /* pass */; + + } else for ( i = 0 + ; r == GETDNS_RETURN_GOOD + ; i++) { + + if ((r = getdns_list_get_dict(list, i, &rdata))) { + if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM) + r = GETDNS_RETURN_GOOD; break; } - /* TODO: Deal with repeat blocks */ + for ( rep_rd_def = rd_def + 1 + , rep_n_rdata_fields = n_rdata_fields - 1 + ; rep_n_rdata_fields + ; rep_n_rdata_fields--, rep_rd_def++ ) { + + if ((r = write_rdata_field(buf, + rdata_start, rep_rd_def, rdata))) + break; + } } gldns_buffer_write_u16_at(buf, rdata_size_mark, (uint16_t)(gldns_buffer_position(buf)-rdata_size_mark-2)); diff --git a/src/rr-dict.h b/src/rr-dict.h index 5faab57a..c605be32 100644 --- a/src/rr-dict.h +++ b/src/rr-dict.h @@ -132,15 +132,15 @@ typedef enum _getdns_rdf_wf_type { } _getdns_rdf_type; typedef struct _getdns_rdata_def { - const char *name; + const char *name; _getdns_rdf_type type; _getdns_rdf_special *special; } _getdns_rdata_def; typedef struct _getdns_rr_def { - const char *name; + const char *name; const _getdns_rdata_def *rdata; - int n_rdata_fields; + int n_rdata_fields; } _getdns_rr_def; const _getdns_rr_def *_getdns_rr_def_lookup(uint16_t rr_type); diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c index f92541b6..f3f5a4b6 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c @@ -54,38 +54,91 @@ int main() getdns_dict *rr_dict; getdns_bindata *dns_name; getdns_bindata address = { 4, "\xb9\x31\x8d\x25" }; - getdns_bindata nothing = { 8, "\x07nothing" }; + getdns_bindata fourth = { 11, "last string" }; + size_t length; + getdns_list *list; char *str; uint8_t wire_buf[4096], *wire = wire_buf, *end_of_wire; - size_t wire_len = sizeof(wire_buf); + size_t wire_len; + + /* Convert string to rr_dict + */ if ((r = getdns_str2rr_dict( - "some.domain.tld. 60 CH TXT \"first string\" second \"and third\"", + "some.domain.tld. 60 IN TXT \"first string\" second \"and third\"", &rr_dict, NULL, 3600))) FAIL_r("getdns_str2rr_dict"); + + /* Add a fourth text element. + */ + if ((r = getdns_dict_set_bindata(rr_dict, "/rdata/txt_strings/-", &fourth))) + FAIL_r("getdns_list_set_bindata"); + print_dict(rr_dict); + + /* Convert to wireformat from rdata_raw. + * Added fourth list element should NOT show. + */ + wire_len = sizeof(wire_buf); if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) FAIL_r("getdns_rr_dict2wire"); print_wire(wire, wire_len); + + /* Convert to wireformat from parsing rdata fields. + * Added fourth list element should show. + */ if ((r = getdns_dict_remove_name(rr_dict, "/rdata/rdata_raw"))) FAIL_r("getdns_dict_remove_name"); - print_dict(rr_dict); + printf("\nremoved \"/rdata/rdata_raw\":\n\n"); + wire_len = sizeof(wire_buf); if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) FAIL_r("getdns_rr_dict2wire"); print_wire(wire, wire_len); + + /* Remove second and third string elements and show text format. + */ + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/txt_strings/1"))) + FAIL_r("getdns_dict_remove_name"); + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/txt_strings/1"))) + FAIL_r("getdns_dict_remove_name"); + + if ((r = getdns_rr_dict2str(rr_dict, &str))) + FAIL_r("getdns_rr_dict2str"); + + printf("\n%s", str); + free(str); + + + /* Remove all string elements and show text format. + */ + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/txt_strings/0"))) + FAIL_r("getdns_dict_remove_name"); + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/txt_strings/0"))) + FAIL_r("getdns_dict_remove_name"); + + if ((r = getdns_rr_dict2str(rr_dict, &str))) + FAIL_r("getdns_rr_dict2str"); + + printf("%s", str); + free(str); + getdns_dict_destroy(rr_dict); + /* Forward wireformat to test scanning from wireformat later on + */ wire += wire_len; wire_len = sizeof(wire_buf) - (wire - wire_buf); + /* Construct rr_dict and convert to string + */ if (!(rr_dict = getdns_dict_create())) FAIL("getdns_dict_create returned NULL"); @@ -108,6 +161,7 @@ int main() FAIL_r("getdns_rr_dict2str"); printf("\n%s\n", str); + free(str); if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) FAIL_r("getdns_rr_dict2wire"); @@ -118,6 +172,73 @@ int main() wire += wire_len; wire_len = sizeof(wire_buf) - (wire - wire_buf); + + /* Convert RR with special rdata fields and repeating last element + * from string to rr_dict + */ + if ((r = getdns_str2rr_dict( + "hip2 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs1.example.com. rvs2.example.com.", + &rr_dict, "nlnetlabs.nl", 3600))) + FAIL_r("getdns_str2rr_dict"); + + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/rdata_raw"))) + FAIL_r("getdns_dict_remove_name"); + + printf("\n"); + print_dict(rr_dict); + + /* Convert RR with special rdata fields and repeating last element + * back to string. + */ + if ((r = getdns_rr_dict2str(rr_dict, &str))) + FAIL_r("getdns_rr_dict2str"); + + printf("%s", str); + free(str); + + + /* Convert RR with special rdata fields without repeating last element + * to string. + */ + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/rendezvous_servers"))) + FAIL_r("getdns_dict_remove_name"); + + if ((r = getdns_dict_get_bindata(rr_dict, "name", &dns_name))) + FAIL_r("getdns_dict_get_bindata"); + + dns_name->data[4] = '0'; + + if ((r = getdns_rr_dict2str(rr_dict, &str))) + FAIL_r("getdns_rr_dict2str"); + + printf("%s\n", str); + free(str); + getdns_dict_destroy(rr_dict); + + + /* Convert RR with repeat block from string to rr_dict + */ + if ((r = getdns_str2rr_dict( + "apl APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.128/25 1:224.0.0.0/4 2:FF00:0:0:0:0:0:0:0/8", + &rr_dict, "net-dns.org", 3600))) + FAIL_r("getdns_str2rr_dict"); + + if ((r = getdns_dict_remove_name(rr_dict, "/rdata/rdata_raw"))) + FAIL_r("getdns_dict_remove_name"); + + print_dict(rr_dict); + + + /* Convert repeat block from rr_dict back to string. + */ + if ((r = getdns_rr_dict2str(rr_dict, &str))) + FAIL_r("getdns_rr_dict2str"); + + printf("%s", str); + free(str); + getdns_dict_destroy(rr_dict); + + /* Parse over wire data, convert to string via dict, and print */ end_of_wire = wire; wire = wire_buf; diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good index 11d4500a..6742cb86 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good @@ -1,5 +1,5 @@ { - "class": GETDNS_RRCLASS_CH, + "class": GETDNS_RRCLASS_IN, "name": , "rdata": { @@ -8,38 +8,95 @@ [ , , - + , + ] }, "ttl": 60, "type": GETDNS_RRTYPE_TXT } 0000 04 73 6f 6d 65 06 64 6f 6d 61 69 6e 03 74 6c 64 .some.do main.tld -0010 00 00 10 00 03 00 00 00 3c 00 1e 0c 66 69 72 73 ........ <...firs +0010 00 00 10 00 01 00 00 00 3c 00 1e 0c 66 69 72 73 ........ <...firs 0020 74 20 73 74 72 69 6e 67 06 73 65 63 6f 6e 64 09 t string .second. 0030 61 6e 64 20 74 68 69 72 64 and thir d....... -{ - "class": GETDNS_RRCLASS_CH, - "name": , - "rdata": - { - "txt_strings": - [ - , - , - - ] - }, - "ttl": 60, - "type": GETDNS_RRTYPE_TXT -} + +removed "/rdata/rdata_raw": + 0000 04 73 6f 6d 65 06 64 6f 6d 61 69 6e 03 74 6c 64 .some.do main.tld -0010 00 00 10 00 03 00 00 00 3c 00 1e 0c 66 69 72 73 ........ <...firs +0010 00 00 10 00 01 00 00 00 3c 00 2a 0c 66 69 72 73 ........ <.*.firs 0020 74 20 73 74 72 69 6e 67 06 73 65 63 6f 6e 64 09 t string .second. -0030 61 6e 64 20 74 68 69 72 64 and thir d....... +0030 61 6e 64 20 74 68 69 72 64 0b 6c 61 73 74 20 73 and thir d.last s +0040 74 72 69 6e 67 tring... ........ + +some.domain.tld. 60 IN TXT "first string" "last string" +some.domain.tld. 60 IN TXT \# 0 www.getdnsapi.net. 0 IN A 185.49.141.37 0000 03 77 77 77 09 67 65 74 64 6e 73 61 70 69 03 6e .www.get dnsapi.n 0010 65 74 00 00 01 00 01 00 00 00 00 00 04 b9 31 8d et...... ......1. 0020 25 %....... ........ + +{ + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "hit": , + "pk_algorithm": 2, + "public_key": , + "rendezvous_servers": + [ + , + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_HIP +} +hip2.nlnetlabs.nl. 3600 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs1.example.com. rvs2.example.com. +hip0.nlnetlabs.nl. 3600 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D + +{ + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "apitems": + [ + { + "address_family": 1, + "afdpart": , + "n": 0, + "prefix": 26 + }, + { + "address_family": 1, + "afdpart": , + "n": 0, + "prefix": 26 + }, + { + "address_family": 1, + "afdpart": , + "n": 1, + "prefix": 25 + }, + { + "address_family": 1, + "afdpart": , + "n": 0, + "prefix": 4 + }, + { + "address_family": 2, + "afdpart": , + "n": 0, + "prefix": 8 + } + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_APL +} +apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.128/25 1:224.0.0.0/4 2:ff00:0000:0000:0000:0000:0000:0000:0000/8 From fe7a1e89e3db729bf68a80ea2467f71ad2465ccd Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 22 Dec 2015 11:32:15 +0100 Subject: [PATCH 13/18] Constify new work --- src/context.c | 7 +++---- src/dnssec.c | 4 ++-- src/request-internal.c | 8 ++++---- src/stub.c | 10 +++++----- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/context.c b/src/context.c index fde95d84..adeb0752 100644 --- a/src/context.c +++ b/src/context.c @@ -3085,10 +3085,9 @@ getdns_context_get_upstream_recursive_servers(getdns_context *context, if (upstream->tsig_alg) { tsig_info = _getdns_get_tsig_info(upstream->tsig_alg); - bindata.data = tsig_info->dname; - bindata.size = tsig_info->dname_len; - if ((r = getdns_dict_set_bindata( - d, "tsig_algorithm", &bindata))) + if ((r = _getdns_dict_set_const_bindata( + d, "tsig_algorithm", + tsig_info->dname_len, tsig_info->dname))) break; if (upstream->tsig_dname_len) { diff --git a/src/dnssec.c b/src/dnssec.c index 573d0ca5..28455678 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -268,7 +268,7 @@ static uint8_t *_dname_label_copy(uint8_t *dst, const uint8_t *src, size_t dst_l return r; } -inline void _dname_canonicalize(const uint8_t *src, uint8_t *dst) +inline static void _dname_canonicalize(const uint8_t *src, uint8_t *dst) { const uint8_t *next_label; @@ -280,7 +280,7 @@ inline void _dname_canonicalize(const uint8_t *src, uint8_t *dst) } } -inline void _dname_canonicalize2(uint8_t *dname) +inline static void _dname_canonicalize2(uint8_t *dname) { _dname_canonicalize(dname, dname); } diff --git a/src/request-internal.c b/src/request-internal.c index dbb8a034..d4826f41 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -402,13 +402,13 @@ _getdns_network_validate_tsig(getdns_network_req *req) { _getdns_rr_iter rr_spc, *rr; _getdns_rdf_iter rdf_spc, *rdf; - uint8_t *request_mac; - uint16_t request_mac_len; + const uint8_t *request_mac; + uint16_t request_mac_len; uint8_t tsig_vars[MAXIMUM_TSIG_SPACE]; gldns_buffer gbuf; - uint8_t *dname; + const uint8_t *dname; size_t dname_len; - uint8_t *response_mac; + const uint8_t *response_mac; uint16_t response_mac_len; uint8_t other_len; uint8_t result_mac[EVP_MAX_MD_SIZE]; diff --git a/src/stub.c b/src/stub.c index fb86b96d..4576851e 100644 --- a/src/stub.c +++ b/src/stub.c @@ -197,7 +197,7 @@ attach_edns_cookie(getdns_network_req *req) /* Will find a matching OPT RR, but leaves the caller to validate it*/ static int match_edns_opt_rr(uint16_t code, uint8_t *response, size_t response_len, - uint8_t **position, uint16_t *option_len) + const uint8_t **position, uint16_t *option_len) { _getdns_rr_iter rr_iter_storage, *rr_iter; const uint8_t *pos; @@ -226,10 +226,10 @@ match_edns_opt_rr(uint16_t code, uint8_t *response, size_t response_len, #if defined(STUB_DEBUG) && STUB_DEBUG char str_spc[8192], *str = str_spc; size_t str_len = sizeof(str_spc); - uint8_t *data = rr_iter->pos; + uint8_t *data = (uint8_t *)rr_iter->pos; size_t data_len = rr_iter->nxt - rr_iter->pos; (void) gldns_wire2str_rr_scan( - &data, &data_len, &str, &str_len, rr_iter->pkt, rr_iter->pkt_end - rr_iter->pkt); + &data, &data_len, &str, &str_len, (uint8_t *)rr_iter->pkt, rr_iter->pkt_end - rr_iter->pkt); DEBUG_STUB("OPT RR: %s", str_spc); #endif @@ -262,7 +262,7 @@ static int match_and_process_server_cookie( getdns_upstream *upstream, uint8_t *response, size_t response_len) { - uint8_t *position = NULL; + const uint8_t *position = NULL; uint16_t option_len = 0; int found = match_edns_opt_rr(EDNS_COOKIE_OPCODE, response, response_len, &position, &option_len); @@ -299,7 +299,7 @@ process_keepalive( getdns_upstream *upstream, getdns_network_req *netreq, uint8_t *response, size_t response_len) { - uint8_t *position = NULL; + const uint8_t *position = NULL; uint16_t option_len = 0; int found = match_edns_opt_rr(GLDNS_EDNS_KEEPALIVE, response, response_len, &position, &option_len); From 6519a05780a68746172aa907e99b11b97443b493 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 22 Dec 2015 11:43:06 +0100 Subject: [PATCH 14/18] all debug config option for broadest src coverage With the 300 tpkg test --- configure.ac | 15 +++++++++++++-- .../300-event-loops-configure.test | 14 +++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index eecff2b2..4b0ed882 100644 --- a/configure.ac +++ b/configure.ac @@ -138,7 +138,20 @@ fi ]) ACX_ARG_RPATH + AC_ARG_ENABLE(debug-sched, AC_HELP_STRING([--enable-debug-sched], [Enable scheduling debugging messages])) +AC_ARG_ENABLE(debug-stub, AC_HELP_STRING([--enable-debug-stub], [Enable stub debugging messages])) +AC_ARG_ENABLE(debug-sec, AC_HELP_STRING([--enable-debug-sec], [Enable dnssec debugging messages])) +AC_ARG_ENABLE(all-debugging, AC_HELP_STRING([--enable-all-debugging], [Enable scheduling, stub and dnssec debugging])) +case "$enable_all_debugging" in + yes) + enable_debug_sched=yes + enable_debug_stub=yes + enable_debug_sec=yes + ;; + no|*) + ;; +esac case "$enable_debug_sched" in yes) AC_DEFINE_UNQUOTED([SCHED_DEBUG], [1], [Define this to enable printing of scheduling debugging messages.]) @@ -146,7 +159,6 @@ case "$enable_debug_sched" in no|*) ;; esac -AC_ARG_ENABLE(debug-stub, AC_HELP_STRING([--enable-debug-stub], [Enable stub debugging messages])) case "$enable_debug_stub" in yes) AC_DEFINE_UNQUOTED([STUB_DEBUG], [1], [Define this to enable printing of stub debugging messages.]) @@ -154,7 +166,6 @@ case "$enable_debug_stub" in no|*) ;; esac -AC_ARG_ENABLE(debug-sec, AC_HELP_STRING([--enable-debug-sec], [Enable dnssec debugging messages])) case "$enable_debug_sec" in yes) AC_DEFINE_UNQUOTED([SEC_DEBUG], [1], [Define this to enable printing of dnssec debugging messages.]) diff --git a/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test b/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test index 693ff791..9ed6f38f 100644 --- a/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test +++ b/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test @@ -7,10 +7,10 @@ rm -fr "${BUILDDIR}/build-event-loops" mkdir "${BUILDDIR}/build-event-loops" cd "${BUILDDIR}/build-event-loops" -"${SRCROOT}/configure" --enable-all-drafts --with-libevent --with-libev --with-libuv \ - || "${SRCROOT}/configure" --enable-all-drafts --with-libevent --with-libev \ - || "${SRCROOT}/configure" --enable-all-drafts --with-libevent --with-libuv \ - || "${SRCROOT}/configure" --enable-all-drafts --with-libev --with-libuv \ - || "${SRCROOT}/configure" --enable-all-drafts --with-libevent \ - || "${SRCROOT}/configure" --enable-all-drafts --with-libev \ - || "${SRCROOT}/configure" --enable-all-drafts --with-libuv +"${SRCROOT}/configure" --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libev --with-libuv \ + || "${SRCROOT}/configure" --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libev \ + || "${SRCROOT}/configure" --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libuv \ + || "${SRCROOT}/configure" --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libev --with-libuv \ + || "${SRCROOT}/configure" --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent \ + || "${SRCROOT}/configure" --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libev \ + || "${SRCROOT}/configure" --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libuv From 0cb513e9b77a3d2d505b1a8e167e3b6a7fd5951a Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 22 Dec 2015 16:04:43 +0100 Subject: [PATCH 15/18] Doc of (|_buf|_scan) style conversion funcs + (|_buf|_scan) versions of most of the conversion directions. + mk-const-info handles new return_t's defines --- src/const-info.c | 1 + src/convert.c | 174 ++++++++++++++++-- src/getdns/getdns_extra.h.in | 147 ++++++++++++++- src/mk-const-info.c.sh | 2 +- src/rr-dict.h | 2 - src/rr-iter.c | 6 +- .../260-conversion-functions.c | 27 +-- 7 files changed, 315 insertions(+), 44 deletions(-) diff --git a/src/const-info.c b/src/const-info.c index 1e55a99a..3cfae20e 100644 --- a/src/const-info.c +++ b/src/const-info.c @@ -23,6 +23,7 @@ static struct const_info consts_info[] = { { 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT }, { 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT }, { 312, "GETDNS_RETURN_NOT_IMPLEMENTED", GETDNS_RETURN_NOT_IMPLEMENTED_TEXT }, + { 399, "GETDNS_RETURN_NEED_MORE_SPACE", GETDNS_RETURN_NEED_MORE_SPACE_TEXT }, { 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT }, { 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT }, { 402, "GETDNS_DNSSEC_INDETERMINATE", GETDNS_DNSSEC_INDETERMINATE_TEXT }, diff --git a/src/convert.c b/src/convert.c index 15e07a1c..c7344875 100644 --- a/src/convert.c +++ b/src/convert.c @@ -220,62 +220,192 @@ getdns_strerror(getdns_return_t err, char *buf, size_t buflen) return GETDNS_RETURN_GOOD; } /* getdns_strerror */ + +/* --------------------- rr_dict, wire, str conversions --------------------- */ + + getdns_return_t getdns_rr_dict2wire( + const getdns_dict *rr_dict, uint8_t **wire, size_t *wire_sz) +{ + uint8_t buf_spc[4096], *buf; + size_t buf_len = sizeof(buf_spc); + getdns_return_t r = getdns_rr_dict2wire_buf( + rr_dict, buf_spc, &buf_len); + + if (r != GETDNS_RETURN_GOOD && r != GETDNS_RETURN_NEED_MORE_SPACE) + return r; + + if (!(buf = malloc(buf_len))) + return GETDNS_RETURN_MEMORY_ERROR; + + if (!r) + memcpy(buf, buf_spc, buf_len); + + else if ((r = getdns_rr_dict2wire_buf(rr_dict, buf, &buf_len))) { + free(buf); + return r; + } + *wire = buf; + *wire_sz = buf_len; + return GETDNS_RETURN_GOOD; +} + +getdns_return_t +getdns_rr_dict2wire_buf( const getdns_dict *rr_dict, uint8_t *wire, size_t *wire_sz) +{ + ssize_t my_wire_sz; + getdns_return_t r; + + if (!wire_sz) + return GETDNS_RETURN_INVALID_PARAMETER; + else + my_wire_sz = *wire_sz; + + r = getdns_rr_dict2wire_scan(rr_dict, &wire, &my_wire_sz); + if (r == GETDNS_RETURN_GOOD || r == GETDNS_RETURN_NEED_MORE_SPACE) + *wire_sz -= my_wire_sz; + return r; +} + +getdns_return_t +getdns_rr_dict2wire_scan( + const getdns_dict *rr_dict, uint8_t **wire, ssize_t *wire_sz) { getdns_return_t r; gldns_buffer gbuf; - if (!rr_dict || !wire || !wire_sz) + if (!rr_dict || !wire || !*wire || !wire_sz) return GETDNS_RETURN_INVALID_PARAMETER; - gldns_buffer_init_frm_data(&gbuf, wire, *wire_sz); - r = _getdns_rr_dict2wire(rr_dict, &gbuf); - *wire_sz = gldns_buffer_position(&gbuf); - if (r) + gldns_buffer_init_frm_data(&gbuf, *wire, *wire_sz); + if ((r = _getdns_rr_dict2wire(rr_dict, &gbuf))) return r; - if (gldns_buffer_position(&gbuf) == 0 || - gldns_buffer_position(&gbuf) > gldns_buffer_capacity(&gbuf)) + if (gldns_buffer_position(&gbuf) == 0) return GETDNS_RETURN_GENERIC_ERROR; - return GETDNS_RETURN_GOOD; + *wire += gldns_buffer_position(&gbuf); + *wire_sz -= gldns_buffer_position(&gbuf); + if (gldns_buffer_position(&gbuf) > gldns_buffer_limit(&gbuf)) + return GETDNS_RETURN_NEED_MORE_SPACE; + else + return GETDNS_RETURN_GOOD; } getdns_return_t getdns_wire2rr_dict( const uint8_t *wire, size_t wire_len, getdns_dict **rr_dict) +{ + return getdns_wire2rr_dict_scan(&wire, &wire_len, rr_dict); +} + +getdns_return_t +getdns_wire2rr_dict_buf( + const uint8_t *wire, size_t *wire_len, getdns_dict **rr_dict) +{ + size_t my_wire_len; + getdns_return_t r; + + if (!wire_len) + return GETDNS_RETURN_INVALID_PARAMETER; + else + my_wire_len = *wire_len; + + if ((r = getdns_wire2rr_dict_scan(&wire, &my_wire_len, rr_dict))) + return r; + + *wire_len -= my_wire_len; + return GETDNS_RETURN_GOOD; +} + +getdns_return_t +getdns_wire2rr_dict_scan( + const uint8_t **wire, size_t *wire_len, getdns_dict **rr_dict) { static struct mem_funcs plain_mem_funcs = { MF_PLAIN, .mf.pln = { malloc, realloc, free } }; _getdns_rr_iter rr_iter_spc, *rr_iter; - if (!wire || !rr_dict) + if (!wire || !*wire || !wire_len || !rr_dict) return GETDNS_RETURN_INVALID_PARAMETER; if (!(rr_iter = _getdns_single_rr_iter_init( - &rr_iter_spc, wire, wire_len))) + &rr_iter_spc, *wire, *wire_len))) return GETDNS_RETURN_GENERIC_ERROR; if (!(*rr_dict = _getdns_rr_iter2rr_dict(&plain_mem_funcs, rr_iter))) return GETDNS_RETURN_MEMORY_ERROR; + *wire_len -= (rr_iter->nxt - rr_iter->pos); + *wire = rr_iter->pos; + return GETDNS_RETURN_GOOD; } + getdns_return_t getdns_rr_dict2str( const getdns_dict *rr_dict, char **str) +{ + char buf_spc[4096], *buf; + size_t buf_len = sizeof(buf_spc) - 1; + getdns_return_t r = getdns_rr_dict2str_buf( + rr_dict, buf_spc, &buf_len); + + if (r != GETDNS_RETURN_GOOD && r != GETDNS_RETURN_NEED_MORE_SPACE) + return r; + + if (!(buf = malloc(buf_len + 1))) + return GETDNS_RETURN_MEMORY_ERROR; + + if (!r) + memcpy(buf, buf_spc, buf_len); + + else if ((r = getdns_rr_dict2str_buf(rr_dict, buf, &buf_len))) { + free(buf); + return r; + } + buf[buf_len] = 0; + *str = buf; + return GETDNS_RETURN_GOOD; +} + +getdns_return_t +getdns_rr_dict2str_buf( + const getdns_dict *rr_dict, char *str, size_t *str_len) +{ + ssize_t my_str_len; + getdns_return_t r; + + if (!str_len) + return GETDNS_RETURN_INVALID_PARAMETER; + else + my_str_len = *str_len; + + r = getdns_rr_dict2str_scan(rr_dict, &str, &my_str_len); + if (r == GETDNS_RETURN_GOOD || r == GETDNS_RETURN_NEED_MORE_SPACE) + *str_len -= my_str_len; + return r; + +} + +getdns_return_t +getdns_rr_dict2str_scan( + const getdns_dict *rr_dict, char **str, ssize_t *str_len) { getdns_return_t r; gldns_buffer gbuf; - uint8_t buf_spc[4096], *buf = buf_spc; - size_t sz; + uint8_t buf_spc[4096], *buf = buf_spc, *scan_buf; + size_t sz, scan_sz; + ssize_t prev_str_len; + char *prev_str; + int sz_needed; - if (!rr_dict || !str) + if (!rr_dict || !str || !*str || !str_len) return GETDNS_RETURN_INVALID_PARAMETER; gldns_buffer_init_frm_data(&gbuf, buf, sizeof(buf_spc)); @@ -293,15 +423,27 @@ getdns_rr_dict2str( GETDNS_FREE(rr_dict->mf, buf); return r; } - if (!(*str = gldns_wire2str_rr(gldns_buffer_begin(&gbuf), - gldns_buffer_position(&gbuf)))) - r = GETDNS_RETURN_MEMORY_ERROR; + scan_buf = gldns_buffer_begin(&gbuf); + scan_sz = gldns_buffer_position(&gbuf); + prev_str = *str; + prev_str_len = *str_len; + sz = (size_t)*str_len; + sz_needed = gldns_wire2str_rr_scan( + &scan_buf, &scan_sz, str, &sz, NULL, 0); + if (sz_needed > prev_str_len) { + *str = prev_str + sz_needed; + *str_len = prev_str_len - sz_needed; + r = GETDNS_RETURN_NEED_MORE_SPACE; + } else + *str_len = sz; + if (buf != buf_spc) GETDNS_FREE(rr_dict->mf, buf); return r; } + getdns_return_t getdns_str2rr_dict( const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl) diff --git a/src/getdns/getdns_extra.h.in b/src/getdns/getdns_extra.h.in index 2cb130a7..a66ee2f9 100644 --- a/src/getdns/getdns_extra.h.in +++ b/src/getdns/getdns_extra.h.in @@ -400,21 +400,166 @@ getdns_context_get_tls_authentication(getdns_context *context, #define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN 545 #define GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT "See getdns_context_set_dns_transport()" +#define GETDNS_RETURN_NEED_MORE_SPACE ((getdns_return_t) 399 ) +#define GETDNS_RETURN_NEED_MORE_SPACE_TEXT "The buffer was too small" + +/** + * Convert rr_dict to wireformat representation of the resource record. + * + * @param rr_dict The getdns dict representation of the resource record + * @return wire A newly allocated buffer which will contain the wireformat. + * @return wire_sz The size of the allocated buffer and the wireformat. + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + */ getdns_return_t getdns_rr_dict2wire( + const getdns_dict *rr_dict, uint8_t **wire, size_t *wire_sz); + +/** + * Convert rr_dict to wireformat representation of the resource record. + * + * @param rr_dict The getdns dict representation of the resource record + * @param wire The buffer in which the wireformat will be written + * @param wire_sz On input the size of the wire buffer, + * On output the amount of wireformat needed for the + * wireformat representation of the resource record; + * even if it did not fit. + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too + * small. wire_sz will be set to the needed buffer space then. + */ +getdns_return_t +getdns_rr_dict2wire_buf( const getdns_dict *rr_dict, uint8_t *wire, size_t *wire_sz); +/** + * Convert rr_dict to wireformat representation of the resource record. + * + * @param rr_dict The getdns dict representation of the resource record + * @param wire A pointer to the buffer pointer in which the wireformat + * will be written. + * On output the buffer pointer will have moved along + * the buffer and point right after the just written RR. + * @param wire_sz On input the size of the wire buffer, + * On output the amount of wireformat needed for the + * wireformat will have been substracted from wire_sz. + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too + * small. The function will pretend that it had written beyond the end + * of the buffer, and wire will point past the buffer and wire_sz will + * contain a negative value. + */ +getdns_return_t +getdns_rr_dict2wire_scan( + const getdns_dict *rr_dict, uint8_t **wire, ssize_t *wire_sz); + + +/** + * Convert wireformat resource record in a getdns rr_dict representation. + * + * @param wire Buffer containing the wireformat rr + * @param wire_sz Size of the wire buffer + * @return rr_dict The returned rr_dict + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + */ getdns_return_t getdns_wire2rr_dict( const uint8_t *wire, size_t wire_sz, getdns_dict **rr_dict); +/** + * Convert wireformat resource record in a getdns rr_dict representation. + * + * @param wire Buffer containing the wireformat rr + * @param wire_sz On input the size of the wire buffer + * On output the length of the wireformat rr. + * @return rr_dict The returned rr_dict + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + */ +getdns_return_t +getdns_wire2rr_dict_buf( + const uint8_t *wire, size_t *wire_sz, getdns_dict **rr_dict); + +/** + * Convert wireformat resource record in a getdns rr_dict representation. + * + * @param wire A pointer to the pointer of the wireformat buffer. + * On return this pointer is moved to after first read + * in resource record. + * @param wire_sz On input the size of the wire buffer + * On output the size is decreased with the length + * of the wireformat resource record. + * @return rr_dict The returned rr_dict + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + */ +getdns_return_t +getdns_wire2rr_dict_scan( + const uint8_t **wire, size_t *wire_sz, getdns_dict **rr_dict); + + +/** + * Convert rr_dict to the string representation of the resource record. + * + * @param rr_dict The getdns dict representation of the resource record + * @return str A newly allocated string representation of the rr + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + */ getdns_return_t getdns_rr_dict2str( const getdns_dict *rr_dict, char **str); +/** + * Convert rr_dict to the string representation of the resource record. + * + * @param rr_dict The getdns dict representation of the resource record + * @param str The buffer in which the string will be written + * @param str_len On input the size of the text buffer, + * On output the amount of characters needed to write + * the string representation of the rr. Even if it does + * not fit. + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too + * small. str_len will be set to the needed buffer space then. + */ +getdns_return_t +getdns_rr_dict2str_buf( + const getdns_dict *rr_dict, char *str, size_t *str_len); + +/** + * Convert rr_dict to the string representation of the resource record. + * + * @param rr_dict The getdns dict representation of the resource record + * @param str A pointer to the buffer pointer in which the string + * will be written. + * On output the buffer pointer will have moved along + * the buffer and point right after the just written RR. + * @param str_len On input the size of the str buffer, + * On output the number of characters needed for the + * string will have been substracted from strlen. + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + * GETDNS_RETURN_NEED_MORE_SPACE will be returned when the buffer was too + * small. The function will pretend that it had written beyond the end + * of the buffer, and str will point past the buffer and str_len will + * contain a negative value. + */ +getdns_return_t +getdns_rr_dict2str_scan( + const getdns_dict *rr_dict, char **str, ssize_t *str_len); + + +/** + * Convert the string representation of the resource record to rr_dict format. + * + * @param str String representation of the resource record. + * @return rr_dict The result getdns dict representation of the resource record + * @param origin Default suffix for not fully qualified domain names + * @param default_ttl Default ttl + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + */ getdns_return_t getdns_str2rr_dict( - const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl); + const char *str, getdns_dict **rr_dict, + const char *origin, uint32_t default_ttl); + #ifdef __cplusplus } diff --git a/src/mk-const-info.c.sh b/src/mk-const-info.c.sh index f343e6fc..1bf7927f 100755 --- a/src/mk-const-info.c.sh +++ b/src/mk-const-info.c.sh @@ -12,7 +12,7 @@ cat > const-info.c << END_OF_HEAD static struct const_info consts_info[] = { { -1, NULL, "/* */" }, END_OF_HEAD -gawk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ key = sprintf("%4d", $3); consts[key] = $1; }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/^#define GETDNS_RRCLASS/ && !/^#define GETDNS_OPCODE/ && !/^#define GETDNS_RCODE/ && !/_TEXT/{ key = sprintf("%4d", $3); consts[key] = $2; }END{ n = asorti(consts, const_vals); for ( i = 1; i <= n; i++) { val = const_vals[i]; name = consts[val]; print "\t{ "val", \""name"\", "name"_TEXT },"}}' getdns/getdns.h.in getdns/getdns_extra.h.in | sed 's/,,/,/g' >> const-info.c +gawk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ key = sprintf("%4d", $3); consts[key] = $1; }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/^#define GETDNS_RRCLASS/ && !/^#define GETDNS_OPCODE/ && !/^#define GETDNS_RCODE/ && !/_TEXT/{ key = sprintf("%4d", $3); consts[key] = $2; }/^#define GETDNS_[A-Z_]+[ ]+\(\(getdns_return_t) [0-9]+ \)/{ key = sprintf("%4d", $4); consts[key] = $2; }END{ n = asorti(consts, const_vals); for ( i = 1; i <= n; i++) { val = const_vals[i]; name = consts[val]; print "\t{ "val", \""name"\", "name"_TEXT },"}}' getdns/getdns.h.in getdns/getdns_extra.h.in | sed 's/,,/,/g' >> const-info.c cat >> const-info.c << END_OF_TAIL }; diff --git a/src/rr-dict.h b/src/rr-dict.h index c605be32..6ab52b88 100644 --- a/src/rr-dict.h +++ b/src/rr-dict.h @@ -36,8 +36,6 @@ #include "getdns/getdns.h" #include "gldns/gbuffer.h" -#define GETDNS_RETURN_NEED_MORE_SPACE ((getdns_return_t)399) - /* rdf_end returns a pointer to the end of this rdf's data, * i.e. where the next rdata field will start. */ diff --git a/src/rr-iter.c b/src/rr-iter.c index 31913b20..1615d761 100644 --- a/src/rr-iter.c +++ b/src/rr-iter.c @@ -39,11 +39,7 @@ rr_iter_find_nxt(_getdns_rr_iter *i) assert(i); assert(i->rr_type); - if (!i->pkt) { - i->nxt = i->pkt_end; - return; - } - i->nxt = i->n < GLDNS_QDCOUNT(i->pkt) + i->nxt = i->pkt && i->n < GLDNS_QDCOUNT(i->pkt) ? i->rr_type + 4 : i->rr_type + 10 > i->pkt_end ? i->pkt_end diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c index f3f5a4b6..614284b4 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c @@ -58,7 +58,7 @@ int main() size_t length; getdns_list *list; char *str; - uint8_t wire_buf[4096], *wire = wire_buf, *end_of_wire; + uint8_t *wire; size_t wire_len; @@ -81,11 +81,12 @@ int main() /* Convert to wireformat from rdata_raw. * Added fourth list element should NOT show. */ - wire_len = sizeof(wire_buf); - if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) + wire = NULL; + if ((r = getdns_rr_dict2wire(rr_dict, &wire, &wire_len))) FAIL_r("getdns_rr_dict2wire"); print_wire(wire, wire_len); + free(wire); /* Convert to wireformat from parsing rdata fields. @@ -96,11 +97,11 @@ int main() printf("\nremoved \"/rdata/rdata_raw\":\n\n"); - wire_len = sizeof(wire_buf); - if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) + if ((r = getdns_rr_dict2wire(rr_dict, &wire, &wire_len))) FAIL_r("getdns_rr_dict2wire"); print_wire(wire, wire_len); + free(wire); /* Remove second and third string elements and show text format. @@ -132,11 +133,6 @@ int main() getdns_dict_destroy(rr_dict); - /* Forward wireformat to test scanning from wireformat later on - */ - wire += wire_len; - wire_len = sizeof(wire_buf) - (wire - wire_buf); - /* Construct rr_dict and convert to string */ if (!(rr_dict = getdns_dict_create())) @@ -163,14 +159,12 @@ int main() printf("\n%s\n", str); free(str); - if ((r = getdns_rr_dict2wire(rr_dict, wire, &wire_len))) + if ((r = getdns_rr_dict2wire(rr_dict, &wire, &wire_len))) FAIL_r("getdns_rr_dict2wire"); getdns_dict_destroy(rr_dict); print_wire(wire, wire_len); - - wire += wire_len; - wire_len = sizeof(wire_buf) - (wire - wire_buf); + free(wire); /* Convert RR with special rdata fields and repeating last element @@ -239,10 +233,5 @@ int main() getdns_dict_destroy(rr_dict); - /* Parse over wire data, convert to string via dict, and print */ - end_of_wire = wire; - wire = wire_buf; - wire_len = end_of_wire - wire; - exit(EXIT_SUCCESS); } From e4fa06a57be85e0a7c2f84247ea844049ba77a32 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 22 Dec 2015 18:37:24 +0100 Subject: [PATCH 16/18] getdns_fp2rr_list conversion function + private conversion functions that respect custom memory handlers + converage of more different example functions in 260-conversion-functions test package --- src/Makefile.in | 44 +- src/convert.c | 124 +- src/convert.h | 57 + src/getdns/getdns_extra.h.in | 14 + src/libgetdns.symbols | 7 + .../260-conversion-functions.c | 77 +- .../260-conversion-functions.good | 1746 +++++++++++++++++ .../260-conversion-functions.net-dns.org | 133 ++ .../260-conversion-functions.test | 10 +- 9 files changed, 2174 insertions(+), 38 deletions(-) create mode 100644 src/convert.h create mode 100644 src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org diff --git a/src/Makefile.in b/src/Makefile.in index a4e632b2..f0ab2074 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -230,14 +230,14 @@ const-info.lo const-info.o: $(srcdir)/const-info.c \ getdns/getdns_extra.h \ $(srcdir)/const-info.h context.lo context.o: $(srcdir)/context.c \ - config.h $(srcdir)/debug.h \ - $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h \ + config.h \ + $(srcdir)/debug.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h \ getdns/getdns.h \ getdns/getdns_extra.h \ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/util-internal.h \ $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h \ - $(srcdir)/list.h + $(srcdir)/list.h $(srcdir)/dict.h convert.lo convert.o: $(srcdir)/convert.c \ config.h \ getdns/getdns.h \ @@ -245,17 +245,18 @@ convert.lo convert.o: $(srcdir)/convert.c \ $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \ $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \ - $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h + $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/convert.h dict.lo dict.o: $(srcdir)/dict.c $(srcdir)/types-internal.h \ getdns/getdns.h \ getdns/getdns_extra.h \ $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \ - config.h $(srcdir)/context.h \ - $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ + config.h \ + $(srcdir)/context.h $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \ $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/const-info.h $(srcdir)/gldns/wire2str.h dnssec.lo dnssec.o: $(srcdir)/dnssec.c \ - config.h $(srcdir)/debug.h \ + config.h \ + $(srcdir)/debug.h \ getdns/getdns.h \ $(srcdir)/context.h \ getdns/getdns_extra.h \ @@ -276,8 +277,8 @@ list.lo list.o: $(srcdir)/list.c $(srcdir)/types-internal.h \ getdns/getdns.h \ getdns/getdns_extra.h \ $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \ - config.h $(srcdir)/context.h \ - $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ + config.h \ + $(srcdir)/context.h $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \ $(srcdir)/list.h $(srcdir)/dict.h request-internal.lo request-internal.o: $(srcdir)/request-internal.c \ @@ -288,7 +289,7 @@ request-internal.lo request-internal.o: $(srcdir)/request-internal.c \ $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h \ - $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h + $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h $(srcdir)/debug.h rr-dict.lo rr-dict.o: $(srcdir)/rr-dict.c $(srcdir)/rr-dict.h \ config.h \ getdns/getdns.h \ @@ -299,21 +300,23 @@ rr-dict.lo rr-dict.o: $(srcdir)/rr-dict.c $(srcdir)/rr-dict.h \ $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h rr-iter.lo rr-iter.o: $(srcdir)/rr-iter.c $(srcdir)/rr-iter.h \ getdns/getdns.h \ - $(srcdir)/rr-dict.h config.h \ + $(srcdir)/rr-dict.h \ + config.h \ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h stub.lo stub.o: $(srcdir)/stub.c \ - config.h $(srcdir)/debug.h \ - $(srcdir)/stub.h \ + config.h \ + $(srcdir)/debug.h $(srcdir)/stub.h \ getdns/getdns.h \ $(srcdir)/types-internal.h \ getdns/getdns_extra.h \ $(srcdir)/util/rbtree.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h \ - $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/context.h \ - $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ + $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \ + $(srcdir)/context.h $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \ $(srcdir)/types-internal.h $(srcdir)/util-internal.h $(srcdir)/general.h sync.lo sync.o: $(srcdir)/sync.c \ getdns/getdns.h \ - config.h $(srcdir)/context.h \ + config.h \ + $(srcdir)/context.h \ getdns/getdns_extra.h \ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/general.h \ @@ -327,6 +330,7 @@ util-internal.lo util-internal.o: $(srcdir)/util-internal.c \ $(srcdir)/list.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h +version.lo version.o: version.c gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c \ config.h \ $(srcdir)/gldns/gbuffer.h @@ -393,14 +397,14 @@ libevent.lo libevent.o: $(srcdir)/extension/libevent.c \ getdns/getdns_extra.h \ $(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libevent.h libmini_event.lo libmini_event.o: $(srcdir)/extension/libmini_event.c \ - config.h $(srcdir)/debug.h \ - $(srcdir)/types-internal.h \ + config.h \ + $(srcdir)/debug.h $(srcdir)/types-internal.h \ getdns/getdns.h \ getdns/getdns_extra.h \ $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h libuv.lo libuv.o: $(srcdir)/extension/libuv.c \ - config.h $(srcdir)/debug.h \ - $(srcdir)/types-internal.h \ + config.h \ + $(srcdir)/debug.h $(srcdir)/types-internal.h \ getdns/getdns.h \ getdns/getdns_extra.h \ $(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libuv.h diff --git a/src/convert.c b/src/convert.c index c7344875..f2293d06 100644 --- a/src/convert.c +++ b/src/convert.c @@ -47,6 +47,8 @@ #include "gldns/wire2str.h" #include "gldns/str2wire.h" #include "dict.h" +#include "list.h" +#include "convert.h" /* stuff to make it compile pedantically */ #define UNUSED_PARAM(x) ((void)(x)) @@ -295,15 +297,26 @@ getdns_rr_dict2wire_scan( return GETDNS_RETURN_GOOD; } +static struct mem_funcs _getdns_plain_mem_funcs = { + MF_PLAIN, .mf.pln = { malloc, realloc, free } +}; + +getdns_return_t +_getdns_wire2rr_dict(struct mem_funcs *mf, + const uint8_t *wire, size_t wire_len, getdns_dict **rr_dict) +{ + return _getdns_wire2rr_dict_scan(mf, &wire, &wire_len, rr_dict); +} getdns_return_t getdns_wire2rr_dict( const uint8_t *wire, size_t wire_len, getdns_dict **rr_dict) { - return getdns_wire2rr_dict_scan(&wire, &wire_len, rr_dict); + return _getdns_wire2rr_dict( + &_getdns_plain_mem_funcs, wire, wire_len, rr_dict); } getdns_return_t -getdns_wire2rr_dict_buf( +_getdns_wire2rr_dict_buf(struct mem_funcs *mf, const uint8_t *wire, size_t *wire_len, getdns_dict **rr_dict) { size_t my_wire_len; @@ -314,20 +327,24 @@ getdns_wire2rr_dict_buf( else my_wire_len = *wire_len; - if ((r = getdns_wire2rr_dict_scan(&wire, &my_wire_len, rr_dict))) + if ((r = _getdns_wire2rr_dict_scan(mf, &wire, &my_wire_len, rr_dict))) return r; *wire_len -= my_wire_len; return GETDNS_RETURN_GOOD; } +getdns_return_t +getdns_wire2rr_dict_buf( + const uint8_t *wire, size_t *wire_len, getdns_dict **rr_dict) +{ + return _getdns_wire2rr_dict_buf( + &_getdns_plain_mem_funcs, wire, wire_len, rr_dict); +} getdns_return_t -getdns_wire2rr_dict_scan( +_getdns_wire2rr_dict_scan(struct mem_funcs *mf, const uint8_t **wire, size_t *wire_len, getdns_dict **rr_dict) { - static struct mem_funcs plain_mem_funcs = { - MF_PLAIN, .mf.pln = { malloc, realloc, free } - }; _getdns_rr_iter rr_iter_spc, *rr_iter; if (!wire || !*wire || !wire_len || !rr_dict) @@ -337,14 +354,21 @@ getdns_wire2rr_dict_scan( &rr_iter_spc, *wire, *wire_len))) return GETDNS_RETURN_GENERIC_ERROR; - if (!(*rr_dict = _getdns_rr_iter2rr_dict(&plain_mem_funcs, rr_iter))) + if (!(*rr_dict = _getdns_rr_iter2rr_dict(mf, rr_iter))) return GETDNS_RETURN_MEMORY_ERROR; *wire_len -= (rr_iter->nxt - rr_iter->pos); - *wire = rr_iter->pos; + *wire = rr_iter->nxt; return GETDNS_RETURN_GOOD; } +getdns_return_t +getdns_wire2rr_dict_scan( + const uint8_t **wire, size_t *wire_len, getdns_dict **rr_dict) +{ + return _getdns_wire2rr_dict_scan( + &_getdns_plain_mem_funcs, wire, wire_len, rr_dict); +} getdns_return_t @@ -445,7 +469,7 @@ getdns_rr_dict2str_scan( getdns_return_t -getdns_str2rr_dict( +_getdns_str2rr_dict(struct mem_funcs *mf, const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl) { uint8_t wire_spc[4096], *wire = wire_spc; @@ -468,20 +492,92 @@ getdns_str2rr_dict( e = gldns_str2wire_rr_buf(str, wire, &wire_len, NULL, default_ttl, origin_wf, origin_len, NULL, 0); if (GLDNS_WIREPARSE_ERROR(e) == GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL) { - if (!(wire = malloc((wire_len = GLDNS_RR_BUF_SIZE)))) + + if (!(wire = GETDNS_XMALLOC( + *mf, uint8_t, (wire_len = GLDNS_RR_BUF_SIZE)))) return GETDNS_RETURN_MEMORY_ERROR; e = gldns_str2wire_rr_buf(str, wire, &wire_len, NULL, default_ttl, origin_wf, origin_len, NULL, 0); } if (e) { if (wire != wire_spc) - free(wire); + GETDNS_FREE(*mf, wire); return GETDNS_RETURN_GENERIC_ERROR; } - r = getdns_wire2rr_dict(wire, wire_len, rr_dict); + r = _getdns_wire2rr_dict(mf, wire, wire_len, rr_dict); if (wire != wire_spc) - free(wire); + GETDNS_FREE(*mf, wire); + return r; +} +getdns_return_t +getdns_str2rr_dict( + const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl) +{ + return _getdns_str2rr_dict( + &_getdns_plain_mem_funcs, str, rr_dict, origin, default_ttl); +} + + +getdns_return_t +_getdns_fp2rr_list(struct mem_funcs *mf, + FILE *in, getdns_list **rr_list, const char *origin, uint32_t default_ttl) +{ + struct gldns_file_parse_state pst; + getdns_list *rrs; + getdns_return_t r = GETDNS_RETURN_GOOD; + uint8_t *rr; + size_t len, dname_len; + getdns_dict *rr_dict; + + if (!in || !rr_list) + return GETDNS_RETURN_INVALID_PARAMETER; + + if (!origin) { + *pst.origin = 0; + pst.origin_len = 0; + + } else if (gldns_str2wire_dname_buf(origin,pst.origin,&pst.origin_len)) + return GETDNS_RETURN_GENERIC_ERROR; + + *pst.prev_rr = 0; + pst.prev_rr_len = 1; + pst.default_ttl = default_ttl; + pst.lineno = 1; + + if (!(rrs = _getdns_list_create_with_mf(mf))) + return GETDNS_RETURN_MEMORY_ERROR; + + + if (!(rr = GETDNS_XMALLOC(*mf, uint8_t, GLDNS_RR_BUF_SIZE))) + r = GETDNS_RETURN_MEMORY_ERROR; + + else while (r == GETDNS_RETURN_GOOD && !feof(in)) { + len = GLDNS_RR_BUF_SIZE; + dname_len = 0; + if (gldns_fp2wire_rr_buf(in, rr, &len, &dname_len, &pst)) + break; + if (len == 0) + continue; + if ((r = _getdns_wire2rr_dict(mf, rr, len, &rr_dict))) + break; + r = _getdns_list_append_dict(rrs, rr_dict); + getdns_dict_destroy(rr_dict); + } + if (rr) + GETDNS_FREE(*mf, rr); + if (r) + getdns_list_destroy(rrs); + else + *rr_list = rrs; return r; } +getdns_return_t +getdns_fp2rr_list( + FILE *in, getdns_list **rr_list, const char *origin, uint32_t default_ttl) +{ + return _getdns_fp2rr_list( + &_getdns_plain_mem_funcs, in, rr_list, origin, default_ttl); +} + /* convert.c */ diff --git a/src/convert.h b/src/convert.h new file mode 100644 index 00000000..18b982ed --- /dev/null +++ b/src/convert.h @@ -0,0 +1,57 @@ +/** + * + * \file convert.h + * @brief getdns label conversion functions + * + */ + +/* + * Copyright (c) 2013, NLnet Labs, Verisign, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the names of the copyright holders nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _GETDNS_CONVERT_H_ +#define _GETDNS_CONVERT_H_ + +#include "types-internal.h" +#include + +getdns_return_t _getdns_wire2rr_dict(struct mem_funcs *mf, + const uint8_t *wire, size_t wire_len, getdns_dict **rr_dict); + +getdns_return_t _getdns_wire2rr_dict_buf(struct mem_funcs *mf, + const uint8_t *wire, size_t *wire_len, getdns_dict **rr_dict); + +getdns_return_t _getdns_wire2rr_dict_scan(struct mem_funcs *mf, + const uint8_t **wire, size_t *wire_len, getdns_dict **rr_dict); + +getdns_return_t _getdns_str2rr_dict(struct mem_funcs *mf, const char *str, + getdns_dict **rr_dict, const char *origin, uint32_t default_ttl); + +getdns_return_t _getdns_fp2rr_list(struct mem_funcs *mf, FILE *in, + getdns_list **rr_list, const char *origin, uint32_t default_ttl); + +#endif +/* convert.h */ diff --git a/src/getdns/getdns_extra.h.in b/src/getdns/getdns_extra.h.in index a66ee2f9..a33e6f4a 100644 --- a/src/getdns/getdns_extra.h.in +++ b/src/getdns/getdns_extra.h.in @@ -30,6 +30,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -560,6 +561,19 @@ getdns_str2rr_dict( const char *str, getdns_dict **rr_dict, const char *origin, uint32_t default_ttl); +/** + * Read the zonefile and convert to a list of rr_dict's. + * + * @param fp String representation of the resource record. + * @return rr_list The result list of rr_dicts representing the zone file. + * @param origin Default suffix for not fully qualified domain names + * @param default_ttl Default ttl + * @return GETDNS_RETURN_GOOD on success or an error code on failure. + */ +getdns_return_t +getdns_fp2rr_list( + FILE *in, getdns_list **rr_list, + const char *origin, uint32_t default_ttl); #ifdef __cplusplus } diff --git a/src/libgetdns.symbols b/src/libgetdns.symbols index 2983f1fc..2503c48c 100644 --- a/src/libgetdns.symbols +++ b/src/libgetdns.symbols @@ -83,6 +83,7 @@ getdns_dict_set_list getdns_dict_util_get_string getdns_dict_util_set_string getdns_display_ip_address +getdns_fp2rr_list getdns_general getdns_general_sync getdns_get_api_version @@ -115,7 +116,11 @@ getdns_print_json_dict getdns_print_json_list getdns_root_trust_anchor getdns_rr_dict2str +getdns_rr_dict2str_buf +getdns_rr_dict2str_scan getdns_rr_dict2wire +getdns_rr_dict2wire_buf +getdns_rr_dict2wire_scan getdns_service getdns_service_sync getdns_snprint_json_dict @@ -124,5 +129,7 @@ getdns_str2rr_dict getdns_strerror getdns_validate_dnssec getdns_wire2rr_dict +getdns_wire2rr_dict_buf +getdns_wire2rr_dict_scan plain_mem_funcs_user_arg priv_getdns_context_mf diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c index 614284b4..c497256e 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c @@ -20,6 +20,13 @@ void print_dict(getdns_dict *rr_dict) free(str); } +void print_list(getdns_list *rr_list) +{ + char *str = getdns_pretty_print_list(rr_list); + printf("%s\n", str); + free(str); +} + void print_wire(uint8_t *wire, size_t wire_len) { size_t pos, i; @@ -48,7 +55,7 @@ void print_wire(uint8_t *wire, size_t wire_len) } -int main() +int main(int argc, char const * const argv[]) { getdns_return_t r; getdns_dict *rr_dict; @@ -56,11 +63,16 @@ int main() getdns_bindata address = { 4, "\xb9\x31\x8d\x25" }; getdns_bindata fourth = { 11, "last string" }; size_t length; - getdns_list *list; char *str; uint8_t *wire; size_t wire_len; - + getdns_list *rr_list; + FILE *in; + uint8_t wire_buf[7800]; + size_t i; + ssize_t available; + char str_buf[10000]; + ssize_t str_len = sizeof(str_buf); /* Convert string to rr_dict */ @@ -232,6 +244,65 @@ int main() free(str); getdns_dict_destroy(rr_dict); + if (!(in = fopen(argv[1], "r"))) + FAIL("Could not fopen %s\n", argv[1]); + + if ((r = getdns_fp2rr_list(in, &rr_list, NULL, 0))) + FAIL_r("getdns_fp2rr_list"); + + fclose(in); + + print_list(rr_list); + + + /* Fill the wire_buf with wireformat RR's in rr_list + * wire_buf is too small for last two rr's. + */ + wire = wire_buf; + available = sizeof(wire_buf); + + for (i = 0; !(r = getdns_list_get_dict(rr_list, i, &rr_dict)); i++) { + if ((r = getdns_rr_dict2wire_scan(rr_dict, &wire, &available))) { + if (r == GETDNS_RETURN_NEED_MORE_SPACE) { + printf("record %.3zu, available buffer space: " + "%zi\n", i, available); + break; + } + else + FAIL_r("getdns_rr_dict2wire_scan"); + } + printf("record %3zu, available buffer space: " + "%zi\n", i, available); + } + if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM) + r = GETDNS_RETURN_GOOD; + + getdns_list_destroy(rr_list); + + /* Now scan over the wireformat buffer and convert to rr_dicts again. + * Then fill a string buffer with those rr_dicts. + */ + wire = wire_buf; + available = sizeof(wire_buf); + + str = str_buf; + str_len = sizeof(str_buf); + + while (available > 0 && str_len > 0) { + rr_dict = NULL; + if ((r = getdns_wire2rr_dict_scan( + (const uint8_t **)&wire, &available, &rr_dict))) + FAIL_r("getdns_wire2rr_dict_scan"); + + if ((r = getdns_rr_dict2str_scan(rr_dict, &str, &str_len))) + FAIL_r("getdns_rr_dict2str_scan"); + + getdns_dict_destroy(rr_dict); + } + *str = 0; + + /* Print the entire buffer */ + printf("%s", str_buf); exit(EXIT_SUCCESS); } diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good index 6742cb86..8a1b184c 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good @@ -100,3 +100,1749 @@ hip0.nlnetlabs.nl. 3600 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSu "type": GETDNS_RRTYPE_APL } apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.128/25 1:224.0.0.0/4 2:ff00:0000:0000:0000:0000:0000:0000:0000/8 +[ + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "expire": 345600, + "minimum": 300, + "mname": , + "rdata_raw": , + "refresh": 450, + "retry": 600, + "rname": , + "serial": 2015081800 + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_SOA + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "nsdname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_NS + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "nsdname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_NS + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "nsdname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_NS + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "nsdname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_NS + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv4_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_A + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv6_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_AAAA + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "exchange": , + "preference": 10, + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_MX + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "exchange": , + "preference": 20, + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_MX + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "certificate_association_data": , + "certificate_usage": 3, + "matching_type": 1, + "rdata_raw": , + "selector": 1 + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TLSA + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "certificate_association_data": , + "certificate_usage": 3, + "matching_type": 1, + "rdata_raw": , + "selector": 1 + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TLSA + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + , + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv4_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_A + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv4_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_A + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv4_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_A + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv4_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_A + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "cname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_CNAME + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "exchange": , + "preference": 10, + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_MX + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "exchange": , + "preference": 10, + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_MX + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "exchange": , + "preference": 15, + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_MX + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + , + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + , + , + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + , + , + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + , + , + , + , + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv4_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_A + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv6_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_AAAA + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "cname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_CNAME + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "cname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_CNAME + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "cname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_CNAME + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "cname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_CNAME + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "cname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_CNAME + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "cname": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_CNAME + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv4_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_A + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "ipv6_address": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_AAAA + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "apitems": + [ + { + "address_family": 1, + "afdpart": , + "n": 0, + "prefix": 26 + }, + { + "address_family": 1, + "afdpart": , + "n": 0, + "prefix": 26 + }, + { + "address_family": 1, + "afdpart": , + "n": 1, + "prefix": 25 + }, + { + "address_family": 1, + "afdpart": , + "n": 0, + "prefix": 4 + }, + { + "address_family": 2, + "afdpart": , + "n": 0, + "prefix": 8 + } + ], + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_APL + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway_type": 0, + "precedence": 2, + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway": , + "gateway_type": 1, + "precedence": 2, + "public_key": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway": , + "gateway_type": 2, + "precedence": 2, + "public_key": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway": , + "gateway_type": 3, + "precedence": 2, + "public_key": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway_type": 0, + "precedence": 2, + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway": , + "gateway_type": 1, + "precedence": 2, + "public_key": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway": , + "gateway_type": 2, + "precedence": 2, + "public_key": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "algorithm": 10, + "gateway": , + "gateway_type": 3, + "precedence": 2, + "public_key": , + "rdata_raw": + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_IPSECKEY + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + }, + { + "class": GETDNS_RRCLASS_IN, + "name": , + "rdata": + { + "rdata_raw": , + "txt_strings": + [ + + ] + }, + "ttl": 3600, + "type": GETDNS_RRTYPE_TXT + } +] +record 0, available buffer space: 7717 +record 1, available buffer space: 7689 +record 2, available buffer space: 7663 +record 3, available buffer space: 7636 +record 4, available buffer space: 7602 +record 5, available buffer space: 7587 +record 6, available buffer space: 7560 +record 7, available buffer space: 7527 +record 8, available buffer space: 7498 +record 9, available buffer space: 7470 +record 10, available buffer space: 7402 +record 11, available buffer space: 7330 +record 12, available buffer space: 7283 +record 13, available buffer space: 7250 +record 14, available buffer space: 7213 +record 15, available buffer space: 7118 +record 16, available buffer space: 7032 +record 17, available buffer space: 6946 +record 18, available buffer space: 6860 +record 19, available buffer space: 6774 +record 20, available buffer space: 6688 +record 21, available buffer space: 6602 +record 22, available buffer space: 6516 +record 23, available buffer space: 6430 +record 24, available buffer space: 6343 +record 25, available buffer space: 6256 +record 26, available buffer space: 6169 +record 27, available buffer space: 6082 +record 28, available buffer space: 5995 +record 29, available buffer space: 5908 +record 30, available buffer space: 5821 +record 31, available buffer space: 5734 +record 32, available buffer space: 5647 +record 33, available buffer space: 5560 +record 34, available buffer space: 5473 +record 35, available buffer space: 5386 +record 36, available buffer space: 5299 +record 37, available buffer space: 5212 +record 38, available buffer space: 5125 +record 39, available buffer space: 5038 +record 40, available buffer space: 4951 +record 41, available buffer space: 4864 +record 42, available buffer space: 4777 +record 43, available buffer space: 4690 +record 44, available buffer space: 4603 +record 45, available buffer space: 4516 +record 46, available buffer space: 4429 +record 47, available buffer space: 4342 +record 48, available buffer space: 4255 +record 49, available buffer space: 4168 +record 50, available buffer space: 4081 +record 51, available buffer space: 3994 +record 52, available buffer space: 3907 +record 53, available buffer space: 3820 +record 54, available buffer space: 3733 +record 55, available buffer space: 3646 +record 56, available buffer space: 3559 +record 57, available buffer space: 3472 +record 58, available buffer space: 3385 +record 59, available buffer space: 3298 +record 60, available buffer space: 3211 +record 61, available buffer space: 3124 +record 62, available buffer space: 3037 +record 63, available buffer space: 2950 +record 64, available buffer space: 2863 +record 65, available buffer space: 2776 +record 66, available buffer space: 2689 +record 67, available buffer space: 2602 +record 68, available buffer space: 2515 +record 69, available buffer space: 2428 +record 70, available buffer space: 2341 +record 71, available buffer space: 2254 +record 72, available buffer space: 2167 +record 73, available buffer space: 2080 +record 74, available buffer space: 1992 +record 75, available buffer space: 1899 +record 76, available buffer space: 1824 +record 77, available buffer space: 1793 +record 78, available buffer space: 1761 +record 79, available buffer space: 1713 +record 80, available buffer space: 1666 +record 81, available buffer space: 1618 +record 82, available buffer space: 1573 +record 83, available buffer space: 1536 +record 84, available buffer space: 1445 +record 85, available buffer space: 1381 +record 86, available buffer space: 1314 +record 87, available buffer space: 1243 +record 88, available buffer space: 1166 +record 89, available buffer space: 1137 +record 90, available buffer space: 1096 +record 91, available buffer space: 1044 +record 92, available buffer space: 990 +record 93, available buffer space: 937 +record 94, available buffer space: 884 +record 95, available buffer space: 819 +record 96, available buffer space: 749 +record 97, available buffer space: 718 +record 98, available buffer space: 675 +record 99, available buffer space: 615 +record 100, available buffer space: 545 +record 101, available buffer space: 471 +record 102, available buffer space: 385 +record 103, available buffer space: 292 +record 104, available buffer space: 223 +record 105, available buffer space: 159 +record 106, available buffer space: 83 +record 107, available buffer space: 0 +record 108, available buffer space: -296 +net-dns.org. 3600 IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. 2015081800 450 600 345600 300 +. 3600 IN NS ns.nlnetlabs.nl. +. 3600 IN NS ns.hactrn.net. +. 3600 IN NS mcvax.nlnet.nl. +. 3600 IN NS sec2.authdns.ripe.net. +. 3600 IN A 185.49.140.22 +. 3600 IN AAAA 2a04:b900::2:0:0:22 +. 3600 IN MX 10 dicht.nlnetlabs.nl. +. 3600 IN MX 20 mcvax.nlnet.nl. +. 3600 IN TXT "Net::DNS domain" +_443._tcp.net-dns.org. 3600 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 +_443._tcp.www.net-dns.org. 3600 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 +dynup.net-dns.org. 3600 IN TXT "fooFoo2" "Bla ; Foo" +lists.net-dns.org. 3600 IN A 63.209.15.196 +localhost.net-dns.org. 3600 IN A 127.0.0.1 +overflow.net-dns.org. 3600 IN TXT "And line 1 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 2 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 3 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 4 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 5 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 6 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 7 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 8 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 9 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 10 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 11 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 12 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 13 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 14 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 15 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 16 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 17 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 18 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 19 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 20 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 21 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 22 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 23 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 25 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 26 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 27 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 28 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 29 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 30 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 31 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 32 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 33 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 34 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 35 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 36 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 37 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 38 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 39 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 40 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 41 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 42 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 43 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 44 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 45 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 46 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 47 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 48 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 49 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 50 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 51 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 52 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 53 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 54 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 55 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 56 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 57 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 58 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 59 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 60 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "And line 224 of al sorts of crap that will just fill the packet " +net-dns.org. 3600 IN TXT "An increadibly large answer section that will lead to packet overflow" +t.net-dns.org. 3600 IN TXT "The names within this domain are used for testing" +a.t.net-dns.org. 3600 IN A 10.0.1.128 +a2.t.net-dns.org. 3600 IN A 10.0.1.129 +cname.t.net-dns.org. 3600 IN CNAME a.t.net-dns.org. +mx.t.net-dns.org. 3600 IN MX 10 a.t.net-dns.org. +mx2.t.net-dns.org. 3600 IN MX 10 a.t.net-dns.org. +t.net-dns.org. 3600 IN MX 15 a2.t.net-dns.org. +txt.t.net-dns.org. 3600 IN TXT "Net-DNS" +txt2.t.net-dns.org. 3600 IN TXT "Net-DNS; complicated $tuff" "sort of \" text; and binary \000 data" +connection-test.t.net-dns.org. 3600 IN TXT "connection-test succes" +txt-utf8.t.net-dns.org. 3600 IN TXT "\229\143\164\230\177\160\227\130\132" "\232\155\153\233\163\155\232\190\188\227\130\128" "\230\176\180\227\129\174\233\159\179" +txt-utf8-bin.t.net-dns.org. 3600 IN TXT "\229\143\164\230\177\160\227\130\132" "\232\155\153\233\163\155\232\190\188\227\130\128" "\230\176\180\227\129\174\233\159\179" +a.few.empty.non.terminals.t.net-dns.org. 3600 IN TXT "a" "few" "empty" "non" "terminals" +t.net-dns.org. 3600 IN A 185.49.140.22 +t.net-dns.org. 3600 IN AAAA 2a04:b900::2:0:0:22 +yx1.cname.t.net-dns.org. 3600 IN CNAME -.t.net-dns.org. +yx2.cname.t.net-dns.org. 3600 IN CNAME a-a.t.net-dns.org. +yx3.cname.t.net-dns.org. 3600 IN CNAME a\..t.net-dns.org. +yx4.cname.t.net-dns.org. 3600 IN CNAME a\000.t.net-dns.org. +nx1.cname.t.net-dns.org. 3600 IN CNAME does.not.exist.t.net-dns.org. +nx2.cname.t.net-dns.org. 3600 IN CNAME empty.non.terminals.t.net-dns.org. +www.net-dns.org. 3600 IN A 185.49.140.22 +www.net-dns.org. 3600 IN AAAA 2a04:b900::2:0:0:22 +apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.128/25 1:224.0.0.0/4 2:ff00:0000:0000:0000:0000:0000:0000:0000/8 +ipseckey0.net-dns.org. 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey1.net-dns.org. 3600 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey2.net-dns.org. 3600 IN IPSECKEY 10 2 2 2001:db8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey3.net-dns.org. 3600 IN IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey.net-dns.org. 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +net-dns.org. 3600 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +net-dns.org. 3600 IN IPSECKEY 10 2 2 2001:db8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +net-dns.org. 3600 IN IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org new file mode 100644 index 00000000..9eb59930 --- /dev/null +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org @@ -0,0 +1,133 @@ +$ORIGIN . +$TTL 30 ; 30 seconds + +net-dns.org IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. ( + 2015081800 ; serial + 450 ; refresh (7 minutes 30 seconds) + 600 ; retry (10 minutes) + 345600 ; expire (4 days) + 300 ; minimum (5 minutes) + ) + NS ns.nlnetlabs.nl + NS ns.hactrn.net. + NS mcvax.nlnet.nl. + NS sec2.authdns.ripe.net. + + A 185.49.140.22 + AAAA 2a04:b900::2:0:0:22 + + MX 10 dicht.nlnetlabs.nl. + MX 20 mcvax.nlnet.nl. + TXT "Net::DNS domain" +$ORIGIN net-dns.org. +_443._tcp TLSA 3 1 1 274c6f96c9885c8050e8a05ad1c3162c1d51752c35b6196474e3f05ad31cd923 +_443._tcp.www TLSA 3 1 1 274c6f96c9885c8050e8a05ad1c3162c1d51752c35b6196474e3f05ad31cd923 + +dynup TXT "fooFoo2" "Bla \; Foo" +lists A 63.209.15.196 +localhost A 127.0.0.1 + +overflow TXT "And line 1 of al sorts of crap that will just fill the packet " + TXT "And line 2 of al sorts of crap that will just fill the packet " + TXT "And line 3 of al sorts of crap that will just fill the packet " + TXT "And line 4 of al sorts of crap that will just fill the packet " + TXT "And line 5 of al sorts of crap that will just fill the packet " + TXT "And line 6 of al sorts of crap that will just fill the packet " + TXT "And line 7 of al sorts of crap that will just fill the packet " + TXT "And line 8 of al sorts of crap that will just fill the packet " + TXT "And line 9 of al sorts of crap that will just fill the packet " + TXT "And line 10 of al sorts of crap that will just fill the packet " + TXT "And line 11 of al sorts of crap that will just fill the packet " + TXT "And line 12 of al sorts of crap that will just fill the packet " + TXT "And line 13 of al sorts of crap that will just fill the packet " + TXT "And line 14 of al sorts of crap that will just fill the packet " + TXT "And line 15 of al sorts of crap that will just fill the packet " + TXT "And line 16 of al sorts of crap that will just fill the packet " + TXT "And line 17 of al sorts of crap that will just fill the packet " + TXT "And line 18 of al sorts of crap that will just fill the packet " + TXT "And line 19 of al sorts of crap that will just fill the packet " + TXT "And line 20 of al sorts of crap that will just fill the packet " + TXT "And line 21 of al sorts of crap that will just fill the packet " + TXT "And line 22 of al sorts of crap that will just fill the packet " + TXT "And line 23 of al sorts of crap that will just fill the packet " + TXT "And line 25 of al sorts of crap that will just fill the packet " + TXT "And line 26 of al sorts of crap that will just fill the packet " + TXT "And line 27 of al sorts of crap that will just fill the packet " + TXT "And line 28 of al sorts of crap that will just fill the packet " + TXT "And line 29 of al sorts of crap that will just fill the packet " + TXT "And line 30 of al sorts of crap that will just fill the packet " + TXT "And line 31 of al sorts of crap that will just fill the packet " + TXT "And line 32 of al sorts of crap that will just fill the packet " + TXT "And line 33 of al sorts of crap that will just fill the packet " + TXT "And line 34 of al sorts of crap that will just fill the packet " + TXT "And line 35 of al sorts of crap that will just fill the packet " + TXT "And line 36 of al sorts of crap that will just fill the packet " + TXT "And line 37 of al sorts of crap that will just fill the packet " + TXT "And line 38 of al sorts of crap that will just fill the packet " + TXT "And line 39 of al sorts of crap that will just fill the packet " + TXT "And line 40 of al sorts of crap that will just fill the packet " + TXT "And line 41 of al sorts of crap that will just fill the packet " + TXT "And line 42 of al sorts of crap that will just fill the packet " + TXT "And line 43 of al sorts of crap that will just fill the packet " + TXT "And line 44 of al sorts of crap that will just fill the packet " + TXT "And line 45 of al sorts of crap that will just fill the packet " + TXT "And line 46 of al sorts of crap that will just fill the packet " + TXT "And line 47 of al sorts of crap that will just fill the packet " + TXT "And line 48 of al sorts of crap that will just fill the packet " + TXT "And line 49 of al sorts of crap that will just fill the packet " + TXT "And line 50 of al sorts of crap that will just fill the packet " + TXT "And line 51 of al sorts of crap that will just fill the packet " + TXT "And line 52 of al sorts of crap that will just fill the packet " + TXT "And line 53 of al sorts of crap that will just fill the packet " + TXT "And line 54 of al sorts of crap that will just fill the packet " + TXT "And line 55 of al sorts of crap that will just fill the packet " + TXT "And line 56 of al sorts of crap that will just fill the packet " + TXT "And line 57 of al sorts of crap that will just fill the packet " + TXT "And line 58 of al sorts of crap that will just fill the packet " + TXT "And line 59 of al sorts of crap that will just fill the packet " + TXT "And line 60 of al sorts of crap that will just fill the packet " + TXT "And line 224 of al sorts of crap that will just fill the packet " + TXT "An increadibly large answer section that will lead to packet overflow" +t TXT "The names within this domain are used for testing" +$ORIGIN t.net-dns.org. +a A 10.0.1.128 +a2 A 10.0.1.129 +cname CNAME a +mx MX 10 a +mx2 MX 10 a + MX 15 a2 +txt TXT "Net-DNS" +txt2 TXT "Net-DNS\; complicated $tuff" "sort of \" text\; and binary \000 data" +connection-test TXT "connection-test succes" +txt-utf8 TXT \# 33 09E58FA4E6B1A0E382840CE89B99E9A39BE8BEBCE3828009E6B0B4E381AEE99FB3 +txt-utf8-bin TXT "古池や" "蛙飛込む" "水の音" +a.few.empty.non.terminals TXT a few empty non terminals + A 185.49.140.22 + AAAA 2a04:b900::2:0:0:22 +yx1.cname CNAME - +yx2.cname CNAME a-a +yx3.cname CNAME a\. +yx4.cname CNAME a\000 +nx1.cname CNAME does.not.exist +nx2.cname CNAME empty.non.terminals + +$ORIGIN net-dns.org. + +www A 185.49.140.22 +www AAAA 2a04:b900::2:0:0:22 + +apl APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.128/25 1:224.0.0.0/4 2:FF00:0:0:0:0:0:0:0/8 + +ipseckey0 IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey1 IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey2 IPSECKEY 10 2 2 2001:0DB8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey3 IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== + IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== + IPSECKEY 10 2 2 2001:0DB8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== + IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== + +default._domainkey IN TXT "v=DKIM1; r=postmaster; g=*; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVG/lfF5GtPlMOcSGnfbp5u+EWM+OOg/f6QmbDXOW/zKQkRIRIZ+BtfSYchP8MeFPfMvUZtdRPzCWg1G7OdD7qaTUqc6kV84on6/8kPVMgdDLyLl2DeU/Lts9hfVHVDSpWuChwDAFXnbnW8jpp54zuof9OIbWSWIxZqLL8flgOsQIDAQAB" ; ----- DKIM default for example.com + +2.3.3.updates.spamassassin TXT "1418219 " +mirrors.updates.spamassassin TXT "http://anonymous@spamassassin.apache.org/updates/MIRRORED.BY" diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test index b840c1dc..91f6787a 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.test @@ -4,4 +4,12 @@ # use .tpkg.var.test for in test variable passing [ -f .tpkg.var.test ] && source .tpkg.var.test -make && "./${TPKG_NAME}" | tee out && diff out "${TPKG_NAME}.good" +if ! make +then + exit 1 +elif ! ( "./${TPKG_NAME}" "${TPKG_NAME}.net-dns.org" | tee out ) +then + exit 1 +else + diff out "${TPKG_NAME}.good" +fi From 11cd8926629982fd21fde3120acb8580a40f17ea Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Tue, 22 Dec 2015 19:14:18 +0100 Subject: [PATCH 17/18] Clean boundries on wireformat scans --- .../260-conversion-functions.c | 9 +- .../260-conversion-functions.good | 258 +++++++++--------- .../260-conversion-functions.net-dns.org | 2 +- 3 files changed, 136 insertions(+), 133 deletions(-) diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c index c497256e..c1d3bf2b 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c @@ -64,11 +64,11 @@ int main(int argc, char const * const argv[]) getdns_bindata fourth = { 11, "last string" }; size_t length; char *str; - uint8_t *wire; + uint8_t *wire, *prev_wire; size_t wire_len; getdns_list *rr_list; FILE *in; - uint8_t wire_buf[7800]; + uint8_t wire_buf[8200]; size_t i; ssize_t available; char str_buf[10000]; @@ -262,10 +262,12 @@ int main(int argc, char const * const argv[]) available = sizeof(wire_buf); for (i = 0; !(r = getdns_list_get_dict(rr_list, i, &rr_dict)); i++) { + prev_wire = wire; if ((r = getdns_rr_dict2wire_scan(rr_dict, &wire, &available))) { if (r == GETDNS_RETURN_NEED_MORE_SPACE) { printf("record %.3zu, available buffer space: " "%zi\n", i, available); + wire = prev_wire; break; } else @@ -273,6 +275,7 @@ int main(int argc, char const * const argv[]) } printf("record %3zu, available buffer space: " "%zi\n", i, available); + fflush(stdout); } if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM) r = GETDNS_RETURN_GOOD; @@ -282,8 +285,8 @@ int main(int argc, char const * const argv[]) /* Now scan over the wireformat buffer and convert to rr_dicts again. * Then fill a string buffer with those rr_dicts. */ + available = wire - wire_buf; wire = wire_buf; - available = sizeof(wire_buf); str = str_buf; str_len = sizeof(str_buf); diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good index 8a1b184c..91781ed0 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good @@ -120,18 +120,18 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { - "nsdname": , - "rdata_raw": + "nsdname": , + "rdata_raw": }, "ttl": 3600, "type": GETDNS_RRTYPE_NS }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "nsdname": , @@ -142,7 +142,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "nsdname": , @@ -153,7 +153,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "nsdname": , @@ -164,7 +164,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "ipv4_address": , @@ -175,7 +175,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "ipv6_address": , @@ -186,7 +186,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "exchange": , @@ -198,7 +198,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "exchange": , @@ -210,7 +210,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1629,125 +1629,125 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "type": GETDNS_RRTYPE_TXT } ] -record 0, available buffer space: 7717 -record 1, available buffer space: 7689 -record 2, available buffer space: 7663 -record 3, available buffer space: 7636 -record 4, available buffer space: 7602 -record 5, available buffer space: 7587 -record 6, available buffer space: 7560 -record 7, available buffer space: 7527 -record 8, available buffer space: 7498 -record 9, available buffer space: 7470 -record 10, available buffer space: 7402 -record 11, available buffer space: 7330 -record 12, available buffer space: 7283 -record 13, available buffer space: 7250 -record 14, available buffer space: 7213 -record 15, available buffer space: 7118 -record 16, available buffer space: 7032 -record 17, available buffer space: 6946 -record 18, available buffer space: 6860 -record 19, available buffer space: 6774 -record 20, available buffer space: 6688 -record 21, available buffer space: 6602 -record 22, available buffer space: 6516 -record 23, available buffer space: 6430 -record 24, available buffer space: 6343 -record 25, available buffer space: 6256 -record 26, available buffer space: 6169 -record 27, available buffer space: 6082 -record 28, available buffer space: 5995 -record 29, available buffer space: 5908 -record 30, available buffer space: 5821 -record 31, available buffer space: 5734 -record 32, available buffer space: 5647 -record 33, available buffer space: 5560 -record 34, available buffer space: 5473 -record 35, available buffer space: 5386 -record 36, available buffer space: 5299 -record 37, available buffer space: 5212 -record 38, available buffer space: 5125 -record 39, available buffer space: 5038 -record 40, available buffer space: 4951 -record 41, available buffer space: 4864 -record 42, available buffer space: 4777 -record 43, available buffer space: 4690 -record 44, available buffer space: 4603 -record 45, available buffer space: 4516 -record 46, available buffer space: 4429 -record 47, available buffer space: 4342 -record 48, available buffer space: 4255 -record 49, available buffer space: 4168 -record 50, available buffer space: 4081 -record 51, available buffer space: 3994 -record 52, available buffer space: 3907 -record 53, available buffer space: 3820 -record 54, available buffer space: 3733 -record 55, available buffer space: 3646 -record 56, available buffer space: 3559 -record 57, available buffer space: 3472 -record 58, available buffer space: 3385 -record 59, available buffer space: 3298 -record 60, available buffer space: 3211 -record 61, available buffer space: 3124 -record 62, available buffer space: 3037 -record 63, available buffer space: 2950 -record 64, available buffer space: 2863 -record 65, available buffer space: 2776 -record 66, available buffer space: 2689 -record 67, available buffer space: 2602 -record 68, available buffer space: 2515 -record 69, available buffer space: 2428 -record 70, available buffer space: 2341 -record 71, available buffer space: 2254 -record 72, available buffer space: 2167 -record 73, available buffer space: 2080 -record 74, available buffer space: 1992 -record 75, available buffer space: 1899 -record 76, available buffer space: 1824 -record 77, available buffer space: 1793 -record 78, available buffer space: 1761 -record 79, available buffer space: 1713 -record 80, available buffer space: 1666 -record 81, available buffer space: 1618 -record 82, available buffer space: 1573 -record 83, available buffer space: 1536 -record 84, available buffer space: 1445 -record 85, available buffer space: 1381 -record 86, available buffer space: 1314 -record 87, available buffer space: 1243 -record 88, available buffer space: 1166 -record 89, available buffer space: 1137 -record 90, available buffer space: 1096 -record 91, available buffer space: 1044 -record 92, available buffer space: 990 -record 93, available buffer space: 937 -record 94, available buffer space: 884 -record 95, available buffer space: 819 -record 96, available buffer space: 749 -record 97, available buffer space: 718 -record 98, available buffer space: 675 -record 99, available buffer space: 615 -record 100, available buffer space: 545 -record 101, available buffer space: 471 -record 102, available buffer space: 385 -record 103, available buffer space: 292 -record 104, available buffer space: 223 -record 105, available buffer space: 159 -record 106, available buffer space: 83 -record 107, available buffer space: 0 -record 108, available buffer space: -296 +record 0, available buffer space: 8117 +record 1, available buffer space: 8065 +record 2, available buffer space: 8027 +record 3, available buffer space: 7988 +record 4, available buffer space: 7942 +record 5, available buffer space: 7915 +record 6, available buffer space: 7876 +record 7, available buffer space: 7831 +record 8, available buffer space: 7790 +record 9, available buffer space: 7750 +record 10, available buffer space: 7682 +record 11, available buffer space: 7610 +record 12, available buffer space: 7563 +record 13, available buffer space: 7530 +record 14, available buffer space: 7493 +record 15, available buffer space: 7398 +record 16, available buffer space: 7312 +record 17, available buffer space: 7226 +record 18, available buffer space: 7140 +record 19, available buffer space: 7054 +record 20, available buffer space: 6968 +record 21, available buffer space: 6882 +record 22, available buffer space: 6796 +record 23, available buffer space: 6710 +record 24, available buffer space: 6623 +record 25, available buffer space: 6536 +record 26, available buffer space: 6449 +record 27, available buffer space: 6362 +record 28, available buffer space: 6275 +record 29, available buffer space: 6188 +record 30, available buffer space: 6101 +record 31, available buffer space: 6014 +record 32, available buffer space: 5927 +record 33, available buffer space: 5840 +record 34, available buffer space: 5753 +record 35, available buffer space: 5666 +record 36, available buffer space: 5579 +record 37, available buffer space: 5492 +record 38, available buffer space: 5405 +record 39, available buffer space: 5318 +record 40, available buffer space: 5231 +record 41, available buffer space: 5144 +record 42, available buffer space: 5057 +record 43, available buffer space: 4970 +record 44, available buffer space: 4883 +record 45, available buffer space: 4796 +record 46, available buffer space: 4709 +record 47, available buffer space: 4622 +record 48, available buffer space: 4535 +record 49, available buffer space: 4448 +record 50, available buffer space: 4361 +record 51, available buffer space: 4274 +record 52, available buffer space: 4187 +record 53, available buffer space: 4100 +record 54, available buffer space: 4013 +record 55, available buffer space: 3926 +record 56, available buffer space: 3839 +record 57, available buffer space: 3752 +record 58, available buffer space: 3665 +record 59, available buffer space: 3578 +record 60, available buffer space: 3491 +record 61, available buffer space: 3404 +record 62, available buffer space: 3317 +record 63, available buffer space: 3230 +record 64, available buffer space: 3143 +record 65, available buffer space: 3056 +record 66, available buffer space: 2969 +record 67, available buffer space: 2882 +record 68, available buffer space: 2795 +record 69, available buffer space: 2708 +record 70, available buffer space: 2621 +record 71, available buffer space: 2534 +record 72, available buffer space: 2447 +record 73, available buffer space: 2360 +record 74, available buffer space: 2272 +record 75, available buffer space: 2179 +record 76, available buffer space: 2104 +record 77, available buffer space: 2073 +record 78, available buffer space: 2041 +record 79, available buffer space: 1993 +record 80, available buffer space: 1946 +record 81, available buffer space: 1898 +record 82, available buffer space: 1853 +record 83, available buffer space: 1816 +record 84, available buffer space: 1725 +record 85, available buffer space: 1661 +record 86, available buffer space: 1594 +record 87, available buffer space: 1523 +record 88, available buffer space: 1446 +record 89, available buffer space: 1417 +record 90, available buffer space: 1376 +record 91, available buffer space: 1324 +record 92, available buffer space: 1270 +record 93, available buffer space: 1217 +record 94, available buffer space: 1164 +record 95, available buffer space: 1099 +record 96, available buffer space: 1029 +record 97, available buffer space: 998 +record 98, available buffer space: 955 +record 99, available buffer space: 895 +record 100, available buffer space: 825 +record 101, available buffer space: 751 +record 102, available buffer space: 665 +record 103, available buffer space: 572 +record 104, available buffer space: 503 +record 105, available buffer space: 439 +record 106, available buffer space: 363 +record 107, available buffer space: 280 +record 108, available buffer space: -16 net-dns.org. 3600 IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. 2015081800 450 600 345600 300 -. 3600 IN NS ns.nlnetlabs.nl. -. 3600 IN NS ns.hactrn.net. -. 3600 IN NS mcvax.nlnet.nl. -. 3600 IN NS sec2.authdns.ripe.net. -. 3600 IN A 185.49.140.22 -. 3600 IN AAAA 2a04:b900::2:0:0:22 -. 3600 IN MX 10 dicht.nlnetlabs.nl. -. 3600 IN MX 20 mcvax.nlnet.nl. -. 3600 IN TXT "Net::DNS domain" +net-dns.org. 3600 IN NS ns.nlnetlabs.nl.net-dns.org. +net-dns.org. 3600 IN NS ns.hactrn.net. +net-dns.org. 3600 IN NS mcvax.nlnet.nl. +net-dns.org. 3600 IN NS sec2.authdns.ripe.net. +net-dns.org. 3600 IN A 185.49.140.22 +net-dns.org. 3600 IN AAAA 2a04:b900::2:0:0:22 +net-dns.org. 3600 IN MX 10 dicht.nlnetlabs.nl. +net-dns.org. 3600 IN MX 20 mcvax.nlnet.nl. +net-dns.org. 3600 IN TXT "Net::DNS domain" _443._tcp.net-dns.org. 3600 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 _443._tcp.www.net-dns.org. 3600 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 dynup.net-dns.org. 3600 IN TXT "fooFoo2" "Bla ; Foo" diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org index 9eb59930..f00e1185 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org @@ -8,6 +8,7 @@ net-dns.org IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. ( 345600 ; expire (4 days) 300 ; minimum (5 minutes) ) +$ORIGIN net-dns.org. NS ns.nlnetlabs.nl NS ns.hactrn.net. NS mcvax.nlnet.nl. @@ -19,7 +20,6 @@ net-dns.org IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. ( MX 10 dicht.nlnetlabs.nl. MX 20 mcvax.nlnet.nl. TXT "Net::DNS domain" -$ORIGIN net-dns.org. _443._tcp TLSA 3 1 1 274c6f96c9885c8050e8a05ad1c3162c1d51752c35b6196474e3f05ad31cd923 _443._tcp.www TLSA 3 1 1 274c6f96c9885c8050e8a05ad1c3162c1d51752c35b6196474e3f05ad31cd923 From f9c2f9699630425cb60320f330822e580605edf9 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Wed, 23 Dec 2015 12:06:09 +0100 Subject: [PATCH 18/18] Fixes for miscelanous little zone parse errors Hopefully the tpkg test is more deterministic now too... --- src/convert.c | 6 +- src/gldns/str2wire.c | 2 +- .../260-conversion-functions.c | 16 +- .../260-conversion-functions.good | 780 +++++++++--------- .../260-conversion-functions.net-dns.org | 2 +- 5 files changed, 407 insertions(+), 399 deletions(-) diff --git a/src/convert.c b/src/convert.c index f2293d06..2c9440b3 100644 --- a/src/convert.c +++ b/src/convert.c @@ -534,7 +534,7 @@ _getdns_fp2rr_list(struct mem_funcs *mf, if (!origin) { *pst.origin = 0; - pst.origin_len = 0; + pst.origin_len = 1; } else if (gldns_str2wire_dname_buf(origin,pst.origin,&pst.origin_len)) return GETDNS_RETURN_GENERIC_ERROR; @@ -556,6 +556,10 @@ _getdns_fp2rr_list(struct mem_funcs *mf, dname_len = 0; if (gldns_fp2wire_rr_buf(in, rr, &len, &dname_len, &pst)) break; + if (dname_len && dname_len < sizeof(pst.prev_rr)) { + memcpy(pst.prev_rr, rr, dname_len); + pst.prev_rr_len = dname_len; + } if (len == 0) continue; if ((r = _getdns_wire2rr_dict(mf, rr, len, &rr_dict))) diff --git a/src/gldns/str2wire.c b/src/gldns/str2wire.c index 937c7c79..df534806 100644 --- a/src/gldns/str2wire.c +++ b/src/gldns/str2wire.c @@ -867,7 +867,7 @@ int gldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len, return s; } else if(strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) { const char* end = NULL; - size_t off = 8; + size_t off = 5; *len = 0; *dname_len = 0; if(!parse_state) return GLDNS_WIREPARSE_ERR_OK; diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c index c1d3bf2b..938d7bf5 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c @@ -263,10 +263,24 @@ int main(int argc, char const * const argv[]) for (i = 0; !(r = getdns_list_get_dict(rr_list, i, &rr_dict)); i++) { prev_wire = wire; - if ((r = getdns_rr_dict2wire_scan(rr_dict, &wire, &available))) { + if ((r = getdns_rr_dict2wire_scan(rr_dict,&wire,&available))) { if (r == GETDNS_RETURN_NEED_MORE_SPACE) { printf("record %.3zu, available buffer space: " "%zi\n", i, available); + + /* The buffer was too small to fit the wire- + * format representation. available now holds + * a negative number. the wire pointer is this + * much beyond the end of the buffer space. + * + * If we would add available to wire, wire + * would be positioned at the end of the buffer + * but would not be positioned at a clean RR + * border. Therefore we have to remember the + * previous position of wire, so we can reset + * it at the end of the wireformat representa- + * tion of the previously converted rr_dict. + */ wire = prev_wire; break; } diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good index 91781ed0..f6c4f2a7 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good @@ -115,7 +115,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "rname": , "serial": 2015081800 }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_SOA }, { @@ -123,10 +123,10 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "name": , "rdata": { - "nsdname": , - "rdata_raw": + "nsdname": , + "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_NS }, { @@ -137,7 +137,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "nsdname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_NS }, { @@ -148,7 +148,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "nsdname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_NS }, { @@ -159,7 +159,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "nsdname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_NS }, { @@ -170,7 +170,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv4_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_A }, { @@ -181,7 +181,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv6_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_AAAA }, { @@ -193,7 +193,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "preference": 10, "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_MX }, { @@ -205,7 +205,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "preference": 20, "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_MX }, { @@ -219,7 +219,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -233,7 +233,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "rdata_raw": , "selector": 1 }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TLSA }, { @@ -247,7 +247,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "rdata_raw": , "selector": 1 }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TLSA }, { @@ -262,7 +262,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -273,7 +273,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv4_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_A }, { @@ -284,7 +284,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv4_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_A }, { @@ -298,12 +298,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -312,12 +312,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -326,12 +326,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -340,12 +340,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -354,12 +354,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -368,12 +368,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -382,12 +382,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -396,12 +396,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -410,12 +410,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -424,12 +424,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -438,12 +438,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -452,12 +452,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -466,12 +466,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -480,12 +480,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -494,12 +494,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -508,12 +508,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -522,12 +522,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -536,12 +536,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -550,12 +550,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -564,12 +564,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -578,12 +578,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -592,12 +592,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -606,12 +606,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -620,12 +620,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -634,12 +634,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -648,12 +648,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -662,12 +662,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -676,12 +676,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -690,12 +690,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -704,12 +704,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -718,12 +718,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -732,12 +732,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -746,12 +746,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -760,12 +760,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -774,12 +774,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -788,12 +788,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -802,12 +802,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -816,12 +816,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -830,12 +830,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -844,12 +844,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -858,12 +858,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -872,12 +872,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -886,12 +886,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -900,12 +900,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -914,12 +914,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -928,12 +928,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -942,12 +942,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -956,12 +956,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -970,12 +970,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -984,12 +984,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -998,12 +998,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1012,12 +1012,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1026,12 +1026,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1040,12 +1040,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1054,12 +1054,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1068,12 +1068,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1082,12 +1082,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1096,12 +1096,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1110,12 +1110,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1124,12 +1124,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "rdata_raw": , @@ -1138,7 +1138,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1152,7 +1152,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1163,7 +1163,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv4_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_A }, { @@ -1174,7 +1174,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv4_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_A }, { @@ -1185,7 +1185,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "cname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_CNAME }, { @@ -1197,7 +1197,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "preference": 10, "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_MX }, { @@ -1209,19 +1209,19 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "preference": 10, "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_MX }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "exchange": , "preference": 15, "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_MX }, { @@ -1235,7 +1235,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1250,7 +1250,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1264,7 +1264,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1280,7 +1280,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1296,7 +1296,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1314,29 +1314,29 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "ipv4_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_A }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "ipv6_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_AAAA }, { @@ -1347,7 +1347,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "cname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_CNAME }, { @@ -1358,7 +1358,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "cname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_CNAME }, { @@ -1369,7 +1369,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "cname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_CNAME }, { @@ -1380,7 +1380,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "cname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_CNAME }, { @@ -1391,7 +1391,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "cname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_CNAME }, { @@ -1402,7 +1402,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "cname": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_CNAME }, { @@ -1413,7 +1413,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv4_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_A }, { @@ -1424,7 +1424,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "ipv6_address": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_AAAA }, { @@ -1467,7 +1467,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ], "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_APL }, { @@ -1480,7 +1480,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "precedence": 2, "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { @@ -1495,7 +1495,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "public_key": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { @@ -1510,7 +1510,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "public_key": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { @@ -1525,7 +1525,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "public_key": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { @@ -1538,12 +1538,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "precedence": 2, "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "algorithm": 10, @@ -1553,12 +1553,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "public_key": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "algorithm": 10, @@ -1568,12 +1568,12 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "public_key": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { "class": GETDNS_RRCLASS_IN, - "name": , + "name": , "rdata": { "algorithm": 10, @@ -1583,7 +1583,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. "public_key": , "rdata_raw": }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_IPSECKEY }, { @@ -1597,7 +1597,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1611,7 +1611,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT }, { @@ -1625,224 +1625,214 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42. ] }, - "ttl": 3600, + "ttl": 30, "type": GETDNS_RRTYPE_TXT } ] record 0, available buffer space: 8117 -record 1, available buffer space: 8065 -record 2, available buffer space: 8027 -record 3, available buffer space: 7988 -record 4, available buffer space: 7942 -record 5, available buffer space: 7915 -record 6, available buffer space: 7876 -record 7, available buffer space: 7831 -record 8, available buffer space: 7790 -record 9, available buffer space: 7750 -record 10, available buffer space: 7682 -record 11, available buffer space: 7610 -record 12, available buffer space: 7563 -record 13, available buffer space: 7530 -record 14, available buffer space: 7493 -record 15, available buffer space: 7398 -record 16, available buffer space: 7312 -record 17, available buffer space: 7226 -record 18, available buffer space: 7140 -record 19, available buffer space: 7054 -record 20, available buffer space: 6968 -record 21, available buffer space: 6882 -record 22, available buffer space: 6796 -record 23, available buffer space: 6710 -record 24, available buffer space: 6623 -record 25, available buffer space: 6536 -record 26, available buffer space: 6449 -record 27, available buffer space: 6362 -record 28, available buffer space: 6275 -record 29, available buffer space: 6188 -record 30, available buffer space: 6101 -record 31, available buffer space: 6014 -record 32, available buffer space: 5927 -record 33, available buffer space: 5840 -record 34, available buffer space: 5753 -record 35, available buffer space: 5666 -record 36, available buffer space: 5579 -record 37, available buffer space: 5492 -record 38, available buffer space: 5405 -record 39, available buffer space: 5318 -record 40, available buffer space: 5231 -record 41, available buffer space: 5144 -record 42, available buffer space: 5057 -record 43, available buffer space: 4970 -record 44, available buffer space: 4883 -record 45, available buffer space: 4796 -record 46, available buffer space: 4709 -record 47, available buffer space: 4622 -record 48, available buffer space: 4535 -record 49, available buffer space: 4448 -record 50, available buffer space: 4361 -record 51, available buffer space: 4274 -record 52, available buffer space: 4187 -record 53, available buffer space: 4100 -record 54, available buffer space: 4013 -record 55, available buffer space: 3926 -record 56, available buffer space: 3839 -record 57, available buffer space: 3752 -record 58, available buffer space: 3665 -record 59, available buffer space: 3578 -record 60, available buffer space: 3491 -record 61, available buffer space: 3404 -record 62, available buffer space: 3317 -record 63, available buffer space: 3230 -record 64, available buffer space: 3143 -record 65, available buffer space: 3056 -record 66, available buffer space: 2969 -record 67, available buffer space: 2882 -record 68, available buffer space: 2795 -record 69, available buffer space: 2708 -record 70, available buffer space: 2621 -record 71, available buffer space: 2534 -record 72, available buffer space: 2447 -record 73, available buffer space: 2360 -record 74, available buffer space: 2272 -record 75, available buffer space: 2179 -record 76, available buffer space: 2104 -record 77, available buffer space: 2073 -record 78, available buffer space: 2041 -record 79, available buffer space: 1993 -record 80, available buffer space: 1946 -record 81, available buffer space: 1898 -record 82, available buffer space: 1853 -record 83, available buffer space: 1816 -record 84, available buffer space: 1725 -record 85, available buffer space: 1661 -record 86, available buffer space: 1594 -record 87, available buffer space: 1523 -record 88, available buffer space: 1446 -record 89, available buffer space: 1417 -record 90, available buffer space: 1376 -record 91, available buffer space: 1324 -record 92, available buffer space: 1270 -record 93, available buffer space: 1217 -record 94, available buffer space: 1164 -record 95, available buffer space: 1099 -record 96, available buffer space: 1029 -record 97, available buffer space: 998 -record 98, available buffer space: 955 -record 99, available buffer space: 895 -record 100, available buffer space: 825 -record 101, available buffer space: 751 -record 102, available buffer space: 665 -record 103, available buffer space: 572 -record 104, available buffer space: 503 -record 105, available buffer space: 439 -record 106, available buffer space: 363 -record 107, available buffer space: 280 -record 108, available buffer space: -16 -net-dns.org. 3600 IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. 2015081800 450 600 345600 300 -net-dns.org. 3600 IN NS ns.nlnetlabs.nl.net-dns.org. -net-dns.org. 3600 IN NS ns.hactrn.net. -net-dns.org. 3600 IN NS mcvax.nlnet.nl. -net-dns.org. 3600 IN NS sec2.authdns.ripe.net. -net-dns.org. 3600 IN A 185.49.140.22 -net-dns.org. 3600 IN AAAA 2a04:b900::2:0:0:22 -net-dns.org. 3600 IN MX 10 dicht.nlnetlabs.nl. -net-dns.org. 3600 IN MX 20 mcvax.nlnet.nl. -net-dns.org. 3600 IN TXT "Net::DNS domain" -_443._tcp.net-dns.org. 3600 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 -_443._tcp.www.net-dns.org. 3600 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 -dynup.net-dns.org. 3600 IN TXT "fooFoo2" "Bla ; Foo" -lists.net-dns.org. 3600 IN A 63.209.15.196 -localhost.net-dns.org. 3600 IN A 127.0.0.1 -overflow.net-dns.org. 3600 IN TXT "And line 1 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 2 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 3 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 4 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 5 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 6 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 7 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 8 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 9 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 10 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 11 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 12 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 13 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 14 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 15 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 16 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 17 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 18 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 19 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 20 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 21 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 22 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 23 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 25 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 26 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 27 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 28 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 29 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 30 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 31 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 32 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 33 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 34 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 35 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 36 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 37 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 38 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 39 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 40 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 41 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 42 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 43 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 44 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 45 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 46 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 47 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 48 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 49 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 50 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 51 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 52 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 53 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 54 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 55 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 56 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 57 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 58 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 59 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 60 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "And line 224 of al sorts of crap that will just fill the packet " -net-dns.org. 3600 IN TXT "An increadibly large answer section that will lead to packet overflow" -t.net-dns.org. 3600 IN TXT "The names within this domain are used for testing" -a.t.net-dns.org. 3600 IN A 10.0.1.128 -a2.t.net-dns.org. 3600 IN A 10.0.1.129 -cname.t.net-dns.org. 3600 IN CNAME a.t.net-dns.org. -mx.t.net-dns.org. 3600 IN MX 10 a.t.net-dns.org. -mx2.t.net-dns.org. 3600 IN MX 10 a.t.net-dns.org. -t.net-dns.org. 3600 IN MX 15 a2.t.net-dns.org. -txt.t.net-dns.org. 3600 IN TXT "Net-DNS" -txt2.t.net-dns.org. 3600 IN TXT "Net-DNS; complicated $tuff" "sort of \" text; and binary \000 data" -connection-test.t.net-dns.org. 3600 IN TXT "connection-test succes" -txt-utf8.t.net-dns.org. 3600 IN TXT "\229\143\164\230\177\160\227\130\132" "\232\155\153\233\163\155\232\190\188\227\130\128" "\230\176\180\227\129\174\233\159\179" -txt-utf8-bin.t.net-dns.org. 3600 IN TXT "\229\143\164\230\177\160\227\130\132" "\232\155\153\233\163\155\232\190\188\227\130\128" "\230\176\180\227\129\174\233\159\179" -a.few.empty.non.terminals.t.net-dns.org. 3600 IN TXT "a" "few" "empty" "non" "terminals" -t.net-dns.org. 3600 IN A 185.49.140.22 -t.net-dns.org. 3600 IN AAAA 2a04:b900::2:0:0:22 -yx1.cname.t.net-dns.org. 3600 IN CNAME -.t.net-dns.org. -yx2.cname.t.net-dns.org. 3600 IN CNAME a-a.t.net-dns.org. -yx3.cname.t.net-dns.org. 3600 IN CNAME a\..t.net-dns.org. -yx4.cname.t.net-dns.org. 3600 IN CNAME a\000.t.net-dns.org. -nx1.cname.t.net-dns.org. 3600 IN CNAME does.not.exist.t.net-dns.org. -nx2.cname.t.net-dns.org. 3600 IN CNAME empty.non.terminals.t.net-dns.org. -www.net-dns.org. 3600 IN A 185.49.140.22 -www.net-dns.org. 3600 IN AAAA 2a04:b900::2:0:0:22 -apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.128/25 1:224.0.0.0/4 2:ff00:0000:0000:0000:0000:0000:0000:0000/8 -ipseckey0.net-dns.org. 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey1.net-dns.org. 3600 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey2.net-dns.org. 3600 IN IPSECKEY 10 2 2 2001:db8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey3.net-dns.org. 3600 IN IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -ipseckey.net-dns.org. 3600 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -net-dns.org. 3600 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -net-dns.org. 3600 IN IPSECKEY 10 2 2 2001:db8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== -net-dns.org. 3600 IN IPSECKEY 10 3 2 mygateway.example.com. AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +record 1, available buffer space: 8077 +record 2, available buffer space: 8039 +record 3, available buffer space: 8000 +record 4, available buffer space: 7954 +record 5, available buffer space: 7927 +record 6, available buffer space: 7888 +record 7, available buffer space: 7843 +record 8, available buffer space: 7802 +record 9, available buffer space: 7762 +record 10, available buffer space: 7694 +record 11, available buffer space: 7622 +record 12, available buffer space: 7575 +record 13, available buffer space: 7542 +record 14, available buffer space: 7505 +record 15, available buffer space: 7410 +record 16, available buffer space: 7315 +record 17, available buffer space: 7220 +record 18, available buffer space: 7125 +record 19, available buffer space: 7030 +record 20, available buffer space: 6935 +record 21, available buffer space: 6840 +record 22, available buffer space: 6745 +record 23, available buffer space: 6650 +record 24, available buffer space: 6554 +record 25, available buffer space: 6458 +record 26, available buffer space: 6362 +record 27, available buffer space: 6266 +record 28, available buffer space: 6170 +record 29, available buffer space: 6074 +record 30, available buffer space: 5978 +record 31, available buffer space: 5882 +record 32, available buffer space: 5786 +record 33, available buffer space: 5690 +record 34, available buffer space: 5594 +record 35, available buffer space: 5498 +record 36, available buffer space: 5402 +record 37, available buffer space: 5306 +record 38, available buffer space: 5210 +record 39, available buffer space: 5114 +record 40, available buffer space: 5018 +record 41, available buffer space: 4922 +record 42, available buffer space: 4826 +record 43, available buffer space: 4730 +record 44, available buffer space: 4634 +record 45, available buffer space: 4538 +record 46, available buffer space: 4442 +record 47, available buffer space: 4346 +record 48, available buffer space: 4250 +record 49, available buffer space: 4154 +record 50, available buffer space: 4058 +record 51, available buffer space: 3962 +record 52, available buffer space: 3866 +record 53, available buffer space: 3770 +record 54, available buffer space: 3674 +record 55, available buffer space: 3578 +record 56, available buffer space: 3482 +record 57, available buffer space: 3386 +record 58, available buffer space: 3290 +record 59, available buffer space: 3194 +record 60, available buffer space: 3098 +record 61, available buffer space: 3002 +record 62, available buffer space: 2906 +record 63, available buffer space: 2810 +record 64, available buffer space: 2714 +record 65, available buffer space: 2618 +record 66, available buffer space: 2522 +record 67, available buffer space: 2426 +record 68, available buffer space: 2330 +record 69, available buffer space: 2234 +record 70, available buffer space: 2138 +record 71, available buffer space: 2042 +record 72, available buffer space: 1946 +record 73, available buffer space: 1850 +record 74, available buffer space: 1753 +record 75, available buffer space: 1651 +record 76, available buffer space: 1576 +record 77, available buffer space: 1545 +record 78, available buffer space: 1513 +record 79, available buffer space: 1465 +record 80, available buffer space: 1418 +record 81, available buffer space: 1370 +record 82, available buffer space: 1321 +record 83, available buffer space: 1284 +record 84, available buffer space: 1193 +record 85, available buffer space: 1129 +record 86, available buffer space: 1062 +record 87, available buffer space: 991 +record 88, available buffer space: 914 +record 89, available buffer space: 859 +record 90, available buffer space: 792 +record 91, available buffer space: 740 +record 92, available buffer space: 686 +record 93, available buffer space: 633 +record 94, available buffer space: 580 +record 95, available buffer space: 515 +record 96, available buffer space: 445 +record 97, available buffer space: 414 +record 98, available buffer space: 371 +record 99, available buffer space: 311 +record 100, available buffer space: 241 +record 101, available buffer space: 167 +record 102, available buffer space: 81 +record 103, available buffer space: -12 +net-dns.org. 30 IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. 2015081800 450 600 345600 300 +net-dns.org. 30 IN NS ns.nlnetlabs.nl. +net-dns.org. 30 IN NS ns.hactrn.net. +net-dns.org. 30 IN NS mcvax.nlnet.nl. +net-dns.org. 30 IN NS sec2.authdns.ripe.net. +net-dns.org. 30 IN A 185.49.140.22 +net-dns.org. 30 IN AAAA 2a04:b900::2:0:0:22 +net-dns.org. 30 IN MX 10 dicht.nlnetlabs.nl. +net-dns.org. 30 IN MX 20 mcvax.nlnet.nl. +net-dns.org. 30 IN TXT "Net::DNS domain" +_443._tcp.net-dns.org. 30 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 +_443._tcp.www.net-dns.org. 30 IN TLSA 3 1 1 274C6F96C9885C8050E8A05AD1C3162C1D51752C35B6196474E3F05AD31CD923 +dynup.net-dns.org. 30 IN TXT "fooFoo2" "Bla ; Foo" +lists.net-dns.org. 30 IN A 63.209.15.196 +localhost.net-dns.org. 30 IN A 127.0.0.1 +overflow.net-dns.org. 30 IN TXT "And line 1 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 2 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 3 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 4 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 5 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 6 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 7 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 8 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 9 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 10 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 11 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 12 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 13 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 14 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 15 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 16 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 17 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 18 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 19 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 20 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 21 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 22 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 23 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 25 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 26 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 27 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 28 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 29 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 30 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 31 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 32 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 33 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 34 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 35 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 36 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 37 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 38 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 39 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 40 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 41 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 42 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 43 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 44 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 45 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 46 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 47 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 48 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 49 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 50 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 51 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 52 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 53 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 54 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 55 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 56 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 57 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 58 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 59 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 60 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "And line 224 of al sorts of crap that will just fill the packet " +overflow.net-dns.org. 30 IN TXT "An increadibly large answer section that will lead to packet overflow" +t.net-dns.org. 30 IN TXT "The names within this domain are used for testing" +a.t.net-dns.org. 30 IN A 10.0.1.128 +a2.t.net-dns.org. 30 IN A 10.0.1.129 +cname.t.net-dns.org. 30 IN CNAME a.t.net-dns.org. +mx.t.net-dns.org. 30 IN MX 10 a.t.net-dns.org. +mx2.t.net-dns.org. 30 IN MX 10 a.t.net-dns.org. +mx2.t.net-dns.org. 30 IN MX 15 a2.t.net-dns.org. +txt.t.net-dns.org. 30 IN TXT "Net-DNS" +txt2.t.net-dns.org. 30 IN TXT "Net-DNS; complicated $tuff" "sort of \" text; and binary \000 data" +connection-test.t.net-dns.org. 30 IN TXT "connection-test succes" +txt-utf8.t.net-dns.org. 30 IN TXT "\229\143\164\230\177\160\227\130\132" "\232\155\153\233\163\155\232\190\188\227\130\128" "\230\176\180\227\129\174\233\159\179" +txt-utf8-bin.t.net-dns.org. 30 IN TXT "\229\143\164\230\177\160\227\130\132" "\232\155\153\233\163\155\232\190\188\227\130\128" "\230\176\180\227\129\174\233\159\179" +a.few.empty.non.terminals.t.net-dns.org. 30 IN TXT "a" "few" "empty" "non" "terminals" +a.few.empty.non.terminals.t.net-dns.org. 30 IN A 185.49.140.22 +a.few.empty.non.terminals.t.net-dns.org. 30 IN AAAA 2a04:b900::2:0:0:22 +yx1.cname.t.net-dns.org. 30 IN CNAME -.t.net-dns.org. +yx2.cname.t.net-dns.org. 30 IN CNAME a-a.t.net-dns.org. +yx3.cname.t.net-dns.org. 30 IN CNAME a\..t.net-dns.org. +yx4.cname.t.net-dns.org. 30 IN CNAME a\000.t.net-dns.org. +nx1.cname.t.net-dns.org. 30 IN CNAME does.not.exist.t.net-dns.org. +nx2.cname.t.net-dns.org. 30 IN CNAME empty.non.terminals.t.net-dns.org. +www.net-dns.org. 30 IN A 185.49.140.22 +www.net-dns.org. 30 IN AAAA 2a04:b900::2:0:0:22 +apl.net-dns.org. 30 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.128/25 1:224.0.0.0/4 2:ff00:0000:0000:0000:0000:0000:0000:0000/8 +ipseckey0.net-dns.org. 30 IN IPSECKEY 10 0 2 . AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey1.net-dns.org. 30 IN IPSECKEY 10 1 2 192.0.2.38 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== +ipseckey2.net-dns.org. 30 IN IPSECKEY 10 2 2 2001:db8:0:8002::2000:1 AQNRU3mG7TVTO2BkR47usntb102uFJtugbo6BSGvgqt4AQ== diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org index f00e1185..9eb59930 100644 --- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org +++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.net-dns.org @@ -8,7 +8,6 @@ net-dns.org IN SOA ns.nlnetlabs.nl. sysadmin.nlnetlabs.nl. ( 345600 ; expire (4 days) 300 ; minimum (5 minutes) ) -$ORIGIN net-dns.org. NS ns.nlnetlabs.nl NS ns.hactrn.net. NS mcvax.nlnet.nl. @@ -20,6 +19,7 @@ $ORIGIN net-dns.org. MX 10 dicht.nlnetlabs.nl. MX 20 mcvax.nlnet.nl. TXT "Net::DNS domain" +$ORIGIN net-dns.org. _443._tcp TLSA 3 1 1 274c6f96c9885c8050e8a05ad1c3162c1d51752c35b6196474e3f05ad31cd923 _443._tcp.www TLSA 3 1 1 274c6f96c9885c8050e8a05ad1c3162c1d51752c35b6196474e3f05ad31cd923