]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tar-util: do not error out if archive_read_next_header() returns ARCHIVE_WARN
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Wed, 28 Jan 2026 12:42:25 +0000 (13:42 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Jan 2026 17:41:11 +0000 (02:41 +0900)
archive_read_header(3) states that `archive_read_next_header()` returns
`ARCHIVE_WARN` if it succeeds but a non-critical error is found, so issue a
warning instead of stopping the untar process in this case.

src/shared/tar-util.c

index 9674599dd3e55633803c8902ee021d49de3a58a5..9436eff868ba621512dd43157e5b8ffe516741d0 100644 (file)
@@ -739,13 +739,15 @@ int tar_x(int input_fd, int tree_fd, TarFlags flags) {
                 ar = sym_archive_read_next_header(a, &entry);
                 if (ar == ARCHIVE_EOF)
                         break;
-                if (ar != ARCHIVE_OK)
+                if (!IN_SET(ar, ARCHIVE_OK, ARCHIVE_WARN))
                         return log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Failed to parse archive: %s", sym_archive_error_string(a));
 
                 const char *p = NULL;
                 r = archive_entry_pathname_safe(entry, &p);
                 if (r < 0)
                         return log_error_errno(r, "Invalid path name in entry, refusing.");
+                if (ar == ARCHIVE_WARN)
+                        log_warning("Non-critical error found while parsing '%s' from the archive, ignoring: %s", p ?: ".", sym_archive_error_string(a));
 
                 if (!p) {
                         /* This is the root inode */