From edd57c8b96d83ab7bfa29cfa25cac821658a872c Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Wed, 7 Feb 2024 00:30:54 -0800 Subject: [PATCH] perform cleanup on sync db parsing errors Cleanup was only being performed when libarchive failed to actually read the file. Signed-off-by: Andrew Gregory --- lib/libalpm/be_sync.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 81676be9..588895e5 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -452,6 +452,14 @@ static int sync_db_populate(alpm_db_t *db) } } } + /* the db file was successfully read, but contained errors */ + if(ret == -1) { + db->status &= ~DB_STATUS_VALID; + db->status |= DB_STATUS_INVALID; + _alpm_db_free_pkgcache(db); + GOTO_ERR(db->handle, ALPM_ERR_DB_INVALID, cleanup); + } + /* reading the db file failed */ if(archive_ret != ARCHIVE_EOF) { _alpm_log(db->handle, ALPM_LOG_ERROR, _("could not read db '%s' (%s)\n"), db->treename, archive_error_string(archive));