summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-12-01 09:45:20 +0000
committerMike Frysinger <vapier@gentoo.org>2005-12-01 09:45:20 +0000
commit79f746dc3f3640d600e708e64061280be7f7fa38 (patch)
treefaef4da555a3c1e042c30937d966b91aad9d753c /app-arch/cpio
parentold (diff)
downloadgentoo-2-79f746dc3f3640d600e708e64061280be7f7fa38.tar.gz
gentoo-2-79f746dc3f3640d600e708e64061280be7f7fa38.tar.bz2
gentoo-2-79f746dc3f3640d600e708e64061280be7f7fa38.zip
Grab fixes from Fedora to resolve buffer overflow #112140.
(Portage version: 2.0.53_rc7)
Diffstat (limited to 'app-arch/cpio')
-rw-r--r--app-arch/cpio/ChangeLog9
-rw-r--r--app-arch/cpio/cpio-2.6-r5.ebuild51
-rw-r--r--app-arch/cpio/files/cpio-2.6-checksum.patch35
-rw-r--r--app-arch/cpio/files/cpio-2.6-warnings.patch174
-rw-r--r--app-arch/cpio/files/cpio-2.6-writeOutHeaderBufferOverflow.patch560
-rw-r--r--app-arch/cpio/files/digest-cpio-2.6-r51
6 files changed, 829 insertions, 1 deletions
diff --git a/app-arch/cpio/ChangeLog b/app-arch/cpio/ChangeLog
index b84d60183301..4031c5221993 100644
--- a/app-arch/cpio/ChangeLog
+++ b/app-arch/cpio/ChangeLog
@@ -1,6 +1,13 @@
# ChangeLog for app-arch/cpio
# Copyright 1999-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/app-arch/cpio/ChangeLog,v 1.37 2005/06/28 05:10:00 kumba Exp $
+# $Header: /var/cvsroot/gentoo-x86/app-arch/cpio/ChangeLog,v 1.38 2005/12/01 09:45:20 vapier Exp $
+
+*cpio-2.6-r5 (01 Dec 2005)
+
+ 01 Dec 2005; Mike Frysinger <vapier@gentoo.org>
+ +files/cpio-2.6-checksum.patch, +files/cpio-2.6-warnings.patch,
+ +files/cpio-2.6-writeOutHeaderBufferOverflow.patch, +cpio-2.6-r5.ebuild:
+ Grab fixes from Fedora to resolve buffer overflow #112140.
28 Jun 2005; Joshua Kinard <kumba@gentoo.org> cpio-2.6-r4.ebuild:
Marked stable on mips.
diff --git a/app-arch/cpio/cpio-2.6-r5.ebuild b/app-arch/cpio/cpio-2.6-r5.ebuild
new file mode 100644
index 000000000000..4fd9e7fba28f
--- /dev/null
+++ b/app-arch/cpio/cpio-2.6-r5.ebuild
@@ -0,0 +1,51 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/app-arch/cpio/cpio-2.6-r5.ebuild,v 1.1 2005/12/01 09:45:20 vapier Exp $
+
+inherit eutils
+
+DESCRIPTION="A file archival tool which can also read and write tar files"
+HOMEPAGE="http://www.gnu.org/software/cpio/cpio.html"
+SRC_URI="mirror://gnu/cpio/${P}.tar.bz2"
+
+LICENSE="GPL-2 LGPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc-macos ~ppc64 ~s390 ~sh ~sparc ~x86"
+IUSE="nls"
+
+DEPEND=""
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+ epatch "${FILESDIR}"/${PV}-rili-big-files.patch #68520
+ epatch "${FILESDIR}"/${PV}-isnumber.patch #74929
+ epatch "${FILESDIR}"/${PV}-umask.patch #79844
+ epatch "${FILESDIR}"/${PV}-lstat.patch #80246
+ epatch "${FILESDIR}"/${P}-chmodRaceC.patch #90619
+ epatch "${FILESDIR}"/${P}-gcc4-tests.patch #89123
+ epatch "${FILESDIR}"/${P}-dirTraversal.patch #90619
+ epatch "${FILESDIR}"/${P}-checksum.patch
+ epatch "${FILESDIR}"/${P}-warnings.patch
+ epatch "${FILESDIR}"/${P}-writeOutHeaderBufferOverflow.patch #112140
+}
+
+src_compile() {
+ # The configure script has a useless check for gethostname in
+ # libnsl ... but cpio doesn't utilize the lib/func anywhere,
+ # so let's force the lib to not be detected
+ ac_cv_lib_nsl_gethostname=no \
+ econf \
+ $(use_enable nls) \
+ --bindir=/bin \
+ --with-rmt=/usr/sbin/rmt \
+ || die
+ emake || die
+}
+
+src_install() {
+ make install DESTDIR="${D}" || die
+ dodoc ChangeLog NEWS README INSTALL
+ rm -f "${D}"/usr/share/man/man1/mt.1
+ rmdir "${D}"/usr/libexec || die
+}
diff --git a/app-arch/cpio/files/cpio-2.6-checksum.patch b/app-arch/cpio/files/cpio-2.6-checksum.patch
new file mode 100644
index 000000000000..0612e0e140ba
--- /dev/null
+++ b/app-arch/cpio/files/cpio-2.6-checksum.patch
@@ -0,0 +1,35 @@
+Ripped from Fedora
+
+--- cpio-2.6/src/extern.h.checksum 2005-10-26 11:17:11.000000000 +0200
++++ cpio-2.6/src/extern.h 2005-10-26 11:15:42.000000000 +0200
+@@ -66,7 +66,7 @@
+ extern int archive_des;
+ extern char *archive_name;
+ extern char *rsh_command_option;
+-extern unsigned long crc;
++extern unsigned int crc;
+ extern int delayed_seek_count;
+ #ifdef DEBUG_CPIO
+ extern int debug_flag;
+--- cpio-2.6/src/copyout.c.checksum 2005-10-26 11:17:11.000000000 +0200
++++ cpio-2.6/src/copyout.c 2005-10-26 11:20:01.000000000 +0200
+@@ -311,7 +311,7 @@
+ file_hdr->c_gid, file_hdr->c_nlink, file_hdr->c_mtime,
+ file_hdr->c_filesize, file_hdr->c_dev_maj, file_hdr->c_dev_min,
+ file_hdr->c_rdev_maj, file_hdr->c_rdev_min, file_hdr->c_namesize,
+- file_hdr->c_chksum);
++ file_hdr->c_chksum & 0xffffffff);
+ tape_buffered_write (ascii_header, out_des, 110L);
+
+ /* Write file name to output. */
+--- cpio-2.6/src/global.c.checksum 2005-10-26 11:17:11.000000000 +0200
++++ cpio-2.6/src/global.c 2005-10-26 11:15:29.000000000 +0200
+@@ -139,7 +139,7 @@
+ char *rsh_command_option = NULL;
+
+ /* CRC checksum. */
+-unsigned long crc;
++unsigned int crc;
+
+ /* Input and output buffers. */
+ char *input_buffer, *output_buffer;
diff --git a/app-arch/cpio/files/cpio-2.6-warnings.patch b/app-arch/cpio/files/cpio-2.6-warnings.patch
new file mode 100644
index 000000000000..1d76c1d52d66
--- /dev/null
+++ b/app-arch/cpio/files/cpio-2.6-warnings.patch
@@ -0,0 +1,174 @@
+Ripped from upstream
+
+2005-05-04 Dmitry V. Levin <ldv@altlinux.org>
+
+ Deal with compilation warnings generated by gcc compiler.
+
+ * src/copyin.c (list_file, copyin_regular_file, long_format,
+ process_copy_in): Fix format strings.
+ (create_defered_links_to_skipped): Remove unused variable
+ `link_res'.
+ (process_copy_in): Initialize tty_in, tty_out and rename_in.
+ * src/copyout.c (write_out_header): Initialize dev along with
+ rdev.
+ * src/tar.c (is_tar_filename_too_long): Remove unused variable `p';
+ * src/util.c: Include <safe-read.h> and <full-write.h>
+ (sparse_write): Add forward declaration. Initialize write_count
+ and cur_write_start variables.
+ (copy_files_disk_to_tape, copy_files_disk_to_disk): Add
+ parentheses around assignment.
+
+diff -uprk.orig cpio-2.6.orig/src/copyin.c cpio-2.6/src/copyin.c
+--- cpio-2.6.orig/src/copyin.c 2004-09-08 11:10:02 +0000
++++ cpio-2.6/src/copyin.c 2005-05-04 12:43:42 +0000
+@@ -176,7 +176,7 @@ list_file(struct new_cpio_header* file_h
+ #endif
+ if (crc != file_hdr->c_chksum)
+ {
+- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
++ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+ file_hdr->c_name, crc, file_hdr->c_chksum);
+ }
+ }
+@@ -307,7 +307,6 @@ create_defered_links_to_skipped (struct
+ int ino;
+ int maj;
+ int min;
+- int link_res;
+ if (file_hdr->c_filesize == 0)
+ {
+ /* The file doesn't have any data attached to it so we don't have
+@@ -541,7 +540,7 @@ copyin_regular_file (struct new_cpio_hea
+ if (archive_format == arf_crcascii)
+ {
+ if (crc != file_hdr->c_chksum)
+- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
++ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+ file_hdr->c_name, crc, file_hdr->c_chksum);
+ }
+ tape_skip_padding (in_file_des, file_hdr->c_filesize);
+@@ -563,7 +562,7 @@ copyin_regular_file (struct new_cpio_hea
+ if (archive_format == arf_crcascii)
+ {
+ if (crc != file_hdr->c_chksum)
+- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
++ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+ file_hdr->c_name, crc, file_hdr->c_chksum);
+ }
+
+@@ -897,7 +896,7 @@ long_format (struct new_cpio_header *fil
+ }
+ tbuf[16] = '\0';
+
+- printf ("%s %3u ", mbuf, file_hdr->c_nlink);
++ printf ("%s %3lu ", mbuf, file_hdr->c_nlink);
+
+ if (numeric_uid)
+ printf ("%-8u %-8u ", (unsigned int) file_hdr->c_uid,
+@@ -908,7 +907,7 @@ long_format (struct new_cpio_header *fil
+
+ if ((file_hdr->c_mode & CP_IFMT) == CP_IFCHR
+ || (file_hdr->c_mode & CP_IFMT) == CP_IFBLK)
+- printf ("%3u, %3u ", file_hdr->c_rdev_maj,
++ printf ("%3lu, %3lu ", file_hdr->c_rdev_maj,
+ file_hdr->c_rdev_min);
+ else
+ printf ("%8lu ", file_hdr->c_filesize);
+@@ -1342,9 +1341,9 @@ void
+ process_copy_in ()
+ {
+ char done = false; /* True if trailer reached. */
+- FILE *tty_in; /* Interactive file for rename option. */
+- FILE *tty_out; /* Interactive file for rename option. */
+- FILE *rename_in; /* Batch file for rename option. */
++ FILE *tty_in = NULL; /* Interactive file for rename option. */
++ FILE *tty_out = NULL; /* Interactive file for rename option. */
++ FILE *rename_in = NULL; /* Batch file for rename option. */
+ struct stat file_stat; /* Output file stat record. */
+ struct new_cpio_header file_hdr; /* Output header information. */
+ int in_file_des; /* Input file descriptor. */
+@@ -1530,7 +1529,7 @@ process_copy_in ()
+ tape_skip_padding (in_file_des, file_hdr.c_filesize);
+ if (crc != file_hdr.c_chksum)
+ {
+- error (0, 0, _("%s: checksum error (0x%x, should be 0x%x)"),
++ error (0, 0, _("%s: checksum error (0x%lx, should be 0x%lx)"),
+ file_hdr.c_name, crc, file_hdr.c_chksum);
+ }
+ /* Debian hack: -v and -V now work with --only-verify-crc.
+diff -uprk.orig cpio-2.6.orig/src/copyout.c cpio-2.6/src/copyout.c
+--- cpio-2.6.orig/src/copyout.c 2004-10-14 09:14:03 +0000
++++ cpio-2.6/src/copyout.c 2005-05-04 12:41:08 +0000
+@@ -346,7 +346,7 @@ write_out_header (struct new_cpio_header
+ #endif
+ file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
+ file_hdr->c_rdev_min);
+- rdev = 1;
++ dev = rdev = 1;
+ break;
+ default:
+ dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
+diff -uprk.orig cpio-2.6.orig/src/tar.c cpio-2.6/src/tar.c
+--- cpio-2.6.orig/src/tar.c 2004-10-14 09:33:41 +0000
++++ cpio-2.6/src/tar.c 2005-05-04 12:41:47 +0000
+@@ -473,7 +473,6 @@ is_tar_filename_too_long (char *name)
+ {
+ int whole_name_len;
+ int prefix_name_len;
+- char *p;
+
+ whole_name_len = strlen (name);
+ if (whole_name_len <= TARNAMESIZE)
+diff -uprk.orig cpio-2.6.orig/src/util.c cpio-2.6/src/util.c
+--- cpio-2.6.orig/src/util.c 2004-09-08 10:44:49 +0000
++++ cpio-2.6/src/util.c 2005-05-04 13:13:24 +0000
+@@ -24,6 +24,8 @@
+ #include "dstring.h"
+ #include "extern.h"
+ #include <rmt.h>
++#include <safe-read.h>
++#include <full-write.h>
+
+ #include <sys/ioctl.h>
+
+@@ -38,6 +40,8 @@
+ extern int errno;
+ #endif
+
++int sparse_write (int fildes, char *buf, unsigned int nbyte);
++
+ /* Write `output_size' bytes of `output_buffer' to file
+ descriptor OUT_DES and reset `output_size' and `out_buff'. */
+
+@@ -471,9 +475,9 @@ copy_files_disk_to_tape (int in_des, int
+ while (num_bytes > 0)
+ {
+ if (input_size == 0)
+- if (rc = disk_fill_input_buffer (in_des,
++ if ((rc = disk_fill_input_buffer (in_des,
+ num_bytes < DISK_IO_BLOCK_SIZE ?
+- num_bytes : DISK_IO_BLOCK_SIZE))
++ num_bytes : DISK_IO_BLOCK_SIZE)))
+ {
+ if (rc > 0)
+ error (0, 0, _("File %s shrunk by %ld bytes, padding with zeros"),
+@@ -517,7 +521,7 @@ copy_files_disk_to_disk (int in_des, int
+ while (num_bytes > 0)
+ {
+ if (input_size == 0)
+- if (rc = disk_fill_input_buffer (in_des, num_bytes))
++ if ((rc = disk_fill_input_buffer (in_des, num_bytes)))
+ {
+ if (rc > 0)
+ error (0, 0, _("File %s shrunk by %ld bytes, padding with zeros"),
+@@ -1157,8 +1161,8 @@ sparse_write (int fildes, char *buf, uns
+ int complete_block_count;
+ int leftover_bytes_count;
+ int seek_count;
+- int write_count;
+- char *cur_write_start;
++ int write_count = 0;
++ char *cur_write_start = buf;
+ int lseek_rc;
+ int write_rc;
+ int i;
diff --git a/app-arch/cpio/files/cpio-2.6-writeOutHeaderBufferOverflow.patch b/app-arch/cpio/files/cpio-2.6-writeOutHeaderBufferOverflow.patch
new file mode 100644
index 000000000000..95bd0e3cfbc2
--- /dev/null
+++ b/app-arch/cpio/files/cpio-2.6-writeOutHeaderBufferOverflow.patch
@@ -0,0 +1,560 @@
+Ripped from Fedora who ripped from upstream
+
+https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=172669
+http://bugs.gentoo.org/112140
+
+--- cpio-2.6/src/copyout.c.bufferOverflow 2005-11-23 16:51:56.000000000 -0500
++++ cpio-2.6/src/copyout.c 2005-11-23 17:00:38.000000000 -0500
+@@ -159,7 +159,7 @@
+ }
+
+ /* We are about to put a file into a newc or crc archive that is
+- multiply linked. We have already seen and defered all of the
++ multiply linked. We have already seen and deferred all of the
+ other links to the file but haven't written them into the archive.
+ Write the other links into the archive, and remove them from the
+ deferouts list. */
+@@ -231,8 +231,10 @@
+ file_hdr.c_filesize,
+ header->c_name);
+
+- write_out_header (&file_hdr, out_file_des);
+- copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, header->c_name);
++ if (write_out_header (&file_hdr, out_file_des))
++ return;
++ copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize,
++ header->c_name);
+ warn_if_file_changed(header->c_name, file_hdr.c_filesize, file_hdr.c_mtime);
+
+ if (archive_format == arf_tar || archive_format == arf_ustar)
+@@ -288,153 +290,311 @@
+ }
+ }
+
+-
+-/* Write out header FILE_HDR, including the file name, to file
+- descriptor OUT_DES. */
++/* FIXME: These two defines should be defined in paxutils */
++#define LG_8 3
++#define LG_16 4
++
++/* FIXME: to_ascii could be used instead of to_oct() and to_octal() from tar,
++ so it should be moved to paxutils too.
++ Allowed values for logbase are: 1 (binary), 2, 3 (octal), 4 (hex) */
++int
++to_ascii (char *where, uintmax_t v, size_t digits, unsigned logbase)
++{
++ static char codetab[] = "0123456789ABCDEF";
++ int i = digits;
++
++ do
++ {
++ where[--i] = codetab[(v & ((1 << logbase) - 1))];
++ v >>= logbase;
++ }
++ while (i);
++
++ return v != 0;
++}
++
++static void
++field_width_error (const char *filename, const char *fieldname)
++{
++ error (0, 0, _("%s: field width not sufficient for storing %s"),
++ filename, fieldname);
++}
++
++static void
++field_width_warning (const char *filename, const char *fieldname)
++{
++ if (warn_option & CPIO_WARN_TRUNCATE)
++ error (0, 0, _("%s: truncating %s"), filename, fieldname);
++}
+
+ void
+-write_out_header (struct new_cpio_header *file_hdr, int out_des)
++to_ascii_or_warn (char *where, uintmax_t n, size_t digits,
++ unsigned logbase,
++ const char *filename, const char *fieldname)
++{
++ if (to_ascii (where, n, digits, logbase))
++ field_width_warning (filename, fieldname);
++}
++
++int
++to_ascii_or_error (char *where, uintmax_t n, size_t digits,
++ unsigned logbase,
++ const char *filename, const char *fieldname)
+ {
+- if (archive_format == arf_newascii || archive_format == arf_crcascii)
++ if (to_ascii (where, n, digits, logbase))
+ {
+- char ascii_header[112];
+- char *magic_string;
++ field_width_error (filename, fieldname);
++ return 1;
++ }
++ return 0;
++}
+
+- if (archive_format == arf_crcascii)
+- magic_string = "070702";
+- else
+- magic_string = "070701";
+- sprintf (ascii_header,
+- "%6s%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx%08lx",
+- magic_string,
+- file_hdr->c_ino, file_hdr->c_mode, file_hdr->c_uid,
+- file_hdr->c_gid, file_hdr->c_nlink, file_hdr->c_mtime,
+- file_hdr->c_filesize, file_hdr->c_dev_maj, file_hdr->c_dev_min,
+- file_hdr->c_rdev_maj, file_hdr->c_rdev_min, file_hdr->c_namesize,
+- file_hdr->c_chksum & 0xffffffff);
+- tape_buffered_write (ascii_header, out_des, 110L);
+-
+- /* Write file name to output. */
+- tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
+- tape_pad_output (out_des, file_hdr->c_namesize + 110);
+- }
+- else if (archive_format == arf_oldascii || archive_format == arf_hpoldascii)
+- {
+- char ascii_header[78];
+- dev_t dev;
+- dev_t rdev;
++int
++write_out_new_ascii_header (const char *magic_string,
++ struct new_cpio_header *file_hdr, int out_des)
++{
++ char ascii_header[110];
++ char *p;
+
+- if (archive_format == arf_oldascii)
+- {
+- dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
+- rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
+- }
+- else
+- {
+- /* HP/UX cpio creates archives that look just like ordinary archives,
+- but for devices it sets major = 0, minor = 1, and puts the
+- actual major/minor number in the filesize field. */
+- switch (file_hdr->c_mode & CP_IFMT)
+- {
+- case CP_IFCHR:
+- case CP_IFBLK:
++ p = stpcpy (ascii_header, magic_string);
++ to_ascii_or_warn (p, file_hdr->c_ino, 8, LG_16,
++ file_hdr->c_name, _("inode number"));
++ p += 8;
++ to_ascii_or_warn (p, file_hdr->c_mode, 8, LG_16, file_hdr->c_name,
++ _("file mode"));
++ p += 8;
++ to_ascii_or_warn (p, file_hdr->c_uid, 8, LG_16, file_hdr->c_name,
++ _("uid"));
++ p += 8;
++ to_ascii_or_warn (p, file_hdr->c_gid, 8, LG_16, file_hdr->c_name,
++ _("gid"));
++ p += 8;
++ to_ascii_or_warn (p, file_hdr->c_nlink, 8, LG_16, file_hdr->c_name,
++ _("number of links"));
++ p += 8;
++ to_ascii_or_warn (p, file_hdr->c_mtime, 8, LG_16, file_hdr->c_name,
++ _("modification time"));
++ p += 8;
++ if (to_ascii_or_error (p, file_hdr->c_filesize, 8, LG_16, file_hdr->c_name,
++ _("file size")))
++ return 1;
++ p += 8;
++ if (to_ascii_or_error (p, file_hdr->c_dev_maj, 8, LG_16, file_hdr->c_name,
++ _("device major number")))
++ return 1;
++ p += 8;
++ if (to_ascii_or_error (p, file_hdr->c_dev_min, 8, LG_16, file_hdr->c_name,
++ _("device minor number")))
++ return 1;
++ p += 8;
++ if (to_ascii_or_error (p, file_hdr->c_rdev_maj, 8, LG_16, file_hdr->c_name,
++ _("rdev major")))
++ return 1;
++ p += 8;
++ if (to_ascii_or_error (p, file_hdr->c_rdev_min, 8, LG_16, file_hdr->c_name,
++ _("rdev minor")))
++ return 1;
++ p += 8;
++ if (to_ascii_or_error (p, file_hdr->c_namesize, 8, LG_16, file_hdr->c_name,
++ _("name size")))
++ return 1;
++ p += 8;
++ to_ascii (p, file_hdr->c_chksum & 0xffffffff, 8, LG_16);
++
++ tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
++
++ /* Write file name to output. */
++ tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
++ tape_pad_output (out_des, file_hdr->c_namesize + sizeof ascii_header);
++ return 0;
++}
++
++int
++write_out_old_ascii_header (dev_t dev, dev_t rdev,
++ struct new_cpio_header *file_hdr, int out_des)
++{
++ char ascii_header[76];
++ char *p = ascii_header;
++
++ to_ascii (p, file_hdr->c_magic, 6, LG_8);
++ p += 6;
++ to_ascii_or_warn (p, dev, 6, LG_8, file_hdr->c_name, _("device number"));
++ p += 6;
++ to_ascii_or_warn (p, file_hdr->c_ino, 6, LG_8, file_hdr->c_name,
++ _("inode number"));
++ p += 6;
++ to_ascii_or_warn (p, file_hdr->c_mode, 6, LG_8, file_hdr->c_name,
++ _("file mode"));
++ p += 6;
++ to_ascii_or_warn (p, file_hdr->c_uid, 6, LG_8, file_hdr->c_name, _("uid"));
++ p += 6;
++ to_ascii_or_warn (p, file_hdr->c_gid, 6, LG_8, file_hdr->c_name, _("gid"));
++ p += 6;
++ to_ascii_or_warn (p, file_hdr->c_nlink, 6, LG_8, file_hdr->c_name,
++ _("number of links"));
++ p += 6;
++ to_ascii_or_warn (p, rdev, 6, LG_8, file_hdr->c_name, _("rdev"));
++ p += 6;
++ to_ascii_or_warn (p, file_hdr->c_mtime, 11, LG_8, file_hdr->c_name,
++ _("modification time"));
++ p += 11;
++ if (to_ascii_or_error (p, file_hdr->c_namesize, 6, LG_8, file_hdr->c_name,
++ _("name size")))
++ return 1;
++ p += 6;
++ if (to_ascii_or_error (p, file_hdr->c_filesize, 11, LG_8, file_hdr->c_name,
++ _("file size")))
++ return 1;
++
++ tape_buffered_write (ascii_header, out_des, sizeof ascii_header);
++
++ /* Write file name to output. */
++ tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
++ return 0;
++}
++
++void
++hp_compute_dev (struct new_cpio_header *file_hdr, dev_t *pdev, dev_t *prdev)
++{
++ /* HP/UX cpio creates archives that look just like ordinary archives,
++ but for devices it sets major = 0, minor = 1, and puts the
++ actual major/minor number in the filesize field. */
++ switch (file_hdr->c_mode & CP_IFMT)
++ {
++ case CP_IFCHR:
++ case CP_IFBLK:
+ #ifdef CP_IFSOCK
+- case CP_IFSOCK:
++ case CP_IFSOCK:
+ #endif
+ #ifdef CP_IFIFO
+- case CP_IFIFO:
++ case CP_IFIFO:
+ #endif
+- file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
+- file_hdr->c_rdev_min);
+- dev = rdev = 1;
+- break;
+- default:
+- dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
+- rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
+- break;
+- }
+- }
++ file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
++ file_hdr->c_rdev_min);
++ *pdev = *prdev = makedev (0, 1);
++ break;
++
++ default:
++ *pdev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
++ *prdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
++ break;
++ }
++}
+
+- if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
+- error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
++int
++write_out_binary_header (dev_t rdev,
++ struct new_cpio_header *file_hdr, int out_des)
++{
++ struct old_cpio_header short_hdr;
+
+- /* Debian hack: The type of dev_t has changed in glibc. Fixed output
+- to ensure that a long int is passed to sprintf. This has been
+- reported to "bug-gnu-utils@prep.ai.mit.edu". (1998/5/26) -BEM */
+- sprintf (ascii_header,
+- "%06ho%06lo%06lo%06lo%06lo%06lo%06lo%06lo%011lo%06lo%011lo",
+- file_hdr->c_magic & 0xFFFF, (long) dev & 0xFFFF,
+- file_hdr->c_ino & 0xFFFF, file_hdr->c_mode & 0xFFFF,
+- file_hdr->c_uid & 0xFFFF, file_hdr->c_gid & 0xFFFF,
+- file_hdr->c_nlink & 0xFFFF, (long) rdev & 0xFFFF,
+- file_hdr->c_mtime, file_hdr->c_namesize & 0xFFFF,
+- file_hdr->c_filesize);
+- tape_buffered_write (ascii_header, out_des, 76L);
++ short_hdr.c_magic = 070707;
++ short_hdr.c_dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
+
+- /* Write file name to output. */
+- tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
+- }
+- else if (archive_format == arf_tar || archive_format == arf_ustar)
+- {
+- write_out_tar_header (file_hdr, out_des);
+- }
+- else
+- {
+- struct old_cpio_header short_hdr;
++ if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
++ error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
+
+- short_hdr.c_magic = 070707;
+- short_hdr.c_dev = makedev (file_hdr->c_dev_maj, file_hdr->c_dev_min);
++ short_hdr.c_ino = file_hdr->c_ino & 0xFFFF;
++ if (short_hdr.c_ino != file_hdr->c_ino)
++ field_width_warning (file_hdr->c_name, _("inode number"));
++
++ short_hdr.c_mode = file_hdr->c_mode & 0xFFFF;
++ if (short_hdr.c_mode != file_hdr->c_mode)
++ field_width_warning (file_hdr->c_name, _("file mode"));
++
++ short_hdr.c_uid = file_hdr->c_uid & 0xFFFF;
++ if (short_hdr.c_uid != file_hdr->c_uid)
++ field_width_warning (file_hdr->c_name, _("uid"));
++
++ short_hdr.c_gid = file_hdr->c_gid & 0xFFFF;
++ if (short_hdr.c_gid != file_hdr->c_gid)
++ field_width_warning (file_hdr->c_name, _("gid"));
++
++ short_hdr.c_nlink = file_hdr->c_nlink & 0xFFFF;
++ if (short_hdr.c_nlink != file_hdr->c_nlink)
++ field_width_warning (file_hdr->c_name, _("number of links"));
++
++ short_hdr.c_rdev = rdev;
++ short_hdr.c_mtimes[0] = file_hdr->c_mtime >> 16;
++ short_hdr.c_mtimes[1] = file_hdr->c_mtime & 0xFFFF;
++
++ short_hdr.c_namesize = file_hdr->c_namesize & 0xFFFF;
++ if (short_hdr.c_namesize != file_hdr->c_namesize)
++ {
++ field_width_error (file_hdr->c_name, _("name size"));
++ return 1;
++ }
++
++ short_hdr.c_filesize = file_hdr->c_filesize;
++ if (short_hdr.c_filesize != file_hdr->c_filesize)
++ {
++ field_width_error (file_hdr->c_name, _("file size"));
++ return 1;
++ }
++
++ short_hdr.c_filesizes[0] = file_hdr->c_filesize >> 16;
++ short_hdr.c_filesizes[1] = file_hdr->c_filesize & 0xFFFF;
+
+- if ((warn_option & CPIO_WARN_TRUNCATE) && (file_hdr->c_ino >> 16) != 0)
+- error (0, 0, _("%s: truncating inode number"), file_hdr->c_name);
++ /* Output the file header. */
++ tape_buffered_write ((char *) &short_hdr, out_des, 26);
+
+- short_hdr.c_ino = file_hdr->c_ino & 0xFFFF;
+- short_hdr.c_mode = file_hdr->c_mode & 0xFFFF;
+- short_hdr.c_uid = file_hdr->c_uid & 0xFFFF;
+- short_hdr.c_gid = file_hdr->c_gid & 0xFFFF;
+- short_hdr.c_nlink = file_hdr->c_nlink & 0xFFFF;
+- if (archive_format != arf_hpbinary)
+- short_hdr.c_rdev = makedev (file_hdr->c_rdev_maj, file_hdr->c_rdev_min);
+- else
+- {
+- switch (file_hdr->c_mode & CP_IFMT)
+- {
+- /* HP/UX cpio creates archives that look just like ordinary
+- archives, but for devices it sets major = 0, minor = 1, and
+- puts the actual major/minor number in the filesize field. */
+- case CP_IFCHR:
+- case CP_IFBLK:
+-#ifdef CP_IFSOCK
+- case CP_IFSOCK:
+-#endif
+-#ifdef CP_IFIFO
+- case CP_IFIFO:
+-#endif
+- file_hdr->c_filesize = makedev (file_hdr->c_rdev_maj,
+- file_hdr->c_rdev_min);
+- short_hdr.c_rdev = makedev (0, 1);
+- break;
+- default:
+- short_hdr.c_rdev = makedev (file_hdr->c_rdev_maj,
+- file_hdr->c_rdev_min);
+- break;
+- }
+- }
+- short_hdr.c_mtimes[0] = file_hdr->c_mtime >> 16;
+- short_hdr.c_mtimes[1] = file_hdr->c_mtime & 0xFFFF;
++ /* Write file name to output. */
++ tape_buffered_write (file_hdr->c_name, out_des, file_hdr->c_namesize);
+
+- short_hdr.c_namesize = file_hdr->c_namesize & 0xFFFF;
++ tape_pad_output (out_des, file_hdr->c_namesize + 26);
++ return 0;
++}
+
+- short_hdr.c_filesizes[0] = file_hdr->c_filesize >> 16;
+- short_hdr.c_filesizes[1] = file_hdr->c_filesize & 0xFFFF;
++
++/* Write out header FILE_HDR, including the file name, to file
++ descriptor OUT_DES. */
+
+- /* Output the file header. */
+- tape_buffered_write ((char *) &short_hdr, out_des, 26L);
++int
++write_out_header (struct new_cpio_header *file_hdr, int out_des)
++{
++ dev_t dev;
++ dev_t rdev;
++
++ switch (archive_format)
++ {
++ case arf_newascii:
++ return write_out_new_ascii_header ("070701", file_hdr, out_des);
++
++ case arf_crcascii:
++ return write_out_new_ascii_header ("070702", file_hdr, out_des);
++
++ case arf_oldascii:
++ return write_out_old_ascii_header (makedev (file_hdr->c_dev_maj,
++ file_hdr->c_dev_min),
++ makedev (file_hdr->c_rdev_maj,
++ file_hdr->c_rdev_min),
++ file_hdr, out_des);
++
++ case arf_hpoldascii:
++ hp_compute_dev (file_hdr, &dev, &rdev);
++ return write_out_old_ascii_header (dev, rdev, file_hdr, out_des);
++
++ case arf_tar:
++ case arf_ustar:
++ if (is_tar_filename_too_long (file_hdr->c_name))
++ {
++ error (0, 0, _("%s: file name too long"), file_hdr->c_name);
++ return 1;
++ }
++ write_out_tar_header (file_hdr, out_des); /* FIXME: No error checking */
++ return 0;
+
+- /* Write file name to output. */
+- tape_buffered_write (file_hdr->c_name, out_des, (long) file_hdr->c_namesize);
++ case arf_binary:
++ return write_out_binary_header (makedev (file_hdr->c_rdev_maj,
++ file_hdr->c_rdev_min),
++ file_hdr, out_des);
++
++ case arf_hpbinary:
++ hp_compute_dev (file_hdr, &dev, &rdev);
++ /* FIXME: dev ignored. Should it be? */
++ return write_out_binary_header (rdev, file_hdr, out_des);
+
+- tape_pad_output (out_des, file_hdr->c_namesize + 26);
++ default:
++ abort ();
+ }
+ }
+
+@@ -593,14 +753,7 @@
+ file_hdr.c_namesize = strlen (p) + 1;
+ }
+ #endif
+- if ((archive_format == arf_tar || archive_format == arf_ustar)
+- && is_tar_filename_too_long (file_hdr.c_name))
+- {
+- error (0, 0, _("%s: file name too long"),
+- file_hdr.c_name);
+- continue;
+- }
+-
++
+ /* Copy the named file to the output. */
+ switch (file_hdr.c_mode & CP_IFMT)
+ {
+@@ -613,7 +766,8 @@
+ file_hdr.c_dev_min)))
+ {
+ file_hdr.c_tar_linkname = otherfile;
+- write_out_header (&file_hdr, out_file_des);
++ if (write_out_header (&file_hdr, out_file_des))
++ continue;
+ break;
+ }
+ }
+@@ -643,7 +797,8 @@
+ file_hdr.c_filesize,
+ input_name.ds_string);
+
+- write_out_header (&file_hdr, out_file_des);
++ if (write_out_header (&file_hdr, out_file_des))
++ continue;
+ copy_files_disk_to_tape (in_file_des, out_file_des, file_hdr.c_filesize, input_name.ds_string);
+ warn_if_file_changed(input_name.ds_string, file_hdr.c_filesize,
+ file_hdr.c_mtime);
+@@ -673,7 +828,8 @@
+
+ case CP_IFDIR:
+ file_hdr.c_filesize = 0;
+- write_out_header (&file_hdr, out_file_des);
++ if (write_out_header (&file_hdr, out_file_des))
++ continue;
+ break;
+
+ case CP_IFCHR:
+@@ -702,14 +858,16 @@
+ file_hdr.c_mode = (file_stat.st_mode & 07777);
+ file_hdr.c_mode |= CP_IFREG;
+ file_hdr.c_tar_linkname = otherfile;
+- write_out_header (&file_hdr, out_file_des);
++ if (write_out_header (&file_hdr, out_file_des))
++ continue;
+ break;
+ }
+ add_inode (file_hdr.c_ino, file_hdr.c_name,
+ file_hdr.c_dev_maj, file_hdr.c_dev_min);
+ }
+ file_hdr.c_filesize = 0;
+- write_out_header (&file_hdr, out_file_des);
++ if (write_out_header (&file_hdr, out_file_des))
++ continue;
+ break;
+
+ #ifdef CP_IFLNK
+@@ -738,12 +896,14 @@
+ {
+ link_name[link_size] = '\0';
+ file_hdr.c_tar_linkname = link_name;
+- write_out_header (&file_hdr, out_file_des);
++ if (write_out_header (&file_hdr, out_file_des))
++ continue;
+ }
+ }
+ else
+ {
+- write_out_header (&file_hdr, out_file_des);
++ if (write_out_header (&file_hdr, out_file_des))
++ continue;
+ tape_buffered_write (link_name, out_file_des, link_size);
+ tape_pad_output (out_file_des, link_size);
+ }
+--- cpio-2.6/src/extern.h.bufferOverflow 2005-11-23 16:51:56.000000000 -0500
++++ cpio-2.6/src/extern.h 2005-11-23 16:51:56.000000000 -0500
+@@ -112,7 +112,7 @@
+ void print_name_with_quoting P_((char *p));
+
+ /* copyout.c */
+-void write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
++int write_out_header P_((struct new_cpio_header *file_hdr, int out_des));
+ void process_copy_out P_((void));
+
+ /* copypass.c */
diff --git a/app-arch/cpio/files/digest-cpio-2.6-r5 b/app-arch/cpio/files/digest-cpio-2.6-r5
new file mode 100644
index 000000000000..822d7f4e46f3
--- /dev/null
+++ b/app-arch/cpio/files/digest-cpio-2.6-r5
@@ -0,0 +1 @@
+MD5 25e0e8725bc60ed3460c9cde92752674 cpio-2.6.tar.bz2 448452