From afdbfc05f771f2c684ee195b46d26b3d08a67085 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Mon, 19 Sep 2011 20:40:32 -0500 Subject: Extract an _alpm_pkg_validate_internal() method _alpm_pkg_load_internal() was becoming a monster. Extract the top bit of the method that dealt with checksum and signature validation into a separate method that should be called before one loads a package to ensure it is valid. Signed-off-by: Dan McGee --- lib/libalpm/sync.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/libalpm/sync.c') diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 732e786f..a5281078 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -971,14 +971,20 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data) _alpm_log(handle, ALPM_LOG_DEBUG, "replacing pkgcache entry with package file for target %s\n", spkg->name); - alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, spkg, 1, level); - if(!pkgfile) { + if(_alpm_pkg_validate_internal(handle, filepath, spkg, level) == -1) { prompt_to_delete(handle, filepath, handle->pm_errno); errors++; *data = alpm_list_add(*data, strdup(spkg->filename)); FREE(filepath); continue; } + alpm_pkg_t *pkgfile =_alpm_pkg_load_internal(handle, filepath, 1); + if(!pkgfile) { + errors++; + *data = alpm_list_add(*data, strdup(spkg->filename)); + FREE(filepath); + continue; + } FREE(filepath); pkgfile->reason = spkg->reason; /* copy over install reason */ i->data = pkgfile; -- cgit v1.2.3-24-g4f1b