Fix double escaping of non-printable bytes in SVCB string-list values#1280
Open
gaoflow wants to merge 1 commit into
Open
Fix double escaping of non-printable bytes in SVCB string-list values#1280gaoflow wants to merge 1 commit into
gaoflow wants to merge 1 commit into
Conversation
The list-level _escapify escaped non-printable bytes into \ddd, and
dns.rdata._escapify() then escaped that backslash, emitting \ddd,
which parses back as the literal characters 'ddd'. Make the inner
escape purely list-level (',' and '\') and let dns.rdata._escapify()
apply the character-string escaping once.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_StringList.to_text()(used by thealpnanddocpathSvcParams) applies the two SVCB escaping levels in the wrong order for bytes outside 0x20-0x7e: the list-level escape renders 0x00 as\000, anddns.rdata._escapify()then escapes that backslash, emitting\\000. The parser composes the levels correctly per RFC 9460 appendix A.1 (_unescapedecodes\ddd, then_splithandles\,and\\), so it reads\\000back as the three literal characters000— a record's ownto_text()output re-parses to a different value. ALPN ids are opaque bytes on the wire, so a record received from the wire and dumped to a zone file can silently change value when reloaded:The fix makes the inner escape purely list-level (
\and,, operating on bytes) and leaves all character-string escaping to the single outerdns.rdata._escapify(). Comma/backslash escaping in printable ids is emitted exactly as before; non-printables now come out as\dddand a quote byte as\", both of which the existing parser already accepts.test_misc_escapepinned the old\\010\\010output; updated it to the round-trippable form plus an assertion that the expected text parses back equal.