Commit ea2d5956be for bind

commit ea2d5956bec6310170183b9290aebe28722b7a24
Author: Nicki Křížek <nicki@isc.org>
Date:   Fri Nov 6 13:08:21 2026 +0000

    Move the TSIG-in-authority check to the formerr test

    The formerr test covers the other conditions of the same TSIG
    placement check in the message parser and asserts on the exact wire
    of the response.  The tsig version sent a hex blob through packet.pl
    and was skipped altogether without the Perl Net::DNS module.  The new
    case is that packet byte for byte but the message ID, hence the TTL
    argument for tsig_rr().

    Assisted-by: Claude:claude-opus-5-5

diff --git a/REUSE.toml b/REUSE.toml
index 5a85be7800..15c3372093 100644
--- a/REUSE.toml
+++ b/REUSE.toml
@@ -102,7 +102,6 @@ path = [
 	"bin/tests/system/statschannel/traffic.expect.5",
 	"bin/tests/system/statschannel/traffic.expect.6",
 	"bin/tests/system/tcp/1996-alloc_dnsbuf-crash-test.pkt",
-	"bin/tests/system/tsig/badlocation",
 	"bin/tests/system/unknown/large.out",
 	"bin/tests/system/xfer/ans5/badkeydata",
 	"bin/tests/system/xfer/ans5/badmessageid",
diff --git a/bin/tests/system/formerr/tests_formerr.py b/bin/tests/system/formerr/tests_formerr.py
index 6666cf5a18..5ab9e60ef9 100644
--- a/bin/tests/system/formerr/tests_formerr.py
+++ b/bin/tests/system/formerr/tests_formerr.py
@@ -26,6 +26,7 @@ import dns.rdtypes.ANY.RRSIG
 import dns.rdtypes.ANY.SOA
 import dns.rdtypes.ANY.TSIG
 import dns.rdtypes.IN.A
+import dns.tsig
 import pytest


@@ -228,6 +229,7 @@ def tsig_rr(
     *,
     owner: bytes = root(),
     rdclass: dns.rdataclass.RdataClass = dns.rdataclass.RdataClass.ANY,
+    ttl: int = 1,
     algorithm: dns.name.Name = dns.name.root,
     time_signed: int = 0x010203040506,
     fudge: int = 0x0102,
@@ -240,6 +242,7 @@ def tsig_rr(
         owner,
         dns.rdatatype.RdataType.TSIG,
         rdclass,
+        ttl=ttl,
         rdata=dns.rdtypes.ANY.TSIG.TSIG(
             rdclass,
             dns.rdatatype.RdataType.TSIG,
@@ -512,6 +515,25 @@ def query_raw_tcp(host: str, port: int, packet_wire: bytes) -> bytes:
             formerr_response_header(opcode=dns.opcode.UPDATE),
             id="malformeddeltype",
         ),
+        pytest.param(
+            wire(
+                header(qdcount=1, nscount=1),
+                question(name("isc.org.")),
+                tsig_rr(
+                    owner=name("sha256."),
+                    ttl=0,
+                    algorithm=dns.tsig.HMAC_SHA256,
+                    time_signed=0,
+                    fudge=300,
+                    mac=b"",
+                ),
+            ),
+            wire(
+                formerr_response_header(qdcount=1),
+                question(name("isc.org.")),
+            ),
+            id="tsigwrongsection",
+        ),
         pytest.param(
             wire(
                 header(arcount=1),
diff --git a/bin/tests/system/tsig/badlocation b/bin/tests/system/tsig/badlocation
deleted file mode 100644
index 4477423644..0000000000
--- a/bin/tests/system/tsig/badlocation
+++ /dev/null
@@ -1,37 +0,0 @@
-# Transaction ID
-1122
-# Standard query
-0000
-# Questions: 1, Additional: 1
-0001 0000 0001 0000
-# QNAME: isc.org
-03 69 73 63 03 6F 72 67 00
-# Type: A (Host Address)
-0001
-# Class: IN
-0001
-# Specially crafted TSIG Resource Record
-# Name: "sha256"
-06 73 68 61 32 35 36 00
-# Type: TSIG (Transaction Signature)
-00fa
-# Class: ANY
-00ff
-# TTL: 0
-00000000
-# RdLen: 29
-001d
-# Algorithm Name: hmac-sha256
-0b 68 6D 61 63 2D 73 68 61 32 35 36 00
-# Time Signed: Jan 1, 1970 01:00:00.000000000 CET
-00 00 00 00 00 00
-# Fudge: 300
-012c
-# MAC Size: 0; MAC: empty
-0000
-# Original ID: 0
-0000
-# Error: no error
-0000
-# Other Data Length: 0
-0000
diff --git a/bin/tests/system/tsig/tests.sh b/bin/tests/system/tsig/tests.sh
index 23a5a9efff..f019deebf8 100644
--- a/bin/tests/system/tsig/tests.sh
+++ b/bin/tests/system/tsig/tests.sh
@@ -248,17 +248,6 @@ ret=0
 $KEYGEN -a hmac-sha256 -b 128 example.net >keygen.out3 2>&1 && ret=1
 grep "unknown algorithm" keygen.out3 >/dev/null || ret=1

-if "$PERL" -e 'use Net::DNS; use Net::DNS::Packet;' >/dev/null 2>&1; then
-  echo_i "check that TSIG in the wrong place returns FORMERR"
-  ret=0
-  $PERL ../packet.pl -a 10.53.0.1 -p ${PORT} -t udp -d <badlocation >packet.out
-  grep "rcode  = FORMERR" packet.out >/dev/null || ret=1
-  if [ $ret -eq 1 ]; then
-    echo_i "failed"
-    status=1
-  fi
-fi
-
 echo_i "check that a malformed truncated response to a TSIG query is handled"
 ret=0
 $DIG +timeout=15 -p $PORT @10.53.0.1 bad-tsig >dig.out.bad-tsig || ret=1
diff --git a/bin/tests/system/tsig/tests_sh_tsig.py b/bin/tests/system/tsig/tests_sh_tsig.py
index cdfc21f9a5..e9b7453eea 100644
--- a/bin/tests/system/tsig/tests_sh_tsig.py
+++ b/bin/tests/system/tsig/tests_sh_tsig.py
@@ -15,7 +15,6 @@ pytestmark = pytest.mark.extra_artifacts(
     [
         "dig.out.*",
         "keygen.out*",
-        "packet.out",
         "ns1/named-fips.conf",
     ]
 )