]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
posix: Move static var into archive_write_disk 3107/head
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 2 Jun 2026 18:28:53 +0000 (20:28 +0200)
committerTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 2 Jun 2026 18:50:12 +0000 (20:50 +0200)
Move a static variable into struct archive_write_disk, which is a safe
location from a thread perspective.

Only create and use it if it's really needed, i.e. for systems which
lack support for extended attributes.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_write_disk_posix.c

index 7b90fc25fa54691966d6121b2a9e4c581aba49d8..4e4e7d935024f3db046d4d5b0d13b06872c7c45d 100644 (file)
@@ -308,6 +308,10 @@ struct archive_write_disk {
        int                      stream_valid;
        int                      decmpfs_compression_level;
 #endif
+#if !(ARCHIVE_XATTR_LINUX || ARCHIVE_XATTR_DARWIN || ARCHIVE_XATTR_AIX ||\
+    ARCHIVE_XATTR_FREEBSD)
+       int                      warning_done;
+#endif
 };
 
 /*
@@ -4693,12 +4697,10 @@ set_xattrs(struct archive_write_disk *a)
 static int
 set_xattrs(struct archive_write_disk *a)
 {
-       static int warning_done = 0;
-
        /* If there aren't any extended attributes, then it's okay not
         * to extract them, otherwise, issue a single warning. */
-       if (archive_entry_xattr_count(a->entry) != 0 && !warning_done) {
-               warning_done = 1;
+       if (archive_entry_xattr_count(a->entry) != 0 && !a->warning_done) {
+               a->warning_done = 1;
                archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                    "Cannot restore extended attributes on this system");
                return (ARCHIVE_WARN);