summaryrefslogtreecommitdiffstats
path: root/lib/libarchive/archive_read.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Overhauled ACL support. This makes us compatiblekientzle2004-04-051-11/+12
| | | | | | | | | | | | with 'star' ACL handling, though there's still a bit more work needed in this area. Added 'write_open_fd' and 'read_open_fd' to simplify, e.g., tar's u and r modes. Eliminated old 'write_open_file_position' as a bad idea. (It required closing/reopening files to do updates, which led to unpleasant implications.) Various other minor fixes, API tweaks, etc.
* Many fixes:kientzle2004-03-191-16/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Disabled shared-library building, as some API breakage is still likely. (I didn't realize it was turned on by default.) If you have an existing /usr/lib/libarchive.so.2, I recommend deleting it. * Pax interchange format now correctly stores and reads UTF8 for extended attributes. In particular, pax format can portably handle arbitrarily long pathnames containing arbitrary characters. * Library compiles cleanly at -O2, -O3, and WARNS=6 on all FreeBSD-CURRENT platforms. * Minor portability improvements inspired by Juergen Lock and Greg Lewis. (Less reliance on stdint.h, isolating of various portability-challenged constructs.) * archive_entry transparently converts multi-byte <-> wide character strings, allowing clients and format handlers to deal with either one, as appropriate. * Support for reading 'L' and 'K' entries in standard tar archives for star compatibility. * Recognize (but don't yet handle) ACL entries from Solaris tar. * Pushed format-specific data for format readers down into format-specific storage and out of library-global storage. This should make it easier to maintain individual formats without mucking with the core library management. * Documentation updates to track the above changes. * Updates to tar.5 to correct a few mistakes and add some additional information about GNU tar and Solaris tar formats. Notes: * The basic 'tar' reader is getting more general; there's not much point in keeping the 'gnutar' reader separate. Merging the two would lose a bunch of duplicate code. * The libc ACL support is looking increasingly inadequate for my needs here. I might need to assemble some fairly significant code for parsing and building ACLs. <sigh>
* Many fixes.kientzle2004-03-091-6/+7
| | | | | | | | | | | | | | | | Portability: Thanks to Juergen Lock, libarchive now compiles cleanly on Linux. Along the way, I cleaned up a lot of error return codes and reorganized some code to simplify conditional compilation of certain sections. Bug fixes: * pax format now actually stores filenames that are 101-154 characters long. * pax format now allows newline characters in extended attributes (this fixes a long-standing bug in ACL handling) * mtime/atime are now restored for directories * directory list is now sorted prior to fix-up to permit correct restore of non-writable dir heirarchies
* Initial import of libarchive.kientzle2004-02-091-0/+505
What it is: A library for reading and writing various streaming archive formats, especially tar and cpio. Being a library, it should be easy to incorporate into pkg_* tools, sysinstall, and any other place that needs to read or write such archives. Features: * Full automatic detection of both compression and archive format. * Extensible internal architecture to make it easy to add new formats. * Support for "pax interchange format," a new POSIX-standard tar format that eliminates essentially all of the restrictions of historic formats. * BSD license Thanks to: jkh for pushing me to start this work, gordon for encouraging me to commit it, bde for answering endless style questions, and many others for feedback and encouragement. Status: Pretty good overall, though there are still a few rough edges and the library could always use more testing. Feedback eagerly solicited.
OpenPOWER on IntegriCloud