Paul Barker [Sun, 6 Apr 2014 21:54:48 +0000 (22:54 +0100)]
Fix intermittent segfault when reading zip files
When looking up the compression name for a zip file the index variable was being
incremented too soon. Thus element zero ("uncompressed") was never checked and
reads could be made past the end of the array. This was causing intermittent
segfaults in the call to sprintf in zip_read_local_file_header.
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
Paul Barker [Thu, 6 Feb 2014 21:20:06 +0000 (21:20 +0000)]
Prevent unnecessary linking against deflate code
In _archive_write_disk_free, the call to deflateEnd was compiled if HAVE_ZLIB_H
was defined. However, all other calls to deflate functions were only compiled
if __APPLE__, UF_COMPRESSED and HAVE_SYS_XATTR_H were also defined. So if one of
these macros was not defined but HAVE_ZLIB_H was defined, the call the
deflateEnd would be unnecessary as deflateInit could never have been called.
In statically linked applications which don't use deflate functions elsewhere
this was causing unnecessary linking of the deflate code from zlib, adding at
least 20k of object code to the final executable size.
This patch fixes the above issue by surrounding the call to deflateEnd with the
same conditional compilation checks as surround the call to deflateInit.
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
Paul Barker [Sun, 6 Apr 2014 14:48:24 +0000 (15:48 +0100)]
Split archive_read_extract2 from archive_read_extract
The function archive_read_extract requires a call to
archive_write_disk_set_standard_lookup but the functions archive_read_extract2
and archive_read_extract_set_progress_callback do not. Therefore, the latter
pair of functions, the internal function __archive_read_get_extract and the
static function copy_data are moved out of archive_read_extract.c into the new
file archive_read_extract2.c.
This ensures that when statically linking, the standard user and group lookup
functions will not be linked into a program unless they are really needed.
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
Paul Barker [Sun, 6 Apr 2014 13:37:03 +0000 (14:37 +0100)]
Refactor archive_read_extract
The initialisation of the archive_write_disk object and the call to
archive_write_disk_set_standard_lookup are only needed in the
archive_read_extract function, not in archive_read_extract2 or other related
functions. Therefore this initialisation is merged into archive_read_extract.
The static function get_extract is renamed to __archive_read_get_extract so that
is can be made non-static. The struct extract is renamed to archive_read_extract
so that it can be placed in a header file without risk of namespace clashes.
Both these declarations are then moved to the archive_read_private.h header.
This preparation is necessary so that the contents of archive_read_extract.c can
be split between two source files.
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
Mike Kazantsev [Sat, 5 Apr 2014 22:40:40 +0000 (04:40 +0600)]
Change bsdcat behavior to process as many files as possible.
Change is to match "cat" behavior of printing any errors (e.g. "unable to
open file") and continue to the next file instead of exiting on first error
encountered.
Paul Barker [Thu, 16 Jan 2014 15:16:31 +0000 (15:16 +0000)]
Fix out-of-tree build
When building outside the source tree, the directories 'libarchive/test',
'tar/test' and 'cpio/test' need to be created before the commands in Makefile.am
are executed which create list.h files in these directories.
Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
Brad King [Mon, 13 Jan 2014 14:36:15 +0000 (09:36 -0500)]
Do not require LibXml2 to configure
In commit 033fc31e (Allow fine grained control over dependancies,
2013-05-16, committed 2013-12-12) the find_package(LibXml2) line was
accidentally given a REQUIRED specifier. Remove it now.
Kevin Locke [Sat, 11 Jan 2014 23:38:52 +0000 (16:38 -0700)]
[PATCH v3] Add read_concatenated_archives
As discussed in http://code.google.com/p/libarchive/issues/detail?id=348
the read_concatenated_archives option provides functionality similar to
the GNUtar --ignore-zeros option in order to support reading from
archives which have been concatenated together.
Changes in v2:
* Replace recursion with looping for reading concatenated archives.
Changes in v3:
* Improve comments about archive format detection and looping when
reading concatenated archives.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Kevin Locke [Sat, 11 Jan 2014 23:35:21 +0000 (16:35 -0700)]
Only consume a second all-null record
Currently any record following an all-null record will be consumed.
This is probably not the intended behavior, as it does not match the
comment and consumes/ignores unexpected and unrecognized data. In
particular, for the read_concatenated_archives case, it could
incorrectly consume a non-null header.
Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
Tim Kientzle [Thu, 9 Jan 2014 05:20:10 +0000 (21:20 -0800)]
Only enable the still-experimental 'el' extra block
if option 'zip:experimental' is specified.
This should limit the use of this option until the
final format is actually nailed down.
Tim Kientzle [Mon, 30 Dec 2013 04:57:17 +0000 (20:57 -0800)]
Support experimental "at" extra block for better streaming.
The writer now writes this extra block with every local
file header; the reader recognizes it and uses it.
This allows streaming extraction to properly restore
file permissions and symlinks.
Without this, streaming extraction of Zip archives is
somewhat hobbled by the lack of full information in
the local file header.
Here's a detailed description of the new extra block.
The details here are subject to change at any time.
-Extended Local File Header Extra Field (0x7461):
The following is the layout of the extended local file
header "extra" block. This allows information to be
included with the local file header that could previously
only be stored with the central directory file header.
Note: all fields stored in Intel low-byte/high-byte order.
Value Size Description
----- ---- -----------
0x7461 2 bytes Tag for this "extra" block type
Size 2 bytes Size of this "extra" block
Version
Made By 2 bytes See "Version Made By" above
Internal File
Attributes 2 bytes See "Internal File Attributes" above
External File
Attributes 4 bytes See "External File Attributes" above
This extra block should only be used with the local
file header. The values stored should exactly match
the corresponding values in the central directory
file header.
Tim Kientzle [Sat, 28 Dec 2013 09:45:32 +0000 (01:45 -0800)]
Test for large Zip archives, following code for large Tar test.
Fix several bugs:
* comparison function for ordering entries in reader was wrong
* writer wasn't including 64-bit sizes for entries of exactly 0xffffffff bytes
Also, add options to suppress CRC calculations and checks
(otherwise, this test spends a *lot* of time in CRC routines).