You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an unsoundness issue with multibyte sequences.
When I give a valid UTF8 string "ö\x1b😀" as input to crates/anstream/src/adapter/strip.rs the code will be confused.
The UTF8 bytes are \xc3\xb6 then \x1b then \xf0\x9f\x98\x80.
When we loop over "non-printable bytes" \x1b\xf0 will be considered as some non-printable sequence...
I do not know whether it is a valid escape sequence or not, but it does not matter: we will produce a broken str from the incorrectly segmented bytes via str::from_utf8_unchecked, and that should never happen.
I have a tentative fix that makes the code sound, which I will reference after filing the issue (so I can reference the issue in the PR).
Full credit goes to @Ralith who reviewed this code and asked me to follow up.
The text was updated successfully, but these errors were encountered:
This fixes a soundness issue where we create invalid UTF-8 data and then
do a `str::from_unchecked` on release builds.
This ensures we ignore up-to the start of UTF-8 sequences and not
mid-way through.
Fixesrust-cli#156
There is an unsoundness issue with multibyte sequences.
When I give a valid UTF8 string "ö\x1b😀" as input to
crates/anstream/src/adapter/strip.rs
the code will be confused.The UTF8 bytes are
\xc3\xb6
then\x1b
then\xf0\x9f\x98\x80
.When we loop over "non-printable bytes" \x1b\xf0 will be considered as some non-printable sequence...
I do not know whether it is a valid escape sequence or not, but it does not matter: we will produce a broken str from the incorrectly segmented bytes via
str::from_utf8_unchecked
, and that should never happen.I have a tentative fix that makes the code sound, which I will reference after filing the issue (so I can reference the issue in the PR).
Full credit goes to @Ralith who reviewed this code and asked me to follow up.
The text was updated successfully, but these errors were encountered: