From 1daf54da67d1c5dfbec032af45a990b89cb411e4 Mon Sep 17 00:00:00 2001 From: Jairo Llopis Date: Tue, 5 Apr 2022 13:58:56 +0100 Subject: [PATCH 1/2] fix: avoid infinite recursion while searching for path In `findGitIgnores`, to find the parent path, we do `path + "/.."`. This means that, for each iteration, the path name grows: 1. `/nix/store/1234-example/a/b/` 2. `/nix/store/1234-example/a/b/..` 3. `/nix/store/1234-example/a/b/../..` 4. etc. Thus, checking if path is not equal to `/` will always return `true`. With this fix, it will instead check that the path exists. If the path goes higher than `/`, it will not exist, thus fixing the false positive. @moduon MT-83 --- lib.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.nix b/lib.nix index a905d30..e201420 100644 --- a/lib.nix +++ b/lib.nix @@ -180,7 +180,7 @@ let hasGitIgnore = builtins.pathExists gitIgnore; gitIgnores = if hasGitIgnore then [ gitIgnore ] else [ ]; in - lib.optionals (builtins.toString path != "/" && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores; + lib.optionals (builtins.pathExists path && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores; /* Provides a source filtering mechanism that: From 5e667bc5271b12946e32ea887b3c7c7b0e1d8906 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Thu, 14 Apr 2022 16:19:59 +1200 Subject: [PATCH 2/2] Fix infinite recusion in the case where no gitignores are found --- lib.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.nix b/lib.nix index e201420..b5bf0c9 100644 --- a/lib.nix +++ b/lib.nix @@ -180,7 +180,7 @@ let hasGitIgnore = builtins.pathExists gitIgnore; gitIgnores = if hasGitIgnore then [ gitIgnore ] else [ ]; in - lib.optionals (builtins.pathExists path && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores; + lib.optionals (builtins.pathExists path && builtins.toString path != "/" && ! isGitRoot) (findGitIgnores parent) ++ gitIgnores; /* Provides a source filtering mechanism that: