Commit 04c92fc042 for bind

commit 04c92fc04261ff2084401ab97083c45f98ee9634
Author: Evan Hunt <each@isc.org>
Date:   Thu Nov 26 08:43:54 2026 -0800

    Fix a regression in stub zone handling for DS queries

    When DELEG processing was introduced in the zone database,
    the special-case handling of at-parent types in stub zones was
    accidentally removed, which enabled a query for type DS to crash
    named. This has been fixed.

diff --git a/bin/tests/system/stub/tests_stub.py b/bin/tests/system/stub/tests_stub.py
index 41d67b0333..7272a6231d 100644
--- a/bin/tests/system/stub/tests_stub.py
+++ b/bin/tests/system/stub/tests_stub.py
@@ -97,3 +97,14 @@ def test_stub_glue_record_with_minimal_response():
     assert res_aaaa.answer[0] == dns.rrset.from_text(
         "ns4.example.", "300", "IN", "AAAA", "fd92:7065:b8e:ffff::4"
     )
+
+
+@pytest.mark.parametrize("dnssec", [False, True])
+def test_stub_origin_ds_referral(dnssec, ns5):
+    msg = isctest.query.create("example.", "DS", dnssec=dnssec, rd=False)
+    res = isctest.query.tcp(msg, ns5.ip)
+    isctest.check.noerror(res)
+    isctest.check.empty_answer(res)
+    assert res.authority[0] == dns.rrset.from_text(
+        "example.", "300", "IN", "NS", "ns4.example."
+    )
diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c
index 5c7f816db4..de925539c5 100644
--- a/lib/dns/qpzone.c
+++ b/lib/dns/qpzone.c
@@ -3641,7 +3641,6 @@ qpzone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
 	isc_rwlock_t *nlock = NULL;
 	isc_rwlocktype_t nlocktype = isc_rwlocktype_none;
 	bool de = (options & DNS_DBFIND_DELEGOK) != 0;
-	bool atparent = dns_rdatatype_atparent_deleg(type, de);

 	REQUIRE(VALID_QPZONE((qpzonedb_t *)db));
 	INSIST(version == NULL ||
@@ -3661,6 +3660,15 @@ qpzone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
 	qpz_search_init(&search, (qpzonedb_t *)db, (qpz_version_t *)version,
 			options);

+	/*
+	 * DS records (and DELEG, for DE=1 queries) live above the zone
+	 * cut in an ordinary zone, but stub zones don't have anything
+	 * above the delegation, so we don't count those as "at parent"
+	 * queries.
+	 */
+	bool atparent = (dns_rdatatype_atparent_deleg(type, de) &&
+			 !IS_STUB(search.qpdb));
+
 	if ((options & DNS_DBFIND_FORCENSEC3) != 0) {
 		nsec3 = true;
 		nspace = DNS_DBNAMESPACE_NSEC3;