Module Name:    src
Committed By:   christos
Date:           Mon Feb 10 15:24:21 UTC 2020

Modified Files:
        src/external/bsd/libarchive/dist/libarchive: archive_write_disk_posix.c

Log Message:
When extracting symlinks atomically remove them like we do for hard links.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c
diff -u src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c:1.4 src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c:1.5
--- src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c:1.4	Tue Jan 14 14:29:45 2020
+++ src/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c	Mon Feb 10 10:24:21 2020
@@ -2301,6 +2301,11 @@ create_filesystem_object(struct archive_
 		}
 		free(linkname_copy);
 		archive_string_free(&error_string);
+		/*
+		 * Unlinking and linking here is really not atomic,
+		 * but doing it right, would require us to construct
+		 * an mktemplink() function, and then use rename(2).
+		 */
 		if (a->flags & ARCHIVE_EXTRACT_ATOMIC)
 			unlink(a->name);
 		r = link(linkname, a->name) ? errno : 0;
@@ -2341,7 +2346,15 @@ create_filesystem_object(struct archive_
 	linkname = archive_entry_symlink(a->entry);
 	if (linkname != NULL) {
 #if HAVE_SYMLINK
-		int error = symlink(linkname, a->name) ? errno : 0;
+		int error;
+		/*
+		 * 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_ATOMIC)
+			unlink(a->name);
+		error = symlink(linkname, a->name) ? errno : 0;
 		if (error == 0) {
 #ifdef HAVE_LSTAT
 			r = lstat(a->name, &st);

Reply via email to