Date: Sun, 24 Oct 2004 09:45:00 -0500 From: Ryan Sommers <ryans@gamersimpact.com> To: "Jason C. Wells" <jcw@highperformance.net> Cc: freebsd-current@freebsd.org Subject: Re: tar dumps core when appending to empty file Message-ID: <417BBFEC.1050100@gamersimpact.com> In-Reply-To: <6CCE035F71E8316B634212C5@[192.168.1.16]> References: <6CCE035F71E8316B634212C5@[192.168.1.16]>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------070001060407060906050207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Jason C. Wells wrote:
> What I am trying to do is:
>
> $ touch Makefiles.tar
> $ find . -name Makefile.orig -exec tar -r -f Makefiles.tar {} \;
>
> This causes tar to dump core as fast as find can find the specified
> files.
>
> So I tried:
>
> $ touch Makefiles.tar
> $ tar -r -f Makefiles.tar Makefile.inc1
>
> And also got a core dump. I then tried:
>
> $ tar -c -f Makefiles.tar Makefile.inc1
> $ find . -name Makefile.orig -exec tar -r -f Makefiles.tar {} \;
>
> This worked as I expected.
>
> I seem to have uncovered a bug. It seems reasonable to me to append
> to an empty file. Perhaps I am missing some sort of arcana here.
>
> Later,
> Jason C. Wells
The following patch appears to fix this:
Index: archive_read_support_format_tar.c
===================================================================
RCS file: /home/ncvs/src/lib/libarchive/archive_read_support_format_tar.c,v
retrieving revision 1.27
diff -u -r1.27 archive_read_support_format_tar.c
--- archive_read_support_format_tar.c 4 Sep 2004 21:49:42 -0000 1.27
+++ archive_read_support_format_tar.c 24 Oct 2004 14:42:04 -0000
@@ -270,7 +270,10 @@
bid++;
/* Now let's look at the actual header and see if it matches. */
- bytes_read = (a->compression_read_ahead)(a, &h, 512);
+ if (a->compression_read_ahead)
+ bytes_read = (a->compression_read_ahead)(a, &h, 512);
+ else
+ bytes_read = 0;
if (bytes_read < 0)
return (ARCHIVE_FATAL);
if (bytes_read == 0 && bid > 0) {
Tim, reply to me if you want me to PR'ify this for ya.
--
Ryan Sommers
ryans@gamersimpact.com
--------------070001060407060906050207
Content-Type: text/plain;
name="libarchive.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="libarchive.patch"
Index: archive_read_support_format_tar.c
===================================================================
RCS file: /home/ncvs/src/lib/libarchive/archive_read_support_format_tar.c,v
retrieving revision 1.27
diff -u -r1.27 archive_read_support_format_tar.c
--- archive_read_support_format_tar.c 4 Sep 2004 21:49:42 -0000 1.27
+++ archive_read_support_format_tar.c 24 Oct 2004 14:42:04 -0000
@@ -270,7 +270,10 @@
bid++;
/* Now let's look at the actual header and see if it matches. */
- bytes_read = (a->compression_read_ahead)(a, &h, 512);
+ if (a->compression_read_ahead)
+ bytes_read = (a->compression_read_ahead)(a, &h, 512);
+ else
+ bytes_read = 0;
if (bytes_read < 0)
return (ARCHIVE_FATAL);
if (bytes_read == 0 && bid > 0) {
--------------070001060407060906050207--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?417BBFEC.1050100>
