>Number:         160430
>Category:       kern
>Synopsis:       [patch] Add __packed to libarchive cpio metadata structs
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>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:
>Originator:     Ian Lepore <[email protected]>
>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     
[email protected]:/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:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to