From: Michael Tremer Date: Tue, 29 Nov 2022 15:50:18 +0000 (+0000) Subject: db: Set correct absolute path for read filelists X-Git-Tag: 0.9.28~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1fab76a468db41a2bf14ed0e1660457ed4ea1c55;p=pakfire.git db: Set correct absolute path for read filelists This prevents Pakfire from deleteing files in the host system. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/db.c b/src/libpakfire/db.c index f584eb7be..b3d72bd87 100644 --- a/src/libpakfire/db.c +++ b/src/libpakfire/db.c @@ -2094,6 +2094,7 @@ static int pakfire_db_load_file_digest(struct pakfire_db* db, struct pakfire_fil static int pakfire_db_load_file(struct pakfire_db* db, struct pakfire_filelist* filelist, sqlite3_stmt* stmt) { struct pakfire_file* file = NULL; + char abspath[PATH_MAX]; int r; // Create a new file object @@ -2118,6 +2119,20 @@ static int pakfire_db_load_file(struct pakfire_db* db, struct pakfire_filelist* goto ERROR; } + // Make the absolute path + r = pakfire_path(db->pakfire, abspath, "%s", path); + if (r) { + ERROR(db->pakfire, "%s: Could not make absolute path: %m\n", path); + goto ERROR; + } + + // Set the absolute path + r = pakfire_file_set_abspath(file, abspath); + if (r) { + ERROR(db->pakfire, "%s: Could not set absolute path %s: %m\n", path, abspath); + goto ERROR; + } + // Size size_t size = sqlite3_column_int64(stmt, 1); if (size)