]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Fix path composition
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 11:12:49 +0000 (11:12 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 1 Nov 2023 11:12:49 +0000 (11:12 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/repo.c

index a37d20d835a860b4ec1fda14adc3d660091dc97e..5bf2ffcb4c4fd8a1cf6e407f9958f49fc7bba488 100644 (file)
@@ -1022,10 +1022,23 @@ PAKFIRE_EXPORT int pakfire_repo_set_baseurl(struct pakfire_repo* repo, const cha
 }
 
 const char* pakfire_repo_get_path(struct pakfire_repo* repo) {
+       const char* baseurl = NULL;
+
        if (!pakfire_repo_is_local(repo))
                return NULL;
 
-       return repo->appdata->baseurl + strlen("file://");
+       // Get the base URL
+       baseurl = pakfire_repo_get_expanded_baseurl(repo);
+       if (!baseurl)
+               return NULL;
+
+       // The URL must start with file://
+       if (!pakfire_string_startswith(baseurl, "file://")) {
+               errno = -EINVAL;
+               return NULL;
+       }
+
+       return baseurl + strlen("file://");
 }
 
 PAKFIRE_EXPORT struct pakfire_key* pakfire_repo_get_key(struct pakfire_repo* repo) {