From bd814b79d4a87faf80e306d705a6a9cc0ae08c11 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 4 Mar 2022 15:19:52 -0800 Subject: [PATCH] add a system test for $GENERATE with an integer overflow 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. --- bin/tests/system/checkzone/tests.sh | 9 +++++++++ .../system/checkzone/zones/generate-overflow.db | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 bin/tests/system/checkzone/zones/generate-overflow.db diff --git a/bin/tests/system/checkzone/tests.sh b/bin/tests/system/checkzone/tests.sh index c8f05925b9..a63e221ea9 100644 --- a/bin/tests/system/checkzone/tests.sh +++ b/bin/tests/system/checkzone/tests.sh @@ -193,9 +193,18 @@ status=$((status+ret)) ret=0 # Step 3: Ensure that output conversion from stdin is the same as the output conversion from a file. diff zones/zone1_file.txt zones/zone1_stdin.txt >/dev/null 2>&1 || ret=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 index 0000000000..c16b517481 --- /dev/null +++ b/bin/tests/system/checkzone/zones/generate-overflow.db @@ -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