Reduce block size to 512 to prevent short read's when reading from a pipe
This commit is contained in:
parent
9af8a72f10
commit
034c371bb2
@ -19,17 +19,15 @@
|
|||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
#include "unarchive.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)
|
extern void archive_copy_file(const archive_handle_t *archive_handle, const int dst_fd)
|
||||||
{
|
{
|
||||||
size_t size;
|
char buffer[512];
|
||||||
char buffer[BUFSIZ];
|
|
||||||
off_t chunksize = archive_handle->file_header->size;
|
off_t chunksize = archive_handle->file_header->size;
|
||||||
|
|
||||||
while (chunksize != 0) {
|
while (chunksize != 0) {
|
||||||
if (chunksize > BUFSIZ) {
|
size_t size;
|
||||||
size = BUFSIZ;
|
if (chunksize > 512) {
|
||||||
|
size = 512;
|
||||||
} else {
|
} else {
|
||||||
size = chunksize;
|
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) {
|
if (write(dst_fd, buffer, size) != size) {
|
||||||
error_msg_and_die ("Short write");
|
error_msg_and_die ("Short write");
|
||||||
}
|
}
|
||||||
|
chunksize -= size;
|
||||||
if (chunksize != -1) {
|
|
||||||
chunksize -= size;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user