diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-12 23:34:15 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2002-11-12 23:34:15 +0000 |
commit | 034c371bb2ea7d66caf3ac29178ce941837edb9f (patch) | |
tree | b3f14b3d0e56486a016a6b16eace0432407ffd61 | |
parent | 9af8a72f10c97e3b06862203bc4b0d4e6d10e7f5 (diff) | |
download | busybox-w32-034c371bb2ea7d66caf3ac29178ce941837edb9f.tar.gz busybox-w32-034c371bb2ea7d66caf3ac29178ce941837edb9f.tar.bz2 busybox-w32-034c371bb2ea7d66caf3ac29178ce941837edb9f.zip |
Reduce block size to 512 to prevent short read's when reading from a pipe
-rw-r--r-- | archival/libunarchive/archive_copy_file.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/archival/libunarchive/archive_copy_file.c b/archival/libunarchive/archive_copy_file.c index 22355ccd5..47d1a5216 100644 --- a/archival/libunarchive/archive_copy_file.c +++ b/archival/libunarchive/archive_copy_file.c | |||
@@ -19,17 +19,15 @@ | |||
19 | #include "libbb.h" | 19 | #include "libbb.h" |
20 | #include "unarchive.h" | 20 | #include "unarchive.h" |
21 | 21 | ||
22 | /* Copy CHUNKSIZE bytes (or untill EOF if chunksize == -1) | ||
23 | * from SRC_FILE to DST_FILE. */ | ||
24 | extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd) | 22 | extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd) |
25 | { | 23 | { |
26 | size_t size; | 24 | char buffer[512]; |
27 | char buffer[BUFSIZ]; | ||
28 | off_t chunksize = archive_handle->file_header->size; | 25 | off_t chunksize = archive_handle->file_header->size; |
29 | 26 | ||
30 | while (chunksize != 0) { | 27 | while (chunksize != 0) { |
31 | if (chunksize > BUFSIZ) { | 28 | size_t size; |
32 | size = BUFSIZ; | 29 | if (chunksize > 512) { |
30 | size = 512; | ||
33 | } else { | 31 | } else { |
34 | size = chunksize; | 32 | size = chunksize; |
35 | } | 33 | } |
@@ -38,10 +36,7 @@ extern void archive_copy_file(const archive_handle_t *archive_handle, const int | |||
38 | if (write(dst_fd, buffer, size) != size) { | 36 | if (write(dst_fd, buffer, size) != size) { |
39 | error_msg_and_die ("Short write"); | 37 | error_msg_and_die ("Short write"); |
40 | } | 38 | } |
41 | 39 | chunksize -= size; | |
42 | if (chunksize != -1) { | ||
43 | chunksize -= size; | ||
44 | } | ||
45 | } | 40 | } |
46 | 41 | ||
47 | return; | 42 | return; |