Skip to content

Commit

Permalink
path: Add length check to TLV payload decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusd committed Jun 19, 2024
1 parent 9906aa0 commit f9ed030
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions path.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/binary"
"fmt"
"io"
"math"

"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/decred/dcrd/wire"
Expand Down Expand Up @@ -261,6 +262,10 @@ func (hp *HopPayload) Decode(r io.Reader) error {
}

payloadSize = uint32(varInt)
if payloadSize > math.MaxUint16 {
return fmt.Errorf("payload size %d larger than max allowed %d",
payloadSize, math.MaxUint16)
}
hp.Type = PayloadTLV
}

Expand Down

0 comments on commit f9ed030

Please sign in to comment.