diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2017-04-17 05:28:32 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2017-05-08 10:53:54 +0200 |
commit | bf23f85d4a844b8e8c70125bce54bbda90cb0019 (patch) | |
tree | 7525479a04e50ae408a2caa6eff05013af249d59 /lib | |
parent | c6b04c04653ba9933fe978829148312e412a9ea7 (diff) | |
download | pacman-bf23f85d4a844b8e8c70125bce54bbda90cb0019.tar.gz pacman-bf23f85d4a844b8e8c70125bce54bbda90cb0019.tar.xz |
be_sync: error out if a db cannot be parsed
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/be_sync.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c index 5f7d31ab..06f509a6 100644 --- a/lib/libalpm/be_sync.c +++ b/lib/libalpm/be_sync.c @@ -465,6 +465,7 @@ static int sync_db_populate(alpm_db_t *db) size_t est_count, count; int fd; int ret = 0; + int archive_ret; struct stat buf; struct archive *archive; struct archive_entry *entry; @@ -502,20 +503,26 @@ static int sync_db_populate(alpm_db_t *db) goto cleanup; } - while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) { + while((archive_ret = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) { mode_t mode = archive_entry_mode(entry); - if(S_ISDIR(mode)) { - continue; - } else { + if(!S_ISDIR(mode)) { /* we have desc, depends or deltas - parse it */ if(sync_db_read(db, archive, entry, &pkg) != 0) { _alpm_log(db->handle, ALPM_LOG_ERROR, _("could not parse package description file '%s' from db '%s'\n"), archive_entry_pathname(entry), db->treename); - continue; + ret = -1; } } } + 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)); + _alpm_db_free_pkgcache(db); + db->handle->pm_errno = ALPM_ERR_LIBARCHIVE; + ret = -1; + goto cleanup; + } count = alpm_list_count(db->pkgcache->list); if(count > 0) { |