From 2a78803049b022087cf0a4a88c5f8f04a985c30a Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Thu, 25 Apr 2019 14:07:42 +0000 Subject: [PATCH] - Fix wrong query name in local zone redirect answers with a CNAME, the copy of the local alias is in unpacked form. git-svn-id: file:///svn/unbound/trunk@5175 be551aaa-1e26-0410-a405-d3ace91eadb9 --- doc/Changelog | 4 ++++ services/mesh.c | 17 +++++------------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index ee0f90882..5c06e446e 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +25 April 2019: Wouter + - Fix wrong query name in local zone redirect answers with a CNAME, + the copy of the local alias is in unpacked form. + 18 April 2019: Ralph - Scrub RRs from answer section when reusing NXDOMAIN message for subdomain answers. diff --git a/services/mesh.c b/services/mesh.c index bee0f76a4..d96289e3a 100644 --- a/services/mesh.c +++ b/services/mesh.c @@ -1341,21 +1341,14 @@ int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns, log_assert(qinfo->local_alias->rrset->rk.dname == sldns_buffer_at(rep->c->buffer, LDNS_HEADER_SIZE)); - d = regional_alloc_init(s->s.region, dsrc, - sizeof(struct packed_rrset_data) - + sizeof(size_t) + sizeof(uint8_t*) + sizeof(time_t)); + /* the rrset is not packed, like in the cache, but it is + * individualy allocated with an allocator from localzone. */ + d = regional_alloc_zero(s->s.region, sizeof(*d)); if(!d) return 0; r->local_alias->rrset->entry.data = d; - d->rr_len = (size_t*)((uint8_t*)d + - sizeof(struct packed_rrset_data)); - d->rr_data = (uint8_t**)&(d->rr_len[1]); - d->rr_ttl = (time_t*)&(d->rr_data[1]); - d->rr_len[0] = dsrc->rr_len[0]; - d->rr_ttl[0] = dsrc->rr_ttl[0]; - d->rr_data[0] = regional_alloc_init(s->s.region, - dsrc->rr_data[0], d->rr_len[0]); - if(!d->rr_data[0]) + if(!rrset_insert_rr(s->s.region, d, dsrc->rr_data[0], + dsrc->rr_len[0], dsrc->rr_ttl[0], "CNAME local alias")) return 0; } else r->local_alias = NULL; -- 2.47.2