doy / pty-process

Other
22 stars 16 forks source link

tokio AsyncPty poll_read can easily panic #2

Closed mental32 closed 1 year ago

mental32 commented 2 years ago

Thanks for this crate, it's been immensely helpful!

I've been noticing panics coming from this line:

https://github.com/doy/pty-process/blob/491ad3de31067cc8cafc540cea2c8891f2985815/src/pty/tokio.rs#L49

And it looks like it occurs when the input buffer is smaller than this intermediate one here:

https://github.com/doy/pty-process/blob/491ad3de31067cc8cafc540cea2c8891f2985815/src/pty/tokio.rs#L44

I've been observing it through code like this

let buf = [0xFF_u8, 512];

while let Ok(n) = child.pty_mut().read(&mut buf).await { ... }

and a combination of a lot of activity in the childs pty output.

I'm not sure what the best way to solve this would be is, but perhaps clamping the internal buffers size with the capacity of the provided readbuf would potential solution?

doy commented 1 year ago

i believe this should have been fixed in 4513e54c073ea169b98f02f330bb31dff26fee99 but let me know if you still see it