From e73e754b2a1af96d9b1346cfc30b7246bc37ef44 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 26 Oct 2024 12:14:29 +0000 Subject: [PATCH] file: Ensure the path is always absolute Even if we import it from libarchive. Signed-off-by: Michael Tremer --- src/libpakfire/file.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libpakfire/file.c b/src/libpakfire/file.c index c168be46d..c4f8a8bd0 100644 --- a/src/libpakfire/file.c +++ b/src/libpakfire/file.c @@ -272,6 +272,7 @@ ERROR: } static int pakfire_file_from_archive_entry(struct pakfire_file* file, struct archive_entry* entry) { + char path[PATH_MAX]; char* buffer = NULL; const char* attr = NULL; const void* value = NULL; @@ -289,7 +290,15 @@ static int pakfire_file_from_archive_entry(struct pakfire_file* file, struct arc // Clone the given entry file->entry = archive_entry_clone(entry); if (!file->entry) - return -ENOMEM; + return -errno; + + // Make the path absolute + r = pakfire_path_absolute(path, archive_entry_pathname(file->entry)); + if (r < 0) + goto ERROR; + + // Store the absolute path + archive_entry_copy_pathname(file->entry, path); // Reset iterating over extended attributes archive_entry_xattr_reset(file->entry); -- 2.39.5