Skip to content

Commit

Permalink
exec/util: fix infinite loop in Depth() if -root is relative
Browse files Browse the repository at this point in the history
If the -root command-line argument isn't an absolute path, and the files
stage tries to write a file, we get stuck in an infinite loop in Depth().
Ignition shouldn't normally be invoked this way, but it might occur
during manual debugging.  Avoid the infinite loop.
  • Loading branch information
bgilbert committed May 6, 2022
1 parent 4b70b44 commit e62e972
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/exec/util/path_sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

func Depth(path string) uint {
var count uint = 0
for p := filepath.Clean(path); p != "/"; count++ {
for p := filepath.Clean(path); p != "/" && p != "."; count++ {
p = filepath.Dir(p)
}
return count
Expand Down

0 comments on commit e62e972

Please sign in to comment.