routing: fix bug in path finding when len(rootPath) > len(shortestPath)

This commit fixes a bug within the k-shortest paths routine which could
result in a daemon panic when traversing a graph with particular
characteristics. Before referencing the path to create a sub-slice, we
we’re properly asserting that the length of the path was at least as
long as the current rootPath in question. We fix this by simply
ensuring the length of the slice is adequate before proceeding with the
operation.
This commit is contained in:
Olaoluwa Osuntokun 2017-04-13 14:44:53 -07:00
parent 2d10d83f07
commit a4e26eaa4a
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
1 changed files with 2 additions and 2 deletions

View File

@ -494,10 +494,10 @@ func findPaths(graph *channeldb.ChannelGraph, source *channeldb.LightningNode,
// next round.
for _, path := range shortestPaths {
// If our current rootPath is a prefix of this
// shortest path, then we'll remove the ege
// shortest path, then we'll remove the edge
// directly _after_ our spur node from the
// graph so we don't repeat paths.
if isSamePath(rootPath, path[:i+1]) {
if len(path) > i+1 && isSamePath(rootPath, path[:i+1]) {
ignoredEdges[path[i+1].ChannelID] = struct{}{}
}
}