Skip to content

fix: prevent TXT corruption and encode IPv4-mapped AAAA/ECS correctly - #135

Merged
lsongdev merged 2 commits into
masterfrom
fix/issue-134-txt-ipv6-rdata
Nov 16, 2026
Merged

lsongdev merged 2 commits into
masterfrom
fix/issue-134-txt-ipv6-rdata

Conversation

@lsongdev

Copy link
Copy Markdown
Owner

Fixes #134

Root cause

  • TXT/SPF wrote a one-octet character-string length even when its UTF-8 payload exceeded 255 bytes, silently truncating the prefix and corrupting record boundaries.
  • AAAA and EDNS ECS treated an IPv4 dotted-quad tail as one hexadecimal IPv6 group (instead of two 16-bit groups), producing incorrect or truncated RDATA.

Changes

  • Split long TXT/SPF entries into valid <=255-octet wire character-strings, avoiding UTF-8 continuation boundaries while preserving explicitly supplied string boundaries.
  • Expand a mixed-notation IPv4 tail into two 16-bit IPv6 groups in fromIPv6 and reuse it for ECS.
  • Reject RDATA larger than the 16-bit RDLENGTH field rather than encoding a wrapped length.
  • Add regression tests for length boundaries, UTF-8 and explicit multi-string TXT/SPF, subsequent records, compressed/uncompressed mapped AAAA, and full/truncated ECS addresses.

Verification

  • Targeted IPv6 and UTF-8 chunking checks passed locally.
  • Full Node.js test workflow will run on this PR.

@lsongdev
lsongdev merged commit 67b2f1e into master Nov 16, 2026
6 checks passed
@lsongdev
lsongdev deleted the fix/issue-134-txt-ipv6-rdata branch November 16, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Packet.toBuffer() corrupts TXT strings over 255 bytes and mis-encodes IPv4-mapped AAAA addresses

1 participant