summaryrefslogtreecommitdiff
path: root/src/archive.c
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>2017-01-05 16:18:39 +0200
commitca368916e0333bf24cdcbdbe42130ec6a92c3f6e (patch)
tree090af10ba66dfbe40a98e6fd0a2c9b13d32dfa35 /src/archive.c
parentce72c8498e40b4330df4cc55bdeb62cf84c1494e (diff)
downloadapk-tools-ca368916e0333bf24cdcbdbe42130ec6a92c3f6e.tar.gz
apk-tools-ca368916e0333bf24cdcbdbe42130ec6a92c3f6e.tar.bz2
apk-tools-ca368916e0333bf24cdcbdbe42130ec6a92c3f6e.tar.xz
apk-tools-ca368916e0333bf24cdcbdbe42130ec6a92c3f6e.zip
tar: return correct error for short read of tar archive
Diffstat (limited to 'src/archive.c')
-rw-r--r--src/archive.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/archive.c b/src/archive.c
index e86a53a..07b33e2 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)