From 2251e9abee68f1f8ad7b80938b2e36a96f7768c1 Mon Sep 17 00:00:00 2001 From: Kornel Date: Mon, 15 Jan 2024 11:28:13 +0000 Subject: [PATCH] Reject infinitely-sized reads from io::Repeat Related to #117925 --- library/std/src/io/util.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/std/src/io/util.rs b/library/std/src/io/util.rs index 6bc8f181c905f..a04bc4811460b 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) -> io::Result { + 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 { + Err(io::Error::from(io::ErrorKind::OutOfMemory)) + } + #[inline] fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result { let mut nwritten = 0;