diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-01-30 11:19:12 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-30 11:19:12 +0100 |
| commit | 5db58538cf0e525b747adf0273ebf0d2ee3efb15 (patch) | |
| tree | f5c23d005739dbdecb79a6d04ddfe0d5c3204492 | |
| parent | 2baa994ec4244ac38b7e089d7fcbf926af06a61e (diff) | |
| parent | 2251e9abee68f1f8ad7b80938b2e36a96f7768c1 (diff) | |
| download | rust-5db58538cf0e525b747adf0273ebf0d2ee3efb15.tar.gz rust-5db58538cf0e525b747adf0273ebf0d2ee3efb15.zip | |
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
| -rw-r--r-- | library/std/src/io/util.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index 6bc8f181c90..a04bc481146 100644 --- a/library/std/src/io/util.rs +++ b/library/std/src/io/util.rs @@ -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; |
