Fixes for miscelanous little zone parse errors

Hopefully the tpkg test is more deterministic now too...
This commit is contained in:
Willem Toorop 2015-12-23 12:06:09 +01:00
parent 11cd892662
commit f9c2f96996
5 changed files with 407 additions and 399 deletions

View File

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

View File

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

View File

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

View File

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