summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read.c
Commit message (Collapse)AuthorAgeFilesLines
* Catch decompression failures earlier. In particular, this giveskientzle2009-12-291-0/+8
| | | | immediate feedback if we fail to fork an external decompression program.
* Various style and portability fixes, including:kientzle2009-12-291-12/+35
| | | | | | * Enforce option interface can only be used before the archive is opened * Correctly handle large skips on platforms with 32-bit off_t * Use int64_t instead of off_t
* New archive_file_count() utility.kientzle2009-12-281-0/+1
|
* Fiz /usr/bin/unzip: A bug deep in libarchive's read-ahead logickientzle2009-09-081-2/+5
| | | | | | | | | | | | (incorrect handling of zero-length reads before the copy buffer is allocated) is masked by the iso9660 taster. Tar and cpio both enable that taster so were protected from the bug; unzip is susceptible. This both fixes the bug and updates the test harness to exercise this case. Submitted by: Ed Schouten diagnosed the bug and drafted a patch MFC after: 7 days
* Fix "tar --options=iso9660:joliet" and other useskientzle2009-06-201-4/+5
| | | | of format-specific options.
* Merge r988,r1064 from libarchive.googlecode.com:kientzle2009-04-271-12/+23
| | | | | | | | | * Split whiny skip function to create a new best-effort skip_lenient() * Correctly increment the top-level file position only for the top filter * Simulate skip by reading against the current filter, not the top filter The latter two bugs aren't currently visible because no existing filter delegates skip operations.
* Accept empty options, add a new read_next_header2() which is morekientzle2009-04-171-5/+22
| | | | efficient for some uses.
* Merge r714,r715 from libarchive.googlecode.com: Fix Debian bug #516577.kientzle2009-03-071-0/+2
| | | | | Don't crash if client does not provide a skip function. Extend one of the test cases to use archive_read_open2() with only a read callback.
* Merge r608 from libarchive.googlecode.com: Clear a newly-allocatedkientzle2009-03-071-1/+3
| | | | bidder object.
* Merge r564,r566 from libarchive.googlecode.com: Fix segfault whenkientzle2009-03-071-14/+22
| | | | | specifying an option and the current format doesn't have an options handler.
* Merge r659 from libarchive.googlecode.com: Correctly report "none"kientzle2009-03-071-4/+2
| | | | | | as the compression name when no other read filter bid. Add some assertions to various tests to verify that read filters are properly setting the textual name as well as the compression code.
* Merge r491,493,500,507,510,530,543 from libarchive.googlecode.com:kientzle2009-03-061-0/+93
| | | | | This implements the new generic options framework that provides a way to override format- and compression-specific parameters.
* Merge r390,r391,r392,r397 from libarchive.googlecode.com: Virtualizekientzle2009-03-051-8/+21
| | | | | | "close" and "finish" across both read and write interfaces. (Someday, "finish" should be renamed to "free" to better reflect what it actually does...)
* Merge r364, r378, r379, r393, and r539 from libarchive.googlecode.com:kientzle2009-03-051-180/+190
| | | | | | | | | | | | | | | | This is the last phase of the "big decompression refactor" that puts a lazy reblocking layer between each pair of read filters. I've also changed the terminology for this area---the two kinds of objects are now called "read filters" and "read filter bidders"---and moved ownership of these objects to the archive_read core. This greatly simplifies implementing new read filters, which can now use peek/consume I/O semantics both for bidding (arbitrary look-ahead!) and for reading streams (look-ahead simplifies handling concatenated streams, for instance). The first merge here is the overhaul proper; the remainder are small fixes to correct errors in the initial implementation.
* Merge r282 from libarchive.googlecode.com: Close multiple filterskientzle2009-03-031-2/+3
| | | | by walking the filter list in archive_read_close().
* MfP4: Big read filter refactoring.kientzle2008-12-061-145/+453
| | | | | | | | | | | | | | | | | | | | | | | This is an attempt to eliminate a lot of redundant code from the read ("decompression") filters by changing them to juggle arbitrary-sized blocks and consolidate reblocking code at a single point in archive_read.c. Along the way, I've changed the internal read/consume API used by the format handlers to a slightly different style originally suggested by des@. It does seem to simplify a lot of common cases. The most dramatic change is, of course, to archive_read_support_compression_none(), which has just evaporated into a no-op as the blocking code this used to hold has all been moved up a level. There's at least one more big round of refactoring yet to come before the individual filters are as straightforward as I think they should be...
* Remove some unused fields from the private archive_read structurekientzle2008-03-121-15/+0
| | | | | | (left over from when the unified read/write structure was copied to form separate read and write structures) and eliminate the pointless initialization of a couple of the unused fields.
* Add an internal utility function to simplify the many, many places wheredes2008-01-031-0/+11
| | | | | | | | the number of bytes read is actually not important as long as we have at least what we ask for. Illustrate its benefits by using it throughout the ZIP support code, except for the few cases where it doesn't apply. Approved by: kientzle
* Update libarchive to 2.4.10. This includes a number of improvementskientzle2007-12-301-6/+12
| | | | | | | | | | | | | | | | | | | | | | | | that I've been working on but put off committing until after the RELENG_7 branch, including: * New manpages: cpio.5 mtree.5 * New archive_entry_strmode() * New archive_entry_link_resolver() * New read support: mtree format * Internal API change: read format auction only runs once * Running the auction only once allowed simplifying a lot of bid logic. * Cpio robustness: search for next header after a sync error * Support device nodes on ISO9660 images * Eliminate a lot of unnecessary copies for uncompressed archives * Corrected handling of new GNU --sparse --posix formats * Correctly handle a zero-byte write to a compressed archive * Fixed memory leaks Many of these improvements were motivated by the upcoming bsdcpio front-end. There have also been extensive improvements to the libarchive_test test harness, which I'll commit separately.
* libarchive 2.2.3kientzle2007-05-291-33/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * "compression_program" support uses an external program * Portability: no longer uses "struct stat" as a primary data interchange structure internally * Part of the above: refactor archive_entry to separate out copy_stat() and stat() functions * More complete tests for archive_entry * Finish archive_entry_clone() * Isolate major()/minor()/makedev() in archive_entry; remove these from everywhere else. * Bug fix: properly handle decompression look-ahead at end-of-data * Bug fixes to 'ar' support * Fix memory leak in ZIP reader * Portability: better timegm() emulation in iso9660 reader * New write_disk flags to suppress auto dir creation and not overwrite newer files (for future cpio front-end) * Simplify trailing-'/' fixup when writing tar and pax * Test enhancements: fix various compiler warnings, improve portability, add lots of new tests. * Documentation: document new functions, first draft of libarchive_internals.3 MFC after: 14 days Thanks to: Joerg Sonnenberger (compression_program) Thanks to: Kai Wang (ar) Thanks to: Colin Percival (many small fixes) Thanks to: Many others who sent me various patches and problem reports.
* Move archive_read_data_into_buffer into archive_read.c, simplify itscperciva2007-04-051-0/+16
| | | | | | | | implementation, and mark it as deprecated. It will be removed entirely in libarchive 3.0 (in FreeBSD 8.0?) but there's no reason for anyone to use it instead of archive_read_data. Approved by: kientzle
* More corrections from Joerg Sonnenberger.kientzle2007-04-051-3/+3
|
* Fix type-punned pointer, minor style fixes.kientzle2007-04-021-6/+7
| | | | Thanks to: Joerg Sonnenberger
* Provide a dummy compression-layer skip function which just reads data andcperciva2007-03-311-0/+40
| | | | | | | | | | discards it, for use when the compression layer code doesn't know how to skip data (e.g., everything other than the "none" compressor). This makes format level code simpler because that code can now assume that the compression layer always knows how to skip and will always skip exactly the requested number of bytes. Discussed with: kientzle (3 months ago)
* libarchive 2.0kientzle2007-03-031-68/+100
| | | | | | | | | | | | | | | | | | | * libarchive_test program exercises many of the core features * Refactored old "read_extract" into new "archive_write_disk", which uses archive_write methods to put entries onto disk. In particular, you can now use archive_write_disk to create objects on disk without having an archive available. * Pushed some security checks from bsdtar down into libarchive, where they can be better optimized. * Rearchitected the logic for creating objects on disk to reduce the number of system calls. Several common cases now use a minimum number of system calls. * Virtualized some internal interfaces to provide a clearer separation of read and write handling and make it simpler to override key methods. * New "empty" format reader. * Corrected return types (this ABI breakage required the "2.0" version bump) * Many bug fixes.
* If (a == NULL), don't dereference (a) to record an error message. [1]cperciva2007-02-051-3/+1
| | | | | | | | | | | Fallout from changing the skip API to use off_t instead of size_t: Print the skip length using %jd and cast to (intmax_t) instead of %d / (int), and if ARCHIVE_API_VERSION >= 2, allow the client skipper to be called for requests longer than SSIZE_MAX. [2] Approved by: kientzle Pointy hats to: kientzle [1], cperciva [2] MFC after: 3 days
* Add support for a new archive format "empty" that reads empty files.kientzle2007-02-011-10/+0
|
* Fix the copyright notice; it was always intended to bekientzle2007-01-091-3/+2
| | | | | | | | | a vanilla 2-clause BSD license, but somehow some confusing extra verbage get copied from somewhere. Also, update the copyright dates to 2007 for all of the files. Prompted by: several questions about what those extra words really mean
* Quiet a compiler warning where (off_t + size_t) has a different signcperciva2007-01-031-1/+1
| | | | | | from (off_t). Submitted by: delphij
* Insert zero-padding between sparse blocks in archive_read_data(). Thiscperciva2007-01-031-1/+22
| | | | | | fixes "tar -c @foo.tar" where "foo.tar" contains sparse entries. MFC after: 1 week
* Correct spelling of "accommodate", "guarantee", "guaranteed", "guard",cperciva2006-12-281-1/+1
| | | | | | "return", "ridiculous", and "success". MFC after: 3 days
* Portability and style fixes:kientzle2006-11-101-3/+11
| | | | | | | | | | | | | | * Actually use the HAVE_<header>_H macros to conditionally include system headers. They've been defined for a long time, but only used in a few places. Now they're used pretty consistently throughout. * Fill in a lot of missing casts for conversions from void*. Although Standard C doesn't require this, some people have been trying to use C++ compilers with this code, and they do require it. Bit-for-bit, the compiled object files are identical, except for one assert() whose line number changed, so I'm pretty confident I didn't break anything. ;-)
* Some minor corrections:kientzle2006-09-051-14/+17
| | | | | | | * Expose functions for setting the "skip file" dev/ino information * Expose functions for setting/querying the block size on reads * Correctly propagate errors out of archive_read_close/archive_write_close * Update manpage with information about new functions
* Use 'skip' when ignoring data in tar archives. This dramaticallykientzle2006-07-301-0/+15
| | | | | | | | | | | | | | | | | | | | increases performance when extracting a single entry from a large uncompressed archive, especially on slow devices such as USB hard drives. Requires a number of changes: * New archive_read_open2() supports a 'skip' client function * Old archive_read_open() is implemented as a wrapper now, to continue supporting the old API/ABI. * _read_open_fd and _read_open_file sprout new 'skip' functions. * compression layer gets a new 'skip' operation. * compression_none passes skip requests through to client. * compression_{gzip,bzip2,compress} simply ignore skip requests. Thanks to: Benjamin Lutz, who designed and implemented the whole thing. I'm just committing it. ;-) TODO: Need to update the documentation a little bit.
* If the attempt to open the archive fails (either the client openkientzle2006-01-171-13/+36
| | | | | | | | | | | | routine fails or the first read fails), invoke the client close routine immediately so the client can clean up. Also, don't store the client pointers in this case, so that the client close routine can't accidentally get called more than once. A minor style fix to archive_read_open_fd.c while I'm here. PR: 86453 Thanks to: Andrew Turner for reporting this and suggesting a fix.
* signed/unsigned fixes (thanks to GCC4) and a few related minor style ↵kientzle2005-09-241-2/+2
| | | | corrections.
* In archive_read_open(), do not set the internal archive state tokientzle2005-09-211-2/+4
| | | | | | | | | | | | "HEADER" unless the open is successful. Instead, leave the state as "NEW." In particular, if archive_read_open() fails, a subsequent call to archive_read_next_header() will now cause an explicit assertion failure instead of a silent segmentation fault. This may need a little more work to fully realize the intention: If archive_read_open() fails, you should be able to call it again on the same archive handle to open a different archive (or the same archive using a different mechanism).
* Add a lot of error checks, based on the patches provided by Dan Lukes.kientzle2005-09-211-0/+9
| | | | | | | Also fixes a memory leak reported by Andrew Turner. PR: bin/83476 Thanks to: Dan Lukes, Andrew Turner
* Fix some errors in archive_read_data that caused failures in bsdtar'skientzle2005-09-101-12/+11
| | | | | | | pass-through filtering. Thanks to: Bjoern Koenigönig PR: bin/82878
* Remove the C99-specific __func__ that is one of the few barrier tokientzle2005-06-011-10/+10
| | | | | | | | | compiling on IRIX and Solaris. Remove the "archive_check_magic" macro that existed only to provide __func__ to the underlying __archive_check_magic function. Thanks to: Darin Broady MFC after: 14 days
* A number of improvements to ZIP support.kientzle2005-04-061-3/+11
| | | | | | | | | | | | | * Handles entries with compressed size >2GB (signed/unsigned cleanup) * Handles entries with compressed size >4GB ("ZIP64" extension) * Handles Unix extensions (ctime, atime, mtime, mode, uid, etc) * Format-specific "skip data" override allows ZIP reader to skip entries without decompressing them, which makes "tar -t" a lot faster. * Handles "length-at-end" entries generated by, e.g., "zip -r - foo" Many thanks to: Dan Nelson, who contributed the code and test files for the first three items above and suggested the fourth.
* Clear the error buffer on entrykientzle2005-01-081-0/+1
| | | | | | | to archive_read_next_header so the next error doesn't just get appended. MFC after: 7 days
* Eliminate reliance on non-portable <err.h> by implementing a verykientzle2004-08-141-7/+8
| | | | | | | simple errx() function. Improve behavior when bzlib/zlib are missing by detecting and issuing an error message on attempts to read gzip/bzip2 compressed archives.
* Split archive_{read,write}_finish into separate "close" (finish the archivekientzle2004-08-071-6/+18
| | | | | | | and close it) and "finish" (destroy the object) functions. For backwards compat and simplicity, have "finish" invoke "close" transparently if needed. This allows clients to close the archive and check end-of-operation statistics before destroying the object.
* Correctly reset archive_read_data state everytime a header is read.kientzle2004-06-041-0/+5
|
* Be more careful about the initial read (used for "tasting" the compression):kientzle2004-06-041-1/+12
| | | | | * Check for and return input errors * Treat empty file (zero-length read) as a fatal error
* Refactor the extraction code somewhat. In particular,kientzle2004-06-031-1/+0
| | | | | | | | | | push extract data down into archive_read_extract.c and out of the library-global archive_private.h; push dir-specific mode/time fixup down into dir restore function; now that the fixup list is file-local, I can use somewhat more natural naming. Oh, yeah, update a bunch of comments to match current reality.
* Refactor read_data:kientzle2004-06-021-50/+84
| | | | | | | | | | | * New read_data_block is both sparse-file aware and uses zero-copy semantics * Push read_data_block down into specific formats (opens door to various encoded entry bodies, such as zip or gtar -S) * Reimplement read_data, read_data_skip, read_data_into_fd in terms of new read_data_block. * Update documentation It's unfortunate that I couldn't just call the new interface archive_read_data, but didn't want to upset the API that much.
* * Plug a buffer overrun in ACL parsing. (archive_entry.c)kientzle2004-04-131-3/+3
| | | | | | | * Re-use a single buffer for shar output formatting rather than hammering the heap. (archive_write_set_format_shar.c) * Fix a handful of minor memory leaks and clean up some of the memory-management code.
* More work on ACLs: fix error in archive_entry's ACL parsing code,kientzle2004-04-121-3/+0
| | | | | | | | | | | | | | try to set ACLs even if fflag restore fails, first cut at reading Solaris tar ACLs Code improvement: merge gnu tar read support into main tar reader; this eliminates a lot of duplicate code and generalizes the tar reader to handle formats with GNU-like extensions. Style: Makefile cleanup, eliminate 'dmalloc' references, remove 'tartype' from archive_entry (this makes archive_entry more format-agnostic) Thanks to: David Magda for providing Solaris tar test files
OpenPOWER on IntegriCloud