Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/libarchive/dist/libarchive When extracting syml...



details:   https://anonhg.NetBSD.org/src/rev/3cc9faeb5481
branches:  trunk
changeset: 744676:3cc9faeb5481
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Feb 10 15:24:21 2020 +0000

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

diffstat:

 external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c |  15 +++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diffs (32 lines):

diff -r e3924e871a7a -r 3cc9faeb5481 external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c
--- a/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c        Mon Feb 10 14:55:53 2020 +0000
+++ b/external/bsd/libarchive/dist/libarchive/archive_write_disk_posix.c        Mon Feb 10 15:24:21 2020 +0000
@@ -2301,6 +2301,11 @@
                }
                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 @@
        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);



Home | Main Index | Thread Index | Old Index