summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index becbc60f..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);
}
@@ -749,7 +759,7 @@ int _alpm_pkg_cmp(const void *p1, const void *p2)
{
pmpkg_t *pkg1 = (pmpkg_t *)p1;
pmpkg_t *pkg2 = (pmpkg_t *)p2;
- return(strcmp(pkg1->name, pkg2->name));
+ return(strcoll(pkg1->name, pkg2->name));
}
/* Test for existence of a package in a alpm_list_t*