Skip to content

Reject empty TXT records in Txt::parse - #709

Open
SebastiaanYN wants to merge 1 commit into
NLnetLabs:mainfrom
SebastiaanYN:txt-parse
Open

Reject empty TXT records in Txt::parse#709
SebastiaanYN wants to merge 1 commit into
NLnetLabs:mainfrom
SebastiaanYN:txt-parse

Conversation

@SebastiaanYN

Copy link
Copy Markdown
Contributor

Txt::parse allows empty TXT records, which breaks the assumption in as_flat_slice that there's always at least one character.

Replace the manual CharStr::skip loop with a single check_slice call so all construction paths share the same validation.

The zero-length unknown-rdata test now uses TYPE65534 instead of TXT since zero-length TXT is correctly invalid.

RFC 1035 section 3.3.14 requires "one or more" character strings, so
rdlength=0 is invalid. `check_slice` (used by `from_octets` /
`from_slice`) already enforced this; `parse` did not, allowing
construction of a `Txt` that panics in `as_flat_slice`.

Replace the manual `CharStr::skip` loop with a single `check_slice`
call so all construction paths share the same validation.

The zero-length unknown-rdata test now uses TYPE65534 instead of TXT
since zero-length TXT is correctly invalid.
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.

1 participant