Skip to content

Commit

Permalink
Avoid LabelIsNotAscii spam when used with mdns
Browse files Browse the repository at this point in the history
Make the data integrity check how the data is interpreted;
the check is for ascii only, but we can deal with UTF8,
so relax a little and allow that.

refs: dylanmckay/mdns#13
  • Loading branch information
wez authored and jxs committed Nov 9, 2022
1 parent 1912667 commit d080e1d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ quick_error! {
display("class {} is invalid", code)
}
/// Invalid characters encountered while reading label
LabelIsNotAscii {
LabelIsNotUtf8 {
description("invalid characters encountered while reading label")
}
/// Invalid characters encountered while reading TXT
Expand Down
4 changes: 2 additions & 2 deletions src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ impl<'a> Name<'a> {
if parse_data.len() < end {
return Err(Error::UnexpectedEOF);
}
if !parse_data[pos+1..end].is_ascii() {
return Err(Error::LabelIsNotAscii);
if from_utf8(&parse_data[pos+1..end]).is_err() {
return Err(Error::LabelIsNotUtf8);
}
pos = end;
if parse_data.len() <= pos {
Expand Down

0 comments on commit d080e1d

Please sign in to comment.