From: Michael Tremer Date: Sat, 26 Oct 2024 12:14:29 +0000 (+0000) Subject: file: Ensure the path is always absolute X-Git-Tag: 0.9.30~844 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e73e754b2a1af96d9b1346cfc30b7246bc37ef44;p=pakfire.git file: Ensure the path is always absolute Even if we import it from libarchive. Signed-off-by: Michael Tremer --- 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);