Konrad Kleine [Wed, 9 Oct 2013 11:53:15 +0000 (13:53 +0200)]
Better archive_read_has_encrypted_entries function
These are the possible return values:
=====================================
ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED (-2):
------------------------------------------------
This is the default return value for reader that don't support
encrpytion detection at all. When this value is returned you can be sure
that it will always be returned even on later calls to
archive_read_has_encrypted_entries.
ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW (-1):
----------------------------------------------
This is the default return value for readers that support encryption. It
means that the reader is not yet ready (e.g. not enough data was read so
far) to say that there are encrypted entries in the archive. Over time
as more data was consumed by a reader this value might change to 0 or 1.
0:
--
No encrypted entries were found yet (maybe there will be one when
reading the next header). When 0 is returned, it might be that on a
later call 1 will be returned.
1:
--
At least one encrypted entry was found. Once 1 is returned. It will
always be returned even if the another entry is not encrypted.
NOTE:
=====
If the metadata/header of an archive is also encrypted, you
cannot rely on the number of encrypted entries. That is why this
function does not return the number of encrypted entries but
just 1 to show that there are some. Also, two distinct readers might
detect the number of entries and their encryption status at different
times. If one reader can say how many files are encrypted after reading
the first header another reader might need more data. In the end the
number of encrypted entries might be the same in two archives while the
appropriate readers output different results at different points in
time. This is more confusing than helpful.
Konrad Kleine [Mon, 1 Jul 2013 15:12:24 +0000 (17:12 +0200)]
Detect encrypted archive entries (ZIP, RAR, 7Zip)
With this change you can detect if an archive entry is encrypted. The
archive formats covered with this change are: ZIP, RAR, and 7zip. Other
formats can be added quite simply by looking at the already supported
formats. For all the already supported formats we have tests that check
if:
* an archive entries's data is encryped (data test)
* an archive entries's metadata is encrypted (header test)
* one file is encrypted while another is not (partially test)
These new functions are introduced.
int archive_read_format_capabilities(struct archive*)
Returns a bitmask of capabilities that are supported by the archive
format reader. If the reader has no special capabilities,
ARCHIVE_READ_FORMAT_CAPS_NONE is returned; otherwise 0 is returned.
You can call this function even before reading the first header from
an archive.
Return Values:
* ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
The reader supports detection of encrypted data.
* ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA
The reader supports detection of encrypted metadata (e.g.
filename, modification time, size, etc.)
* ARCHIVE_READ_FORMAT_CAPS_NONE
None of the above capabilities. If this value is returned, this
doesn't mean that the format itself doesn't support any type of
encryption it simply means that the reader is not capable of
detecting it.
int archive_read_has_encrypted_entries(struct archive *)
Returns "true" (non-zero) if the archive contains at least one
encrypted entry, no matter which encryption type (data or metadata)
is used; otherwise 0 is returned.
You should only call this function after reading the first header
from an archive.
NOTE: I'm not sure that this function will stay in for long.
int archive_entry_is_data_encrypted(struct archive_entry*)
Returns "true" (non-zero) if the archive entry's data is encrypted;
otherwise 0 is returned. You can call this function after calling
archive_read_next_header().
int archive_entry_is_metadata_encrypted(struct archive_entry*)
Returns "true" (non-zero) if the archive entry's metadata is
encrypted; otherwise 0 is returned. You can call this function after
calling archive_read_next_header().
int archive_entry_is_encrypted(struct archive_entry*)
Returns "true" (non-zero) if either the archive entry's data and/or
it's metadata is encrypted; otherwise 0 is returned. You can call
this function after calling archive_read_next_header().
If you use archive_read_format_capabilities() in combination with one of
the archive_entry_is_[data|metadata]_encrypted() functions, you can be
sure that you've encountered an encrypted entry. This allows you to
react differently depending on libarchive's return codes. For instance,
you might want to skip encrypted files from being extracted until
decryption support has been implemented.
Here's how I generated the 7zip test files:
-------------------------------------------
Konrad Kleine [Thu, 12 Sep 2013 15:01:31 +0000 (17:01 +0200)]
Added all Zip compression names from 6.3.3 format
I've added all the compression names and IDs from the ".ZIP File Format
Specification" version 6.3.3 that can be found in section "4.4.5
compression method" of this document:
Pavel Raiskup [Thu, 27 Jun 2013 14:01:30 +0000 (16:01 +0200)]
Use ustar format in the test_option_b test
.. because the ustar archive does not store SELinux context. As the default
format for bsdtar is "restricted pax" (trying to store xattrs and other
things by default), the test failed on Fedora because our files have by
default SELinux context set. This results in additional data in tested
archive ~> and the test failed because the archive was unexpectedly big:
tar/test/test_option_b.c:41: File archive1.tar has size 3072, expected 2048
Reviewed by Konrad Kleine <konrad.wilhelm.kleine@gmail.com>
Tim Kientzle [Thu, 11 Apr 2013 04:52:15 +0000 (21:52 -0700)]
Issue 314: A tar archive containing only a single 'g' record
should be treated as a valid empty tar archive.
(Such archives are generated by 'git archive' from an empty
repository.)
Tim Kientzle [Sat, 23 Mar 2013 06:48:41 +0000 (23:48 -0700)]
Limit write requests to at most INT_MAX.
This prevents a certain common programming error (passing -1 to write)
from leading to other problems deeper in the library.
Xi Wang [Sun, 20 Jan 2013 23:17:20 +0000 (18:17 -0500)]
Fix overflow checking in archive_entry_sparse_add_entry()
gcc will optimize the overflow check x + y < 0 (assuming x, y >= 0)
into false, since signed integer overflow is undefined behavior in C.
Use a safe precondition check instead.
Andres Mejia [Sun, 24 Feb 2013 18:06:28 +0000 (13:06 -0500)]
Fix test_archive_write_add_filter_by_name_lrzip test case.
There's some bug in lrzip where small files cannot use 2nd stage
compression.
See http://ck-hack.blogspot.com/2012/03/lrzip-0612.html?showComment=1337356929450#c3154145708572533571
Andres Mejia [Sun, 24 Feb 2013 16:54:26 +0000 (11:54 -0500)]
Fix test cases for LZO write support.
Some architectures would produce a bigger archive for compression
level 9 than with the default level, possibly due to memory
limitations.
Fixes #303
Andres Mejia [Fri, 8 Feb 2013 20:00:05 +0000 (15:00 -0500)]
Change crypto checks, find necessary library before corresponding checks are done.
LIBS are set back to original value if all crypto checks for that implementation
fail.
Andres Mejia [Tue, 5 Feb 2013 22:51:15 +0000 (17:51 -0500)]
Provide better check for when libpcreposix is to be used for regex support.
On Windows, if the static libraries for PCRE are to be used and the PCRE static libs were built
using the mingw toolchain, libgcc must also be linked for resolving the symbol ___chkstk_ms.
Dave Reisner [Fri, 6 Jul 2012 03:31:49 +0000 (23:31 -0400)]
build-sys: install all library manpages
A number of manpages were curiously omitted from the installation
process, but are referred to in installed manpages. To avoid developers
spontaneously combusting, ship all available manpages.
Andres Mejia [Mon, 4 Feb 2013 03:05:34 +0000 (22:05 -0500)]
Fix crypto check failures on Windows.
Checks will now be similar to checks done with autotools, where all defines are passed into a source file
along with the append source code to be checked. Also, once a library that support a crypto function is
found, all other checks for that crypto function will be skipped.
Andres Mejia [Fri, 1 Feb 2013 21:52:19 +0000 (16:52 -0500)]
Modify CHECK_C_SOURCE_* checks to fix builds using Visual Studio 12.
This is needed to fix build failures using Visual Studio 12 and using libraries such as liblzma which
have been built without the "/SAFESEH" linker flag (which is the usual case for libraries built using
the mingw toolchain).
Andres Mejia [Fri, 1 Feb 2013 00:20:34 +0000 (19:20 -0500)]
Add CMake option to explicitly enable/disable /SAFESEH linker flag for Visual Studio builds.
Visual Studio 12 enables this option by default. Enabling /SAFESEH will produce build failures when
attempting to link other libraries which were not built with /SAFESEH. This would typically be
the case for libraries built using the mingw toolchain, where the option to use structured exception
handling is not yet available.
The option is used as follows.
Setting to "YES" sets "/SAFESEH" linker flag
Setting to "NO" sets "/SAFESEH:NO" linker flag
Setting to any other value such as "AUTO" won't do anything (set the default linker flag from Visual Studio)
Andres Mejia [Thu, 31 Jan 2013 23:39:39 +0000 (18:39 -0500)]
Support POSIX regular expression support using PCRE in CMake builds.
This change is mainly meant for Windows regex support, where PCRE Windows development is much
more active than development of the regex library found in the GNUWin32 packages. I found that
the latest release of PCRE built right out of the box, unlike the GNUWin32 regex library released
6 years ago which failed to build from source for me using the mingw toolchain.