Version in base suite: 4.9.18-0+deb13u1 Base version: pdns_4.9.18-0+deb13u1 Target version: pdns_4.9.20-0+deb13u1 Base file: /srv/ftp-master.debian.org/ftp/pool/main/p/pdns/pdns_4.9.18-0+deb13u1.dsc Target file: /srv/ftp-master.debian.org/policy/pool/main/p/pdns/pdns_4.9.20-0+deb13u1.dsc configure | 20 ++--- configure.ac | 2 debian/changelog | 10 ++ docs/calidns.1 | 2 docs/dnsbulktest.1 | 2 docs/dnsgram.1 | 2 docs/dnspcap2calidns.1 | 2 docs/dnspcap2protobuf.1 | 2 docs/dnsreplay.1 | 2 docs/dnsscan.1 | 2 docs/dnsscope.1 | 2 docs/dnstcpbench.1 | 2 docs/dnswasher.1 | 2 docs/dumresp.1 | 2 docs/ixfrdist.1 | 2 docs/ixfrdist.yml.5 | 2 docs/ixplore.1 | 2 docs/nproxy.1 | 2 docs/nsec3dig.1 | 2 docs/pdns_control.1 | 2 docs/pdns_notify.1 | 2 docs/pdns_server.1 | 2 docs/pdnsutil.1 | 2 docs/saxfr.1 | 2 docs/sdig.1 | 2 docs/zone2json.1 | 2 docs/zone2ldap.1 | 2 docs/zone2sql.1 | 2 ext/yahttp/yahttp/Makefile.am | 1 ext/yahttp/yahttp/Makefile.in | 1 ext/yahttp/yahttp/cookie.hpp | 144 ------------------------------------ ext/yahttp/yahttp/reqresp.cpp | 94 ++++++++++++++--------- ext/yahttp/yahttp/reqresp.hpp | 20 ++--- ext/yahttp/yahttp/yahttp.hpp | 1 modules/bindbackend/bindbackend2.cc | 30 ++++++- pdns/auth-main.cc | 6 + pdns/auth-primarycommunicator.cc | 27 ++++-- pdns/auth-secondarycommunicator.cc | 19 +++- pdns/axfr-retriever.cc | 7 + pdns/communicator.hh | 2 pdns/dnspacket.cc | 76 ++++++++++++++----- pdns/dnspacket.hh | 5 + pdns/dnsparser.cc | 13 ++- pdns/dnsparser.hh | 6 - pdns/dnsproxy.cc | 23 +++++ pdns/dnsrecords.cc | 7 + pdns/dnswriter.cc | 3 pdns/dnswriter.hh | 2 pdns/ixfr.cc | 9 +- pdns/ixfrutils.cc | 9 +- pdns/misc.hh | 18 ++++ pdns/qtype.cc | 5 - pdns/rcpgenerator.cc | 11 ++ pdns/rcpgenerator.hh | 4 - pdns/resolver.cc | 7 + pdns/rfc2136handler.cc | 9 +- pdns/saxfr.cc | 3 pdns/test-dnsparser_cc.cc | 25 ++++++ pdns/test-dnsrecords_cc.cc | 2 pdns/test-misc_hh.cc | 14 +++ pdns/test-rcpgenerator_cc.cc | 30 +++++++ pdns/tkey.cc | 5 + pdns/ws-auth.cc | 16 +++- 63 files changed, 427 insertions(+), 309 deletions(-) dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp7mb5lna1/pdns_4.9.18-0+deb13u1.dsc: no acceptable signature found dpkg-source: warning: cannot verify inline signature for /srv/release.debian.org/tmp/tmp7mb5lna1/pdns_4.9.20-0+deb13u1.dsc: no acceptable signature found diff -Nru pdns-4.9.18/configure pdns-4.9.20/configure --- pdns-4.9.18/configure 2026-10-07 06:10:01.000000000 +0000 +++ pdns-4.9.20/configure 2026-11-26 08:18:38.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for pdns 4.9.18. +# Generated by GNU Autoconf 2.71 for pdns 4.9.20. # # # Copyright (C) 1992-1996, 1998-2017, 2020-2021 Free Software Foundation, @@ -618,8 +618,8 @@ # Identity of this package. PACKAGE_NAME='pdns' PACKAGE_TARNAME='pdns' -PACKAGE_VERSION='4.9.18' -PACKAGE_STRING='pdns 4.9.18' +PACKAGE_VERSION='4.9.20' +PACKAGE_STRING='pdns 4.9.20' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1698,7 +1698,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pdns 4.9.18 to adapt to many kinds of systems. +\`configure' configures pdns 4.9.20 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1769,7 +1769,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pdns 4.9.18:";; + short | recursive ) echo "Configuration of pdns 4.9.20:";; esac cat <<\_ACEOF @@ -2040,7 +2040,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pdns configure 4.9.18 +pdns configure 4.9.20 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -2529,7 +2529,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pdns $as_me 4.9.18, which was +It was created by pdns $as_me 4.9.20, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -4027,7 +4027,7 @@ # Define the identity of the package. PACKAGE='pdns' - VERSION='4.9.18' + VERSION='4.9.20' printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h @@ -32469,7 +32469,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pdns $as_me 4.9.18, which was +This file was extended by pdns $as_me 4.9.20, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -32537,7 +32537,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -pdns config.status 4.9.18 +pdns config.status 4.9.20 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff -Nru pdns-4.9.18/configure.ac pdns-4.9.20/configure.ac --- pdns-4.9.18/configure.ac 2026-10-07 06:09:48.000000000 +0000 +++ pdns-4.9.20/configure.ac 2026-11-26 08:18:29.000000000 +0000 @@ -1,6 +1,6 @@ AC_PREREQ([2.69]) -AC_INIT([pdns], [4.9.18]) +AC_INIT([pdns], [4.9.20]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip tar-ustar -Wno-portability subdir-objects parallel-tests 1.11]) AM_SILENT_RULES([yes]) diff -Nru pdns-4.9.18/debian/changelog pdns-4.9.20/debian/changelog --- pdns-4.9.18/debian/changelog 2026-10-27 10:56:54.000000000 +0000 +++ pdns-4.9.20/debian/changelog 2026-11-29 20:22:44.000000000 +0000 @@ -1,3 +1,13 @@ +pdns (4.9.20-0+deb13u1) trixie-security; urgency=medium + + * New upstream version 4.9.20, fixing security issues + CVE-2026-123757, CVE-2026-123758, CVE-2026-123756, + CVE-2026-123759, CVE-2026-123760, CVE-2026-123761, + CVE-2026-123762, CVE-2026-123764, CVE-2026-124727, + CVE-2026-124728 (Closes: #1155794) + + -- Chris Hofstaedtler Sun, 29 Nov 2026 21:22:44 +0100 + pdns (4.9.18-0+deb13u1) trixie-security; urgency=medium * New upstream version 4.9.18, fixing security issue diff -Nru pdns-4.9.18/docs/calidns.1 pdns-4.9.20/docs/calidns.1 --- pdns-4.9.18/docs/calidns.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/calidns.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "CALIDNS" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "CALIDNS" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME calidns \- A DNS recursor testing tool .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnsbulktest.1 pdns-4.9.20/docs/dnsbulktest.1 --- pdns-4.9.18/docs/dnsbulktest.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnsbulktest.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSBULKTEST" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSBULKTEST" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnsbulktest \- A debugging tool for intermittent resolver failures .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnsgram.1 pdns-4.9.20/docs/dnsgram.1 --- pdns-4.9.18/docs/dnsgram.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnsgram.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSGRAM" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSGRAM" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnsgram \- A debugging tool for intermittent resolver failures .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnspcap2calidns.1 pdns-4.9.20/docs/dnspcap2calidns.1 --- pdns-4.9.18/docs/dnspcap2calidns.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnspcap2calidns.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSPCAP2CALIDNS" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSPCAP2CALIDNS" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnspcap2calidns \- A tool to convert PCAPs of DNS traffic to calidns input .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnspcap2protobuf.1 pdns-4.9.20/docs/dnspcap2protobuf.1 --- pdns-4.9.18/docs/dnspcap2protobuf.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnspcap2protobuf.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSPCAP2PROTOBUF" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSPCAP2PROTOBUF" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnspcap2protobuf \- A tool to convert PCAPs of DNS traffic to PowerDNS Protobuf .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnsreplay.1 pdns-4.9.20/docs/dnsreplay.1 --- pdns-4.9.18/docs/dnsreplay.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnsreplay.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSREPLAY" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSREPLAY" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnsreplay \- A PowerDNS nameserver debugging tool .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnsscan.1 pdns-4.9.20/docs/dnsscan.1 --- pdns-4.9.18/docs/dnsscan.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnsscan.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSSCAN" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSSCAN" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnsscan \- List the amount of queries per qtype in a pcap .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnsscope.1 pdns-4.9.20/docs/dnsscope.1 --- pdns-4.9.18/docs/dnsscope.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnsscope.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSSCOPE" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSSCOPE" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnsscope \- A PowerDNS nameserver debugging tool .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnstcpbench.1 pdns-4.9.20/docs/dnstcpbench.1 --- pdns-4.9.18/docs/dnstcpbench.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnstcpbench.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSTCPBENCH" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSTCPBENCH" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnstcpbench \- tool to perform TCP benchmarking of nameservers .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dnswasher.1 pdns-4.9.20/docs/dnswasher.1 --- pdns-4.9.18/docs/dnswasher.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dnswasher.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DNSWASHER" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DNSWASHER" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dnswasher \- A PowerDNS nameserver debugging tool .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/dumresp.1 pdns-4.9.20/docs/dumresp.1 --- pdns-4.9.18/docs/dumresp.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/dumresp.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "DUMRESP" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "DUMRESP" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME dumresp \- A dumb DNS responder .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/ixfrdist.1 pdns-4.9.20/docs/ixfrdist.1 --- pdns-4.9.18/docs/ixfrdist.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/ixfrdist.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "IXFRDIST" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "IXFRDIST" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME ixfrdist \- An IXFR/AXFR-only server that re-distributes zones .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/ixfrdist.yml.5 pdns-4.9.20/docs/ixfrdist.yml.5 --- pdns-4.9.18/docs/ixfrdist.yml.5 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/ixfrdist.yml.5 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "IXFRDIST.YML" "5" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "IXFRDIST.YML" "5" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME ixfrdist.yml \- The ixfrdist configuration file .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/ixplore.1 pdns-4.9.20/docs/ixplore.1 --- pdns-4.9.18/docs/ixplore.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/ixplore.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "IXPLORE" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "IXPLORE" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME ixplore \- A tool that provides insights into IXFRs .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/nproxy.1 pdns-4.9.20/docs/nproxy.1 --- pdns-4.9.18/docs/nproxy.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/nproxy.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "NPROXY" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "NPROXY" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME nproxy \- DNS notification proxy .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/nsec3dig.1 pdns-4.9.20/docs/nsec3dig.1 --- pdns-4.9.18/docs/nsec3dig.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/nsec3dig.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "NSEC3DIG" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "NSEC3DIG" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME nsec3dig \- Show and validate NSEC3 proofs .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/pdns_control.1 pdns-4.9.20/docs/pdns_control.1 --- pdns-4.9.18/docs/pdns_control.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/pdns_control.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "PDNS_CONTROL" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "PDNS_CONTROL" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME pdns_control \- Control the PowerDNS nameserver .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/pdns_notify.1 pdns-4.9.20/docs/pdns_notify.1 --- pdns-4.9.18/docs/pdns_notify.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/pdns_notify.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "PDNS_NOTIFY" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "PDNS_NOTIFY" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME pdns_notify \- A simple DNS NOTIFY sender .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/pdns_server.1 pdns-4.9.20/docs/pdns_server.1 --- pdns-4.9.18/docs/pdns_server.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/pdns_server.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "PDNS_SERVER" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "PDNS_SERVER" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME pdns_server \- The PowerDNS Authoritative Nameserver .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/pdnsutil.1 pdns-4.9.20/docs/pdnsutil.1 --- pdns-4.9.18/docs/pdnsutil.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/pdnsutil.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "PDNSUTIL" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "PDNSUTIL" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME pdnsutil \- PowerDNS record and DNSSEC command and control .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/saxfr.1 pdns-4.9.20/docs/saxfr.1 --- pdns-4.9.18/docs/saxfr.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/saxfr.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "SAXFR" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "SAXFR" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME saxfr \- Perform AXFRs and show information about it .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/sdig.1 pdns-4.9.20/docs/sdig.1 --- pdns-4.9.18/docs/sdig.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/sdig.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "SDIG" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "SDIG" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME sdig \- Perform a DNS query and show the results .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/zone2json.1 pdns-4.9.20/docs/zone2json.1 --- pdns-4.9.18/docs/zone2json.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/zone2json.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "ZONE2JSON" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "ZONE2JSON" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME zone2json \- convert BIND zones to JSON .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/zone2ldap.1 pdns-4.9.20/docs/zone2ldap.1 --- pdns-4.9.18/docs/zone2ldap.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/zone2ldap.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "ZONE2LDAP" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "ZONE2LDAP" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME zone2ldap \- convert zonefiles to ldif .SH SYNOPSIS diff -Nru pdns-4.9.18/docs/zone2sql.1 pdns-4.9.20/docs/zone2sql.1 --- pdns-4.9.18/docs/zone2sql.1 2026-10-07 06:11:32.000000000 +0000 +++ pdns-4.9.20/docs/zone2sql.1 2026-11-26 08:19:41.000000000 +0000 @@ -27,7 +27,7 @@ .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. -.TH "ZONE2SQL" "1" "Oct 07, 2026" "" "PowerDNS Authoritative Server" +.TH "ZONE2SQL" "1" "Nov 26, 2026" "" "PowerDNS Authoritative Server" .SH NAME zone2sql \- convert BIND zones to SQL .SH SYNOPSIS diff -Nru pdns-4.9.18/ext/yahttp/yahttp/Makefile.am pdns-4.9.20/ext/yahttp/yahttp/Makefile.am --- pdns-4.9.18/ext/yahttp/yahttp/Makefile.am 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/ext/yahttp/yahttp/Makefile.am 2026-11-26 08:18:13.000000000 +0000 @@ -1,7 +1,6 @@ noinst_LTLIBRARIES = libyahttp.la libyahttp_la_SOURCES = \ - cookie.hpp \ exception.hpp \ reqresp.cpp \ reqresp.hpp \ diff -Nru pdns-4.9.18/ext/yahttp/yahttp/Makefile.in pdns-4.9.20/ext/yahttp/yahttp/Makefile.in --- pdns-4.9.18/ext/yahttp/yahttp/Makefile.in 2026-10-07 06:10:03.000000000 +0000 +++ pdns-4.9.20/ext/yahttp/yahttp/Makefile.in 2026-11-26 08:18:40.000000000 +0000 @@ -488,7 +488,6 @@ top_srcdir = @top_srcdir@ noinst_LTLIBRARIES = libyahttp.la libyahttp_la_SOURCES = \ - cookie.hpp \ exception.hpp \ reqresp.cpp \ reqresp.hpp \ diff -Nru pdns-4.9.18/ext/yahttp/yahttp/cookie.hpp pdns-4.9.20/ext/yahttp/yahttp/cookie.hpp --- pdns-4.9.18/ext/yahttp/yahttp/cookie.hpp 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/ext/yahttp/yahttp/cookie.hpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -namespace YaHTTP { - /*! Implements a single cookie */ - class Cookie { - public: - Cookie() { - secure = false; - httponly = false; - name = value = ""; - expires = DateTime(); - }; //!< Set the cookie to empty value - - Cookie(const Cookie &rhs) { - name = rhs.name; - value = rhs.value; - domain = rhs.domain; - path = rhs.path; - secure = rhs.secure; - httponly = rhs.httponly; - expires = rhs.expires; - }; //0) - oss << "; domain=" << domain; - if (path.size()>0) - oss << "; path=" << path; - if (secure) - oss << "; secure"; - if (httponly) - oss << "; httpOnly"; - return oss.str(); - }; //!< Stringify the cookie - }; - - /*! Implements a Cookie jar for storing multiple cookies */ - class CookieJar { - public: - std::map cookies; //cookies = rhs.cookies; - } //cookies.clear(); - } - - void keyValuePair(const std::string &keyvalue, std::string &key, std::string &value) { - size_t pos; - pos = keyvalue.find("="); - if (pos == std::string::npos) throw ParseError("Not a Key-Value pair (cookie)"); - key = std::string(keyvalue.begin(), keyvalue.begin()+pos); - value = std::string(keyvalue.begin()+pos+1, keyvalue.end()); - } // lcookies; - Cookie c; - pos = 0; - while(pos < cookiestr.size()) { - if ((npos = cookiestr.find("; ", pos)) == std::string::npos) - npos = cookiestr.size(); - keyValuePair(cookiestr.substr(pos, npos-pos), c.name, c.value); - c.name = YaHTTP::Utility::decodeURL(c.name); - c.value = YaHTTP::Utility::decodeURL(c.value); - lcookies.push_back(c); - pos = npos+2; - } - for(std::list::iterator i = lcookies.begin(); i != lcookies.end(); i++) { - this->cookies[i->name] = *i; - } - } - - void parseSetCookieHeader(const std::string &cookiestr) { - Cookie c; - size_t pos,npos; - std::string k, v; - - if ((pos = cookiestr.find("; ", 0)) == std::string::npos) - pos = cookiestr.size(); - keyValuePair(cookiestr.substr(0, pos), c.name, c.value); - c.name = YaHTTP::Utility::decodeURL(c.name); - c.value = YaHTTP::Utility::decodeURL(c.value); - if (pos < cookiestr.size()) pos+=2; - - while(pos < cookiestr.size()) { - if ((npos = cookiestr.find("; ", pos)) == std::string::npos) - npos = cookiestr.size(); - std::string s = cookiestr.substr(pos, npos-pos); - if (s.find("=") != std::string::npos) - keyValuePair(s, k, v); - else - k = std::move(s); - if (k == "expires") { - DateTime dt; - dt.parseCookie(v); - c.expires = dt; - } else if (k == "domain") { - c.domain = v; - } else if (k == "path") { - c.path = v; - } else if (k == "httpOnly") { - c.httponly = true; - } else if (k == "secure") { - c.secure = true; - } else { - // ignore crap - break; - } - pos = npos+2; - } - - this->cookies[c.name] = c; - }; // +#include namespace YaHTTP { @@ -43,7 +44,7 @@ bool AsyncLoader::feed(const std::string& somedata) { if (state < 2) { - headersize += somedata.length(); // maye include some body data, we don't know yet... + headersize += somedata.length(); // maybe include some body data, we don't know yet... if (headersize > target->max_header_size) { if (target->kind == YAHTTP_TYPE_REQUEST) { throw ParseError("Request header too large"); @@ -54,21 +55,34 @@ } } buffer.append(somedata); + size_t cursor = 0; while(state < 2) { int cr=0; - pos = buffer.find_first_of("\n"); + size_t pos = buffer.find_first_of("\n", cursor); // need to find CRLF in buffer - if (pos == std::string::npos) return false; - if (pos>0 && buffer[pos-1]=='\r') + if (pos == std::string::npos) { + // Remove all the data which has been consumed as header. + if (cursor != 0) { + buffer.erase(buffer.begin(), buffer.begin() + cursor); + } + return false; + } + if (pos>0 && buffer[pos-1]=='\r') { cr=1; - std::string line(buffer.begin(), buffer.begin()+pos-cr); // exclude CRLF - buffer.erase(buffer.begin(), buffer.begin()+pos+1); // remove line from buffer including CRLF + } + std::string_view line(buffer.data() + cursor, (pos - cr) - cursor); // exclude CRLF + cursor = pos + 1; // skip line, including CRLF + // Release memory as soon as we can + if (cursor == buffer.length()) { + buffer.clear(); + cursor = 0; + } if (state == 0) { // startup line if (target->kind == YAHTTP_TYPE_REQUEST) { std::string ver; std::string tmpurl; - std::istringstream iss(line); + std::istringstream iss{std::string(line)}; iss >> target->method >> tmpurl >> ver; if (ver.size() == 0) target->version = 9; @@ -87,7 +101,7 @@ state = 1; } else if(target->kind == YAHTTP_TYPE_RESPONSE) { std::string ver; - std::istringstream iss(line); + std::istringstream iss{std::string(line)}; std::string::size_type pos1; iss >> ver >> target->status; std::getline(iss, target->statusText); @@ -117,6 +131,11 @@ state = 2; break; } + // give up if there are too many header lines - this shouldn't happen in legitimate traffic + ++headerlines; + if (headerlines > YAHTTP_MAX_HEADER_LINES) { + throw ParseError("Too many headers"); + } // split headers if ((pos1 = line.find(":")) == std::string::npos) { throw ParseError("Malformed header line"); @@ -132,9 +151,9 @@ // is it already defined if (key == "set-cookie" && target->kind == YAHTTP_TYPE_RESPONSE) { - target->jar.parseSetCookieHeader(value); + // Nothing (intentional). } else if (key == "cookie" && target->kind == YAHTTP_TYPE_REQUEST) { - target->jar.parseCookieHeader(value); + // Nothing (intentional). } else { if (key == "host" && target->kind == YAHTTP_TYPE_REQUEST) { // maybe it contains port? @@ -153,6 +172,10 @@ } } } + // Remove all the data which has been consumed as header, if we haven't been able to do so earlier. + if (cursor != 0) { + buffer.erase(buffer.begin(), buffer.begin() + cursor); + } minbody = 0; // check for expected body size @@ -181,7 +204,8 @@ if (chunk_size == 0) { char buf[100]; // read chunk length - if ((pos = buffer.find('\n')) == std::string::npos) { + size_t pos = buffer.find('\n'); + if (pos == std::string::npos) { if (buffer.size() > 99) { throw ParseError("Nonsensical chunk_size"); } @@ -201,11 +225,25 @@ } } else { int crlf=1; - if (buffer.size() < chunk_size+1) return false; // expect newline - if (buffer.at(chunk_size) == '\r') { - if (buffer.size() < chunk_size+2 || buffer.at(chunk_size+1) != '\n') return false; // expect newline after carriage return - crlf=2; - } else if (buffer.at(chunk_size) != '\n') return false; + if (buffer.size() < chunk_size + 1) { + return false; // expecting \n or \r\n at chunk_size, but we're not there yet. + } + switch (buffer.at(chunk_size)) { + case '\n': + // Well-formed chunk + break; + case '\r': + if (buffer.size() < chunk_size + 2) { + return false; // expecting \n to follow \r, but we're not there yet. + } + if (buffer.at(chunk_size+1) == '\n') { + crlf=2; + break; + } + [[fallthrough]]; + default: + throw ParseError("Chunked body is not terminated correctly"); + } if (bodysize + chunk_size > maxbody) { throw ParseError("Chunked body is too large"); } @@ -225,7 +263,7 @@ bodybuf << buffer; bodysize += buffer.length(); } - buffer = ""; + buffer.clear(); } } @@ -258,7 +296,6 @@ } os << "\r\n"; - bool cookieSent = false; bool sendChunked = false; if (this->version > 10) { // 1.1 or better @@ -273,7 +310,7 @@ os << "Transfer-Encoding: chunked\r\n"; } } else { - sendChunked = false; + sendChunked = false; } } @@ -283,28 +320,9 @@ if (iter->first == "host" && (kind != YAHTTP_TYPE_REQUEST || version < 10)) { iter++; continue; } if (iter->first == "transfer-encoding" && sendChunked) { iter++; continue; } std::string header = Utility::camelizeHeader(iter->first); - if (header == "Cookie" || header == "Set-Cookie") cookieSent = true; os << Utility::camelizeHeader(iter->first) << ": " << iter->second << "\r\n"; iter++; } - if (version > 9 && !cookieSent && jar.cookies.size() > 0) { // write cookies - if (kind == YAHTTP_TYPE_REQUEST) { - bool first = true; - os << "Cookie: "; - for(strcookie_map_t::const_iterator i = jar.cookies.begin(); i != jar.cookies.end(); i++) { - if (first) - first = false; - else - os << "; "; - os << Utility::encodeURL(i->second.name) << "=" << Utility::encodeURL(i->second.value); - } - } else if (kind == YAHTTP_TYPE_RESPONSE) { - for(strcookie_map_t::const_iterator i = jar.cookies.begin(); i != jar.cookies.end(); i++) { - os << "Set-Cookie: "; - os << i->second.str() << "\r\n"; - } - } - } os << "\r\n"; #ifdef HAVE_CPP_FUNC_PTR this->renderer(this, os, sendChunked); diff -Nru pdns-4.9.18/ext/yahttp/yahttp/reqresp.hpp pdns-4.9.20/ext/yahttp/yahttp/reqresp.hpp --- pdns-4.9.18/ext/yahttp/yahttp/reqresp.hpp 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/ext/yahttp/yahttp/reqresp.hpp 2026-11-26 08:18:13.000000000 +0000 @@ -24,6 +24,10 @@ #define YAHTTP_MAX_HEADER_SIZE (100 * 1024) #endif +#ifndef YAHTTP_MAX_HEADER_LINES +#define YAHTTP_MAX_HEADER_LINES 1000 +#endif + #ifndef YAHTTP_MAX_REQUEST_SIZE #define YAHTTP_MAX_REQUEST_SIZE 2097152 #endif @@ -36,8 +40,6 @@ #define YAHTTP_TYPE_RESPONSE 2 namespace YaHTTP { - typedef std::map strcookie_map_t; //url = rhs.url; this->kind = rhs.kind; this->status = rhs.status; this->statusText = rhs.statusText; this->method = rhs.method; this->headers = rhs.headers; - this->jar = rhs.jar; this->postvars = rhs.postvars; + this->postvars = rhs.postvars; this->parameters = rhs.parameters; this->getvars = rhs.getvars; this->body = rhs.body; this->max_request_size = rhs.max_request_size; this->max_response_size = rhs.max_response_size; this->version = rhs.version; @@ -144,7 +145,7 @@ this->url = rhs.url; this->kind = rhs.kind; this->status = rhs.status; this->statusText = rhs.statusText; this->method = rhs.method; this->headers = rhs.headers; - this->jar = rhs.jar; this->postvars = rhs.postvars; + this->postvars = rhs.postvars; this->parameters = rhs.parameters; this->getvars = rhs.getvars; this->body = rhs.body; this->max_request_size = rhs.max_request_size; this->max_response_size = rhs.max_response_size; this->version = rhs.version; @@ -163,7 +164,6 @@ std::string statusText; //url = rhs.url; this->method = rhs.method; - this->jar = rhs.jar; this->version = rhs.version; } friend std::ostream& operator<<(std::ostream& os, const Response &resp); @@ -252,7 +250,6 @@ // copy SOME attributes this->url = rhs.url; this->method = rhs.method; - this->jar = rhs.jar; this->version = rhs.version; } void setup(const std::string& method_, const std::string& url_) { @@ -304,7 +301,6 @@ public: T* target; //target = target_; + state = 0; this->target = target_; hasBody = false; buffer = ""; headersize = 0; + headerlines = 0; bodysize = 0; this->target->initialize(); }; //(letter)); ret += ebuf.data(); break; @@ -304,6 +306,23 @@ return ret; } +static const std::string bindEscapeContent(const std::string& content) +{ + std::string ret; + std::array ebuf{}; + for (char letter : content) { + // any non-printables or brackets + if (letter < ' ' || letter == '(' || letter == ')' || letter >= '\x7f') { + snprintf(ebuf.data(), ebuf.size(), "\\%03u", static_cast(letter)); + ret += ebuf.data(); + } + else { + ret += letter; + } + } + return ret; +} + bool Bind2Backend::feedRecord(const DNSResourceRecord& rr, const DNSName& /* ordername */, bool /* ordernameIsNSEC3 */) { if (d_transaction_id < 1) { @@ -341,7 +360,7 @@ [[fallthrough]]; default: if (d_of && *d_of) { - *d_of << qname << "\t" << rr.ttl << "\t" << rr.qtype.toString() << "\t" << content << endl; + *d_of << qname << "\t" << rr.ttl << "\t" << rr.qtype.toString() << "\t" << bindEscapeContent(content) << endl; } } return true; @@ -1459,13 +1478,16 @@ throw PDNSException("Unauthorized characters in domain name for bind configuration file"); } - string filename = getArg("autoprimary-destdir") + '/'; + std::string filename = getArg("autoprimary-destdir") + '/'; + std::string configname{}; if (domainname.empty()) { filename.append("rootzone."); + configname = "."; } else { // Make sure the zone file name does not contain path separators. filename.append(boost::replace_all_copy(domainname, "/", "\\047")); + configname = domainname; } g_log << Logger::Warning << d_logprefix @@ -1482,8 +1504,8 @@ } c_of << endl; - c_of << "# AutoSecondary zone '" << domainname << "' (added: " << nowTime() << ") (account: " << account << ')' << endl; - c_of << "zone \"" << domainname << "\" {" << endl; + c_of << "# AutoSecondary zone '" << configname << "' (added: " << nowTime() << ") (account: " << account << ')' << endl; + c_of << "zone \"" << configname << "\" {" << endl; c_of << "\ttype secondary;" << endl; c_of << "\tfile \"" << filename << "\";" << endl; c_of << "\tprimaries { " << ipAddress << "; };" << endl; diff -Nru pdns-4.9.18/pdns/auth-main.cc pdns-4.9.20/pdns/auth-main.cc --- pdns-4.9.18/pdns/auth-main.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/auth-main.cc 2026-11-26 08:18:13.000000000 +0000 @@ -536,6 +536,12 @@ avg_latency = 0.999 * avg_latency + 0.001 * std::max(diff, 0); } + catch (const PDNSException& exc) { + // UDPNameserver::send can throw a PDNSException if signing the packet + // fails. + SLOG(g_log << Logger::Error << "Caught unhandled exception while sending a response: " << exc.reason << endl, + slog->error(Logr::Error, exc.reason, "Caught unhandled exception while sending a response")); + } catch (const std::exception& e) { g_log << Logger::Error << "Caught unhandled exception while sending a response: " << e.what() << endl; } diff -Nru pdns-4.9.18/pdns/auth-primarycommunicator.cc pdns-4.9.20/pdns/auth-primarycommunicator.cc --- pdns-4.9.18/pdns/auth-primarycommunicator.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/auth-primarycommunicator.cc 2026-11-26 08:18:13.000000000 +0000 @@ -75,7 +75,7 @@ for (const auto& ip : ips) { g_log << Logger::Notice << "Queued notification of domain '" << di.zone << "' to " << ip << endl; - d_nq.add(di.zone, ip, d_delayNotifications); + d_nq.lock()->add(di.zone, ip, d_delayNotifications); hasQueuedItem = true; } } @@ -98,7 +98,7 @@ g_log << Logger::Notice << "Queued also-notification of domain '" << di.zone << "' to " << caIp.toStringWithPort() << endl; if (!ips.count(caIp.toStringWithPort())) { ips.insert(caIp.toStringWithPort()); - d_nq.add(di.zone, caIp.toStringWithPort(), d_delayNotifications); + d_nq.lock()->add(di.zone, caIp.toStringWithPort(), d_delayNotifications); } hasQueuedItem = true; } @@ -242,12 +242,14 @@ g_log << Logger::Warning << "Received unsuccessful notification report for '" << p.qdomain << "' from " << from.toStringWithPort() << ", error: " << RCode::to_s(p.d.rcode) << endl; } - if (d_nq.removeIf(from, p.d.id, p.qdomain)) { + if (d_nq.lock()->removeIf(from, p.d.id, p.qdomain)) { g_log << Logger::Notice << "Removed from notification list: '" << p.qdomain << "' to " << from.toStringWithPort() << " " << (p.d.rcode ? RCode::to_s(p.d.rcode) : "(was acknowledged)") << endl; } else { g_log << Logger::Warning << "Received spurious notify answer for '" << p.qdomain << "' from " << from.toStringWithPort() << endl; - // d_nq.dump(); +#if 0 + d_nq.read_only_lock()->dump(); +#endif } } @@ -257,13 +259,15 @@ uint16_t id = 0; bool purged; - while (d_nq.getOne(domain, ip, &id, purged)) { + + auto locked_nq = d_nq.lock(); + while (locked_nq->getOne(domain, ip, &id, purged)) { if (!purged) { try { ComboAddress remote(ip, 53); // default to 53 if ((d_nsock6 < 0 && remote.sin4.sin_family == AF_INET6) || (d_nsock4 < 0 && remote.sin4.sin_family == AF_INET)) { g_log << Logger::Warning << "Unable to notify " << remote.toStringWithPort() << " for domain '" << domain << "', address family is disabled. Is an IPv" << (remote.sin4.sin_family == AF_INET ? "4" : "6") << " address set in query-local-address?" << endl; - d_nq.removeIf(remote, id, domain); // Remove, we'll never be able to notify + locked_nq->removeIf(remote, id, domain); // Remove, we'll never be able to notify continue; // don't try to notify what we can't! } if (d_preventSelfNotification && AddressIsUs(remote)) { @@ -282,7 +286,7 @@ } } - return d_nq.earliest(); + return locked_nq->earliest(); } void CommunicatorClass::sendNotification(int sock, const DNSName& domain, const ComboAddress& remote, uint16_t id, UeberBackend* B) @@ -320,7 +324,12 @@ g_log << Logger::Error << "Unable to Base-64 decode TSIG key '" << tsigkeyname << "' for domain '" << domain << "'" << endl; return; } - addTSIG(pw, trc, tsigkeyname, tsigsecret, "", false); + try { + addTSIG(pw, trc, tsigkeyname, tsigsecret, "", false); + } + catch (const PDNSException& exc) { + throw ResolverException(exc.reason); + } } if (sendto(sock, &packet[0], packet.size(), 0, (struct sockaddr*)(&remote), remote.getSocklen()) < 0) { @@ -369,5 +378,5 @@ void CommunicatorClass::notify(const DNSName& domain, const string& ip) { - d_nq.add(domain, ip); + d_nq.lock()->add(domain, ip); } diff -Nru pdns-4.9.18/pdns/auth-secondarycommunicator.cc pdns-4.9.20/pdns/auth-secondarycommunicator.cc --- pdns-4.9.18/pdns/auth-secondarycommunicator.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/auth-secondarycommunicator.cc 2026-11-26 08:18:13.000000000 +0000 @@ -87,7 +87,8 @@ int numDeltas{0}; }; -static bool catalogDiff(const DomainInfo& di, vector& fromXFR, vector& fromDB, const string& logPrefix) +// NOLINTNEXTLINE(readability-function-cognitive-complexity) +static bool catalogDiff(UeberBackend& B, const DomainInfo& di, vector& fromXFR, vector& fromDB, const string& logPrefix) { extern CommunicatorClass Communicator; @@ -182,7 +183,7 @@ if (create && remove) { g_log << Logger::Warning << logPrefix << "zone '" << ciCreate.d_zone << "' state reset" << endl; } - else if (create && di.backend->getDomainInfo(ciCreate.d_zone, d)) { // detect clash + else if (create && B.getDomainInfo(ciCreate.d_zone, d)) { // detect clash CatalogInfo ci; ci.fromJson(d.options, CatalogInfo::CatalogType::Consumer); @@ -258,7 +259,7 @@ for (const auto& zone : clearCache) { if (g_zoneCache.isEnabled()) { if (zone.second) { - if (di.backend->getDomainInfo(zone.first, d)) { + if (B.getDomainInfo(zone.first, d)) { g_zoneCache.add(zone.first, d.id); } else { @@ -304,7 +305,7 @@ return false; } -static bool catalogProcess(const DomainInfo& di, vector& rrs, string logPrefix) +static bool catalogProcess(UeberBackend& B, const DomainInfo& di, vector& rrs, string logPrefix) { logPrefix += "Catalog-Zone "; @@ -380,8 +381,12 @@ ci.d_zone = DNSName(rr.content); ci.d_unique = unique; + if (ci.d_zone.isRoot()) { + g_log << Logger::Warning << logPrefix << "zone '" << di.zone << "', invalid member zone '" << ci.d_zone << "'" << endl; + zoneInvalid = true; + } if (!dupcheck.insert(ci.d_zone).second) { - g_log << Logger::Warning << logPrefix << "zone '" << di.zone << "', duplicate member zone'" << ci.d_zone << "'" << endl; + g_log << Logger::Warning << logPrefix << "zone '" << di.zone << "', duplicate member zone '" << ci.d_zone << "'" << endl; zoneInvalid = true; } } @@ -422,7 +427,7 @@ } // Process - return catalogDiff(di, fromXFR, fromDB, logPrefix); + return catalogDiff(B, di, fromXFR, fromDB, logPrefix); } void CommunicatorClass::ixfrSuck(const DNSName& domain, const TSIGTriplet& tt, const ComboAddress& laddr, const ComboAddress& remote, ZoneStatus& zs, vector* axfr) @@ -790,7 +795,7 @@ } if (di.kind == DomainInfo::Consumer) { - if (!catalogProcess(di, rrs, logPrefix)) { + if (!catalogProcess(B, di, rrs, logPrefix)) { g_log << Logger::Warning << logPrefix << "Catalog-Zone update failed, only import records" << endl; } } diff -Nru pdns-4.9.18/pdns/axfr-retriever.cc pdns-4.9.20/pdns/axfr-retriever.cc --- pdns-4.9.18/pdns/axfr-retriever.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/axfr-retriever.cc 2026-11-26 08:18:13.000000000 +0000 @@ -69,7 +69,12 @@ d_trc.d_fudge = 300; d_trc.d_origID=ntohs(pw.getHeader()->id); d_trc.d_eRcode=0; - addTSIG(pw, d_trc, tt.name, tt.secret, "", false); + try { + addTSIG(pw, d_trc, tt.name, tt.secret, "", false); + } + catch (const PDNSException& exc) { + throw ResolverException(exc.reason); + } } uint16_t replen=htons(packet.size()); diff -Nru pdns-4.9.18/pdns/communicator.hh pdns-4.9.20/pdns/communicator.hh --- pdns-4.9.18/pdns/communicator.hh 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/communicator.hh 2026-11-26 08:18:13.000000000 +0000 @@ -200,7 +200,7 @@ set d_alsoNotify; NetmaskGroup d_onlyNotify; - NotificationQueue d_nq; + LockGuarded d_nq; time_t d_tickinterval; bool d_secondarieschanged; diff -Nru pdns-4.9.18/pdns/dnspacket.cc pdns-4.9.20/pdns/dnspacket.cc --- pdns-4.9.18/pdns/dnspacket.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnspacket.cc 2026-11-26 08:18:13.000000000 +0000 @@ -63,6 +63,25 @@ memset(&d, 0, sizeof(d)); } +bool DNSPacket::preparePayload(std::string& error, bool throwsOnTruncation) +{ + if (!d_wrapped) { + try { + wrapup(throwsOnTruncation); + } + catch (const PDNSException& exc) { + error = exc.reason; + return false; + } + catch (const std::exception& exc) { + error = exc.what(); + return false; + } + } + error.clear(); + return true; +} + const string& DNSPacket::getString(bool throwsOnTruncation) { if(!d_wrapped) @@ -348,6 +367,7 @@ if(!d_rrs.empty() || !opts.empty() || d_haveednssubnet || d_haveednssection || d_haveednscookie) { try { uint8_t maxScopeMask=0; + bool shallCommit{true}; for(pos=d_rrs.begin(); pos < d_rrs.end(); ++pos) { maxScopeMask = max(maxScopeMask, pos->scopeMask); @@ -360,16 +380,14 @@ pw.rollback(); pw.truncate(); pw.getHeader()->tc=1; - goto noCommit; + shallCommit = false; + break; } } + if (shallCommit && !d_rrs.empty()) { + pw.commit(); + } - // if(!pw.getHeader()->tc) // protect against double commit from addSignature - - if(!d_rrs.empty()) pw.commit(); - - noCommit:; - if(d_haveednssubnet) { EDNSSubnetOpts eso = d_eso; // use the scopeMask from the resolver, if it is greater - issue #5469 @@ -396,10 +414,12 @@ throw; } } - - if(d_trc.d_algoName.countLabels()) + + if (!d_tsigkeyname.empty() && d_trc.d_algoName.countLabels()) { + // may throw PDNSException if signing fails addTSIG(pw, d_trc, d_tsigkeyname, d_tsigsecret, d_tsigprevious, d_tsigtimersonly); - + } + d_rawpacket.assign((char*)&packet[0], packet.size()); // XXX we could do this natively on a vector.. // copy RR counts so they can be read later @@ -481,7 +501,7 @@ } } -int DNSPacket::noparse(const char *mesg, size_t length) +int DNSPacket::reinit(const char *mesg, size_t length) { d_rawpacket.assign(mesg,length); if(length < 12) { @@ -489,12 +509,36 @@ << getRemoteStringWithPort(); return -1; } + memcpy((void *)&d,(const void *)d_rawpacket.c_str(),12); + + d_havetsig = false; + d_tsig_algo = TSIG_MD5; + d_tsigkeyname.clear(); + d_tsigsecret.clear(); + d_tsigprevious.clear(); + d_tsigtimersonly = false; + + return 0; +} + +int DNSPacket::noparse(const char *mesg, size_t length) +{ + if (reinit(mesg, length) != 0) { + return -1; + } d_wantsnsid=false; d_maxreplylen=512; - memcpy((void *)&d,(const void *)d_rawpacket.c_str(),12); return 0; } +void DNSPacket::clearTSIGDetails() +{ + d_trc = {}; // resets d_algoName + d_tsigkeyname.clear(); + d_tsigsecret.clear(); + d_tsigprevious.clear(); +} + void DNSPacket::setTSIGDetails(const TSIGRecordContent& tr, const DNSName& keyname, const string& secret, const string& previous, bool timersonly) { d_trc=tr; @@ -587,14 +631,11 @@ int DNSPacket::parse(const char *mesg, size_t length) try { - d_rawpacket.assign(mesg,length); - d_wrapped=true; - if(length < 12) { - g_log << Logger::Debug << "Ignoring packet: too short from " - << getRemoteString() << endl; + if (reinit(mesg, length) != 0) { return -1; } + d_wrapped=true; MOADNSParser mdp(d_isQuery, d_rawpacket); EDNSOpts edo; @@ -646,7 +687,6 @@ d_ednsRawPacketSizeLimit=-1; } - memcpy((void *)&d,(const void *)d_rawpacket.c_str(),12); qdomain=mdp.d_qname; // if(!qdomain.empty()) // strip dot // boost::erase_tail(qdomain, 1); diff -Nru pdns-4.9.18/pdns/dnspacket.hh pdns-4.9.20/pdns/dnspacket.hh --- pdns-4.9.18/pdns/dnspacket.hh 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnspacket.hh 2026-11-26 08:18:13.000000000 +0000 @@ -58,6 +58,7 @@ int noparse(const char *mesg, size_t len); //!< just suck the data inward int parse(const char *mesg, size_t len); //!< parse a raw UDP or TCP packet and suck the data inward + bool preparePayload(std::string& error, bool throwsOnTruncation=false); const string& getString(bool throwsOnTruncation=false); //!< for serialization - just passes the whole packet. If throwsOnTruncation is set, an exception will be raised if the records are too large to fit inside a single DNS payload, instead of setting the TC bit // address & socket manipulation @@ -105,7 +106,6 @@ void setQuestion(int op, const DNSName &qdomain, int qtype); // wipes 'd', sets a random id, creates start of packet (domain, type, class etc) DTime d_dt; //!< the time this packet was created. replyPacket() copies this in for you, so d_dt becomes the time spent processing the question+answer - void wrapup(bool throwsOnTruncation=false); // writes out queued rrs, and generates the binary packet. also shuffles. also rectifies dnsheader 'd', and copies it to the stringbuffer. If throwsOnTruncation is set, an exception will be raised if the records are too large to fit inside a single DNS payload, instead of setting the TC bit void spoofQuestion(const DNSPacket& qd); //!< paste in the exact right case of the question. Useful for PacketCache unsigned int getMinTTL(); //!< returns lowest TTL of any record in the packet bool isEmpty(); //!< returns true if there are no rrs in the packet @@ -163,6 +163,7 @@ bool getTSIGDetails(TSIGRecordContent* tr, DNSName* keyname, uint16_t* tsigPos=nullptr) const; void setTSIGDetails(const TSIGRecordContent& tr, const DNSName& keyname, const string& secret, const string& previous, bool timersonly=false); + void clearTSIGDetails(); bool getTKEYRecord(TKEYRecordContent* tr, DNSName* keyname) const; vector& getRRS() { return d_rrs; } @@ -179,7 +180,9 @@ #endif private: + int reinit(const char *mesg, size_t len); void pasteQ(const char *question, int length); //!< set the question of this packet, useful for crafting replies + void wrapup(bool throwsOnTruncation=false); // writes out queued rrs, and generates the binary packet. also shuffles. also rectifies dnsheader 'd', and copies it to the stringbuffer. If throwsOnTruncation is set, an exception will be raised if the records are too large to fit inside a single DNS payload, instead of setting the TC bit string d_tsigsecret; DNSName d_tsigkeyname; diff -Nru pdns-4.9.18/pdns/dnsparser.cc pdns-4.9.20/pdns/dnsparser.cc --- pdns-4.9.18/pdns/dnsparser.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnsparser.cc 2026-11-26 08:18:13.000000000 +0000 @@ -529,13 +529,16 @@ return ret; } -string PacketReader::getUnquotedText(bool lenField) +string PacketReader::getUnquotedText(bool lenField, const std::string& validChars) { uint16_t stop_at; - if(lenField) + if (lenField) { stop_at = static_cast(d_content.at(d_pos)) + d_pos + 1; - else + d_pos++; // d_pos now points at the start of the text + } + else { stop_at = d_recordlen; + } /* think unsigned overflow */ if (stop_at < d_pos) { @@ -545,8 +548,10 @@ if(stop_at == d_pos) return ""; - d_pos++; string ret(d_content.substr(d_pos, stop_at-d_pos)); + if (!validChars.empty() && ret.find_first_not_of(validChars) != string::npos) { + throw std::out_of_range("getUnquotedText: invalid character found in record content"); + } d_pos = stop_at; return ret; } diff -Nru pdns-4.9.18/pdns/dnsparser.hh pdns-4.9.20/pdns/dnsparser.hh --- pdns-4.9.18/pdns/dnsparser.hh 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnsparser.hh 2026-11-26 08:18:13.000000000 +0000 @@ -153,8 +153,8 @@ text=getText(multi, lenField); } - void xfrUnquotedText(string &text, bool lenField){ - text=getUnquotedText(lenField); + void xfrUnquotedText(string &text, bool lenField, const std::string& validChars=""){ + text=getUnquotedText(lenField, validChars); } void xfrBlob(string& blob); @@ -169,7 +169,7 @@ DNSName getName(); string getText(bool multi, bool lenField); - string getUnquotedText(bool lenField); + string getUnquotedText(bool lenField, const std::string& validChar); bool eof() { return true; }; diff -Nru pdns-4.9.18/pdns/dnsproxy.cc pdns-4.9.20/pdns/dnsproxy.cc --- pdns-4.9.18/pdns/dnsproxy.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnsproxy.cc 2026-11-26 08:18:13.000000000 +0000 @@ -134,6 +134,17 @@ } } + std::string error; + if (!reply->preparePayload(error)) { + SLOG(g_log << Logger::Error << "Error building packet (" << error << "), returning SERVFAIL" << endl, + d_slog->error(Logr::Error, error, "Error building packet, returning SERVFAIL")); + reply->clearRecords(); + reply->clearTSIGDetails(); + reply->setRcode(RCode::ServFail); + // By clearing the TSIG information, we should be able to build a packet + // without any error now. + } + uint16_t len = htons(reply->getString().length()); string buffer((const char*)&len, 2); buffer.append(reply->getString()); @@ -298,6 +309,18 @@ iter->second.complete->clearRecords(); iter->second.complete->setRcode(RCode::ServFail); } + + std::string error; + if (!iter->second.complete->preparePayload(error)) { + SLOG(g_log << Logger::Error << "Error building packet (" << error << "), returning SERVFAIL" << endl, + d_slog->error(Logr::Error, error, "Error building packet, returning SERVFAIL")); + iter->second.complete->clearRecords(); + iter->second.complete->clearTSIGDetails(); + iter->second.complete->setRcode(RCode::ServFail); + // By clearing the TSIG information, we should be able to build a + // packet without any error now. + } + reply = iter->second.complete->getString(); iov.iov_base = (void*)reply.c_str(); iov.iov_len = reply.length(); diff -Nru pdns-4.9.18/pdns/dnsrecords.cc pdns-4.9.20/pdns/dnsrecords.cc --- pdns-4.9.18/pdns/dnsrecords.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnsrecords.cc 2026-11-26 08:18:13.000000000 +0000 @@ -852,7 +852,12 @@ boilerplate_conv(CAA, conv.xfr8BitInt(d_flags); - conv.xfrUnquotedText(d_tag, true); + // RFC 8659 section 4.1: + // Tags MAY contain ASCII characters "a" through "z", "A" through "Z", and the numbers 0 through 9. + // Tags MUST NOT contain any other characters. + conv.xfrUnquotedText(d_tag, true, "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789"); conv.xfrText(d_value, true, false); /* no lenField */ ) diff -Nru pdns-4.9.18/pdns/dnswriter.cc pdns-4.9.20/pdns/dnswriter.cc --- pdns-4.9.18/pdns/dnswriter.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnswriter.cc 2026-11-26 08:18:13.000000000 +0000 @@ -204,8 +204,9 @@ } } -template void GenericDNSPacketWriter::xfrUnquotedText(const string& text, bool lenField) +template void GenericDNSPacketWriter::xfrUnquotedText(const string& text, bool lenField, const std::string& /* validChars */) { + // We're not checking validChars, we expect that either the RecordTextReader or the PacketReader did this if(text.empty()) { d_content.push_back(0); return; diff -Nru pdns-4.9.18/pdns/dnswriter.hh pdns-4.9.20/pdns/dnswriter.hh --- pdns-4.9.18/pdns/dnswriter.hh 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/dnswriter.hh 2026-11-26 08:18:13.000000000 +0000 @@ -129,7 +129,7 @@ void xfrName(const DNSName& label, bool compress=false, bool noDot=false); void xfrText(const string& text, bool multi=false, bool lenField=true); - void xfrUnquotedText(const string& text, bool lenField); + void xfrUnquotedText(const string& text, bool lenField, const std::string& validChars=""); void xfrBlob(const string& blob, int len=-1); void xfrBlob(const vector& blob); void xfrSvcParamKeyVals(const set& kvs); diff -Nru pdns-4.9.18/pdns/ixfr.cc pdns-4.9.20/pdns/ixfr.cc --- pdns-4.9.18/pdns/ixfr.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/ixfr.cc 2026-11-26 08:18:13.000000000 +0000 @@ -143,7 +143,7 @@ pw.commit(); TSIGRecordContent trc; TSIGTCPVerifier tsigVerifier(tt, primary, trc); - if(!tt.algo.empty()) { + if(!tt.name.empty() && !tt.algo.empty()) { TSIGHashEnum the; getTSIGHashEnum(tt.algo, the); try { @@ -155,7 +155,12 @@ trc.d_fudge = 300; trc.d_origID=ntohs(pw.getHeader()->id); trc.d_eRcode=0; - addTSIG(pw, trc, tt.name, tt.secret, "", false); + try { + addTSIG(pw, trc, tt.name, tt.secret, "", false); + } + catch (const PDNSException& exc) { + throw std::runtime_error(exc.reason); + } } uint16_t len=htons(packet.size()); string msg((const char*)&len, 2); diff -Nru pdns-4.9.18/pdns/ixfrutils.cc pdns-4.9.20/pdns/ixfrutils.cc --- pdns-4.9.18/pdns/ixfrutils.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/ixfrutils.cc 2026-11-26 08:18:13.000000000 +0000 @@ -35,14 +35,19 @@ { vector packet; DNSPacketWriter pw(packet, zone, QType::SOA); - if(!tt.algo.empty()) { + if (!tt.name.empty() && !tt.algo.empty()) { TSIGRecordContent trc; trc.d_algoName = tt.algo; trc.d_time = time(nullptr); trc.d_fudge = 300; trc.d_origID=ntohs(pw.getHeader()->id); trc.d_eRcode=0; - addTSIG(pw, trc, tt.name, tt.secret, "", false); + try { + addTSIG(pw, trc, tt.name, tt.secret, "", false); + } + catch (const PDNSException& exc) { + throw std::runtime_error(exc.reason); + } } Socket s(primary.sin4.sin_family, SOCK_DGRAM); diff -Nru pdns-4.9.18/pdns/misc.hh pdns-4.9.20/pdns/misc.hh --- pdns-4.9.18/pdns/misc.hh 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/misc.hh 2026-11-26 08:18:13.000000000 +0000 @@ -459,9 +459,23 @@ inline bool isCanonical(const string& qname) { - if(qname.empty()) + if (qname.empty()) { return false; - return qname[qname.size()-1]=='.'; + } + auto iter = qname.rbegin(); + if (*iter == '.') { + iter++; + size_t backslashCount = 0; + while (iter != qname.rend()) { + if (*iter != '\\') { + break; + } + backslashCount++; + iter++; + } + return (backslashCount % 2) == 0; + } + return false; } inline DNSName toCanonic(const DNSName& zone, const string& qname) diff -Nru pdns-4.9.18/pdns/qtype.cc pdns-4.9.20/pdns/qtype.cc --- pdns-4.9.18/pdns/qtype.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/qtype.cc 2026-11-26 08:18:13.000000000 +0000 @@ -45,7 +45,6 @@ {"TXT", 16}, {"RP", 17}, {"AFSDB", 18}, - {"SIG", 24}, {"KEY", 25}, {"AAAA", 28}, {"LOC", 29}, @@ -53,7 +52,6 @@ {"NAPTR", 35}, {"KX", 36}, {"CERT", 37}, - {"A6", 38}, {"DNAME", 39}, {"OPT", 41}, {"APL", 42}, @@ -87,13 +85,10 @@ {"TSIG", 250}, {"IXFR", 251}, {"AXFR", 252}, - {"MAILB", 253}, - {"MAILA", 254}, {"ANY", 255}, {"URI", 256}, {"CAA", 257}, {"DLV", 32769}, - {"ADDR", 65400}, #if !defined(RECURSOR) {"ALIAS", 65401}, {"LUA", 65402}, diff -Nru pdns-4.9.18/pdns/rcpgenerator.cc pdns-4.9.20/pdns/rcpgenerator.cc --- pdns-4.9.18/pdns/rcpgenerator.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/rcpgenerator.cc 2026-11-26 08:18:13.000000000 +0000 @@ -637,7 +637,7 @@ } } -void RecordTextReader::xfrUnquotedText(string& val, bool /* lenField */) +void RecordTextReader::xfrUnquotedText(string& val, bool /* lenField */, const std::string& validChars) { val.clear(); val.reserve(d_end - d_pos); @@ -650,6 +650,9 @@ while(++d_pos < d_end && d_string[d_pos] != ' '){ val.append(1, d_string[d_pos]); } + if (!validChars.empty() && val.find_first_not_of(validChars) != string::npos) { + throw RecordTextException("found invalid character in record content '" + d_string + "'"); + } } void RecordTextReader::xfrType(uint16_t& val) @@ -979,10 +982,12 @@ d_string.append(val); } -void RecordTextWriter::xfrUnquotedText(const string& val, bool /* lenField */) +void RecordTextWriter::xfrUnquotedText(const string& val, bool /* lenField */, const std::string& /*validChars*/) { - if(!d_string.empty()) + // We're not checking validChars, we expect that either the RecordTextReader or the PacketReader did this + if(!d_string.empty()) { d_string.append(1,' '); + } d_string.append(val); } diff -Nru pdns-4.9.18/pdns/rcpgenerator.hh pdns-4.9.20/pdns/rcpgenerator.hh --- pdns-4.9.18/pdns/rcpgenerator.hh 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/rcpgenerator.hh 2026-11-26 08:18:13.000000000 +0000 @@ -57,7 +57,7 @@ void xfrName(DNSName& val, bool compress=false, bool noDot=false); void xfrText(string& val, bool multi=false, bool lenField=true); - void xfrUnquotedText(string& val, bool lenField=true); + void xfrUnquotedText(string& val, bool lenField=true, const std::string& validChars=""); void xfrHexBlob(string& val, bool keepReading=false); void xfrBase32HexBlob(string& val); @@ -101,7 +101,7 @@ void xfrType(const uint16_t& val); void xfrName(const DNSName& val, bool compress=false, bool noDot=false); void xfrText(const string& val, bool multi=false, bool lenField=true); - void xfrUnquotedText(const string& val, bool lenField=true); + void xfrUnquotedText(const string& val, bool lenField=true, const std::string& validChars=""); void xfrBlobNoSpaces(const string& val, int len=-1); void xfrBlob(const string& val, int len=-1); void xfrHexBlob(const string& val, bool keepReading=false); diff -Nru pdns-4.9.18/pdns/resolver.cc pdns-4.9.20/pdns/resolver.cc --- pdns-4.9.18/pdns/resolver.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/resolver.cc 2026-11-26 08:18:13.000000000 +0000 @@ -152,7 +152,12 @@ trc.d_fudge = 300; trc.d_origID=ntohs(randomid); trc.d_eRcode=0; - addTSIG(pw, trc, tsigkeyname, tsigsecret, "", false); + try { + addTSIG(pw, trc, tsigkeyname, tsigsecret, "", false); + } + catch (const PDNSException& exc) { + throw ResolverException(exc.reason); + } } int sock; diff -Nru pdns-4.9.18/pdns/rfc2136handler.cc pdns-4.9.20/pdns/rfc2136handler.cc --- pdns-4.9.18/pdns/rfc2136handler.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/rfc2136handler.cc 2026-11-26 08:18:13.000000000 +0000 @@ -590,8 +590,13 @@ DNSPacket l_forwardPacket(p); l_forwardPacket.setID(dns_random_uint16()); l_forwardPacket.setRemote(&remote); - uint16_t len=htons(l_forwardPacket.getString().length()); - buffer.assign((const char*)&len, 2); + std::string error; + if (!l_forwardPacket.preparePayload(error)) { + g_log << Logger::Error << msgPrefix << "Unable to forward update message to " << remote.toStringWithPort() << ", error:" << error << endl; + continue; + } + uint16_t len = htons(l_forwardPacket.getString().length()); + buffer.assign((const char*)&len, 2); // NOLINT(cppcoreguidelines-pro-type-cstyle-cast): less ugly than a reinterpret_cast which would require a linter annotation anyway buffer.append(l_forwardPacket.getString()); if(write(sock, buffer.c_str(), buffer.length()) < 0) { g_log<id = dns_random_uint16(); - if (tsig) { + if (tsig && !tsig_key.empty()) { TSIGRecordContent trc; trc.d_algoName = getTSIGAlgoName(tsig_algo); trc.d_time = time((time_t*)NULL); trc.d_fudge = 300; trc.d_origID=ntohs(pw.getHeader()->id); trc.d_eRcode=0; + // may throw PDNSException if signing fails addTSIG(pw, trc, tsig_key, tsig_secret, "", false); } diff -Nru pdns-4.9.18/pdns/test-dnsparser_cc.cc pdns-4.9.20/pdns/test-dnsparser_cc.cc --- pdns-4.9.18/pdns/test-dnsparser_cc.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/test-dnsparser_cc.cc 2026-11-26 08:18:13.000000000 +0000 @@ -730,4 +730,29 @@ BOOST_CHECK_THROW(MOADNSParser(false, packet.data(), packet.size(), 22U), MOADNSException); } +BOOST_AUTO_TEST_CASE(test_xfrUnquotedText) +{ + std::vector> tests = { + // {input, value after reader, validChars, lengthfield, throws} + {"aString", "aString", "", false, false}, + {"validstring", "validstring", "validstrng", false, false}, + {"notvalidstring", "", "validstrng", false, true}, // "o" is not the list of valid chars + {"with\r\nnewlines", "", "withnewlnes", false, true}, // Invalid characters + {"\x0Awithlength", "withlength", "", true, false}, + {"\x0Bwithlength", "", "", true, true}, // length is too long by 1 + }; + + for (auto& [source, expectedAfterReader, validChars, lengthField, throws] : tests) { + PacketReader pr(source, 0); + string recordValue; + if (throws) { + BOOST_CHECK_THROW(pr.xfrUnquotedText(recordValue, lengthField, validChars), std::exception); + return; + } else { + BOOST_CHECK_NO_THROW(pr.xfrUnquotedText(recordValue, lengthField, validChars)); + } + BOOST_CHECK_EQUAL(recordValue, expectedAfterReader); + } +} + BOOST_AUTO_TEST_SUITE_END() diff -Nru pdns-4.9.18/pdns/test-dnsrecords_cc.cc pdns-4.9.20/pdns/test-dnsrecords_cc.cc --- pdns-4.9.18/pdns/test-dnsrecords_cc.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/test-dnsrecords_cc.cc 2026-11-26 08:18:13.000000000 +0000 @@ -381,6 +381,8 @@ // non-local overly large name (256), must be broken (ZONE_CASE(QType::CNAME, "123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.12345678901234567890123456789012345678901234567890123456789012.")) (ZONE_CASE(QType::SOA, "ns.rec.test hostmaster.test.rec 20130512010 3600 3600 604800 120")) // too long serial + (ZONE_CASE(QType::CAA, "256 issue example.com")) // flags is > 255 + (ZONE_CASE(QType::CAA, "0 issue_ example.com")) // tag contains forbidden character ; int n=0; diff -Nru pdns-4.9.18/pdns/test-misc_hh.cc pdns-4.9.20/pdns/test-misc_hh.cc --- pdns-4.9.18/pdns/test-misc_hh.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/test-misc_hh.cc 2026-11-26 08:18:13.000000000 +0000 @@ -419,4 +419,18 @@ BOOST_CHECK_EQUAL(cleanSlashesWrapper("test///"), "test/"); } +BOOST_AUTO_TEST_CASE(test_isCanonical) +{ + BOOST_CHECK(isCanonical("example.com.")); + BOOST_CHECK(isCanonical("com.")); + BOOST_CHECK(isCanonical("com\\\\.")); + BOOST_CHECK(isCanonical("\\\\.")); + BOOST_CHECK(isCanonical("example\\.com.")); + + BOOST_CHECK(!isCanonical("com")); + BOOST_CHECK(!isCanonical("com\\.")); + BOOST_CHECK(!isCanonical("\\.")); + BOOST_CHECK(!isCanonical("\\\\\\.")); +} + BOOST_AUTO_TEST_SUITE_END() diff -Nru pdns-4.9.18/pdns/test-rcpgenerator_cc.cc pdns-4.9.20/pdns/test-rcpgenerator_cc.cc --- pdns-4.9.18/pdns/test-rcpgenerator_cc.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/test-rcpgenerator_cc.cc 2026-11-26 08:18:13.000000000 +0000 @@ -7,10 +7,11 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif + +#include #include #include "rcpgenerator.hh" #include "misc.hh" -#include using std::string; @@ -541,4 +542,31 @@ BOOST_CHECK_EQUAL(source, target); } +BOOST_AUTO_TEST_CASE(test_xfrUnquotedText) +{ + std::vector> tests = { + // {input, value after reader, value after writer, validChars, throws} + {"aString", "aString", "aString", "", false}, + {"validstring", "validstring", "validstring", "validstrng", false}, + {"notvalidstring", "", "", "validstrng", true}, // "o" is not the list of valid chars + }; + + for (auto& [source, expectedAfterReader, expectedAfterWriter, validChars, throws] : tests) { + RecordTextReader rtr(source); + string recordValue; + if (throws) { + BOOST_CHECK_THROW(rtr.xfrUnquotedText(recordValue, false, validChars), std::exception); + continue; + } else { + BOOST_CHECK_NO_THROW(rtr.xfrUnquotedText(recordValue, false, validChars)); + } + BOOST_CHECK_EQUAL(recordValue, expectedAfterReader); + + string target; + RecordTextWriter rtw(target); + rtw.xfrUnquotedText(recordValue); + BOOST_CHECK_EQUAL(target, expectedAfterWriter); + } +} + BOOST_AUTO_TEST_SUITE_END() diff -Nru pdns-4.9.18/pdns/tkey.cc pdns-4.9.20/pdns/tkey.cc --- pdns-4.9.18/pdns/tkey.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/tkey.cc 2026-11-26 08:18:13.000000000 +0000 @@ -58,7 +58,7 @@ tkey_out->d_error = 19; } else { - sign = true; + sign = ctx.valid(); } } } else { @@ -127,6 +127,9 @@ // this should cause it to lookup name context r->setTSIGDetails(trc, name, name.toStringNoDot(), "", false); } + else { + r->clearTSIGDetails(); + } #endif r->commitD(); diff -Nru pdns-4.9.18/pdns/ws-auth.cc pdns-4.9.20/pdns/ws-auth.cc --- pdns-4.9.18/pdns/ws-auth.cc 2026-10-07 06:09:31.000000000 +0000 +++ pdns-4.9.20/pdns/ws-auth.cc 2026-11-26 08:18:13.000000000 +0000 @@ -966,16 +966,24 @@ } } - if (!document["master_tsig_key_ids"].is_null()) { + const auto& master_tsig = document["master_tsig_key_ids"]; + if (!master_tsig.is_null()) { + if (!master_tsig.is_array()) { + throw ApiException("master_tsig_key_ids is not an array"); + } vector metadata; - extractJsonTSIGKeyIds(backend, document["master_tsig_key_ids"], metadata); + extractJsonTSIGKeyIds(backend, master_tsig, metadata); if (!domainInfo.backend->setDomainMetadata(zonename, "TSIG-ALLOW-AXFR", metadata)) { throw HttpInternalServerErrorException("Unable to set new TSIG primary keys for zone '" + zonename.toLogString() + "'"); } } - if (!document["slave_tsig_key_ids"].is_null()) { + const auto& slave_tsig = document["slave_tsig_key_ids"]; + if (!slave_tsig.is_null()) { + if (!slave_tsig.is_array()) { + throw ApiException("slave_tsig_key_ids is not an array"); + } vector metadata; - extractJsonTSIGKeyIds(backend, document["slave_tsig_key_ids"], metadata); + extractJsonTSIGKeyIds(backend, slave_tsig, metadata); if (!domainInfo.backend->setDomainMetadata(zonename, "AXFR-MASTER-TSIG", metadata)) { throw HttpInternalServerErrorException("Unable to set new TSIG secondary keys for zone '" + zonename.toLogString() + "'"); }