From: Volker Lendecke Date: Fri, 29 Dec 2017 12:09:15 +0000 (+0100) Subject: ndr_dns: fix pushing unknown resource records X-Git-Tag: talloc-2.1.11~76 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=15748c325c35c5e63ccff8cfcc4f3f555ebda77a;p=thirdparty%2Fsamba.git ndr_dns: fix pushing unknown resource records When pulling for example an RRSIG record, we end up with length!=0 *and* unexpected.length != 0, but with an unknown rrec. We should be able to marshall what we retrieved from the wire. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/librpc/ndr/ndr_dns.c b/librpc/ndr/ndr_dns.c index 4e4c556e20d..d37c8cc2ece 100644 --- a/librpc/ndr/ndr_dns.c +++ b/librpc/ndr/ndr_dns.c @@ -289,11 +289,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_dns_res_rec(struct ndr_push *ndr, _saved_offset1 = ndr->offset; NDR_CHECK(ndr_push_uint16(ndr, NDR_SCALARS, 0)); if (r->length > 0) { + uint32_t _saved_offset3; + NDR_CHECK(ndr_push_set_switch_value(ndr, &r->rdata, r->rr_type)); + _saved_offset3 = ndr->offset; NDR_CHECK(ndr_push_dns_rdata(ndr, NDR_SCALARS, &r->rdata)); - if (r->unexpected.length > 0) { + if ((ndr->offset != _saved_offset3) && + (r->unexpected.length > 0)) { + /* + * ndr_push_dns_rdata pushed a known + * record, but we have something + * unexpected. That's invalid. + */ return ndr_push_error(ndr, NDR_ERR_LENGTH, "Invalid...Unexpected " \