4615. [bug] AD could be set on truncated answer with no records

present in the answer and authority sections.
                        [RT #45140]

(cherry picked from commit 33e94f501f)
This commit is contained in:
Mark Andrews
2017-05-03 08:09:05 +10:00
parent 673dd20a78
commit d7d9376e61
6 changed files with 57 additions and 0 deletions
+4
View File
@@ -1,3 +1,7 @@
4615. [bug] AD could be set on truncated answer with no records
present in the answer and authority sections.
[RT #45140]
4614. [test] Fixed an error in the sockaddr unit test. [RT #45146]
4612. [bug] Silence 'may be use uninitalised' warning and simplify
@@ -0,0 +1,12 @@
; Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
;
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at http://mozilla.org/MPL/2.0/.
; $Id: example.net.db.in,v 1.3 2010/11/17 23:47:08 tbox Exp $
$TTL 600
@ IN SOA ns hostmaster 1 1800 900 604800 600
@ IN NS ns
ns IN A 10.53.0.6
+9
View File
@@ -19,6 +19,15 @@
SYSTEMTESTTOP=../..
. $SYSTEMTESTTOP/conf.sh
zone=ds.example.net
zonefile="${zone}.db"
infile="${zonefile}.in"
cp $infile $zonefile
ksk=`$KEYGEN -q -3 -r $RANDFILE -fk $zone`
zsk=`$KEYGEN -q -3 -r $RANDFILE -b 2048 $zone`
cat $ksk.key $zsk.key >> $zonefile
$SIGNER -P -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
zone=example.net
zonefile="${zone}.db"
infile="${zonefile}.in"
+6
View File
@@ -37,6 +37,12 @@ options {
root-delegation-only exclude { "a"; };
};
zone "ds.example.net" {
type master;
file "ds.example.net.db.signed";
allow-update { any; };
};
zone "." {
type master;
file "root.db";
+16
View File
@@ -574,5 +574,21 @@ test ${ttl:-1} -eq 0 || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo "I:check that 'ad' in not returned in truncated answer with empty answer and authority sections to request with +ad (${n})"
ret=0
$DIG @10.53.0.6 -p 5300 dnskey ds.example.net +bufsize=512 +ad +nodnssec +ignore +norec > dig.out.$n
grep "flags: qr aa tc; QUERY: 1, ANSWER: 0, AUTHORITY: 0" dig.out.$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
n=`expr $n + 1`
echo "I:check that 'ad' in not returned in truncated answer with empty answer and authority sections to request with +dnssec (${n})"
ret=0
$DIG @10.53.0.6 -p 5300 dnskey ds.example.net +bufsize=512 +noad +dnssec +ignore +norec > dig.out.$n
grep "flags: qr aa tc; QUERY: 1, ANSWER: 0, AUTHORITY: 0" dig.out.$n > /dev/null || ret=1
if [ $ret != 0 ]; then echo "I:failed"; fi
status=`expr $status + $ret`
echo "I:exit status: $status"
[ $status -eq 0 ] || exit 1
+10
View File
@@ -1956,6 +1956,15 @@ renderset(dns_rdataset_t *rdataset, dns_name_t *owner_name,
return (result);
}
static void
maybe_clear_ad(dns_message_t *msg, dns_section_t sectionid) {
if (msg->counts[sectionid] == 0 &&
(sectionid == DNS_SECTION_ANSWER ||
(sectionid == DNS_SECTION_AUTHORITY &&
msg->counts[DNS_SECTION_ANSWER] == 0)))
msg->flags &= ~DNS_MESSAGEFLAG_AD;
}
isc_result_t
dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid,
unsigned int options)
@@ -2153,6 +2162,7 @@ dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid,
*(msg->buffer) = st; /* rollback */
msg->buffer->length += msg->reserved;
msg->counts[sectionid] += total;
maybe_clear_ad(msg, sectionid);
return (result);
}