From: Mark Andrews Date: Wed, 3 Feb 2021 00:10:20 +0000 (+1100) Subject: Add a system test checking a malformed IXFR X-Git-Tag: v9.11.33~3^2 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=8db59aea114c8224b4084a98199d81c7ab15c291;p=thirdparty%2Fbind9.git Add a system test checking a malformed IXFR Make sure an incoming IXFR containing an SOA record which is not placed at the apex of the transferred zone does not result in a broken version of the zone being served by named and/or a subsequent crash. (cherry picked from commit 5547003a3d41f42f9c086d959e0e5df4240ccd4d) --- diff --git a/bin/tests/system/ixfr/tests.sh b/bin/tests/system/ixfr/tests.sh index 5ff071f406f..cd1baf87ff4 100644 --- a/bin/tests/system/ixfr/tests.sh +++ b/bin/tests/system/ixfr/tests.sh @@ -104,7 +104,7 @@ $DIG $DIGOPTS @10.53.0.1 nil. TXT | grep 'successful IXFR' >/dev/null || { } n=`expr $n + 1` -echo_i "testing AXFR fallback after IXFR failure ($n)" +echo_i "testing AXFR fallback after IXFR failure (not exact error) ($n)" # Provide a broken IXFR response and a working fallback AXFR response @@ -138,6 +138,66 @@ $DIG $DIGOPTS @10.53.0.1 nil. TXT | grep 'fallback AXFR' >/dev/null || { status=`expr $status + 1` } +n=`expr $n + 1` +echo_i "testing AXFR fallback after IXFR failure (bad SOA owner) ($n)" +ret=0 + +# Prepare for checking the logs later on. +nextpart ns1/named.run >/dev/null + +# Provide a broken IXFR response and a working fallback AXFR response. +$SENDCMD < dig.out.test$n.1 && + grep -q -F "serial 4" dig.out.test$n.1 +} +if ! retry_quiet 10 _wait_until_transfer_is_finished; then + echo_i "timed out waiting for version 4 of zone nil. to be transferred" + ret=1 +fi + +# At this point a broken server would be serving a zone with no SOA records. +# Try crashing it by triggering a SOA refresh query. +$RNDCCMD 10.53.0.1 refresh nil | sed 's/^/ns1 /' | cat_i + +# Do not wait until the zone refresh completes - even if a crash has not +# happened by now, a broken server would never serve the record which is only +# present in the fallback AXFR, so checking for that is enough to verify if a +# server is broken or not; if it is, it is bound to crash shortly anyway. +$DIG $DIGOPTS test.nil. TXT @10.53.0.1 > dig.out.test$n.2 || ret=1 +grep -q -F "serial 4, fallback AXFR" dig.out.test$n.2 || ret=1 + +# Ensure the expected error is logged. +nextpart ns1/named.run | grep -q -F "SOA name mismatch" || ret=1 + +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + n=`expr $n + 1` echo_i "testing ixfr-from-differences option ($n)" # ns3 is master; ns4 is slave