tar-util: add missing dlopen libarchive

Otherwise, if the library is not loaded yet, these functions will fail.

Note, currently, all callers of tar_x/tar_c() load libarchive before
calling them. So, this should not change any behavior. Just for safety
and following our usual coding style.
This commit is contained in:
Yu Watanabe
2026-08-26 08:20:34 +09:00
parent 32798431dd
commit 06318e7b98
+8
View File
@@ -749,6 +749,10 @@ int tar_x(int input_fd, int tree_fd, TarFlags flags) {
assert(input_fd >= 0);
assert(tree_fd >= 0);
r = dlopen_libarchive(LOG_DEBUG);
if (r < 0)
return r;
_cleanup_(archive_read_freep) struct archive *a = NULL;
a = sym_archive_read_new();
if (!a)
@@ -1605,6 +1609,10 @@ int tar_c(int tree_fd, int output_fd, const char *filename, int hardlink_db_fd,
assert(tree_fd >= 0);
assert(output_fd >= 0);
r = dlopen_libarchive(LOG_DEBUG);
if (r < 0)
return r;
_cleanup_(archive_write_freep) struct archive *a = sym_archive_write_new();
if (!a)
return log_oom();