From owner-freebsd-current@FreeBSD.ORG Sun Oct 24 14:44:56 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D747F16A4CE for ; Sun, 24 Oct 2004 14:44:56 +0000 (GMT) Received: from node15.coopprint.com (node15.cooperativeprinting.com [208.4.77.15]) by mx1.FreeBSD.org (Postfix) with SMTP id 4509643D4C for ; Sun, 24 Oct 2004 14:44:56 +0000 (GMT) (envelope-from ryans@gamersimpact.com) Received: (qmail 76794 invoked by uid 0); 24 Oct 2004 14:43:35 -0000 Received: from unknown (HELO ?192.168.0.5?) (63.231.165.205) by node15.coopprint.com with SMTP; 24 Oct 2004 14:43:35 -0000 Message-ID: <417BBFEC.1050100@gamersimpact.com> Date: Sun, 24 Oct 2004 09:45:00 -0500 From: Ryan Sommers User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Jason C. Wells" References: <6CCE035F71E8316B634212C5@[192.168.1.16]> In-Reply-To: <6CCE035F71E8316B634212C5@[192.168.1.16]> Content-Type: multipart/mixed; boundary="------------070001060407060906050207" cc: Tim Kientzle cc: freebsd-current@freebsd.org Subject: Re: tar dumps core when appending to empty file X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Oct 2004 14:44:57 -0000 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--