Date: Sat, 10 Feb 2007 16:15:16 -0800 From: Tim Kientzle <kientzle@freebsd.org> Cc: freebsd-bugs@freebsd.org Subject: Re: bin/108990: incorrect error handling in tar(1) for files that change size Message-ID: <45CE6014.2000500@freebsd.org> In-Reply-To: <200702092105.l19L5rUg025648@freefall.freebsd.org> References: <200702092105.l19L5rUg025648@freefall.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Ade Lovett wrote: > Synopsis: incorrect error handling in tar(1) for files that change size > > http://www.freebsd.org/cgi/query-pr.cgi?pr=108990 This is caused by a recent fix to libarchive, which no longer silently consumes data written past the end of the entry. I think the patch presented in the PR is acceptable, but I like this better. Any concerns? Index: write.c =================================================================== --- write.c (revision 120) +++ write.c (working copy) @@ -851,11 +851,19 @@ bytes_read = read(fd, buff, sizeof(buff)); while (bytes_read > 0) { bytes_written = archive_write_data(a, buff, bytes_read); - if (bytes_written <= 0) { + if (bytes_written < 0) { /* Write failed; this is bad */ bsdtar_warnc(bsdtar, 0, "%s", archive_error_string(a)); return (-1); } + if (bytes_written < bytes_read) { + /* Write was truncated; warn but continue. */ + bsdtar_warnc(bsdtar, 0, + "Truncated write; file may have grown while being archived."); + /* Make bsdtar return a final error. */ + bsdtar->return_value = 1; + return (0); + } bytes_read = read(fd, buff, sizeof(buff)); } return 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45CE6014.2000500>