svn commit: r200351 - head/lib/libarchive

Tim Kientzle kientzle at FreeBSD.org
Wed Dec 9 22:42:28 PST 2009


Author: kientzle
Date: Thu Dec 10 06:42:28 2009
New Revision: 200351
URL: http://svn.freebsd.org/changeset/base/200351

Log:
  Merge two cpio fixes from libarchive.googlecode.com:
   1) Avoid an infinite loop in the header resync for certain malformed
      archives.
   2) Don't try to match hardlinks if the nlinks count is < 2.   This
      reduces the likelihood of a false hardlink match due to ino truncation.
  
  MFC after:	7 days

Modified:
  head/lib/libarchive/archive_read_support_format_cpio.c

Modified: head/lib/libarchive/archive_read_support_format_cpio.c
==============================================================================
--- head/lib/libarchive/archive_read_support_format_cpio.c	Thu Dec 10 06:24:16 2009	(r200350)
+++ head/lib/libarchive/archive_read_support_format_cpio.c	Thu Dec 10 06:42:28 2009	(r200351)
@@ -356,7 +356,7 @@ find_newc_header(struct archive_read *a)
 		 * Scan ahead until we find something that looks
 		 * like an odc header.
 		 */
-		while (p + sizeof(struct cpio_newc_header) < q) {
+		while (p + sizeof(struct cpio_newc_header) <= q) {
 			switch (p[5]) {
 			case '1':
 			case '2':
@@ -490,7 +490,7 @@ find_odc_header(struct archive_read *a)
 		 * Scan ahead until we find something that looks
 		 * like an odc header.
 		 */
-		while (p + sizeof(struct cpio_odc_header) < q) {
+		while (p + sizeof(struct cpio_odc_header) <= q) {
 			switch (p[5]) {
 			case '7':
 				if (memcmp("070707", p, 6) == 0
@@ -731,6 +731,9 @@ record_hardlink(struct cpio *cpio, struc
 	dev_t dev;
 	ino_t ino;
 
+	if (archive_entry_nlink(entry) <= 1)
+		return;
+
 	dev = archive_entry_dev(entry);
 	ino = archive_entry_ino(entry);
 


More information about the svn-src-head mailing list