Peter Wu [Fri, 23 Dec 2016 11:45:43 +0000 (12:45 +0100)]
Issue #822: Try harder to detect directories in zip archives
Assume that anything with a trailing slash is a directory. This avoids
creating regular files when a directory is expected and could occur
when the External File Attributes (EFA) field in the Central Directory
contains bogus values:
- Jar file: observed to have OS MS-DOS (0) and EFA 0.
- dex2jar-2.0.zip: observed to have OS Unix (3), but EFA 0xffff0010.
After this patch, bsdtar tv still shows mode drwsrwsrwt, but at least
it successfully creates a directory instead of a regular file.
A test case has been added for the first case (based on
test_read_format_zip_nofiletype).
Ngie Cooper [Sun, 11 Dec 2016 02:32:11 +0000 (18:32 -0800)]
Fix memory management issues
1. Assert that `f` isn't NULL to strengthen the guarantee that
it's valid.
2. Assert that `rawimage` isn't NULL to strengthen the guarantee
that it's valid.
3. Do not leak `tmp`
4. Free `rawimage` in all instances; NULL out the value to avoid
double-free'ing it by accident
Ngie Cooper [Sun, 11 Dec 2016 02:17:01 +0000 (18:17 -0800)]
- Only allocate `mine` when level == 1 to clarify its lifetime and
leak the value less often.
- Only free mine->copy_buff when mine != NULL to avoid segfaults if
memory_read_close(..) is called with client_data == NULL.
This should either address or mitigate the issue reported with Coverity
(CID # 1331663)
Ngie Cooper [Sun, 11 Dec 2016 01:59:03 +0000 (17:59 -0800)]
Fix several coverity issues with test_read_append_filter_wrong_program
1. Ignore errors from fsetpos to mute complaint from Coverity
2. Make sure the first dup2 succeeds to quell complaints from Coverity
about negative values being passed into the subsequent dup2 call.
3. Unconditionally close fd [3]. Although it's unlikely for freopen to
fail, it can happen.. closing fd shouldn't be contingent on freopen's
success.
Ngie Cooper [Sun, 11 Dec 2016 00:15:18 +0000 (16:15 -0800)]
Increase the size of buff by 1 and adjust the readlink(2) call to
subtract the buffer len by 1 to account for the needed space for a
NUL terminator, as readlink isn't guaranteed to provide one
Martin Matuska [Mon, 5 Dec 2016 00:05:12 +0000 (01:05 +0100)]
Relax sanity checks of number fields in tar header even more.
This fixes reading tar archives created by plexus-archiver (used e.g. by
maven-assembly-plugin to create source and binary tar distributions)
version 2.6.2 and lower. These archives may have entries with uid and gid
header fields filled with spaces without any octal digits.
Tim Kientzle [Fri, 2 Dec 2016 04:09:59 +0000 (20:09 -0800)]
Rework the valid_number_field test function to be more
lenient. There are an enormous number of tar writing
programs, many which don't quite follow the specs.
Note: I don't think I recall seeing any that left
number fields with trailing garbage; I may be wrong
about that, in which case, this would have to stop
at the first NUL (after the first octal character).
Jan Osusky [Wed, 23 Nov 2016 19:24:38 +0000 (20:24 +0100)]
Allow tar header fields without null terminator
The "archive_read_format_tar_bid" and related "validate_number_field"
were revisited to allow one more non-standard way of coding UID/GID
and similar number fields in the tar header.
Modified "test_compat_gtar" to verify reading of such value.
Jan Osusky [Tue, 22 Nov 2016 17:17:31 +0000 (18:17 +0100)]
Add test of raw file which fooled tar
Added test with raw file (truncated to 4kB) which was mis-detected
as tar and caused quite an issue. The file was originally compressed
that's why any libarchive functionality was used on it but the
key issue was the similarity of the raw data to a tar file header.
The data is a BUFR bulletin in WMO FTP file format.
Jan Osusky [Tue, 22 Nov 2016 15:19:25 +0000 (16:19 +0100)]
Make sanity check of UID/GID/... fields compatible GNU TAR
The GNU tar uses a nasty trick to overcome size limitation of certain fields.
If the value is reasonable it uses octal numbers but if the value is too big,
e.g. 2097152 (10000000 octal) for UID, then it switches to base265 encoding
(i.e. raw binary representation of the corresponding integer).
Now the sanity check in "archive_read_format_tar_bid" uses helper function
validate_number_field() which validates what can be validated.
Tomas Mraz [Thu, 17 Nov 2016 20:44:44 +0000 (15:44 -0500)]
Add support for building with OpenSSL 1.1
OpenSSL 1.1 made some CTX structures opaque. Port our code to use the
structures only through pointers via OpenSSL 1.1 APIs. Use our adaption
layer to make this work with OpenSSL 1.0 and below.
Brad King [Thu, 17 Nov 2016 20:26:41 +0000 (15:26 -0500)]
Add infrastructure to adapt between OpenSSL 1.1 and older versions
Add private forwarding headers for `openssl/{evp,hmac}.h` to give us a
central place to add adaptation code to work across multiple
incompatible OpenSSL versions. Provide compatibility implementations of
some OpenSSL 1.1 APIs when using older OpenSSL versions.
Jan Osusky [Mon, 14 Nov 2016 10:24:35 +0000 (11:24 +0100)]
Add sanity check of tar "uid, "gid" and "mtime" fields
Sometimes a bz2 file is identified as tar.bz2, i.e. a chunk of
raw data may look like a tar header (metadata block).
To reduce chance of such false positive, the format of uid, gid
and mtime field is checked. This fields are expected to contain
octal numbers. In fact, also space and '\0' are allowed - perhaps
I am too liberal.
Andrew Gregory [Tue, 1 Nov 2016 16:42:14 +0000 (12:42 -0400)]
mtree: use hash table for duplicate entry search
Because mtree combines multiple non-adjacent entries for the same file,
parse_file() has to compare every entry to every other entry. For large
mtree files, this results in extremely long parse times. By breaking
the entries down into a hash table, the number of comparisons required
can be drastically reduced. The hash function was taken directly from
the standard user/group lookup code.
Pavel Raiskup [Tue, 25 Oct 2016 12:30:31 +0000 (14:30 +0200)]
distribute README.md
This issue happened because 'foreign' automake option is enabled,
and the file README was renamed as README.md (not included
automatically by automake).
This issue is not ppc64le specific. I have experienced on my
4.4.22-gnu #1 SMP 1 i686 GNU/Linux. Might be dependant on kernel
version and/or machine load. POSIX says errors after posix_spawnp
returns can be signaled by child exitting with an 127 exit code.
Martin Matuska [Fri, 14 Oct 2016 12:31:23 +0000 (14:31 +0200)]
Add build/ci_build.sh for automatic building on Travis CI, Jenkins, etc.
Add autotools build to .travis.yml
Downgrade minimal supported autoconf version to 2.68 (Travis CI)