Skip to content

dns: rebuild compression pointers when repacking decoded records - #694

Open
omrzk wants to merge 1 commit into
kbandla:masterfrom
omrzk:fix/dns-repack-compressed-rdata
Open

omrzk wants to merge 1 commit into
kbandla:masterfrom
omrzk:fix/dns-repack-compressed-rdata

Conversation

@omrzk

@omrzk omrzk commented Oct 27, 2026

Copy link
Copy Markdown

Decoded resource records keep their original wire RDATA. Reusing it while packing a new message leaves compressed names pointing at old offsets. A four-answer reply reproduces an Invalid label length error after an unchanged decode/encode cycle; inserting a question can instead silently change mail.google.com to mail.google.example.net.

Rebuild decoded NS/CNAME/PTR/SOA/MX data against the current compression table. Keep caller-supplied raw RDATA and explicit overrides on decoded records. MX repacking accepts the existing tuple-valued decoded preference without changing that API.

Fixes #443.

Validation on Linux/Python 3.12: regressions reproduce the old behavior; python -m pytest dpkt --cov=dpkt -q passes all 456 tests (99% coverage). The workflow's blocking flake8 selection and git diff --check pass. Tests cover unchanged multi-answer round trips, relocated records, all five name-bearing types, and raw-data compatibility. Packet fixtures only; no live DNS deployment was tested.

This branch has not been deployed

No deployments
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.

dns resource record pack not working in certain cases

1 participant