From 9eeb384a5bfc8b32c7c124bf3869ff2c6b7af6de Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 1 Nov 2023 11:12:49 +0000 Subject: [PATCH] repo: Fix path composition Signed-off-by: Michael Tremer --- src/libpakfire/repo.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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) { -- 2.47.3