From 492d581df632fac6c9fe6753efb3f5b3b42db220 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Fri, 31 Aug 2018 14:59:34 -0700 Subject: [PATCH] channeldb/graph: fix off-by-one public key slice In this commit, we fix an off-by-one error when slicing the public key from the serialized node info byte slice. This would cause us to write an extra byte to all edge policies. Even though the values were read correctly, when attempting to calculate the offset of an edge's update time going backwards, we'd always be incorrect, causing us to not properly prune the edge update index. --- channeldb/graph.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/channeldb/graph.go b/channeldb/graph.go index e5057bc21..b53bf344f 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -1644,9 +1644,9 @@ func updateEdgePolicy(edges, edgeIndex *bolt.Bucket, var fromNode, toNode []byte if edge.Flags&lnwire.ChanUpdateDirection == 0 { fromNode = nodeInfo[:33] - toNode = nodeInfo[33:67] + toNode = nodeInfo[33:66] } else { - fromNode = nodeInfo[33:67] + fromNode = nodeInfo[33:66] toNode = nodeInfo[:33] } @@ -3103,7 +3103,7 @@ func fetchChanEdgePolicies(edgeIndex *bolt.Bucket, edges *bolt.Bucket, // Similarly, the second node is contained within the latter // half of the edge information. - node2Pub := edgeInfo[33:67] + node2Pub := edgeInfo[33:66] edge2, err := fetchChanEdgePolicy(edges, chanID, node2Pub, nodes) if err != nil { return nil, nil, err