diff options
Diffstat (limited to 'src/daemon.rs')
| -rw-r--r-- | src/daemon.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/daemon.rs b/src/daemon.rs index f12efd9..12757a3 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -298,9 +298,13 @@ fn handle_client( "request too large".into(), )); writer.write_all(resp.as_bytes())?; - // Drain remaining bytes until newline - let mut discard = String::new(); - let _ = reader.read_line(&mut discard); + // Drain remaining bytes until newline (bounded to + // prevent a client without newlines from blocking + // indefinitely beyond the read timeout). + let mut discard = Vec::new(); + let _ = (&mut reader) + .take(MAX_LINE_SIZE as u64) + .read_until(b'\n', &mut discard); continue; } let line = line.trim(); |