mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
io: fix unsoundness in read_to_end (#3428)
This commit is contained in:
parent
2330edc875
commit
ad8fb41103
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -1,8 +1,8 @@
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
branches: ["master", "tokio-*.x"]
|
||||
pull_request:
|
||||
branches: ["master"]
|
||||
branches: ["master", "tokio-*.x"]
|
||||
|
||||
name: CI
|
||||
|
||||
|
@ -72,14 +72,13 @@ fn poll_read_to_end<R: AsyncRead + ?Sized>(
|
||||
|
||||
let mut unused_capacity = ReadBuf::uninit(get_unused_capacity(buf));
|
||||
|
||||
let ptr = unused_capacity.filled().as_ptr();
|
||||
ready!(read.poll_read(cx, &mut unused_capacity))?;
|
||||
assert_eq!(ptr, unused_capacity.filled().as_ptr());
|
||||
|
||||
let n = unused_capacity.filled().len();
|
||||
let new_len = buf.len() + n;
|
||||
|
||||
// This should no longer even be possible in safe Rust. An implementor
|
||||
// would need to have unsafely *replaced* the buffer inside `ReadBuf`,
|
||||
// which... yolo?
|
||||
assert!(new_len <= buf.capacity());
|
||||
unsafe {
|
||||
buf.set_len(new_len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user