Skip to content

Commit 5db5853

Browse files
Rollup merge of #119991 - kornelski:endless-read, r=the8472
Reject infinitely-sized reads from io::Repeat These calls would always run out of memory. Related to #117925
2 parents 2baa994 + 2251e9a commit 5db5853

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: 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)