bind9/bin/dig
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
..
.gitignore [master] update gitignore files; use rev-parse to get srcid 2014-06-17 13:49:30 -07:00
dig.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
dig.rst Add examples to the dig man page 2026-02-22 11:03:10 -05:00
dighost.c Process dig -x reverse octets iteratively 2026-04-30 14:02:02 +02:00
dighost.h Add +[no]showtruncated to dig 2025-12-02 09:34:13 +11:00
host.c switch to RETERR where it wasn't being used 2025-12-03 13:45:43 -08:00
host.rst Do HTTPS record query from host in addition 2025-02-18 14:56:08 +00:00
meson.build replace the build system with meson 2025-06-11 10:30:12 +03:00
nslookup.c add dns_message API to add EDNS options 2025-11-21 11:13:18 -08:00
nslookup.rst Add internal hyperlinks to See Also section of manual pages 2022-03-14 10:46:36 +01:00