summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2017-01-05 16:14:44 +0200
committerTimo Teräs <timo.teras@iki.fi>2018-09-06 14:35:52 +0300
commite48f441ed53744d24b3f745efccb8134e5abedb1 (patch)
tree57618c48fa52aec9a000ea184f7fc9ce41dbf05d
parent483f64ea1f6e5ebf37f7a75581b9d8b5465cf4a3 (diff)
downloadapk-tools-e48f441ed53744d24b3f745efccb8134e5abedb1.tar.bz2
apk-tools-e48f441ed53744d24b3f745efccb8134e5abedb1.tar.xz
tar: return correct error for short read of tar archive
(cherry picked from commit ca368916e0333bf24cdcbdbe42130ec6a92c3f6e)
-rw-r--r--src/archive.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/archive.c b/src/archive.c
index a1a4052..f84e440 100644
--- a/src/archive.c
+++ b/src/archive.c
@@ -105,12 +105,17 @@ static ssize_t tar_entry_read(void *stream, void *ptr, size_t size)
if (size > teis->bytes_left)
size = teis->bytes_left;
- if (size == 0)
- return 0;
+ if (size == 0)
+ return 0;
r = teis->tar_is->read(teis->tar_is, ptr, size);
- if (r < 0)
+ if (r <= 0) {
+ /* If inner stream returned zero (end-of-stream), we
+ * are getting short read, because tar header indicated
+ * more was to be expected. */
+ if (r == 0) return -ECONNABORTED;
return r;
+ }
teis->bytes_left -= r;
if (teis->csum == NULL)