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).
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)
Graham Percival [Wed, 28 Sep 2016 18:02:34 +0000 (11:02 -0700)]
Initialize subst rule->result pointer to NULL
This is not directly useful in libarchive at the present time, but
it might be in the future. If a project which uses this code adds
an atexit(3) handler to clean up memory, and somebody runs:
bsdtar somestring -t
then "omestring" will be interpreted as an (invalid) substitution
rule and call lafe_errc(). However, if the atexit() handler then
calls cleanup_substition(), it will try to free(rule->result)
which was not initialized.
Graham Percival [Mon, 26 Sep 2016 19:50:29 +0000 (12:50 -0700)]
Add chmod() after make_{dir,file} in test suites
This is the same change that 38b3f516df865e2dffd0a1bbc9feb923ab2efc38
made to
libarchive/test/main.c
, but now applied to:
cat/test/main.c
cpio/test/main.c
tar/test/main.c
Graham Percival [Fri, 23 Sep 2016 17:56:21 +0000 (10:56 -0700)]
Issue 774, 782: chmod() after creating a file or dir
If the user's system has a default umask, then
mkdir(pathname, mode);
will report "success" even if the created dir does not match the specified
mode. Presumably that is desired in the general case, but when it comes to
testing libarchive this can generate false errors in `make check`.
chmod() is not affected by umask, so we call that after creating the file
or directory.
The sample file that demonstrated this had multiple 'EmptyStream'
attributes. The first one ended up being used to calculate
certain statistics, then was overwritten by the second which
was incompatible with those statistics.
The fix here is to reject any header with multiple EmptyStream
attributes. While here, also reject headers with multiple
EmptyFile, AntiFile, Name, or Attributes markers.
Tim Kientzle [Mon, 19 Sep 2016 00:27:47 +0000 (17:27 -0700)]
Issue 747 (and others?): Avoid OOB read when parsing multiple long lines
The mtree bidder needs to look several lines ahead
in the input. It does this by extending the read-ahead
and parsing subsequent lines from the same growing buffer.
A bookkeeping error when extending the read-ahead would
sometimes lead it to significantly over-count the
size of the line being read.