Skip to content

Commit

Permalink
Don't keep reading on EOF and get killed by OOM
Browse files Browse the repository at this point in the history
  • Loading branch information
vvilhonen committed May 27, 2020
1 parent e08d8cb commit 417517e
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main.rs
Expand Up @@ -289,6 +289,9 @@ impl Shell {
while buf.len() < 1024 {
let mut chunk = [0u8; 256];
let n = timeout(Duration::from_secs(500), self.socket.read(&mut chunk)).await??;
if n == 0 {
break;
}
buf.extend(&chunk[..n]);
let empty = buf
.iter()
Expand Down

0 comments on commit 417517e

Please sign in to comment.