Commit Graph

59 Commits

Author SHA1 Message Date
Martin Matuska
9f3de9e26d MFV r313071:
Sync libarchive with vendor

Vendor changes (relevant to FreeBSD):
- support extracting NFSv4 ACLs from Solaris tar archives
- bugfixes and optimizations in the ACL code
- multiple fixes in the test suite
- typo and other small bugfixes

Security fixes:
- cab reader: endless loop when parsing MSZIP signature (OSS-Fuzz 335)
- LHA reader: heap-buffer-overflow in lha_read_file_header_1()
  (CVE-2017-5601)
- LZ4 reader: null-pointer dereference in lz4_filter_read_legacy_stream()
  (OSS-Fuzz 453)
- mtree reader: heap-buffer-overflow in detect_form() (OSS-Fuzz 421, 443)
- WARC reader: heap-buffer-overflow in xstrpisotime() (OSS-Fuzz 382, 458)

Memory leak fixes:
- ACL support: free memory allocated by acl_get_qualifier()
- disk writer: missing free in create_filesystem_object()
- file reader: fd leak (Coverity 1016755)
- gnutar writer: fix free in archive_write_gnutar_header()
  (Coverity 101675)
- iso 9660 reader: missing free in parse_file_info()
  (partial Coverity 1016754)
- program reader: missing free in __archive_read_program()
- program writer: missing free in __archive_write_program_free()
- xar reader: missing free in xar_cleanup()
- xar reader: missing frees in expat_xmlattr_setup()
  (Coverity 1229979-1229981)
- xar writer: missing free in file_free()
- zip reader: missing free in zip_read_local_file_header()

MFC after:	1 week
X-MFC with:	310866, 310868, 310870, 311899
2017-02-02 00:50:46 +00:00
Martin Matuska
2dbf8c4a76 MFV r311899:
Sync libarchive with vendor.

Vendor bugfixes:
#691: Support for SCHILY.xattr extended attributes
#854: Spelling fixes

Multiple fixes in ACL code:
  - prefer acl_set_fd_np() to acl_set_fd()
  - if acl_set_fd_np() fails, do no fallback to acl_set_file()
  - do not warn if trying to write ACLs to a filesystem without ACL support
  - fix id handling in archive_acl_(from_to)_text*() for NFSv4 ACLs

MFC after:	1 week
X-MFC with:	r310866
2017-01-10 21:59:35 +00:00
Martin Matuska
739d7cfd6d MFV r310869:
Sync libarchive with vendor.

Vendor bugfixes:
Use __LA_DEPRECATED macro with functions deprecated in 379867e (r310796)

MFC after:	2 weeks
X-MFC with:	r310866
2016-12-30 23:05:06 +00:00
Martin Matuska
09c253fd1b MFV r310798:
Sync libarchive with vendor.

Vendor bugfixes (relevant to FreeBSD):
PR #843: Fix memory leak of struct archive_entry in cpio/cpio.c
PR #851: Spelling fixes
Fix two protoypes in manual page archive_read_disk.3

MFC after:	2 weeks
2016-12-30 22:54:08 +00:00
Martin Matuska
e9ed7ea4dc MFV r310796, r310797:
Sync libarchive with vendor.

Vendor changes (relevant to FreeBSD):
PR #771: Add NFSv4 ACL support to pax and restricted pax

NFSv4 ACL information may now be stored to and restored from tar archives.
ACL must be non-trivial and supported by the underlying filesystem, e.g.
natively by ZFS or by UFS with the NFSv4 ACL enable flag set.

MFC after:	2 weeks
Relnotes:	yes
2016-12-30 22:18:22 +00:00
Martin Matuska
7105995c64 MFV r310622:
Sync libarchive with vendor.

Vendor bugfixes (relevant to FreeBSD):
PR 846: Spelling fixes
PR 850: Fix issues with reading certain jar files
OSS-Fuzz 286: Bugfix in archive_strncat_l()
2016-12-27 01:10:28 +00:00
Martin Matuska
6a414569b3 MFV r310115,310184:
Sync libarchive with vendor.

Vendor bugfixes (relevant to FreeBSD):
PR 830, 831, 833: Spelling fixes
OSS-Fuzz 227, 230, 239: Fix possible memory leak in archive_read_free()
OSS-Fuzz 237: Fix heap buffer overflow when reading invalid ar archives

MFC after:	1 week
2016-12-17 02:07:08 +00:00
Enji Cooper
63ecfce853 Merge changes from vendor to address several Coverity issues with
contrib/libarchive's tests

