Skip to content

Commit 3bd7fa3

Browse files
committed
local-store: fix infinite loop on Windows
Also switch to std::filesystem.
1 parent 2e2198f commit 3bd7fa3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/libstore/local-store.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,15 @@ LocalStore::LocalStore(
212212

213213
/* Ensure that the store and its parents are not symlinks. */
214214
if (!settings.allowSymlinkedStore) {
215-
Path path = realStoreDir;
216-
struct stat st;
217-
while (path != "/") {
218-
st = lstat(path);
219-
if (S_ISLNK(st.st_mode))
215+
std::filesystem::path path = realStoreDir.get();
216+
std::filesystem::path root = path.root_path();
217+
while (path != root) {
218+
if (std::filesystem::is_symlink(path))
220219
throw Error(
221220
"the path '%1%' is a symlink; "
222221
"this is not allowed for the Nix store and its parent directories",
223222
path);
224-
path = dirOf(path);
223+
path = path.parent_path();
225224
}
226225
}
227226

0 commit comments

Comments
 (0)