diff options
author | kientzle <kientzle@FreeBSD.org> | 2009-12-10 06:42:28 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2009-12-10 06:42:28 +0000 |
commit | 4cc001f60b95737eaf4334d899e190f9dbee86c9 (patch) | |
tree | 60541dbca9aa7005fe992e2ae332665bcc4f9b99 /lib | |
parent | 798466d5795a04d7f7b6886898aa8aaf1910085a (diff) | |
download | FreeBSD-src-4cc001f60b95737eaf4334d899e190f9dbee86c9.zip FreeBSD-src-4cc001f60b95737eaf4334d899e190f9dbee86c9.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libarchive/archive_read_support_format_cpio.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libarchive/archive_read_support_format_cpio.c b/lib/libarchive/archive_read_support_format_cpio.c index 3bf05ce..f16c6cb 100644 --- a/lib/libarchive/archive_read_support_format_cpio.c +++ b/lib/libarchive/archive_read_support_format_cpio.c @@ -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, struct archive_entry *entry) dev_t dev; ino_t ino; + if (archive_entry_nlink(entry) <= 1) + return; + dev = archive_entry_dev(entry); ino = archive_entry_ino(entry); |