Skip to content

Commit ef1ec4d

Browse files
dwahdanyclaude
andcommitted
utils: use lstat() instead of stat() in ensure_file()
ensure_file() checks !S_ISLNK to reject symlinks as bind-mount destinations, but uses stat() which follows symlinks. Since stat() resolves the symlink before returning, S_ISLNK is never true for valid symlinks, making the check dead code. Use lstat() so the S_ISLNK check works as intended. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Dariush Wahdany <86673488+dwahdany@users.noreply.github.com>
1 parent 0c408e1 commit ef1ec4d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

utils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ ensure_file (const char *path,
513513
We're trying to set up a mount point for a non-directory, so any
514514
non-directory, non-symlink is acceptable - it doesn't necessarily
515515
have to be a regular file. */
516-
if (stat (path, &buf) == 0 &&
516+
if (lstat (path, &buf) == 0 &&
517517
!S_ISDIR (buf.st_mode) &&
518518
!S_ISLNK (buf.st_mode))
519519
return 0;

0 commit comments

Comments
 (0)