summaryrefslogtreecommitdiff
path: root/src/archive.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-22 14:56:27 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-22 14:56:27 +0300
commit93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8 (patch)
tree84261f2a088ff9bf53a6db30669602f159a01b00 /src/archive.c
parent0a7991f70dcfe9f8e05f6a4a4a59af21be878915 (diff)
downloadapk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.tar.gz
apk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.tar.bz2
apk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.tar.xz
apk-tools-93f0b3524c1263b99a1a4bf718c27e6ad7b6aea8.zip
various: more informative error messages
Diffstat (limited to 'src/archive.c')
-rw-r--r--src/archive.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/archive.c b/src/archive.c
index 2cfb3e6..3a430b2 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -81,27 +81,28 @@ struct apk_tar_entry_istream {
struct apk_checksum *csum;
};
-static size_t tar_entry_read(void *stream, void *ptr, size_t size)
+static ssize_t tar_entry_read(void *stream, void *ptr, size_t size)
{
struct apk_tar_entry_istream *teis =
container_of(stream, struct apk_tar_entry_istream, is);
+ ssize_t r;
if (size > teis->bytes_left)
size = teis->bytes_left;
- size = teis->tar_is->read(teis->tar_is, ptr, size);
- if (size < 0)
- return -1;
+ r = teis->tar_is->read(teis->tar_is, ptr, size);
+ if (r < 0)
+ return r;
- teis->bytes_left -= size;
+ teis->bytes_left -= r;
if (teis->csum == NULL)
- return size;
+ return r;
- EVP_DigestUpdate(&teis->mdctx, ptr, size);
+ EVP_DigestUpdate(&teis->mdctx, ptr, r);
if (teis->bytes_left == 0) {
teis->csum->type = EVP_MD_CTX_size(&teis->mdctx);
EVP_DigestFinal_ex(&teis->mdctx, teis->csum->data, NULL);
}
- return size;
+ return r;
}
static void tar_entry_close(void *stream)
@@ -221,13 +222,13 @@ int apk_tar_parse(struct apk_istream *is, apk_archive_entry_parser parser,
if (r == 512) {
while ((r = is->read(is, &buf, 512)) == 512) {
if (buf.name[0] != 0)
- return -1;
+ return -EBADMSG;
}
}
/* Check that there was no partial record */
if (r > 0)
- r = -1;
+ r = -EBADMSG;
return r;