Skip to content

Commit

Permalink
Never follow symlinks when setting file flags on Linux
Browse files Browse the repository at this point in the history
When opening a file descriptor to set file flags on linux, ensure
no symbolic links are followed. This fixes the case when an archive
contains a directory entry followed by a symlink entry with the same
path. The fixup code would modify file flags of the symlink target.
  • Loading branch information
mmatuska committed Aug 22, 2021
1 parent fba4f12 commit e2ad1a2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libarchive/archive_write_disk_posix.c
Expand Up @@ -3927,7 +3927,8 @@ set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,

/* If we weren't given an fd, open it ourselves. */
if (myfd < 0) {
myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY | O_CLOEXEC);
myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY |
O_CLOEXEC | O_NOFOLLOW);
__archive_ensure_cloexec_flag(myfd);
}
if (myfd < 0)
Expand Down

0 comments on commit e2ad1a2

Please sign in to comment.