Skip to content

ensure_file() uses stat() instead of lstat(), making S_ISLNK check dead code #733

@dwahdany

Description

@dwahdany

ensure_file() in utils.c intends to reject symlinks as bind-mount destinations — the comment says "non-directory, non-symlink is acceptable" and the code checks !S_ISLNK(buf.st_mode).

However, it 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.

bubblewrap/utils.c

Lines 513 to 519 in 0c408e1

We're trying to set up a mount point for a non-directory, so any
non-directory, non-symlink is acceptable - it doesn't necessarily
have to be a regular file. */
if (stat (path, &buf) == 0 &&
!S_ISDIR (buf.st_mode) &&
!S_ISLNK (buf.st_mode))
return 0;

Should use lstat() so the S_ISLNK check works as intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions