Reduce block size to 512 to prevent short read's when reading from a pipe
authorGlenn L McGrath <bug1@ihug.co.nz>
Tue, 12 Nov 2002 23:34:15 +0000 (23:34 -0000)
committerGlenn L McGrath <bug1@ihug.co.nz>
Tue, 12 Nov 2002 23:34:15 +0000 (23:34 -0000)
archival/libunarchive/archive_copy_file.c

index 22355ccd5da96384a8ee8da541bcb943b0a523ea..47d1a5216301ebc3e4c61d744316e578fa0ae17d 100644 (file)
 #include "libbb.h"
 #include "unarchive.h"
 
-/* Copy CHUNKSIZE bytes (or untill EOF if chunksize == -1)
- * from SRC_FILE to DST_FILE. */
 extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd)
 {
-       size_t size;
-       char buffer[BUFSIZ];
+       char buffer[512];
        off_t chunksize = archive_handle->file_header->size;
 
        while (chunksize != 0) {
-               if (chunksize > BUFSIZ) {
-                       size = BUFSIZ;
+               size_t size;
+               if (chunksize > 512) {
+                       size = 512;
                } else {
                        size = chunksize;
                }
@@ -38,10 +36,7 @@ extern void archive_copy_file(const archive_handle_t *archive_handle, const int
                if (write(dst_fd, buffer, size) != size) {
                        error_msg_and_die ("Short write");
                }
-
-               if (chunksize != -1) {
-                       chunksize -= size;
-               }
+               chunksize -= size;
        }
 
        return;