]> git.ipfire.org Git - pakfire.git/commitdiff
file: Ensure the path is always absolute
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 12:14:29 +0000 (12:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Oct 2024 12:14:29 +0000 (12:14 +0000)
Even if we import it from libarchive.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/file.c

index c168be46d7328ddd204cdb3848b2f6b338c0f8e8..c4f8a8bd0f6737dca91380966727947dbd464913 100644 (file)
@@ -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);