From 61bc62e9424b987ed3e19e77e0889ae5d7685809 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sat, 28 Aug 2004 03:13:05 +0000 Subject: [PATCH] Recognize and skip 'x' and 'g' pax extension entries. In particular, this avoids the creation of "PaxHeader" dirs when unpacking pax-format tar archives such as those written by bsdtar. MFC after: 3 days --- contrib/cpio/tar.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/contrib/cpio/tar.c b/contrib/cpio/tar.c index 333ec20efd5b..832ad4f37868 100644 --- a/contrib/cpio/tar.c +++ b/contrib/cpio/tar.c @@ -15,6 +15,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* $FreeBSD$ */ + #include #include #include @@ -343,6 +345,19 @@ read_in_tar_header (file_hdr, in_des) else file_hdr->c_mode |= CP_IFREG; break; + case 'x': case 'g': + /* Ignore pax 'x' and 'g' extension entries. */ + /* Skip body of this entry. */ + while (file_hdr->c_filesize > 0) { + tape_buffered_read(((char *) &tar_rec), in_des, TARRECORDSIZE); + if (file_hdr->c_filesize > TARRECORDSIZE) + file_hdr->c_filesize -= TARRECORDSIZE; + else + file_hdr->c_filesize = 0; + } + /* Read next header and return that instead. */ + read_in_tar_header(file_hdr, in_des); + break; } break; }