Skip to content

Commit

Permalink
Fix panic unmarshalling hello verify request
Browse files Browse the repository at this point in the history
This could cause us to panic when unmarshalling a Hello Verify request
message.
  • Loading branch information
Sam Lancia authored and daenney committed Feb 5, 2023
1 parent 7a14903 commit a50d26c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/protocol/handshake/message_hello_verify_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func (m *MessageHelloVerifyRequest) Unmarshal(data []byte) error {
}
m.Version.Major = data[0]
m.Version.Minor = data[1]
cookieLength := data[2]
if len(data) < (int(cookieLength) + 3) {
cookieLength := int(data[2])
if len(data) < cookieLength+3 {
return errBufferTooSmall
}
m.Cookie = make([]byte, cookieLength)
Expand Down

0 comments on commit a50d26c

Please sign in to comment.