mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
invoice: sanity check routing info field
This commit allows parseRoutingInfo to return an error when parsing a routing info field whose length is not a multiple of 51 bytes, rather than crash.
This commit is contained in:
parent
db7154a401
commit
fa2cc57ca6
@ -37,6 +37,10 @@ const (
|
||||
// with zeroes.
|
||||
pubKeyBase32Len = 53
|
||||
|
||||
// routingInfoLen is the number of bytes needed to encode the extra
|
||||
// routing info of a single private route.
|
||||
routingInfoLen = 51
|
||||
|
||||
// The following byte values correspond to the supported field types.
|
||||
// The field name is the character representing that 5-bit value in the
|
||||
// bech32 string.
|
||||
@ -860,6 +864,11 @@ func parseRoutingInfo(data []byte) ([]ExtraRoutingInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(base256Data)%routingInfoLen != 0 {
|
||||
return nil, fmt.Errorf("expected length multiple of %d bytes, got %d",
|
||||
routingInfoLen, len(base256Data))
|
||||
}
|
||||
|
||||
var routingInfo []ExtraRoutingInfo
|
||||
info := ExtraRoutingInfo{}
|
||||
for len(base256Data) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user