aboutsummaryrefslogtreecommitdiff
path: root/lib/libarchive/archive_read_support_format_zip.c
Commit message (Collapse)AuthorAgeFilesLines
* Use contrib sources for building libarchive, tar and cpio.Martin Matuska2011-12-221-950/+0
| | | | | | | | | Make "make test" fully operational. MFC after: 2 weeks Notes: svn path=/head/; revision=228797
* Update libarchive, tar and cpio to version 2.8.5Martin Matuska2011-12-201-1/+1
| | | | | | | | | | | | | The following additional vendor revisions are applied: Revision 3740: Use archive_clear_error() to clear the error markers. Obtained from: http://code.google.com/p/libarchive MFC after: 2 weeks Notes: svn path=/head/; revision=228745
* If the Zip reader doesn't see a PK signature blockTim Kientzle2010-11-071-3/+50
| | | | | | | | | | | because there's inter-entry garbage, just scan forward to find the next one. This allows us to handle a lot of Zip archives that have been modified in-place. Thanks to: Gleb Kurtsou for sending me a sample archive Notes: svn path=/head/; revision=214905
* Handle Zip CRC validation for uncompressed Zip archives even onTim Kientzle2009-12-281-6/+5
| | | | | | | platforms that lack zlib. Notes: svn path=/head/; revision=201102
* Merge r541,r542 from libarchive.googlecode.com: Two sign mismatchesTim Kientzle2009-03-061-2/+3
| | | | | | | in the Zip reader. Notes: svn path=/head/; revision=189439
* Merge r491,493,500,507,510,530,543 from libarchive.googlecode.com:Tim Kientzle2009-03-061-0/+2
| | | | | | | | This implements the new generic options framework that provides a way to override format- and compression-specific parameters. Notes: svn path=/head/; revision=189438
* Merge r407,r508 from libarchive.googlecode.com: Correctly handleTim Kientzle2009-03-061-44/+41
| | | | | | | | | | | | | Zip entries that are zero length but stored with deflate. This is arguably a silly thing to do (deflating a zero-length file actually makes it bigger) but apparently quite a few Zip writers do this. This was broken in two places: archive_write_disk disliked being asked to write data to zero-length files (even if the write was zero-length) and zip_read_file_header tripped over itself when non-regular files had compressed bodies. Notes: svn path=/head/; revision=189430
* MfP4: Big read filter refactoring.Tim Kientzle2008-12-061-53/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | 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... Notes: svn path=/head/; revision=185679
* If we don't know the file size, leave the file size unset.Tim Kientzle2008-10-211-4/+10
| | | | | | | | | | | | | | | If it's not a regular file, don't return any data, even if the size is unknown. Update the Zip test with a hand-tweaked Zip archive that has a directory (with length-at-end set), a regular file without length-at-end set, and a regular file with length-at-end set and a bad CRC. Update the test code to verify that the file size is unset for the regular file with length-at-end. MFC after: 7 days Notes: svn path=/head/; revision=184109
* More explicit error message.Dag-Erling Smørgrav2008-06-301-1/+2
| | | | Notes: svn path=/head/; revision=180123
* Implement CRC32 verification. Note that you have to read until EOF toDag-Erling Smørgrav2008-06-261-5/+12
| | | | | | | | | | trigger the check. Requested by: ache Approved by: kientzle Notes: svn path=/head/; revision=180027
* Fix reading TOC from zip archives with unsupportedTim Kientzle2008-06-151-2/+6
| | | | | | | | compression. We can't read the body, but we shouldn't try to skip the body twice. Notes: svn path=/head/; revision=179794
* MFp4: libarchive 2.5.4b. (Still 'b' until I get a bit moreTim Kientzle2008-05-261-5/+112
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | feedback, but the 2.5 branch is shaping up nicely.) In addition to many small bug fixes and code improvements: * Another iteration of versioning; I think I've got it right now. * Portability: A lot of progress on Windows support (though I'm not committing all of the Windows support files to FreeBSD CVS) * Explicit tracking of MBS, WCS, and UTF-8 versions of strings in archive_entry; the archive_entry routines now correctly return NULL only when something is unset, setting NULL properly clears string values. Most charset conversions have been pushed down to archive_string. * Better handling of charset conversion failure when writing or reading UTF-8 headers in pax archives * archive_entry_linkify() provides multiple strategies for hardlink matching to suit different format expectations * More accurate bzip2 format detection * Joerg Sonnenberger's extensive improvements to mtree support * Rough support for self-extracting ZIP archives. Not an ideal approach, but it works for the archives I've tried. * New "sparsify" option in archive_write_disk converts blocks of nulls into seeks. * Better default behavior for the test harness; it now reports all failures by default instead of coredumping at the first one. Notes: svn path=/head/; revision=179321
* Optimize skipping over Zip entries.Tim Kientzle2008-02-271-14/+5
| | | | | | | | Thanks to: Dan Nelson, who sent me the patch MFC after: 7 days Notes: svn path=/head/; revision=176619
* Rename the archive_endian.h functions to avoid name clashesTim Kientzle2008-02-261-21/+23
| | | | | | | | | with NetBSD's sys/endian.h file. Pointed out by: Joerg Sonnenberger Notes: svn path=/head/; revision=176576
* Handle Zip archives that are "multi-part archives with onlyTim Kientzle2008-01-151-1/+19
| | | | | | | | | | | | | | | one part" by simply ignoring the marker at the beginning of the file. (Zip archivers reserve four bytes at the beginning of each part of a multi-part archive, if it happens to only require one part, those four bytes get filled with a placeholder that can be ignored.) Thanks to: Marius Nuennerich, for pointing me to a Zip archive that libarchive couldn't handle MFC after: 7 days Notes: svn path=/head/; revision=175358
* Crib {be,le}{16,32,64}{dec,enc} from src/sys/sys/endian.h and use it insteadDag-Erling Smørgrav2008-01-031-57/+22
| | | | | | | | | of home-rolled [iu][248] in the ZIP support code. Approved by: kientzle Notes: svn path=/head/; revision=175073
* Add an internal utility function to simplify the many, many places whereDag-Erling Smørgrav2008-01-031-25/+10
| | | | | | | | | | | 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 Notes: svn path=/head/; revision=175072
* Update libarchive to 2.4.10. This includes a number of improvementsTim Kientzle2007-12-301-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=174991
* If a Zip entry has the "length at end" flag set, then just ignoreTim Kientzle2007-12-041-1/+2
| | | | | | | | | | a length field of zero; it does not mean the body is empty. Thanks to: Lapo Luchini for sending me a JAR archive that demonstrated this bug MFC after: 3 days Notes: svn path=/head/; revision=174246
* Correct the return values of the final zero-length block at EOF.Tim Kientzle2007-10-121-0/+7
| | | | | | | | | | | Return EOF immediately if an entry in a ZIP archive has no body. In particular, the latter issue was causing bsdtar to emit spurious warnings when extracting directory entries from ZIP archives. MFC after: 3 days Notes: svn path=/head/; revision=172559
* archive_string_ensure() used to call exit(3) if itTim Kientzle2007-07-151-1/+2
| | | | | | | | | | | | | couldn't allocate more memory for a string. Change this so it returns NULL in that case, and update all of its callers to handle the error. Some of those callers can now return errors back to the client instead of calling exit(3). Approved by: re (bmah) Notes: svn path=/head/; revision=171460
* libarchive 2.2.3Tim Kientzle2007-05-291-42/+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. Notes: svn path=/head/; revision=170079
* Consolidate numeric limit macros in one place; include themTim Kientzle2007-04-151-5/+2
| | | | | | | only on platforms that need them. FreeBSD doesn't. Notes: svn path=/head/; revision=168743
* libarchive 2.0Tim Kientzle2007-03-031-50/+58
| | | | | | | | | | | | | | | | | | | | | | * 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. Notes: svn path=/head/; revision=167186
* Fix the copyright notice; it was always intended to beTim Kientzle2007-01-091-2/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=165912
* Portability and style fixes:Tim Kientzle2006-11-101-17/+21
| | | | | | | | | | | | | | | | | * 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. ;-) Notes: svn path=/head/; revision=164142
* Make some purely internal symbols static to reduce link pollution.Tim Kientzle2005-10-121-1/+1
| | | | Notes: svn path=/head/; revision=151259
* signed/unsigned fixes (thanks to GCC4) and a few related minor style ↵Tim Kientzle2005-09-241-1/+1
| | | | | | | corrections. Notes: svn path=/head/; revision=150527
* Add a lot of error checks, based on the patches provided by Dan Lukes.Tim Kientzle2005-09-211-0/+4
| | | | | | | | | | Also fixes a memory leak reported by Andrew Turner. PR: bin/83476 Thanks to: Dan Lukes, Andrew Turner Notes: svn path=/head/; revision=150407
* A number of improvements to ZIP support.Tim Kientzle2005-04-061-64/+322
| | | | | | | | | | | | | | | | * 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. Notes: svn path=/head/; revision=144703
* Performance optimization, code clarification, and bug workaround.Tim Kientzle2005-02-121-28/+36
| | | | | | | | | | | | | | When reading the bodies of Zip archive entries, request a minimum of 1 byte, rather than a minimum of the full entry size. This is faster (since it does not force the decompression layer to combine reads) and works around a bug in the "none" decompression handler (which I'm testing a separate fix for now). I've also renamed "bytes_read" to "bytes_avail" in several places to more accurately reflect that the value returned from (a->compression_read_ahead) is the number of bytes available, not necessarily the number of bytes requested. Notes: svn path=/head/; revision=141772
* This should (finally) fix the 64-bit build. <sigh>Tim Kientzle2005-01-261-1/+1
| | | | Notes: svn path=/head/; revision=140842
* Fix some signed/unsigned mismatches.Tim Kientzle2005-01-251-12/+14
| | | | | | | | Reported by: tinderbox Pointy hat: me Notes: svn path=/head/; revision=140826
* Basic support for ZIP archives.Tim Kientzle2005-01-251-0/+525
Only supports "deflate" and "none" compression for now. Also, add a few clarifications to the archive_read.3 manpage as requested by William Dean DeVries. Notes: svn path=/head/; revision=140790