aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-04-27 10:51:38 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-04-27 10:51:38 +0000
commitd32ba7c18542a261f8d27aadd75c36bc79d6ac5e (patch)
tree6b1e7a75c9cbf9fde7e9dabd1508e84632f04d2c /libbb
parent1ed098819b56c5caa541a7d9046c67678a4df337 (diff)
downloadbusybox-w32-d32ba7c18542a261f8d27aadd75c36bc79d6ac5e.tar.gz
busybox-w32-d32ba7c18542a261f8d27aadd75c36bc79d6ac5e.tar.bz2
busybox-w32-d32ba7c18542a261f8d27aadd75c36bc79d6ac5e.zip
Correct errors preventing busybox tar from working properly,
fixing bug http://bugs.uclibc.org/view.php?id=231 git-svn-id: svn://busybox.net/trunk/busybox@10187 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/copyfd.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/libbb/copyfd.c b/libbb/copyfd.c
index baf99df51..27d65a419 100644
--- a/libbb/copyfd.c
+++ b/libbb/copyfd.c
@@ -39,7 +39,7 @@ static size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size2)
39 int status; 39 int status;
40 size_t xread, wrote, total, size = size2; 40 size_t xread, wrote, total, size = size2;
41 41
42 if ((dst_fd < 0) || (src_fd < 0)) { 42 if (src_fd < 0) {
43 return -1; 43 return -1;
44 } 44 }
45 45
@@ -56,11 +56,16 @@ static size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size2)
56 while (total < size) 56 while (total < size)
57 { 57 {
58 xread = BUFSIZ; 58 xread = BUFSIZ;
59 if (size < (wrote + BUFSIZ)) 59 if (size < (total + BUFSIZ))
60 xread = size - wrote; 60 xread = size - total;
61 xread = bb_full_read(src_fd, buffer, xread); 61 xread = bb_full_read(src_fd, buffer, xread);
62 if (xread > 0) { 62 if (xread > 0) {
63 wrote = bb_full_write(dst_fd, buffer, xread); 63 if (dst_fd < 0) {
64 /* A -1 dst_fd means we need to fake it... */
65 wrote = xread;
66 } else {
67 wrote = bb_full_write(dst_fd, buffer, xread);
68 }
64 if (wrote < xread) { 69 if (wrote < xread) {
65 bb_perror_msg(bb_msg_write_error); 70 bb_perror_msg(bb_msg_write_error);
66 break; 71 break;
@@ -78,8 +83,8 @@ static size_t bb_full_fd_action(int src_fd, int dst_fd, const size_t size2)
78 RELEASE_CONFIG_BUFFER(buffer); 83 RELEASE_CONFIG_BUFFER(buffer);
79 } 84 }
80 85
81 if (status == 0 || wrote) 86 if (status == 0 || total)
82 return wrote; 87 return total;
83 /* Some sortof error occured */ 88 /* Some sortof error occured */
84 return -1; 89 return -1;
85} 90}