Skip to content

Commit

Permalink
Reject infinitely-sized reads from io::Repeat
Browse files Browse the repository at this point in the history
Related to rust-lang#117925
  • Loading branch information
kornelski committed Jan 27, 2024
1 parent 6b4f1c5 commit 2251e9a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions library/std/src/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ impl Read for Repeat {
Ok(())
}

/// This function is not supported by `io::Repeat`, because there's no end of its data
fn read_to_end(&mut self, _: &mut Vec<u8>) -> io::Result<usize> {
Err(io::Error::from(io::ErrorKind::OutOfMemory))
}

/// This function is not supported by `io::Repeat`, because there's no end of its data
fn read_to_string(&mut self, _: &mut String) -> io::Result<usize> {
Err(io::Error::from(io::ErrorKind::OutOfMemory))
}

#[inline]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
let mut nwritten = 0;
Expand Down

0 comments on commit 2251e9a

Please sign in to comment.