From 10dd11de71401ee4dbbb4344f5efb212349ad17c Mon Sep 17 00:00:00 2001 From: Anders Eknert Date: Fri, 26 Apr 2024 10:59:12 +0200 Subject: [PATCH] fix: Avoid panic in config finder Signed-off-by: Anders Eknert --- pkg/config/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index f3f960b4..581721d7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -139,6 +139,10 @@ func FindRegalDirectory(path string) (*os.File, error) { return nil, errors.New("stopping as dir is empty string") } + if len(parts) < 2 { + return nil, errors.New("stopping as dir is root directory") + } + parts = parts[:len(parts)-1] if parts[0] == volume {