Fix segfaults on opening invalid archive files
commit7f51ba99ae6db204d69ce271cd5cc4e959135738
authorDan McGee <dan@archlinux.org>
Sun, 8 Jan 2012 17:53:22 +0000 (8 11:53 -0600)
committerDan McGee <dan@archlinux.org>
Sun, 8 Jan 2012 17:53:22 +0000 (8 11:53 -0600)
treee8e1739373b18cb17222238107fb7285dd50fdaa
parent6f9ab22fd8c446eab58f1a6bbef7cb984575ef8a
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>
lib/libalpm/be_package.c
lib/libalpm/be_sync.c
lib/libalpm/util.c