tar dumps core when appending to empty file
Ryan Sommers
ryans at gamersimpact.com
Sun Oct 24 07:44:57 PDT 2004
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 at gamersimpact.com
-------------- next part --------------
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) {
More information about the freebsd-current
mailing list