6139ce
From eee06b7744c4999ec3c7cb0654f97a9b4c79f77f Mon Sep 17 00:00:00 2001
6139ce
From: Mark Andrews <marka@isc.org>
6139ce
Date: Wed, 25 Mar 2020 17:44:51 +1100
6139ce
Subject: [PATCH] Check that a 'BADTIME' response with 'QR=0' is handled as a
6139ce
 request
6139ce
6139ce
(cherry picked from commit 67ba3f8f3ab2a748dff1e8a2029fde3bc84ec3f1)
6139ce
---
6139ce
 bin/tests/system/tsig/badtime  | 37 ++++++++++++++++++++++++++++++++++
6139ce
 bin/tests/system/tsig/tests.sh |  9 +++++++++
6139ce
 2 files changed, 46 insertions(+)
6139ce
 create mode 100644 bin/tests/system/tsig/badtime
6139ce
6139ce
diff --git a/bin/tests/system/tsig/badtime b/bin/tests/system/tsig/badtime
6139ce
new file mode 100644
6139ce
index 0000000000..7926404cfb
6139ce
--- /dev/null
6139ce
+++ b/bin/tests/system/tsig/badtime
6139ce
@@ -0,0 +1,37 @@
6139ce
+# Transaction ID
6139ce
+1122
6139ce
+# Standard query
6139ce
+0000
6139ce
+# Questions: 1, Additional: 1
6139ce
+0001 0000 0000 0001
6139ce
+# QNAME: isc.org
6139ce
+03 69 73 63 03 6F 72 67 00
6139ce
+# Type: A (Host Address)
6139ce
+0001
6139ce
+# Class: IN
6139ce
+0001
6139ce
+# Specially crafted TSIG Resource Record
6139ce
+# Name: "sha256"
6139ce
+06 73 68 61 32 35 36 00
6139ce
+# Type: TSIG (Transaction Signature)
6139ce
+00fa
6139ce
+# Class: ANY
6139ce
+00ff
6139ce
+# TTL: 0
6139ce
+00000000
6139ce
+# RdLen: 29
6139ce
+001d
6139ce
+# Algorithm Name: hmac-sha256
6139ce
+0b 68 6D 61 63 2D 73 68 61 32 35 36 00
6139ce
+# Time Signed: Jan 1, 1970 01:00:00.000000000 CET
6139ce
+00 00 00 00 00 00
6139ce
+# Fudge: 300
6139ce
+012c
6139ce
+# MAC Size: 0; MAC: empty
6139ce
+0000
6139ce
+# Original ID: 0
6139ce
+0000
6139ce
+# Error: BADSIG
6139ce
+0010
6139ce
+# Other Data Length: 0
6139ce
+0000
6139ce
diff --git a/bin/tests/system/tsig/tests.sh b/bin/tests/system/tsig/tests.sh
6139ce
index cade35bc1d..284aea1056 100644
6139ce
--- a/bin/tests/system/tsig/tests.sh
6139ce
+++ b/bin/tests/system/tsig/tests.sh
6139ce
@@ -233,5 +233,14 @@ if [ $ret -eq 1 ] ; then
6139ce
 	echo "I: failed"; status=1
6139ce
 fi
6139ce
 
6139ce
+echo_i "check that a 'BADTIME' response with 'QR=0' is handled as a request"
6139ce
+ret=0
6139ce
+$PERL ../packet.pl -a 10.53.0.1 -p ${PORT} -t tcp < badtime > /dev/null
6139ce
+$DIG -p ${PORT} @10.53.0.1 version.bind txt ch > dig.out.verify || ret=1
6139ce
+grep "status: NOERROR" dig.out.verify > /dev/null || ret=1
6139ce
+if [ $ret -eq 1 ] ; then
6139ce
+    echo_i "failed"; status=1
6139ce
+fi
6139ce
+
6139ce
 echo_i "exit status: $status"
6139ce
 [ $status -eq 0 ] || exit 1
6139ce
-- 
6139ce
2.21.1
6139ce