Skip to content

Commit 9763e0c

Browse files
authored
Rollup merge of #72888 - poliorcetics:improve-read_line-read_until-doc, r=Dylan-DPC
Add a warning about infinite reading in read_(until|line) Fix for #48788. This PR adds a warning to [`BufRead::read_line`](https://doc.rust-lang.org/stable/std/io/trait.BufRead.html#method.read_line) and [`BufRead::read_until`](https://doc.rust-lang.org/stable/std/io/trait.BufRead.html#method.read_until) about the possibility of an attack using the behaviour of these functions. I did not mention a possible fix (using [`Read::take`](https://doc.rust-lang.org/stable/std/io/trait.Read.html#method.take), should I ?
2 parents 466d3e7 + d8cc2c1 commit 9763e0c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libstd/io/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1883,6 +1883,10 @@ pub trait BufRead: Read {
18831883
///
18841884
/// If successful, this function will return the total number of bytes read.
18851885
///
1886+
/// This function is blocking and should be used carefully: it is possible for
1887+
/// an attacker to continuously send bytes without ever sending the delimiter
1888+
/// or EOF.
1889+
///
18861890
/// # Errors
18871891
///
18881892
/// This function will ignore all instances of [`ErrorKind::Interrupted`] and
@@ -1945,6 +1949,10 @@ pub trait BufRead: Read {
19451949
///
19461950
/// If this function returns `Ok(0)`, the stream has reached EOF.
19471951
///
1952+
/// This function is blocking and should be used carefully: it is possible for
1953+
/// an attacker to continuously send bytes without ever sending a newline
1954+
/// or EOF.
1955+
///
19481956
/// # Errors
19491957
///
19501958
/// This function has the same error semantics as [`read_until`] and will

0 commit comments

Comments
 (0)