bind9/bin/tests/system/digdelv
Ondřej Surý f1ec5e1809 Process dig -x reverse octets iteratively
reverse_octets() recursed once per dot, with depth bounded only by
ARG_MAX (~2 MiB on Linux), so feeding dig -x a deep input like
'1.1.1.…1' busted the call stack and crashed the tool with SIGSEGV
instead of a structured error.  The transformation it performs is
purely textual (split on '.', emit components in reverse), so the
recursion was never load-bearing.

Walk the input once into a fixed-size array of label slices, capped at
DNS_NAME_MAXLABELS (which is the most we could ever fit into the
result buffer anyway), then iterate the array in reverse to write the
output.  Inputs with more than DNS_NAME_MAXLABELS labels now return
DNS_R_NAMETOOLONG, which dig.c surfaces as 'Invalid IP address' and
exit 1.  Drop the unnecessary (int) casts on ptrdiff_t/size_t lengths
while at it.

Assisted-by: Claude:claude-opus-4-7
2026-04-30 14:02:02 +02:00
..
ans4 Automatically sort imports in Python code 2026-02-20 15:17:32 +01:00
ans5 Replace deprecated typing imports 2026-02-20 15:17:32 +01:00
ans6 Replace deprecated typing imports 2026-02-20 15:17:32 +01:00
ans7 Replace deprecated typing imports 2026-02-20 15:17:32 +01:00
ns1 Remove license headers from test zone files 2026-03-31 17:57:58 +02:00
ns2 Remove license headers from test zone files 2026-03-31 17:57:58 +02:00
ns3 Remove license headers from named.conf test files 2026-03-31 17:57:58 +02:00
prereq.sh Remove obsolete dnspython prerequisite checks 2025-11-28 11:24:11 +01:00
root.hint Remove licensing header check for root.hint[s] 2026-04-28 15:37:10 +01:00
setup.sh Replace .in with .j2 templates for simple copy_setports cases 2025-12-09 14:23:14 +01:00
tests.sh Process dig -x reverse octets iteratively 2026-04-30 14:02:02 +02:00
tests_sh_digdelv.py Remove compatibility hacks for dnspython<2.7.0 2026-01-21 16:07:31 +01:00
yamlget.py Remove superfluous 'pylint: disable' directives 2026-02-20 15:17:32 +01:00