Skip to content

Commit 1cd0303

Browse files
committed
Auto merge of rust-lang#81151 - Mark-Simulacrum:beta-next, r=Mark-Simulacrum
[beta] backports This backports: * Update RLS and Rustfmt rust-lang#81027 * bump rustfmt to v1.4.32 rust-lang#81093 * Fix handling of malicious Readers in read_to_end rust-lang#80895 * Fix broken ./x.py install rust-lang#80514 * Fix x.py install not working with relative prefix rust-lang#80797 * [security] Update mdbook rust-lang#80688 * rustdoc: Render visibilities succinctly rust-lang#80368 r? `@ghost`
2 parents 33b84bb + d239ea6 commit 1cd0303

File tree

14 files changed

+301
-304
lines changed

14 files changed

+301
-304
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1973,9 +1973,9 @@ dependencies = [
19731973

19741974
[[package]]
19751975
name = "mdbook"
1976-
version = "0.4.3"
1976+
version = "0.4.5"
19771977
source = "registry+https://github.com/rust-lang/crates.io-index"
1978-
checksum = "29be448fcafb00c5a8966c4020c2a5ffbbc333e5b96d0bb5ef54b5bd0524d9ff"
1978+
checksum = "21251d3eb9ca5e8ac5b73384ddaa483a9bbc7d7dcd656b1fa8f266634810334a"
19791979
dependencies = [
19801980
"ammonia",
19811981
"anyhow",

library/std/src/io/mod.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,6 @@ where
367367
{
368368
let start_len = buf.len();
369369
let mut g = Guard { len: buf.len(), buf };
370-
let ret;
371370
loop {
372371
if g.len == g.buf.len() {
373372
unsafe {
@@ -386,21 +385,20 @@ where
386385
}
387386
}
388387

389-
match r.read(&mut g.buf[g.len..]) {
390-
Ok(0) => {
391-
ret = Ok(g.len - start_len);
392-
break;
388+
let buf = &mut g.buf[g.len..];
389+
match r.read(buf) {
390+
Ok(0) => return Ok(g.len - start_len),
391+
Ok(n) => {
392+
// We can't allow bogus values from read. If it is too large, the returned vec could have its length
393+
// set past its capacity, or if it overflows the vec could be shortened which could create an invalid
394+
// string if this is called via read_to_string.
395+
assert!(n <= buf.len());
396+
g.len += n;
393397
}
394-
Ok(n) => g.len += n,
395398
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
396-
Err(e) => {
397-
ret = Err(e);
398-
break;
399-
}
399+
Err(e) => return Err(e),
400400
}
401401
}
402-
403-
ret
404402
}
405403

406404
pub(crate) fn default_read_vectored<F>(read: F, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>

0 commit comments

Comments
 (0)