MFC after:	2 weeks
Obtained from:	libarchive (ebe29c, fd0ea2, f9e3de)
Reported by:	Coverity
2016-12-12 02:21:56 +00:00
Martin Matuska
a2e802b76b MFV r309587:
Sync libarchive with vendor.

Vendor bugfixes:

libarchive #831:
  Spelling fixes
libarchive #832:
  Relax sanity checks of number fields in tar header even more
OSS-Fuzz #16:
  Fix possible hang in uudecode_filter_read()
OSS-Fuzz #220:
  Reject an 'ar' filename table larger than 1GB or a filename larger
  than 1MB.

MFC after:	1 week
2016-12-06 01:35:27 +00:00
Martin Matuska
43d91c021f Relax sanity check of number fields in tar header even more.
This fixes reading tar archives created by older versions of
plexus-archiver (used by maven-assembly-plugin) that fill uid and gid
fields with spaces (PLXCOMP-233).

Vendor issue:
https://github.com/libarchive/libarchive/issues/832

Reported by:	Antoine Brodin <antoine@freebsd.org>
MFC after:	1 week
2016-12-04 02:58:13 +00:00
Martin Matuska
c4247af46a MFV r309403:
Sync libarchive with vendor.

Vendor bugfixes:
Fix for heap-buffer-overflow in archive_le16dec()
Fix for heap-buffer-overflow in uudecode_bidder_bid()
Reworked fix for compatibility with archives created by Perl Archive::Tar

MFC after:	1 week
2016-12-02 09:30:13 +00:00
Martin Matuska
007dbc1f18 MFC r309362:
Sync libarchive with vendor.
Small improvements, style fixes, bugfixes.
Restores compatibility with tar archives created with Perl Archive::Tar (1)

MFC after:	1 week
Reported by:	Matthew Seaman <matthew@freebsd.org> (1)
2016-12-01 15:46:26 +00:00
Martin Matuska
d5d08d297d MFV r309299:
Sync libarchive with vendor.

Important vendor bugfixes (relevant to FreeBSD):
#821: tar -P cannot extract hardlinks through symlinks
#825: Add sanity check of tar "uid, "gid" and "mtime" fields

PR:		213255
Reported by:	Tijl Coosemans <tilj@FreeBSD.org>
MFC after:	1 week
2016-11-29 22:14:42 +00:00
Martin Matuska
98b53e14eb MFV r307859:
Update libarchive to 3.2.2
2016-10-24 14:08:05 +00:00
Martin Matuska
2a21e8bd77 MFV r307214:
Sync libarchive with vendor. Style and tests fixes.

Important vendor bugfixes (relevant to FreeBSD):
#801: FreeBSD Coverity report: resource leak in libarchive/tar/test/main.c

MFC after:	1 week
2016-10-13 11:40:34 +00:00
Martin Matuska
f3e9b21a7a MFV r306669:
Sync libarchive with vendor including security fixes.

Important vendor bugfixes (relevant to FreeBSD):
#747: Out of bounds read in mtree parser
#761: heap-based buffer overflow in read_Header (7-zip)
#784: Invalid file on bsdtar command line results in internal errors (1)

PR:		213092 (1)
MFC after:	1 week
2016-10-04 11:56:46 +00:00
Martin Matuska
24113d8c17 MFV r305816:
Sync libarchive with vendor including important security fixes.

Issues fixed (FreeBSD):
PR #778: ACL error handling
Issue #745: Symlink check prefix optimization is too aggressive
Issue #746: Hard links with data can evade sandboxing restrictions

This update fixes the vulnerability #3 and vulnerability #4 as reported in
"non-cryptanalytic attacks against FreeBSD update components".
https://gist.github.com/anonymous/e48209b03f1dd9625a992717e7b89c4f

Fix for vulnerability #2 has already been merged in r304989.

MFC after:	1 week
Security: http://gist.github.com/anonymous/e48209b03f1dd9625a992717e7b89c4f
2016-09-14 21:15:01 +00:00
Martin Matuska
47af42f8e7 MFV r305420:
Sync libarchive with vendor

Vendor issues fixed:
PR #777: Multiple bugfixes for setup_acls()

This includes a bugfix for a bug that caused ACLs not to be read properly
for files and directories inside subdirectories and as a result not being
stored or being incorrectly stored in tar archives.

MFC after:	3 days
2016-09-05 15:40:41 +00:00
Martin Matuska
cff8ef76a4 Redo MFV r304866:
Sync libarchive with vendor including security fixes

Vendor issues fixed:
Issue #731: Reject tar entries >= INT64_MAX
Issue #744 (part of Issue #743): Enforce sandbox with very long pathnames
Issue #748: Zip decompression failure with highly-compressed data
Issue #767: Buffer overflow printing a filename
Issue #770: Zip read: be more careful about extra_length

