diff options
author | Timo Teräs <timo.teras@iki.fi> | 2013-06-17 13:51:49 +0300 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2013-06-17 14:23:14 +0300 |
commit | dbb642206d2ef73c5428a04cb10bb27e7cdd3b29 (patch) | |
tree | a1844d9b309d3d46ab14317ca5c42b9905222452 /src/io.c | |
parent | f79e3946a40bf6beb2a38050a866c0fb1ed4bcf4 (diff) | |
download | apk-tools-dbb642206d2ef73c5428a04cb10bb27e7cdd3b29.tar.gz apk-tools-dbb642206d2ef73c5428a04cb10bb27e7cdd3b29.tar.bz2 apk-tools-dbb642206d2ef73c5428a04cb10bb27e7cdd3b29.tar.xz apk-tools-dbb642206d2ef73c5428a04cb10bb27e7cdd3b29.zip |
io: fix splice for copying unknown lengths
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) { |