fix data length check in STREAM frame parser

We should check if the rest of the STREAM frame contains enough bytes to
read the full data length, not if this overflows the MaxPacketSize
(which is the maximum packet size we use for sending, and has nothing to
do with receiving packets).
This commit is contained in:
Marten Seemann
2017-10-18 13:54:28 +07:00
parent 8297c52b79
commit 2f1db1c23d
2 changed files with 9 additions and 4 deletions

View File

@@ -2,6 +2,7 @@ package wire
import (
"bytes"
"io"
"github.com/lucas-clemente/quic-go/internal/protocol"
"github.com/lucas-clemente/quic-go/qerr"
@@ -168,9 +169,9 @@ var _ = Describe("StreamFrame", func() {
})
It("rejects frames to too large dataLen", func() {
b := bytes.NewReader([]byte{0xa0, 0x1, 0xff, 0xf})
b := bytes.NewReader([]byte{0xa0, 0x1, 0xff, 0xff})
_, err := ParseStreamFrame(b, protocol.VersionWhatever)
Expect(err).To(MatchError(qerr.Error(qerr.InvalidStreamData, "data len too large")))
Expect(err).To(MatchError(io.EOF))
})
It("rejects frames that overflow the offset", func() {