Skip to content

Commit 2251e9a

Browse files
committed
Reject infinitely-sized reads from io::Repeat
Related to #117925
1 parent 6b4f1c5 commit 2251e9a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/std/src/io/util.rs

+10
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,16 @@ impl Read for Repeat {
204204
Ok(())
205205
}
206206

207+
/// This function is not supported by `io::Repeat`, because there's no end of its data
208+
fn read_to_end(&mut self, _: &mut Vec<u8>) -> io::Result<usize> {
209+
Err(io::Error::from(io::ErrorKind::OutOfMemory))
210+
}
211+
212+
/// This function is not supported by `io::Repeat`, because there's no end of its data
213+
fn read_to_string(&mut self, _: &mut String) -> io::Result<usize> {
214+
Err(io::Error::from(io::ErrorKind::OutOfMemory))
215+
}
216+
207217
#[inline]
208218
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
209219
let mut nwritten = 0;

0 commit comments

Comments
 (0)