Bug 147969 - cpio(1): cpio -i cannot extract tar archives, breaking release builds
Summary: cpio(1): cpio -i cannot extract tar archives, breaking release builds
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Xin LI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-18 14:00 UTC by Rudolf Polzer
Modified: 2010-06-22 00:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rudolf Polzer 2010-06-18 14:00:14 UTC
cpio (GNU cpio 2.8-FreeBSD) is unable to extract archives made by tar on 7-STABLE.

The bug had surfaced before in 8-CURRENT, but got fixed by instead replacing cpio by bsdcpio. See the mailing list discussion on:

http://kerneltrap.org/mailarchive/freebsd-current/2008/8/18/2980244/thread

This also e.g. surfaces when creating a release CD using release/Makefile, then trying to install from it - the installation routine will bail out on extracting the distributions.

Fix: 

Either: undo the upgrade to cpio 2.8
Or: use bsdcpio in 7-STABLE too
Or: change from_ascii() in contrib/cpio/src/copyin.c to accept trailing spaces
How-To-Repeat: # tar cvf - /var/empty | cpio -i -t
tar: Removing leading '/' from member names
a var/empty
cpio: Malformed number 000555 
cpio: Malformed number 00000000166 
cpio: Malformed number 11351324133 
cpio: Malformed number 000000 
cpio: Malformed number 000000 
4 blocks

(note: the numbers all have a trailing space, causing the "Malformed" output)
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2010-06-18 22:24:34 UTC
Responsible Changed
From-To: freebsd-bugs->kientzle

Tim, can you comment on this one please?  Thanks.
Comment 2 Xin LI freebsd_committer freebsd_triage 2010-06-21 23:54:58 UTC
State Changed
From-To: open->closed

Patch from Tim have been committed against 7-STABLE. 

Thanks for your submission! 


Comment 3 Xin LI freebsd_committer freebsd_triage 2010-06-21 23:54:58 UTC
Responsible Changed
From-To: kientzle->delphij

Take.  I have tested the patch so bugs are mine.
Comment 4 dfilter service freebsd_committer freebsd_triage 2010-06-21 23:54:58 UTC
Author: delphij
Date: Mon Jun 21 22:54:47 2010
New Revision: 209406
URL: http://svn.freebsd.org/changeset/base/209406

Log:
  Fix a regression when dealing with tar(1) format files
  introduced with GNU cpio 2.8.
  
  This is a direct commit against stable/7 because the
  code have been removed on -HEAD and stable/8.
  
  PR:		bin/147969
  Submitted by:	kientzle

Modified:
  stable/7/contrib/cpio/src/tar.c

Modified: stable/7/contrib/cpio/src/tar.c
==============================================================================
--- stable/7/contrib/cpio/src/tar.c	Mon Jun 21 22:20:52 2010	(r209405)
+++ stable/7/contrib/cpio/src/tar.c	Mon Jun 21 22:54:47 2010	(r209406)
@@ -32,6 +32,32 @@
 
 /* Stash the tar linkname in static storage.  */
 
+#undef FROM_OCTAL
+#define FROM_OCTAL(f)	tar_otoa(f, sizeof f)
+
+/* Convert the string of octal digits S into a number.
+ * Converted from GNU cpio 2.6 sources in
+ * order to fix tar breakage caused by using
+ * from_ascii.
+ */
+static unsigned long
+tar_otoa(const char *where, size_t digs)
+{
+  const char *s = where;
+  const char *end = s + digs;
+  unsigned long val = 0;
+
+  while (s < end && *s == ' ')
+    ++s;
+  while (s < end && *s >= '0' && *s <= '7')
+    val = 8 * val + *s++ - '0';
+  while (s < end && (*s == ' ' || *s == '\0'))
+    ++s;
+  if (s < end)
+	  error (0, 0, _("Malformed number %.*s"), digs, where);
+  return val;
+}
+
 static char *
 stash_tar_linkname (char *linkname)
 {
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"