summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read_data_into_fd.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2006-11-12 23:45:40 +0000
committerkientzle <kientzle@FreeBSD.org>2006-11-12 23:45:40 +0000
commit7f111df0280b73ecaf3370e35a7e2dd7c92ba596 (patch)
tree80996be19c4adc221d2616262d6adf7a6169c3c4 /lib/libarchive/archive_read_data_into_fd.c
parente9b95a7ee6d5a20eda85e12eedc5f32db6142aa7 (diff)
downloadFreeBSD-src-7f111df0280b73ecaf3370e35a7e2dd7c92ba596.zip
FreeBSD-src-7f111df0280b73ecaf3370e35a7e2dd7c92ba596.tar.gz
Correctly handle writing very large blocks (>1M) through to a disk
file. This doesn't happen in normal use, because the file I/O and decompression layers only pass through smaller blocks. It can happen with custom read functions that block I/O in larger blocks.
Diffstat (limited to 'lib/libarchive/archive_read_data_into_fd.c')
-rw-r--r--lib/libarchive/archive_read_data_into_fd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libarchive/archive_read_data_into_fd.c b/lib/libarchive/archive_read_data_into_fd.c
index 579174e..509094b 100644
--- a/lib/libarchive/archive_read_data_into_fd.c
+++ b/lib/libarchive/archive_read_data_into_fd.c
@@ -63,6 +63,7 @@ archive_read_data_into_fd(struct archive *a, int fd)
while ((r = archive_read_data_block(a, &buff, &size, &offset)) ==
ARCHIVE_OK) {
+ const char *p = buff;
if (offset > output_offset) {
lseek(fd, offset - output_offset, SEEK_CUR);
output_offset = offset;
@@ -71,13 +72,14 @@ archive_read_data_into_fd(struct archive *a, int fd)
bytes_to_write = size;
if (bytes_to_write > MAX_WRITE)
bytes_to_write = MAX_WRITE;
- bytes_written = write(fd, buff, bytes_to_write);
+ bytes_written = write(fd, p, bytes_to_write);
if (bytes_written < 0) {
archive_set_error(a, errno, "Write error");
return (-1);
}
output_offset += bytes_written;
total_written += bytes_written;
+ p += bytes_written;
size -= bytes_written;
if (a->extract_progress != NULL)
(*a->extract_progress)(a->extract_progress_user_data);
OpenPOWER on IntegriCloud