Skip to content

Commit a518f7d

Browse files
authored
Merge pull request #9084 from morehouse/detect_invalid_timestamp_field
lnwire: detect invalid timestamp field
2 parents a6f0ec9 + 532fe05 commit a518f7d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

discovery/syncer.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,6 @@ func (g *GossipSyncer) processChanRangeReply(msg *lnwire.ReplyChannelRange) erro
835835
}
836836

837837
g.prevReplyChannelRange = msg
838-
if len(msg.Timestamps) != 0 &&
839-
len(msg.Timestamps) != len(msg.ShortChanIDs) {
840-
841-
return fmt.Errorf("number of timestamps not equal to " +
842-
"number of SCIDs")
843-
}
844838

845839
for i, scid := range msg.ShortChanIDs {
846840
info := channeldb.NewChannelUpdateInfo(

lnwire/reply_channel_range.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ func (c *ReplyChannelRange) Decode(r io.Reader, pver uint32) error {
104104
// Set the corresponding TLV types if they were included in the stream.
105105
if val, ok := typeMap[TimestampsRecordType]; ok && val == nil {
106106
c.Timestamps = timeStamps
107+
108+
// Check that a timestamp was provided for each SCID.
109+
if len(c.Timestamps) != len(c.ShortChanIDs) {
110+
return fmt.Errorf("number of timestamps does not " +
111+
"match number of SCIDs")
112+
}
107113
}
108114

109115
if len(tlvRecords) != 0 {

0 commit comments

Comments
 (0)