fix: escape dots and special characters in DNS label text representation #36
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
Reported by fanf2 on HN:
read_qnamepushes raw bytes from wire format labels without escaping special characters. A label containing a dot (byte0x2E) produces ambiguous text output.Example: Wire format
[8]exa.mple[3]com[0](two labels) → currently outputsexa.mple.com(looks like three labels). Should outputexa\.mple.com.Root cause
src/buffer.rsline 123-125:Raw bytes pushed directly without escaping.
Fix needed
read_qname— escape per RFC 1035 §5.1:\.\\\DDD(3-digit decimal)write_qname— parse escaped characters when splitting labels:\.(escaped dot)\\and\DDDsequencesImpact
Low in practice — real-world domains don't contain dots in labels. But it's a correctness issue that could cause wire format round-trip failures with adversarial input.
Credit: fanf2 (HN)