summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/be_package.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-01-08 18:53:22 +0100
committerDan McGee <dan@archlinux.org>2012-01-08 18:53:22 +0100
commit7f51ba99ae6db204d69ce271cd5cc4e959135738 (patch)
treee8e1739373b18cb17222238107fb7285dd50fdaa /lib/libalpm/be_package.c
parent6f9ab22fd8c446eab58f1a6bbef7cb984575ef8a (diff)
downloadpacman-7f51ba99ae6db204d69ce271cd5cc4e959135738.tar.gz
pacman-7f51ba99ae6db204d69ce271cd5cc4e959135738.tar.xz
Fix segfaults on opening invalid archive files
"invalid" in this case simply means files that may or may not be archives. Discovered via a `pacman -Sc` operation with delta files in the package cache directory, but can be triggered if any file is passed to `pacman -Ql` that isn't an archive, for instance, or if the sync database file is not an archive. Fix it up so we are more careful about calling archive_read_finish() only on archives that are valid and have not already been closed, and teach our archive open function to set the returned archive to NULL if we aren't going to be returning something valid anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/be_package.c')
-rw-r--r--lib/libalpm/be_package.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index fccbb10a..3188a2fe 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -380,7 +380,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
int ret, fd, config = 0;
struct archive *archive;
struct archive_entry *entry;
- alpm_pkg_t *newpkg = NULL;
+ alpm_pkg_t *newpkg;
struct stat st;
size_t files_count = 0, files_size = 0;
alpm_file_t *files = NULL;
@@ -394,7 +394,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
if(errno == ENOENT) {
handle->pm_errno = ALPM_ERR_PKG_NOT_FOUND;
}
- goto error;
+ return NULL;
}
newpkg = _alpm_pkg_new();