Skip to content

reject out-of-range \DDD escapes in name text parsing - #1308

Merged
rthalley merged 1 commit into
rthalley:mainfrom
Nashit-h:name-escape-octet-range
Sep 30, 2026
Merged

rthalley merged 1 commit into
rthalley:mainfrom
Nashit-h:name-escape-octet-range

Conversation

@Nashit-h

Copy link
Copy Markdown
Contributor

\DDD denotes a single octet (RFC 1035 5.1), but the two name-text decoders disagree on out-of-range values.

  1. from_unicode() builds the escape as a code point with chr(total) and never bounds total, so \256 through \999 are accepted and IDNA-encoded instead of rejected.
  2. from_text() (the all-ASCII path) does reject them, but via a raw struct.error out of struct.pack("!B", total) rather than a DNSException.

Both now raise BadEscape once the three digits exceed 255, matching the tokenizer and SVCB _unescape decoders that already cap at a single octet. Added a regression test covering both entry points.

@rthalley
rthalley merged commit 8d480e5 into rthalley:main Sep 30, 2026
@rthalley

Copy link
Copy Markdown
Owner

Thanks!

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.

2 participants