diff options
author | Stuart Henderson <sthen@cvs.openbsd.org> | 2012-08-23 22:28:47 +0000 |
---|---|---|
committer | Stuart Henderson <sthen@cvs.openbsd.org> | 2012-08-23 22:28:47 +0000 |
commit | 74812bbf7ac58db7587bea655c092fffebad2578 (patch) | |
tree | 89bb5873b17ab331b6f37c5ddc249148b71195a7 /usr.sbin/unbound/ldns/dname.c | |
parent | 1ea05aac9ef595aba000bcd21f54ee3354c05507 (diff) |
update to ldns 1.6.13, tested by okan@, thanks (not yet linked to build).
Diffstat (limited to 'usr.sbin/unbound/ldns/dname.c')
-rw-r--r-- | usr.sbin/unbound/ldns/dname.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/usr.sbin/unbound/ldns/dname.c b/usr.sbin/unbound/ldns/dname.c index 0e63ef26895..f3770feafb5 100644 --- a/usr.sbin/unbound/ldns/dname.c +++ b/usr.sbin/unbound/ldns/dname.c @@ -87,9 +87,6 @@ ldns_dname_cat(ldns_rdf *rd1, ldns_rdf *rd2) if (left_size > 0 &&ldns_rdf_data(rd1)[left_size - 1] == 0) { left_size--; } - if(left_size == 0) { - return LDNS_STATUS_OK; - } size = left_size + ldns_rdf_size(rd2); newd = LDNS_XREALLOC(ldns_rdf_data(rd1), uint8_t, size); @@ -530,6 +527,7 @@ ldns_dname_label(const ldns_rdf *rdf, uint8_t labelpos) uint16_t len; ldns_rdf *tmpnew; size_t s; + uint8_t *data; if (ldns_rdf_get_type(rdf) != LDNS_RDF_TYPE_DNAME) { return NULL; @@ -543,19 +541,19 @@ ldns_dname_label(const ldns_rdf *rdf, uint8_t labelpos) while ((len > 0) && src_pos < s) { if (labelcnt == labelpos) { /* found our label */ - tmpnew = LDNS_MALLOC(ldns_rdf); - if (!tmpnew) { + data = LDNS_XMALLOC(uint8_t, len + 2); + if (!data) { return NULL; } - tmpnew->_type = LDNS_RDF_TYPE_DNAME; - tmpnew->_data = LDNS_XMALLOC(uint8_t, len + 2); - if (!tmpnew->_data) { - LDNS_FREE(tmpnew); + memcpy(data, ldns_rdf_data(rdf) + src_pos, len + 1); + data[len + 2 - 1] = 0; + + tmpnew = ldns_rdf_new( LDNS_RDF_TYPE_DNAME + , len + 2, data); + if (!tmpnew) { + LDNS_FREE(data); return NULL; } - memset(tmpnew->_data, 0, len + 2); - memcpy(tmpnew->_data, ldns_rdf_data(rdf) + src_pos, len + 1); - tmpnew->_size = len + 2; return tmpnew; } src_pos++; |