From e62e9726eb2a5d8d87c3ccff9619d8af728c63e7 Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Fri, 6 May 2022 06:30:08 -0400 Subject: [PATCH] exec/util: fix infinite loop in Depth() if -root is relative 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. --- internal/exec/util/path_sort.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/exec/util/path_sort.go b/internal/exec/util/path_sort.go index 05ad40c82..c241736bf 100644 --- a/internal/exec/util/path_sort.go +++ b/internal/exec/util/path_sort.go @@ -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