From 99e20e46c7561dae42be7fae3f561676e43fa1f5 Mon Sep 17 00:00:00 2001 From: zoulasc Date: Mon, 10 Feb 2020 19:43:32 -0500 Subject: [PATCH] Just like the hard link case, for symlinks we need to remove first for ARCHIVE_EXTRACT_SAFE_WRITES. --- libarchive/archive_write_disk_posix.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 63a5fc71f..cc53a3d31 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -2306,6 +2306,13 @@ create_filesystem_object(struct archive_write_disk *a) linkname = archive_entry_symlink(a->entry); if (linkname != NULL) { #if HAVE_SYMLINK + /* + * Unlinking and linking here is really not atomic, + * but doing it right, would require us to construct + * an mktempsymlink() function, and then use rename(2). + */ + if (a->flags & ARCHIVE_EXTRACT_SAFE_WRITES) + unlink(a->name); return symlink(linkname, a->name) ? errno : 0; #else return (EPERM); -- 2.47.2