forked from quic-go/quic-go
wire: correctly parse multi-byte frame types (#3736)
This commit is contained in:
@@ -2,6 +2,7 @@ package wire
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/quic-go/quic-go/internal/protocol"
|
||||
"github.com/quic-go/quic-go/internal/qerr"
|
||||
@@ -14,9 +15,8 @@ import (
|
||||
var _ = Describe("STOP_SENDING frame", func() {
|
||||
Context("when parsing", func() {
|
||||
It("parses a sample frame", func() {
|
||||
data := []byte{0x5}
|
||||
data = append(data, encodeVarInt(0xdecafbad)...) // stream ID
|
||||
data = append(data, encodeVarInt(0x1337)...) // error code
|
||||
data := encodeVarInt(0xdecafbad) // stream ID
|
||||
data = append(data, encodeVarInt(0x1337)...) // error code
|
||||
b := bytes.NewReader(data)
|
||||
frame, err := parseStopSendingFrame(b, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -26,14 +26,14 @@ var _ = Describe("STOP_SENDING frame", func() {
|
||||
})
|
||||
|
||||
It("errors on EOFs", func() {
|
||||
data := []byte{0x5}
|
||||
data = append(data, encodeVarInt(0xdecafbad)...) // stream ID
|
||||
data = append(data, encodeVarInt(0x123456)...) // error code
|
||||
_, err := parseStopSendingFrame(bytes.NewReader(data), protocol.Version1)
|
||||
data := encodeVarInt(0xdecafbad) // stream ID
|
||||
data = append(data, encodeVarInt(0x123456)...) // error code
|
||||
b := bytes.NewReader(data)
|
||||
_, err := parseStopSendingFrame(b, protocol.Version1)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
for i := range data {
|
||||
_, err := parseStopSendingFrame(bytes.NewReader(data[:i]), protocol.Version1)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(io.EOF))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user