diff options
author | emaste <emaste@FreeBSD.org> | 2017-07-31 08:19:44 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2017-07-31 08:19:44 +0000 |
commit | 258c375b290682e514751928336d1f15c41f5078 (patch) | |
tree | e4bcbb95e1ecc80c4cf95aaaf873b9abe0f783ea /usr.bin | |
parent | b4b44bfbb930c9e460f9b6334691071d0b18f2ef (diff) | |
download | FreeBSD-src-258c375b290682e514751928336d1f15c41f5078.zip FreeBSD-src-258c375b290682e514751928336d1f15c41f5078.tar.gz |
MFC r321436: ar: handle partial writes from archive_write_data
libarchive may limit a single archive_write_data call to handling
0x7fffffff bytes. Add a loop to handle partial writes.
Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ar/write.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/ar/write.c b/usr.bin/ar/write.c index 96f4199..49f539b 100644 --- a/usr.bin/ar/write.c +++ b/usr.bin/ar/write.c @@ -586,10 +586,17 @@ prefault_buffer(const char *buf, size_t s) static void write_data(struct bsdar *bsdar, struct archive *a, const void *buf, size_t s) { + ssize_t written; + prefault_buffer(buf, s); - if (archive_write_data(a, buf, s) != (ssize_t)s) - bsdar_errc(bsdar, EX_SOFTWARE, 0, "%s", - archive_error_string(a)); + while (s > 0) { + written = archive_write_data(a, buf, s); + if (written < 0) + bsdar_errc(bsdar, EX_SOFTWARE, 0, "%s", + archive_error_string(a)); + buf = (const char *)buf + written; + s -= written; + } } /* |