diff options
author | Jesse Luehrs <doy@tozt.net> | 2022-02-25 20:16:42 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2022-02-25 20:16:42 -0500 |
commit | f0710ededc80610fdaff3209f8b94fa0d7bb78ce (patch) | |
tree | 669db33fe8e316502dcad0486614a3f850f55757 /src | |
parent | aca49b2f55df04142d4b2fcfcb361361e76d0820 (diff) | |
download | pty-process-f0710ededc80610fdaff3209f8b94fa0d7bb78ce.tar.gz pty-process-f0710ededc80610fdaff3209f8b94fa0d7bb78ce.zip |
ensure read_buf doesn't overflow the buffer
Diffstat (limited to 'src')
-rw-r--r-- | src/pty.rs | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -76,7 +76,7 @@ impl tokio::io::AsyncRead for Pty { std::task::Poll::Ready(guard) => guard, std::task::Poll::Pending => return std::task::Poll::Pending, }?; - let mut b = [0u8; 4096]; + let mut b = vec![0u8; buf.capacity()]; match guard.try_io(|inner| (&inner.get_ref().0).read(&mut b)) { Ok(Ok(bytes)) => { // XXX this is safe, but not particularly efficient @@ -154,7 +154,7 @@ impl<'a> tokio::io::AsyncRead for ReadPty<'a> { std::task::Poll::Ready(guard) => guard, std::task::Poll::Pending => return std::task::Poll::Pending, }?; - let mut b = [0u8; 4096]; + let mut b = vec![0u8; buf.capacity()]; match guard.try_io(|inner| (&inner.get_ref().0).read(&mut b)) { Ok(Ok(bytes)) => { // XXX this is safe, but not particularly efficient @@ -267,7 +267,7 @@ impl tokio::io::AsyncRead for OwnedReadPty { std::task::Poll::Ready(guard) => guard, std::task::Poll::Pending => return std::task::Poll::Pending, }?; - let mut b = [0u8; 4096]; + let mut b = vec![0u8; buf.capacity()]; match guard.try_io(|inner| (&inner.get_ref().0).read(&mut b)) { Ok(Ok(bytes)) => { // XXX this is safe, but not particularly efficient |