diff options
author | Sebastian Nowicki <sebnow@gmail.com> | 2010-09-12 22:01:14 +0800 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-09-27 10:53:48 -0500 |
commit | 821ff061b181d009e0633e5ab12aec7aa608884a (patch) | |
tree | 25299e8d5deec49b8a934b0ff526857a76626ac6 /lib | |
parent | f7895cc188e221c064aac475908a09d2f50b8d38 (diff) | |
download | pacman-821ff061b181d009e0633e5ab12aec7aa608884a.tar.xz |
Set pm_errno on libarchive errors while reading
Signed-off-by: Sebastian Nowicki <sebnow@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/package.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index 0060300c..717d32ce 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -488,12 +488,15 @@ void SYMEXPORT *alpm_pkg_changelog_open(pmpkg_t *pkg) /** * Read data from an open changelog 'file stream'. Similar to fread in - * functionality, this function takes a buffer and amount of data to read. + * functionality, this function takes a buffer and amount of data to read. If an + * error occurs pm_errno will be set. + * * @param ptr a buffer to fill with raw changelog data * @param size the size of the buffer * @param pkg the package that the changelog is being read from * @param fp a 'file stream' to the package changelog - * @return the number of characters read, or 0 if there is no more data + * @return the number of characters read, or 0 if there is no more data or an + * error occurred. */ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size, const pmpkg_t *pkg, const void *fp) @@ -502,7 +505,14 @@ size_t SYMEXPORT alpm_pkg_changelog_read(void *ptr, size_t size, if(pkg->origin == PKG_FROM_CACHE) { ret = fread(ptr, 1, size, (FILE*)fp); } else if(pkg->origin == PKG_FROM_FILE) { - ret = archive_read_data((struct archive*)fp, ptr, size); + ssize_t sret = archive_read_data((struct archive*)fp, ptr, size); + /* Report error (negative values) */ + if(sret < 0) { + pm_errno = PM_ERR_LIBARCHIVE; + ret = 0; + } else { + ret = (size_t)sret; + } } return(ret); } |