MFC after:	3 days
2016-08-29 06:54:38 +00:00
Martin Matuska
c438d38492 Revert r304869
This commit was incorrect and will be re-committed asap.
2016-08-29 06:50:45 +00:00
Martin Matuska
c4676089b0 MFV r304866:
Sync libarchive with vendor including security fixes

Vendor issues fixed:
Issue #731: Reject tar entries >= INT64_MAX
Issue #744 (part of Issue #743): Enforce sandbox with very long pathnames
Issue #748: Zip decompression failure with highly-compressed data
Issue #767: Buffer overflow printing a filename
Issue #770: Zip read: be more careful about extra_length

MFC after:	3 days
2016-08-26 23:50:44 +00:00
Martin Matuska
cfa49a9b0b MFV r304060:
Sync libarchive with vendor including three security fixes

Vendor issues fixed:

Issue #744: Very long pathnames evade symlink checks
Issue #748: libarchive can compress, but cannot decompress zip some files
PR #750: ustar: fix out of bounds read on empty string ("") filename
PR #755: fix use of acl_get_flagset_np() on FreeBSD

MFC after:	3 days
2016-08-14 09:26:10 +00:00
Martin Matuska
ae5876ea19 MFV r302264:
Sync libarchive with vendor, bugfixes for tests:
- fix tests on filesystems without birthtime support, e.g. UFS1 (1)
- vendor issue #729: avoid use of C99 for-scope declarations in
  test_write_format_gnutar_filenames.c

MFC after:	1 week
PR:		204157 (1)
Approved by:	re (hrs)
2016-06-30 08:51:50 +00:00
Martin Matuska
f061a2215f MFV r302003,r302037,r302038,r302056:
Update libarchive to 3.2.1 (bugfix and security fix release)

List of vendor fixes:
- fix exploitable heap overflow vulnerability in Rar decompression
  (vendor issue 719, CVE-2016-4302, TALOS-2016-0154)
- fix exploitable stack based buffer overflow vulnebarility in mtree
  parse_device functionality (vendor PR 715, CVE-2016-4301, TALOS-2016-0153)
- fix exploitable heap overflow vulnerability in 7-zip read_SubStreamsInfo
  (vendor issue 718, CVE-2016-4300, TALOS-2016-152)
- fix integer overflow when computing location of volume descriptor
  (vendor issue 717)
- fix buffer overflow when reading a crafred rar archive (vendor issue 521)
- fix possible buffer overflow when reading ISO9660 archives on machines
  where sizeof(int) < sizeof(size_t) (vendor issue 711)
- tar and cpio should fail if an input file named on the command line is
  missing (vendor issue 708)
- fix incorrect writing of gnutar filenames that are exactly 512 bytes
  long (vendor issue 682)
- allow tests to be run from paths that are equal or longer than 128
  characters (vendor issue 657)
- add memory allocation errors in archive_entry_xattr.c (vendor PR 603)
- remove dead code in archive_entry_xattr_add_entry() (vendor PR 716)
- fix broken decryption of ZIP files (vendor issue 553)
- manpage style, typo and description fixes

Post-3.2.1 vendor fixes:
- fix typo in cpio version reporting (Vendor PR 725, 726)
- fix argument range of ctype functions in libarchive_fe/passphrase.c
- fix ctype use and avoid empty loop bodies in WARC reader

MFC after:	1 week
Security:	CVE-2016-4300, CVE-2016-4301, CVE-2016-4302
Approved by:	re (kib)
2016-06-22 07:49:59 +00:00
Martin Matuska
c38ff13d6a Revert r299576 and MFV r299895:
Revert r299576:
Fix broken cpio behavior.

MFV r299895:
Update to vendor git commit 860ec63.

MFC after:	3 weeks (together with libarchive 3.2.0)
Fix broken cpio behavior in pass-through mode with vendor code.
2016-05-16 05:01:44 +00:00
Martin Matuska
ec0bb2035e Fix broken cpio behavior.
Suggested upstream as PR #704.

MFC:	1 month (together with libarchive 3.2.0)
2016-05-12 22:51:04 +00:00
Martin Matuska
cdf63a700c MFV r299425:
Update libarchive to 3.2.0

New features:
- new bsdcat command-line utility
- LZ4 compression (in src only via external utility from ports)
- Warc format support
- 'Raw' format writer
- Zip: Support archives >4GB, entries >4GB
- Zip: Support encrypting and decrypting entries
- Zip: Support experimental streaming extension
- Identify encrypted entries in several formats
- New --clear-nochange-flags option to bsdtar tries to remove noschg and
  similar flags before deleting files
