]> git.ipfire.org Git - pakfire.git/commitdiff
FHS: Ensure the checked path is absolute
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Oct 2024 09:25:00 +0000 (09:25 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Oct 2024 09:25:00 +0000 (09:25 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/fhs.c

index 3bcb78bcded337f325a9be11a3014d385528dc7d..a60f5676e183db3b82afc5bb83fa5aca3ac56292 100644 (file)
@@ -25,6 +25,7 @@
 #include <pakfire/fhs.h>
 #include <pakfire/file.h>
 #include <pakfire/logging.h>
+#include <pakfire/path.h>
 #include <pakfire/util.h>
 
 /*
@@ -195,13 +196,16 @@ static const struct pakfire_fhs_check {
 static const struct pakfire_fhs_check* pakfire_fhs_find_check(
                struct pakfire_ctx* ctx, struct pakfire_file* file) {
        const struct pakfire_fhs_check* check = NULL;
+       char path[PATH_MAX];
        int r;
 
        // Fetch the file type
        const mode_t type = pakfire_file_get_type(file);
 
-       // Fetch the path
-       const char* path = pakfire_file_get_path(file);
+       // Fetch the path and make it absolute
+       r = pakfire_path_absolute(path, pakfire_file_get_path(file));
+       if (r < 0)
+               goto ERROR;
 
        // Walk through all possible checks
        for (check = pakfire_fhs_check; check->path; check++) {