Skip to content

Commit

Permalink
Fix infinite loop caused by invalid UTF-8 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
newca12 authored and taiki-e committed Oct 26, 2023
1 parent 8570ea6 commit 2f2ec39
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions futures-util/src/io/read_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub(super) fn read_line_internal<R: AsyncBufRead + ?Sized>(
) -> Poll<io::Result<usize>> {
let ret = ready!(read_until_internal(reader, cx, b'\n', bytes, read));
if str::from_utf8(bytes).is_err() {
bytes.clear();
Poll::Ready(ret.and_then(|_| {
Err(io::Error::new(io::ErrorKind::InvalidData, "stream did not contain valid UTF-8"))
}))
Expand Down

0 comments on commit 2f2ec39

Please sign in to comment.