Skip to content

Commit

Permalink
Fix ChannelOpen length validation
Browse files Browse the repository at this point in the history
Integer overflow in ChannelOpen length validation could cause crash.
  • Loading branch information
daniel@poradnik-webmastera.com authored and sirzooro committed Jul 6, 2024
1 parent 498e053 commit 0246611
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion message_channel_open.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (c *channelOpen) Unmarshal(raw []byte) error {
labelLength := binary.BigEndian.Uint16(raw[8:])
protocolLength := binary.BigEndian.Uint16(raw[10:])

if expectedLen := int(channelOpenHeaderLength + labelLength + protocolLength); len(raw) != expectedLen {
if expectedLen := channelOpenHeaderLength + int(labelLength) + int(protocolLength); len(raw) != expectedLen {
return fmt.Errorf("%w expected(%d) actual(%d)", ErrExpectedAndActualLengthMismatch, expectedLen, len(raw))
}

Expand Down

0 comments on commit 0246611

Please sign in to comment.