[9.20] fix: usr: Fix a memory leak issue in the catalog zones

The :iscman:`named` process could leak small amounts of memory
when processing a catalog zone entry which had defined custom
primary servers with TSIG keys using both the regular ``primaries``
custom property syntax and the legacy alternative syntax (``masters``)
at the same time. This has been fixed.

Closes #5943

Backport of MR !11951

Merge branch 'backport-5943-catz-primaries-tsig-key-name-leak-fix-9.20' into 'bind-9.20'

See merge request isc-projects/bind9!11973
This commit is contained in:
Arаm Sаrgsyаn 2026-05-06 19:35:18 +00:00
commit 5fcb6d8809
2 changed files with 54 additions and 0 deletions

View file

@ -2993,6 +2993,52 @@ wait_for_soa @10.53.0.2 dom21.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
##########################################################################
nextpart ns2/named.run >/dev/null
echo_i "Testing primaries and masters suboptions together"
n=$((n + 1))
echo_i "adding domain dom22.example. to primary via RNDC ($n)"
ret=0
echo "@ 3600 IN SOA . . 1 3600 3600 3600 3600" >ns1/dom22.example.db
echo "@ IN NS invalid." >>ns1/dom22.example.db
echo "@ IN A 192.0.2.1" >>ns1/dom22.example.db
rndccmd 10.53.0.1 addzone dom22.example. in default '{type primary; file "dom22.example.db"; allow-transfer { key tsig_key; };};' || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "adding dom22.example. with both primaries and masters suboptions ($n)"
ret=0
$NSUPDATE -d <<END >>nsupdate.out.test$n 2>&1 || ret=1
server 10.53.0.1 ${PORT}
update add double.zones.catalog1.example. 3600 IN PTR dom22.example.
update add samelabel.primaries.ext.double.zones.catalog1.example. 3600 IN A 10.53.0.1
update add samelabel.primaries.ext.double.zones.catalog1.example. 3600 IN TXT "tsig_key"
update add samelabel.masters.ext.double.zones.catalog1.example. 3600 IN A 10.53.0.1
update add samelabel.masters.ext.double.zones.catalog1.example. 3600 IN TXT "tsig_key"
send
END
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "waiting for secondary to sync up ($n)"
ret=0
wait_for_message ns2/named.run "catz: adding zone 'dom22.example' from catalog 'catalog1.example'" \
&& wait_for_message ns2/named.run "transfer of 'dom22.example/IN/default' from 10.53.0.1#${PORT}: Transfer status: success" || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
n=$((n + 1))
echo_i "checking that dom22.example. is served by secondary ($n)"
ret=0
wait_for_soa @10.53.0.2 dom22.example. dig.out.test$n || ret=1
if [ $ret -ne 0 ]; then echo_i "failed"; fi
status=$((status + ret))
##########################################################################
echo_i "exit status: $status"
[ $status -eq 0 ] || exit 1

View file

@ -1490,6 +1490,14 @@ catz_process_primaries(dns_catz_zone_t *catz, dns_ipkeylist_t *ipkl,
if (i < ipkl->count) { /* we have this record already */
if (value->type == dns_rdatatype_txt) {
if (ipkl->keys[i] != NULL) {
if (dns_name_dynamic(ipkl->keys[i])) {
dns_name_free(ipkl->keys[i],
mctx);
}
isc_mem_put(mctx, ipkl->keys[i],
sizeof(*ipkl->keys[i]));
}
ipkl->keys[i] = keyname;
} else { /* A/AAAA */
memmove(&ipkl->addrs[i], &sockaddr,