From 412b277077445e142c882c992ee97543a228edf2 Mon Sep 17 00:00:00 2001 From: SAI KISHAN A <222060771+kishansaaai@users.noreply.github.com> Date: Sat, 6 Jun 2026 23:55:06 +0530 Subject: [PATCH] utils: fix ensure_file() to use lstat() instead of stat() stat() follows symlinks, making the S_ISLNK(buf.st_mode) check permanently dead code. Switch to lstat() so symlinks are correctly detected and rejected as bind-mount destinations. Fixes #733 Signed-off-by: SAI KISHAN A <222060771+kishansaaai@users.noreply.github.com> --- utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils.c b/utils.c index 55a7f5b1..632ff6e3 100644 --- a/utils.c +++ b/utils.c @@ -515,7 +515,7 @@ ensure_file (const char *path, it and look at the target: again, any non-directory is good enough. We'll only get S_ISLNK if the path is a dangling symlink (target doesn't exist). */ - if (stat (path, &buf) == 0 && + if (lstat (path, &buf) == 0 && !S_ISDIR (buf.st_mode) && !S_ISLNK (buf.st_mode)) return 0;