summaryrefslogtreecommitdiffhomepage
path: root/libbb
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2005-11-12 11:04:11 +0000
committerRob Landley <rob@landley.net>2005-11-12 11:04:11 +0000
commit9033453c1849df49d2be39bca92c5b7cdb3234e3 (patch)
tree5f3087f3dbcc849b1ed7f881217d08c625fba1c4 /libbb
parent5412843e79d7738cf9ef3e06de288a4fa1f04295 (diff)
My last change to this file broke tar x. Sigh. (Trying to make sure we work
on file sizes between 2 and 4 gigs on 32 bit machines. For supporting >4 gigs, just use a 64 bit machine already...)
Diffstat (limited to 'libbb')
-rw-r--r--libbb/copyfd.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libbb/copyfd.c b/libbb/copyfd.c
index c1962e3c6..0b850884b 100644
--- a/libbb/copyfd.c
+++ b/libbb/copyfd.c
@@ -29,11 +29,13 @@ static ssize_t bb_full_fd_action(int src_fd, int dst_fd, size_t size)
RESERVE_CONFIG_BUFFER(buffer,BUFSIZ);
if (src_fd < 0) goto out;
-
while (!size || total < size)
{
- ssize_t wrote, xread = (size && size < BUFSIZ) ? size : BUFSIZ;
- xread = safe_read(src_fd, buffer, xread);
+ ssize_t wrote, xread;
+
+ xread = safe_read(src_fd, buffer,
+ (!size || size - total > BUFSIZ) ? BUFSIZ : size - total);
+
if (xread > 0) {
/* A -1 dst_fd means we need to fake it... */
wrote = (dst_fd < 0) ? xread : bb_full_write(dst_fd, buffer, xread);
@@ -42,7 +44,6 @@ static ssize_t bb_full_fd_action(int src_fd, int dst_fd, size_t size)
break;
}
total += wrote;
- size -= wrote;
} else if (xread < 0) {
bb_perror_msg(bb_msg_read_error);
break;