mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-06 05:37:36 +03:00
parent
20b2069d78
commit
745d7b7e9f
2 changed files with 18 additions and 1 deletions
|
@ -79,7 +79,11 @@ func ParseStreamFrame(r *bytes.Reader) (*StreamFrame, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if !frame.FinBit && len(frame.Data) == 0 {
|
||||
if frame.Offset+frame.DataLen() < frame.Offset {
|
||||
return nil, qerr.Error(qerr.InvalidStreamData, "data overflows maximum offset")
|
||||
}
|
||||
|
||||
if !frame.FinBit && frame.DataLen() == 0 {
|
||||
return nil, qerr.EmptyStreamFrameNoFin
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,19 @@ var _ = Describe("StreamFrame", func() {
|
|||
Expect(err).To(MatchError(qerr.Error(qerr.InvalidStreamData, "data len too large")))
|
||||
})
|
||||
|
||||
It("rejects frames that overflow the offset", func() {
|
||||
// Offset + len(Data) overflows MaxByteCount
|
||||
f := &StreamFrame{
|
||||
StreamID: 1,
|
||||
Offset: protocol.MaxByteCount,
|
||||
Data: []byte{'f'},
|
||||
}
|
||||
b := &bytes.Buffer{}
|
||||
f.Write(b, protocol.VersionWhatever)
|
||||
_, err := ParseStreamFrame(bytes.NewReader(b.Bytes()))
|
||||
Expect(err).To(MatchError(qerr.Error(qerr.InvalidStreamData, "data overflows maximum offset")))
|
||||
})
|
||||
|
||||
It("errors on EOFs", func() {
|
||||
data := []byte{0xa4, 0x1, 0x2a, 0x00, 0x06, 0x00, 'f', 'o', 'o', 'b', 'a', 'r'}
|
||||
_, err := ParseStreamFrame(bytes.NewReader(data))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue