Skip to content

Commit 09a709d

Browse files
committed
h3: while receiving DATA frames, check if the stream has been reset
1 parent 997326f commit 09a709d

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

quiche/src/h3/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,20 @@ impl Connection {
27442744
break;
27452745
}
27462746

2747+
// Do a dummy read to check if the stream has been reset
2748+
// while waiting to receive more data from a declared DATA
2749+
// frame length. Doing this prevents an Event::Data frame
2750+
// being triggered, which then might be followed by an
2751+
// immediate Event::Finished if an application has already
2752+
// read exactly the stream final size.
2753+
if let Err(crate::Error::StreamReset(e)) =
2754+
conn.stream_recv(stream_id, &mut [])
2755+
{
2756+
return Err(Error::TransportError(
2757+
crate::Error::StreamReset(e),
2758+
));
2759+
}
2760+
27472761
if !stream.try_trigger_data_event() {
27482762
break;
27492763
}
@@ -7231,8 +7245,7 @@ mod tests {
72317245

72327246
s.advance().ok();
72337247

7234-
assert_eq!(s.poll_client(), Ok((stream, Event::Data)));
7235-
assert_eq!(s.poll_client(), Ok((stream, Event::Finished)));
7248+
assert_eq!(s.poll_client(), Ok((stream, Event::Reset(42))));
72367249
assert_eq!(s.poll_client(), Err(Error::Done));
72377250
}
72387251

0 commit comments

Comments
 (0)