Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Jul 2017 09:28:43 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r321775 - stable/10/usr.bin/ar
Message-ID:  <201707310928.v6V9Sh8X048772@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Mon Jul 31 09:28:43 2017
New Revision: 321775
URL: https://svnweb.freebsd.org/changeset/base/321775

Log:
  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

Modified:
  stable/10/usr.bin/ar/write.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/ar/write.c
==============================================================================
--- stable/10/usr.bin/ar/write.c	Mon Jul 31 09:18:53 2017	(r321774)
+++ stable/10/usr.bin/ar/write.c	Mon Jul 31 09:28:43 2017	(r321775)
@@ -581,10 +581,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;
+	}
 }
 
 /*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707310928.v6V9Sh8X048772>