rust-lang / ferris-says

A Rust flavored implementation of `cowsay`
https://crates.io/crates/ferris-says
Apache License 2.0
194 stars 34 forks source link

Fix unsoundness on invalid utf-8 inputs #21

Closed lf- closed 3 years ago

lf- commented 3 years ago

Previously, unchecked user input bytes were passed into str::from_utf8_unchecked, which was unsound as it was within a safe function. It's been revised to check the user input and fail if there's invalid input.

For a file with fun contents of broken UTF-8 to test with, see https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt

mgattozzi commented 3 years ago

Thanks! Must of missed it when reviewing other's prs