Date: Sat, 3 Sep 2011 10:10:34 -0600 (MDT) From: Ian Lepore <freebsd@damnhippie.dyndns.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/160430: [patch] Add __packed to libarchive cpio metadata structs Message-ID: <201109031610.p83GAYXB098629@revolution.hippie.lan> Resent-Message-ID: <201109031630.p83GUAKA028946@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 <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: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109031610.p83GAYXB098629>