Skip to content

Commit e2ad1a2

Browse files
committed
Never follow symlinks when setting file flags on Linux
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.
1 parent fba4f12 commit e2ad1a2

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

libarchive/archive_write_disk_posix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3927,7 +3927,8 @@ set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,
39273927

39283928
/* If we weren't given an fd, open it ourselves. */
39293929
if (myfd < 0) {
3930-
myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY | O_CLOEXEC);
3930+
myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY |
3931+
O_CLOEXEC | O_NOFOLLOW);
39313932
__archive_ensure_cloexec_flag(myfd);
39323933
}
39333934
if (myfd < 0)

0 commit comments

Comments
 (0)