From: Martin Matuska Date: Sun, 22 Aug 2021 01:53:28 +0000 (+0200) Subject: Never follow symlinks when setting file flags on Linux X-Git-Tag: v3.5.2~3 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2ad1a2c3064fa9eba6274b3641c4c1beed25c0b;p=thirdparty%2Flibarchive.git 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. --- diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index ba4e65df7..8474617eb 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -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)