diff options
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -138,7 +138,7 @@ size_t apk_istream_splice(void *stream, int fd, size_t size, bufsz = size; if (size > 128 * 1024) { - if (ftruncate(fd, size) == 0) + if (size != APK_SPLICE_ALL && ftruncate(fd, size) == 0) mmapbase = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (bufsz > 2*1024*1024) @@ -165,6 +165,8 @@ size_t apk_istream_splice(void *stream, int fd, size_t size, r = is->read(is, buf, togo); if (r < 0) goto err; + if (r == 0) + break; if (mmapbase == MAP_FAILED) { if (write(fd, buf, r) != r) { |