- New --ignore-zeros option to bsdtar to handle concatenated tar archives
- Use multi-threaded LZMA decompression if liblzma supports it
- Expose version info for libraries used by libarchive

Patched files (fixed compiler warnings):

contrib/libarchive/cat/bsdcat.c (vendor PR #702)
contrib/libarchive/cat/bsdcat.h (vendor PR #702)
contrib/libarchive/libarchive/archive_read_support_format_mtree.c (PR #701)
contrib/libarchive/libarchive_fe/err.c (vendor PR #703)

MFC after:	1 month
Relnotes:	yes
2016-05-12 10:16:16 +00:00
Xin LI
876964d12a MFV r295913:
Partially apply upstream changeset 6e06b1c8 (kientzle).

Limit filter recursion level to 25 (instead of infinite).  This fixes a
potential crash issue discovered by Alexander Cherepanov.

PR:		207362
Reported by:	Robert Clausecker
Obtained from:	libarchive github project
2016-02-23 07:13:22 +00:00
Bryan Drewery
75f66cde5c MFV r285970:
Apply upstream changeset bf4f6ec64e:

  Fix issue 356: properly skip a sparse file entry in a tar file.

PR:		201506
MFC after:	3 days
Relnotes:	yes
2015-07-28 18:41:28 +00:00
Xin LI
a85f1b1ac5 MFV r282927,r282928,r282930 (kientzle):
Don't segfault when reading malformed cpio archives.

MFC after:	3 days
2015-05-14 22:35:26 +00:00
Bryan Drewery
eb828e1bb5 Fix --one-file-system to include the directory encountered rather than
excluding it.  This was broken in 3.0.4 (r238856).

Obtained from:	https://github.com/libarchive/libarchive/commit/fa9e61
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2015-03-31 00:00:47 +00:00
Dimitry Andric
fdaadf20c4 Fix the following -Werror warning from clang 3.5.0, while building
usr.bin/cpio on amd64 (or any arch with 64-bit time_t):

contrib/libarchive/cpio/cpio.c:1143:6: error: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value]
        if (abs(mtime - now) > (365/2)*86400)
            ^
contrib/libarchive/cpio/cpio.c:1143:6: note: use function 'labs' instead
        if (abs(mtime - now) > (365/2)*86400)
            ^~~
            labs
1 error generated.

This is because time_t is a long on amd64. To avoid the warning, just
copy the equivalent test from a few lines before, which is used in the
Windows case, and which is type safe.

Reviewed by:	emaste
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D1198
2014-11-22 12:10:09 +00:00
Andrey V. Elsukov
44418c8be9 Remove leading '/' from hardlink name when removing them from the
regular file name. This fixes the problem, when bsdtar can not create
hardlinks to extracted files.

Silence from:	kientzle@
MFC after:	1 week
Sponsored by:	Yandex LLC
2014-08-26 13:11:38 +00:00
Matthew D Fleming
e324bf91e8 Fix return type of extattr_set_* and fix rmextattr(8) utility.
extattr_set_{fd,file,link} is logically a write(2)-like operation and
should return ssize_t, just like extattr_get_*.  Also, the user-space
utility was using an int for the return value of extattr_get_* and
extattr_list_*, both of which return an ssize_t.

MFC after:	1 week
2013-04-02 05:30:41 +00:00
Martin Matuska
70970541ad Merge bugfix from vendor master branch:
Limit write requests to at most INT_MAX.
This prevents a certain common programming error (passing -1 to write)
from leading to other problems deeper in the library.

References:
https://github.com/libarchive/libarchive/commit/22531545514043e0

Reported by:	Xin Li <delphij@FreeBSD.org>
Obtained from:  libarchive (master branch)
2013-03-23 21:34:10 +00:00
Martin Matuska
acc60b03c1 MFV r248590,248594:
Update libarchive to 3.1.2

Some of new features:
  - support for lrzip and grzip compression
  - support for writing tar v7 format
  - b64encode and uuencode filters
  - support for __MACOSX directory in Zip archives
  - support for lzop compresion (external utility)
2013-03-22 13:36:03 +00:00
Tim Kientzle
3fd25813ed Fix an obvious typo that broke time specifications of the form
"2 hours ago".
2013-02-02 06:06:39 +00:00
Martin Matuska
7ceb94332b Apply fix for vendor pull request #17:
Support appending to empty archives

References:
  https://github.com/libarchive/libarchive/pull/17

Submitted by:	myself
Obtained from:	libarchive master branch on github
2012-08-23 19:40:28 +00:00
Martin Matuska
10ed66fdf8 Backport NFSv4 ACL fix from libarchive master branch.
Source:
https://github.com/libarchive/libarchive/commit/f67370d5

Obtained from:	libarchive (master branch)
2012-07-30 14:47:35 +00:00
Martin Matuska
88b860fc7a Fix endless loop if reading unsupported ACL type.
Apply fix from vendor's master branch.

References:
https://github.com/libarchive/libarchive/commit/d8b9dbd

Reported on:	freebsd-current@
Obtained from:	libarchive
2012-07-29 06:33:27 +00:00
Martin Matuska
fd082e96c4 Update libarchive to 3.0.4 2012-07-28 06:38:44 +00:00
Martin Matuska
48cbf1ba5b Update information on obtaining libarchive sources and FreeBSD-Xlist 2012-07-27 08:28:44 +00:00
Martin Matuska
6c95142e79 Update libarchive to 3.0.3
Some of new features:
  - New readers: RAR, LHA/LZH, CAB reader, 7-Zip
  - New writers: ISO9660, XAR
  - Improvements to many formats, especially including ISO9660 and Zip
  - Stackable write filters to write, e.g., tar.gz.uu in a single pass
  - Exploit seekable input; new "seekable" Zip reader can exploit the Zip
    Central Directory when it's available; the old "streamable" Zip reader
    is still fully supported for cases where seeking is not possible.

Full release notes available at:
	https://github.com/libarchive/libarchive/wiki/ReleaseNotes
2012-02-25 10:58:02 +00:00
Martin Matuska
e60867e953 Uupdate code to vendor rev. 4183 (release/2.8)
Fixes vendor issue 224:
"Mishandling CD9660 images with RockRidge extensions from FreeBSD makefs"

References:
http://code.google.com/p/libarchive/issues/detail?id=224

MFC after:	1 week
2012-01-29 22:20:28 +00:00
Martin Matuska
73278c5812 Update to vendor revision 4016.
Vendor has integrated most of our local changes in revisions 3976-3979 so
future updates are going to be easier.
Thanks to Tim Kientzle <kientzle@FreeBSD.org>.

MFC after:	8 days
2011-12-27 10:36:56 +00:00
Martin Matuska
cfd8eb6299 Fix typo s/xz/libarchive/
Reported by:	Emil Mikulic (private e-mail)
MFC after:	12 days
2011-12-23 08:50:26 +00:00
Martin Matuska
584ad8fd32 Merge FreeBSD changes from usr.bin/cpio to contrib/libarchive/cpio:
r204111 (uqs):
Fix common misspelling of hierarchy

r211054 (kientzle);
Fix -R when used with -p.  Previously, the
uname and gname weren't overwritten, so the
disk restore would use those to lookup the
original uid/gid again.  Clearing the uname
and gname prevents this.

r212263 (gjb):
Fix typo in bsdcpio manual:
s/libarchive_formats/libarchive-formats

MFC after:	2 weeks
2011-12-21 15:33:13 +00:00
Martin Matuska
c5d360f82a Merge FreeBSD changes from usr.bin/tar to contrib/libarchive/tar:
r204111 (uqs):
Fix common misspelling of hierarchy

r207786 (kientzle):
Various manpage updates, including many long-option synonyms that were
previously undocumented.

r208028 (uqs):
mdoc: move remaining sections into consistent order

This pertains mostly to FILES, HISTORY, EXIT STATUS and AUTHORS sections.

r209152 (kientzle):
If the compressed data is larger than the uncompressed,
report the compression ratio as 0% instead of displaying
nonsense triggered by numeric overflow.  This is common
when dealing with uncompressed files when the I/O blocking
causes there to be small transient differences in the
accounting.

r210720 (joel):
Fix typos.

r223541 (kientzle):
If there is a read error reading Y/N confirmation from the keyboard,
exit immediately with an error.

If there is an error opening or reading a file to put into the archive,
set the return value for a deferred error exit.

r223573 (kientzle):
The --newer-than test should descend into old
directories to look for new files.

r226636 (kientzle):
Typo from previous commit. Urgh.

r224153 (mm, partial):
Update bsdtar.1 manpage

MFC after:	2 weeks
2011-12-21 15:30:49 +00:00
Martin Matuska
e9dd49674a Merge FreeBSD changes from usr.bin/tar to contrib/libarchive/libarchive_fe:
r213469:
Recognize both ! and ^ as markers for negated character classes.

MFC after:	2 weeks
2011-12-21 15:22:05 +00:00
Martin Matuska
457fe389bb Add $FreeBSD$ to libarchive_fe headers where missing.
MFC after:	2 weeks
2011-12-21 15:20:17 +00:00