fix typos in error messages when parsing Version Negotiation packets

This commit is contained in:
Marten Seemann 2019-06-29 11:00:57 +07:00
parent 0333f424bb
commit 4fe0f6752c
2 changed files with 4 additions and 4 deletions

View file

@ -208,10 +208,10 @@ func (h *Header) parseLongHeader(b *bytes.Reader) error {
func (h *Header) parseVersionNegotiationPacket(b *bytes.Reader) error { func (h *Header) parseVersionNegotiationPacket(b *bytes.Reader) error {
if b.Len() == 0 { if b.Len() == 0 {
return errors.New("Version Negoation packet has empty version list") return errors.New("Version Negotiation packet has empty version list")
} }
if b.Len()%4 != 0 { if b.Len()%4 != 0 {
return errors.New("Version Negotation packet has a version list with an invalid length") return errors.New("Version Negotiation packet has a version list with an invalid length")
} }
h.SupportedVersions = make([]protocol.VersionNumber, b.Len()/4) h.SupportedVersions = make([]protocol.VersionNumber, b.Len()/4)
for i := 0; b.Len() > 0; i++ { for i := 0; b.Len() > 0; i++ {

View file

@ -137,7 +137,7 @@ var _ = Describe("Header Parsing", func() {
data, err := ComposeVersionNegotiation(connID, connID, versions) data, err := ComposeVersionNegotiation(connID, connID, versions)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
_, _, _, err = ParsePacket(data[:len(data)-2], 0) _, _, _, err = ParsePacket(data[:len(data)-2], 0)
Expect(err).To(MatchError("Version Negotation packet has a version list with an invalid length")) Expect(err).To(MatchError("Version Negotiation packet has a version list with an invalid length"))
}) })
It("errors if the version list is empty", func() { It("errors if the version list is empty", func() {
@ -148,7 +148,7 @@ var _ = Describe("Header Parsing", func() {
// remove 8 bytes (two versions), since ComposeVersionNegotiation also added a reserved version number // remove 8 bytes (two versions), since ComposeVersionNegotiation also added a reserved version number
data = data[:len(data)-8] data = data[:len(data)-8]
_, _, _, err = ParsePacket(data, 0) _, _, _, err = ParsePacket(data, 0)
Expect(err).To(MatchError("Version Negoation packet has empty version list")) Expect(err).To(MatchError("Version Negotiation packet has empty version list"))
}) })
}) })