Tim Kientzle [Sun, 8 Feb 2015 03:03:43 +0000 (19:03 -0800)]
Issue 406: Segfault on malformed Zip archive
Issue here was reading a size field as a signed number
and then using that as an offset. Fixed by correctly
masking the size value to an unsigned result.
Includes test based on the archive provided in the issue report.
Tim Kientzle [Sat, 7 Feb 2015 21:44:34 +0000 (13:44 -0800)]
A correct fix for Issue 404: Read past end of string parsing fflags
The previous fix actually broke the fflag parsing. We
cannot use strcmp() here because we're comparing a null-terminated
string to a part of another string.
This fix explicitly tracks the various string lengths and
checks that they match before calling memcmp() or wmemcmp().
That avoids any buffer overrun without breaking the parser.
Tim Kientzle [Sat, 7 Feb 2015 21:32:58 +0000 (13:32 -0800)]
Issue 402: Failed to recognize empty dir name in lha/lzh file
When parsing a directory name, we checked for the name
length being zero, but not for the first byte being a
null byte. Add a similar check for the file case.
Tim Kientzle [Sat, 7 Feb 2015 20:35:33 +0000 (12:35 -0800)]
Issue 403: Buffer underflow parsing 'ar' header
While pruning trailing text from ar filenames, we did not
check for an empty filename. This results in reading the byte
before the filename on the stack.
While here, change a number of ar format issues from WARN to FATAL.
It's better to abort on a damaged file than risk reading garbage.
No doubt, this will require additional tuning in the future.
Tim Kientzle [Sat, 7 Feb 2015 07:00:30 +0000 (23:00 -0800)]
Issue 398: Overlapping memcpy
Some of the pathname edits parse a part of the pathname
in the entry, then try to set the pathname from that part.
This leads the text routines to memcpy() from within the
string buffer.
Avoid this by simply using memmove() for low-level string append
operations.
Do not request 0-length skips; sanity-check return.
I noticed that my skip callback was always being invoked with a request of
0. This is a bit wasteful since skip callbacks commonly involve a syscall
like lseek().
Also, it seems good to error out when the skip callback is buggy, and claims
to skip more than requested.
Test Plan:
```
autoreconf -ivf && ./configure && make && make check
```
The same tests fail as before, with the same error messages. If interested,
both failure logs are here:
This commit ensures the variables CMAKE_C_COMPILER_ID and
CMAKE_C_COMPILER_ID will always be interpreted by removing
the double quotes.
It fixes warnings like this one:
CMake Warning (dev) at CMakeLists.txt:91 (IF):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "CMAKE_C_COMPILER_ID" will no longer be dereferenced
when the policy is set to NEW. Since the policy is not set the OLD
behavior will be used.
This warning is for project developers. Use -Wno-dev to suppress it.
Tim Kientzle [Sat, 10 Jan 2015 20:24:58 +0000 (12:24 -0800)]
Fix a potential crash issue discovered by Alexander Cherepanov:
It seems bsdtar automatically handles stacked compression. This is a
nice feature but it could be problematic when it's completely
unlimited. Most clearly it's illustrated with quines:
Tim Kientzle [Sat, 10 Jan 2015 19:55:29 +0000 (11:55 -0800)]
Issue #131: Implement tar --no-xattr
This option suppresses both archiving and
restoring xattrs. The latter relies on existing
machinery; for the former, I've added a
ARCHIVE_READDISK_NO_XATTR flag to archive_read_disk.
Caveat: I've not implemented any tests for these new features.
Tim Kientzle [Sat, 10 Jan 2015 18:27:11 +0000 (10:27 -0800)]
Issue 327: tar should accept zero-sized exclude files with -X
Key problem: We were using archive_read_format_raw() to read
the exclude file which does not accept empty files.
Enabling archive_read_format_empty() and reworking the
end-of-input handling fixed this.
Also add a test for this case to prevent it from regressing.
Tim Kientzle [Sun, 4 Jan 2015 07:46:57 +0000 (23:46 -0800)]
Issue 379: Zip containing another Zip misparsed
The revised code now scans backwards from the end
of the file to ensure we always pick the last end-of-central-directory
record in case there is more than one.
Tim Kientzle [Mon, 15 Dec 2014 04:14:19 +0000 (20:14 -0800)]
Fix typos in archive_pathmatch logic.
This was explored in pull request #78 by github user maksqwe.
After considering the alternatives, I think the existing
behavior was correct (but the comments were wrong and there was
extraneous code). Extended tests to cover this case and some
other cases that were not fully exercised.
This was originally submitted as:
https://github.com/libarchive/libarchive/pull/84
I've made the following corrections:
* Added a new variable for the deflate compression level (the submitted patch mis-used the requested_compression variable)
* Extended the Zip store format test to also verify correct results with compression-level=0
TODO: This really needs a new test to exercises non-zero compression-level options.
Dimitry Andric [Sat, 22 Nov 2014 12:01:08 +0000 (13:01 +0100)]
Fix the following -Werror warning from clang 3.5.0, while building cpio.c on amd64 (or any arch with 64-bit time_t):
libarchive/cpio/cpio.c:1143:6: error: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Werror,-Wabsolute-value]
if (abs(mtime - now) > (365/2)*86400)
^
libarchive/cpio/cpio.c:1143:6: note: use function 'labs' instead
if (abs(mtime - now) > (365/2)*86400)
^~~
labs
1 error generated.
This is because time_t is a long on amd64. To avoid the warning, just copy the equivalent test from a few lines before, which is used in the Windows case, and which is type safe.
Fix build failure on Windows.
- MSC does not allow this statement, char buf[static 10U].
- Use archive_string utility instead of snprintf.
- Use gmtime_r or _gmtime64_s if available for thread safe.
Property handle __archive_read_next_passphrase function.
Return the same passphrase while the passphraes is passed
even if it was passed by a callback function.