Skip to content

Commit

Permalink
routing: fix bug in path finding when len(rootPath) > len(shortestPath)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Roasbeef committed Apr 13, 2017
1 parent 2d10d83 commit a4e26ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions routing/pathfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
}
}
Expand Down

0 comments on commit a4e26ea

Please sign in to comment.