Hans Hinrichsen [Tue, 5 May 2015 03:30:01 +0000 (22:30 -0500)]
Fixes for VS2012 Compile
Updated includes in bsdtar_windows.h to bring in _setmode and _O_BINARY via io.h and fcntl.h
Explicitly cast a few void * to their structs to suppress Intellisense warnings
Moved variable in read_archive - VS2012 needs variables declared at the top of the block (does not support C99)
Hans Hinrichsen [Thu, 30 Apr 2015 03:45:31 +0000 (22:45 -0500)]
Fixes for VS2012 Compile
Fixes for VS2012 Compile
Added headers needed when compiling in Win32 without Cygwin
Some pointers needed to be explicitly cast
VS had a lot of trouble with storing the result of
archive_entry_pathname in a local variable
The only way I could get it to compile was to call the function twice
Tim Kientzle [Sun, 12 Apr 2015 06:21:43 +0000 (23:21 -0700)]
Nudge the Zip64 cutoff a little higher.
A simple test (feeding /dev/random through gzip) suggests
that deflate will only expand the data by 0.03% in the worst case.
So allow a 0.4% margin instead of the 6.25% I had here earlier.
Tim Kientzle [Sun, 12 Apr 2015 05:44:12 +0000 (22:44 -0700)]
Issue #522: Dir loop in malformed ISO causes segfault
Github Issue #522 revealed that we could blow the stack
when recursing to assemble ISO paths. I saw this happen
at 130,000 dir levels. This patch addresses this by limiting
the directory recursion to 1,000 elements.
TODO: It would be even better to track and detect the dir loop
directly.
Tim Kientzle [Wed, 4 Mar 2015 04:17:37 +0000 (20:17 -0800)]
Issue 410: Segfault on invalid rar archive
Libarchive's API passes a void ** which is set by the format
to the address of the entry data that was just read.
In one particular case, the RAR decompression logic uses a
non-NULL value here to indicate that the internal 128k decompression
buffer has been filled. But the RAR code took no steps to ensure
that the value was set NULL on entry. As a result, a crafted RAR
file can trick libarchive into returning to the caller a 128k block
of data starting at whatever value was previously in the caller's
variable.
The fix is simply to set *buff = NULL on entry to the RAR
decompression logic.
Tim Kientzle [Sat, 21 Feb 2015 17:36:23 +0000 (09:36 -0800)]
Issue 407: Tar reader tries to examine last character of an empty filename
Of interest: While working on this, I noted that we have
an existing test for tar files with empty filenames.
That test asserts that the correct behavior here is for the
format handler to return the entry with the empty filename
and a status of ARCHIVE_OK. Clients need to be robust against
empty filenames.
Rui Paulo [Tue, 17 Feb 2015 19:19:55 +0000 (11:19 -0800)]
xz: add the xz:threads option.
It's now possible to chose the number of threads used by the lzma
multi-threaded compressor using tar ... --xz --option xz:threads=N where
N is the number of threads. When N is 0, it will create threads based
on the number of CPUs (following the xz(1) model).
Rui Paulo [Mon, 9 Feb 2015 18:15:38 +0000 (10:15 -0800)]
libarchive: use lzma_stream_encoder_mt() if it's available.
This is the multi-threaded stream encoder version of lzma that brings
significant speed improvements. libarchive is using all the available
threads when lzma_stream_encoder_mt() is present.
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.