]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add a system test for $GENERATE with an integer overflow
authorEvan Hunt <each@isc.org>
Fri, 4 Mar 2022 23:19:52 +0000 (15:19 -0800)
committerMark Andrews <marka@isc.org>
Fri, 1 Apr 2022 10:47:24 +0000 (21:47 +1100)
the line "$GENERATE 19-28/2147483645 $ CNAME x" should generate
a single CNAME with the owner "19.example.com", but prior to the
overflow bug it generated several CNAMEs, half of them with large
negative values.

we now test for the bugfix by using "named-checkzone -D" and
grepping for a single CNAME in the output.

(cherry picked from commit bd814b79d4a87faf80e306d705a6a9cc0ae08c11)

bin/tests/system/checkzone/tests.sh
bin/tests/system/checkzone/zones/generate-overflow.db [new file with mode: 0644]

index 1e772f9d727729feae914f5616f59689a99dbc8b..ab2a54db844514955df97cbfa9676535d20b8d1a 100644 (file)
@@ -184,5 +184,15 @@ n=$((n+1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status+ret))
 
+n=$((n+1))
+ret=0
+echo_i "checking integer overflow is prevented in \$GENERATE ($n)"
+$CHECKZONE -D example.com zones/generate-overflow.db > test.out.$n 2>&1 || ret=1
+lines=$(grep -c CNAME test.out.$n)
+echo $lines
+[ "$lines" -eq 1 ] || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status+ret))
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1
diff --git a/bin/tests/system/checkzone/zones/generate-overflow.db b/bin/tests/system/checkzone/zones/generate-overflow.db
new file mode 100644 (file)
index 0000000..c16b517
--- /dev/null
@@ -0,0 +1,17 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; SPDX-License-Identifier: MPL-2.0
+;
+; 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 https://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+$TTL 600
+@              SOA     ns hostmaster 2011012708 3600 1200 604800 1200
+               NS      ns
+ns             A       192.0.2.1
+
+$GENERATE 19-28/2147483645     $ CNAME x