From f2d01fb2ad0d466255ab978a00993a554717047c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 25 Jan 2021 20:55:23 +0100 Subject: [PATCH] quinn-proto: check for stopped assembler before reading data I'm guessing these were missed when these new methods were added, and it seems like they do present a bit of a layering violation. --- quinn-proto/src/connection/streams/recv.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/quinn-proto/src/connection/streams/recv.rs b/quinn-proto/src/connection/streams/recv.rs index b0e4d51c1..2d0450010 100644 --- a/quinn-proto/src/connection/streams/recv.rs +++ b/quinn-proto/src/connection/streams/recv.rs @@ -95,6 +95,10 @@ impl Recv { } pub(super) fn read_chunk(&mut self, max_length: usize) -> StreamReadResult { + if self.assembler.is_stopped() { + return Err(ReadError::UnknownStream); + } + match self.assembler.read(max_length)? { Some(bytes) => Ok(Some(bytes)), None => self.read_blocked().map(|()| None), @@ -105,6 +109,10 @@ impl Recv { &mut self, chunks: &mut [Bytes], ) -> Result, ReadError> { + if self.assembler.is_stopped() { + return Err(ReadError::UnknownStream); + } + let mut out = ReadChunks { bufs: 0, read: 0 }; if chunks.is_empty() { return Ok(Some(out));