error when receiving stream data with a larger offset than the final offset

This could happen when a peer send a STREAM frame with the Fin bit set,
and then sends STREAM frames with a higher offset.
This commit is contained in:
Marten Seemann
2017-10-25 10:43:29 +07:00
parent 816cf90ea7
commit 636bf4578c
2 changed files with 24 additions and 3 deletions

View File

@@ -12,10 +12,12 @@ import (
type streamFlowController struct {
baseFlowController
connection connectionFlowControllerI
streamID protocol.StreamID
streamID protocol.StreamID
connection connectionFlowControllerI
contributesToConnection bool // does the stream contribute to connection level flow control
receivedFinalOffset bool
}
var _ StreamFlowController = &streamFlowController{}
@@ -50,7 +52,12 @@ func (c *streamFlowController) UpdateHighestReceived(byteOffset protocol.ByteCou
c.mutex.Lock()
defer c.mutex.Unlock()
// TODO(#382): check for StreamDataAfterTermination errors, when receiving an offset after we already received a final offset
if c.receivedFinalOffset && byteOffset > c.highestReceived {
return qerr.StreamDataAfterTermination
}
if final {
c.receivedFinalOffset = true
}
if byteOffset == c.highestReceived {
return nil
}