Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jun 2010 22:10:42 -0700
From:      Tim Kientzle <kientzle@freebsd.org>
To:        Xin LI <delphij@freebsd.org>
Cc:        svn-src-stable-7@freebsd.org
Subject:   Re: svn commit: r209311 - stable/7/contrib/cpio/src
Message-ID:  <4C1C5152.3020802@freebsd.org>
In-Reply-To: <201006181815.o5IIFeuV033961@svn.freebsd.org>
References:  <201006181815.o5IIFeuV033961@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040003050706090704020008
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Could you also take a look at bin/147969:

http://www.freebsd.org/cgi/query-pr.cgi?pr=147969

I looked at it and came up with a tentative fix
(attached), but haven't had a chance to test it yet.

Cheers,

Tim

Xin LI wrote:
> Author: delphij
> Date: Fri Jun 18 18:15:40 2010
> New Revision: 209311
> URL: http://svn.freebsd.org/changeset/base/209311
> 
> Log:
>   Fix two regressions introduced by GNU cpio 2.8 import:
>   
>   cpio/src/copyout.c:
>   	Old behavior is not to strip leading / from symbol link target.
>   
>   	By default cpio will replace the symbol link rather than following
>   	it so this should not be a risk.
>   
>   cpio/src/util.c:
>   	Zero out rdev_{maj,min} for files where they are not applicable.
>   
>   This is a direct commit since GNU cpio has been removed from -HEAD.
>   
>   Sorry for the breakage...
>   
>   Reported by:	sbruno
> 
> Modified:
>   stable/7/contrib/cpio/src/copyout.c
>   stable/7/contrib/cpio/src/util.c
> 
> Modified: stable/7/contrib/cpio/src/copyout.c
> ==============================================================================
> --- stable/7/contrib/cpio/src/copyout.c	Fri Jun 18 17:39:56 2010	(r209310)
> +++ stable/7/contrib/cpio/src/copyout.c	Fri Jun 18 18:15:40 2010	(r209311)
> @@ -836,9 +836,6 @@ process_copy_out ()
>  		    continue;
>  		  }
>  		link_name[link_size] = 0;
> -		cpio_safer_name_suffix (link_name, false,
> -					abs_paths_flag, true);
> -		link_size = strlen (link_name);
>  		file_hdr.c_filesize = link_size;
>  		if (archive_format == arf_tar || archive_format == arf_ustar)
>  		  {
> 
> Modified: stable/7/contrib/cpio/src/util.c
> ==============================================================================
> --- stable/7/contrib/cpio/src/util.c	Fri Jun 18 17:39:56 2010	(r209310)
> +++ stable/7/contrib/cpio/src/util.c	Fri Jun 18 18:15:40 2010	(r209311)
> @@ -1252,8 +1252,25 @@ stat_to_cpio (struct cpio_file_stat *hdr
>    hdr->c_uid = CPIO_UID (st->st_uid);
>    hdr->c_gid = CPIO_GID (st->st_gid);
>    hdr->c_nlink = st->st_nlink;
> -  hdr->c_rdev_maj = major (st->st_rdev);
> -  hdr->c_rdev_min = minor (st->st_rdev);
> +
> +  switch (hdr->c_mode & CP_IFMT)
> +  {
> +    case CP_IFBLK:
> +    case CP_IFCHR:
> +#ifdef CP_IFIFO
> +    case CP_IFIFO:
> +#endif
> +#ifdef CP_IFSOCK
> +    case CP_IFSOCK:
> +#endif
> +      hdr->c_rdev_maj = major (st->st_rdev);
> +      hdr->c_rdev_min = minor (st->st_rdev);
> +      break;
> +    default:
> +      hdr->c_rdev_maj = 0;
> +      hdr->c_rdev_min = 0;
> +      break;
> +  }
>    hdr->c_mtime = st->st_mtime;
>    hdr->c_filesize = st->st_size;
>    hdr->c_chksum = 0;
> 
> 

--------------040003050706090704020008
Content-Type: text/x-patch;
 name="gnu-cpio.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="gnu-cpio.patch"

Index: contrib/cpio/src/tar.c
===================================================================
--- contrib/cpio/src/tar.c	(revision 209324)
+++ contrib/cpio/src/tar.c	(working copy)
@@ -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)
 {

--------------040003050706090704020008--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C1C5152.3020802>