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
This commit is contained in:
Willem Toorop 2015-12-22 18:37:24 +01:00
parent 0cb513e9b7
commit e4fa06a57b
9 changed files with 2174 additions and 38 deletions

View File

@ -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

View File

@ -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 */

57
src/convert.h Normal file
View File

@ -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 <stdio.h>
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 */

View File

@ -30,6 +30,7 @@
#include <getdns/getdns.h>
#include <sys/time.h>
#include <stdio.h>
#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
}

View File

@ -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

View File

@ -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);
}

View File

@ -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"

View File

@ -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