Skip to content

Commit dbe8c46

Browse files
authored
Unrolled build for rust-lang#119991
Rollup merge of rust-lang#119991 - kornelski:endless-read, r=the8472 Reject infinitely-sized reads from io::Repeat These calls would always run out of memory. Related to rust-lang#117925
2 parents c401f09 + 2251e9a commit dbe8c46

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)