]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Just like the hard link case, for symlinks we need to remove first 1330/head
authorzoulasc <christos@zoulas.com>
Tue, 11 Feb 2020 00:43:32 +0000 (19:43 -0500)
committerzoulasc <christos@zoulas.com>
Tue, 11 Feb 2020 00:43:32 +0000 (19:43 -0500)
for ARCHIVE_EXTRACT_SAFE_WRITES.

libarchive/archive_write_disk_posix.c

index 63a5fc71fbb496abff1f5de7b5f207412f565437..cc53a3d318e0196a6694b9a27d5119a672086d19 100644 (file)
@@ -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);