From: Michael Tremer Date: Wed, 1 Nov 2023 11:12:49 +0000 (+0000) Subject: repo: Fix path composition X-Git-Tag: 0.9.30~1353 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9eeb384a5bfc8b32c7c124bf3869ff2c6b7af6de;p=pakfire.git repo: Fix path composition Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/repo.c b/src/libpakfire/repo.c index a37d20d83..5bf2ffcb4 100644 --- a/src/libpakfire/repo.c +++ b/src/libpakfire/repo.c @@ -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) {