From ilepore@damnhippie.dyndns.org  Sat Sep  3 16:23:46 2011
Return-Path: <ilepore@damnhippie.dyndns.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1D71E1065678
	for <freebsd-gnats-submit@freebsd.org>; Sat,  3 Sep 2011 16:23:46 +0000 (UTC)
	(envelope-from ilepore@damnhippie.dyndns.org)
Received: from qmta07.emeryville.ca.mail.comcast.net (qmta07.emeryville.ca.mail.comcast.net [76.96.30.64])
	by mx1.freebsd.org (Postfix) with ESMTP id 03D648FC0A
	for <freebsd-gnats-submit@freebsd.org>; Sat,  3 Sep 2011 16:23:45 +0000 (UTC)
Received: from omta14.emeryville.ca.mail.comcast.net ([76.96.30.60])
	by qmta07.emeryville.ca.mail.comcast.net with comcast
	id UG4d1h0081HpZEsA7GAX2v; Sat, 03 Sep 2011 16:10:31 +0000
Received: from damnhippie.dyndns.org ([24.8.232.202])
	by omta14.emeryville.ca.mail.comcast.net with comcast
	id UGAQ1h0034NgCEG8aGAQBo; Sat, 03 Sep 2011 16:10:24 +0000
Received: from revolution.hippie.lan (revolution.hippie.lan [172.22.42.240])
	by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id p83GAYes033930
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 3 Sep 2011 10:10:34 -0600 (MDT)
	(envelope-from ilepore@damnhippie.dyndns.org)
Received: (from ilepore@localhost)
	by revolution.hippie.lan (8.14.4/8.14.4/Submit) id p83GAYXB098629;
	Sat, 3 Sep 2011 10:10:34 -0600 (MDT)
	(envelope-from ilepore)
Message-Id: <201109031610.p83GAYXB098629@revolution.hippie.lan>
Date: Sat, 3 Sep 2011 10:10:34 -0600 (MDT)
From: Ian Lepore <freebsd@damnhippie.dyndns.org>
Reply-To: Ian Lepore <freebsd@damnhippie.dyndns.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] Add __packed to libarchive cpio metadata structs
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         160430
>Category:       kern
>Synopsis:       [libarchive] [patch] Add __packed to libarchive cpio metadata structs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kientzle
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep 03 16:30:10 UTC 2011
>Closed-Date:    
>Last-Modified:  Tue Sep 13 06:00:19 UTC 2011
>Originator:     Ian Lepore <freebsd@damnhippie.dyndns.org>
>Release:        FreeBSD 8.2-RC3 arm
>Organization:
none
>Environment:
FreeBSD dvb 8.2-RC3 FreeBSD 8.2-RC3 #49: Tue Feb 15 22:52:14 UTC 2011     root@revolution.hippie.lan:/usr/obj/arm/usr/src/sys/DVB  arm

>Description:
Some platforms (such as ARM) pad structures to a multiple of the platform's
"natural alignment".  This causes libarchive to go into an endless loop when
processing a cpio archive on such a platform.  Adding the __packed attribute
fixes the problem.

>How-To-Repeat:
Create a cpio archive ('newc' format) and attempt to list or extract it on ARM.

>Fix:
Patch attached.  This patch is well-tested; it has been in use at Symmetricom
since 2007 for our products that run on both ARM and x86 (32-bit) platforms.


--- diff.tmp begins here ---
--- archive_read_support_format_cpio.c.orig	2009-12-28 22:50:34.000000000 -0700
+++ archive_read_support_format_cpio.c	2011-09-03 09:50:07.000000000 -0600
@@ -54,7 +54,7 @@ struct cpio_bin_header {
 	unsigned char	c_mtime[4];
 	unsigned char	c_namesize[2];
 	unsigned char	c_filesize[4];
-};
+} __packed;	/* prevent struct size padding on arm */
 
 struct cpio_odc_header {
 	char	c_magic[6];
@@ -68,7 +68,7 @@ struct cpio_odc_header {
 	char	c_mtime[11];
 	char	c_namesize[6];
 	char	c_filesize[11];
-};
+} __packed;	/* prevent struct size padding on arm */
 
 struct cpio_newc_header {
 	char	c_magic[6];
@@ -85,7 +85,7 @@ struct cpio_newc_header {
 	char	c_rdevminor[8];
 	char	c_namesize[8];
 	char	c_crc[8];
-};
+} __packed;	/* prevent struct size padding on arm */
 
 struct links_entry {
         struct links_entry      *next;
--- diff.tmp ends here ---

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->kientzle 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Sep 4 06:25:27 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160430 
State-Changed-From-To: open->patched 
State-Changed-By: kientzle 
State-Changed-When: Tue Sep 13 05:53:13 UTC 2011 
State-Changed-Why:  
Patch committed to FreeBSD-CURRENT. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/160430: commit references a PR
Date: Tue, 13 Sep 2011 05:52:48 +0000 (UTC)

 Author: kientzle
 Date: Tue Sep 13 05:52:34 2011
 New Revision: 225525
 URL: http://svn.freebsd.org/changeset/base/225525
 
 Log:
   Fix cpio on ARM.
   
   PR:		bin/160430
   Submitted by:	Ian Lepore
   Approved by:	re (Kostik Belousov)
   MFC after:	7 days
 
 Modified:
   head/lib/libarchive/archive_read_support_format_cpio.c
   head/lib/libarchive/archive_write_set_format_cpio.c
 
 Modified: head/lib/libarchive/archive_read_support_format_cpio.c
 ==============================================================================
 --- head/lib/libarchive/archive_read_support_format_cpio.c	Tue Sep 13 02:46:22 2011	(r225524)
 +++ head/lib/libarchive/archive_read_support_format_cpio.c	Tue Sep 13 05:52:34 2011	(r225525)
 @@ -54,7 +54,7 @@ struct cpio_bin_header {
  	unsigned char	c_mtime[4];
  	unsigned char	c_namesize[2];
  	unsigned char	c_filesize[4];
 -};
 +} __packed;
  
  struct cpio_odc_header {
  	char	c_magic[6];
 @@ -68,7 +68,7 @@ struct cpio_odc_header {
  	char	c_mtime[11];
  	char	c_namesize[6];
  	char	c_filesize[11];
 -};
 +} __packed;
  
  struct cpio_newc_header {
  	char	c_magic[6];
 @@ -85,7 +85,7 @@ struct cpio_newc_header {
  	char	c_rdevminor[8];
  	char	c_namesize[8];
  	char	c_crc[8];
 -};
 +} __packed;
  
  struct links_entry {
          struct links_entry      *next;
 
 Modified: head/lib/libarchive/archive_write_set_format_cpio.c
 ==============================================================================
 --- head/lib/libarchive/archive_write_set_format_cpio.c	Tue Sep 13 02:46:22 2011	(r225524)
 +++ head/lib/libarchive/archive_write_set_format_cpio.c	Tue Sep 13 05:52:34 2011	(r225525)
 @@ -74,7 +74,7 @@ struct cpio_header {
  	char	c_mtime[11];
  	char	c_namesize[6];
  	char	c_filesize[11];
 -};
 +} __packed;
  
  /*
   * Set output format to 'cpio' format.
 _______________________________________________
 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"
 
>Unformatted:
