From: zoulasc Date: Tue, 11 Feb 2020 00:43:32 +0000 (-0500) Subject: Just like the hard link case, for symlinks we need to remove first X-Git-Tag: v3.4.2~3^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=99e20e46c7561dae42be7fae3f561676e43fa1f5;p=thirdparty%2Flibarchive.git Just like the hard link case, for symlinks we need to remove first for ARCHIVE_EXTRACT_SAFE_WRITES. --- 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);