Romain Fliedel [Fri, 20 Jun 2014 13:45:09 +0000 (15:45 +0200)]
Silently ignore lchmod failure in when not supported
lchmod might be defined but not supported by the platform,
(this is the case with musl implementation of fchmodat) in
this case we can safely ignore the error.
Check for legal HTTP but illegal unix filenames in WARCs archives.
This changeset will refuse to extract WARCs that contain filenames
a la http://example.com/implicit/content/
There is a todo note in archive_read_support_format_warc.c discussing
possible archive options to extract filenames like those either by
explicit user input or by some sort of heuristic as used in wget
for example.
This changeset adheres to the previously imported read test.
The archive format is hard-set to ARCHIVE_FORMAT_WARC, while the
format name is the stringified WARC/x.y version designator, which
for performance reasons will be cached between calls to the header
reader _warc_rdhdr().
Hygiene, set unconsumed slot exactly once for each branch
in _warc_read(). Also kick __archive_read_consume() because the writer
will consume the bytes for us. So for the EOF case, set unconsumed to 0,
for the non-EOF case set unconsumed to the minimum of the number of bytes
read and the content length.
Hygiene, trust __archive_read_ahead() and kick superfluous check.
Heeding Tim's advice, a non-NULL from __archive_read_ahead() is
guaranteed to be of at least the minimum size, therefore no need to
check for this condition again.
fix, never write more bytes in _warc_data() than ...
previously announce in _warc_header().
The test suite (as is) is one offender. It populates a 9-byte string, mimicking an IFREG file
but by the time the header makes it into the archive, the size changes from 0 to 9.
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.