Eliminate warnings on Visual Studio 10 W64.
On Win64, the size of 'int' is stil 4 bytes and the size of 'size_t'
is 8 bytes. A conversion from 'size_t' to 'int', causes warning
with compiling.
Brad King [Wed, 16 Dec 2009 13:52:05 +0000 (08:52 -0500)]
Isolate libxml header check
The check HAVE_LIBXML_XMLREADER_H should not use LA_CHECK_INCLUDE_FILE
because it sets CMAKE_REQUIRED_INCLUDES for only the one check. The
LA_CHECK_INCLUDE_FILE macro accumulates headers that exist for use in
future checks, but including libxml/xmlreader.h breaks later checks
because they do not set CMAKE_REQUIRED_INCLUDES. Instead we use
CHECK_INCLUDE_FILES directly for this check.
Brad King [Wed, 16 Dec 2009 13:32:27 +0000 (08:32 -0500)]
Create ENABLE_OPENSSL CMake option
This option tells libarchive whether to check for OpenSSL and use it.
We enable it by default since we previously did this unconditionally.
This provides the CMake equivalent to the --without-openssl option,
spelled as -DENABLE_OPENSSL=OFF. See issue #22.
Tim Kientzle [Mon, 14 Dec 2009 02:54:07 +0000 (21:54 -0500)]
Refactor the release-building scripts just a bit:
* bump-version.sh actually bumps the 'version' value
* clean.sh attempts to clean the local directory as thoroughly as possible
* autogen.sh runs clean.sh, edits the current version value into
configure.ac, archive.h, and archive_entry.h, re-runs autoconf/automake/etc,
and does a ./configure && make distcheck to verify the distribution on the
local system.
Tim Kientzle [Sun, 13 Dec 2009 23:30:00 +0000 (18:30 -0500)]
A few Cmake build improvements from Issue 48:
* Use the path holding the current file to make the build/cmake/*.cmake
files more independent
* Use CMAKE_CURRENT_SOURCE_DIR in the top-level CMakeLists.txt to locate
the macro files and the version file.
Tim Kientzle [Sat, 12 Dec 2009 23:40:49 +0000 (18:40 -0500)]
Cpio "odc" format limits the ino value to 18 bits. Previously, we
simply truncated larger values, which can lead to false collisions and
false hardlink detection, especially on filesystems such as NTFS that
use 64-bit ino values. Because of the risk, we must issue a warning
in this case, and the warnings have been creating problems for the
bsdcpio test suite.
In order to avoid this problem, map the incoming ino values to new ino
values. This allows us to store up to 256k distinct files without
risk of false hardlinks. The only drawback to this approach is the risk
of losing hardlinks when appending to existing archives.
Tim Kientzle [Sun, 6 Dec 2009 07:36:55 +0000 (02:36 -0500)]
Further refine the index number checks for cpio and extend
them to newc as well.
This is in preparation for work to generate synthetic index
numbers when writing cpio formats, in order to avoid truncation
problems.
Tim Kientzle [Sun, 6 Dec 2009 07:30:32 +0000 (02:30 -0500)]
1) Empty cpio test uses assertEqualMem() for better error reporting.
2) cpio_odc test permits synthetic ino values:
* Zero input values must get written as zero
* Matching non-zero values must get written as matching non-zero values
* Non-matching non-zero values must get written as non-matching non-zero values
When creationg a hash, a persisted private key is unneeded.
This patch avoids a possibility that calling CryptAcquireContext()
cause an accss error.
see also http://support.microsoft.com/kb/238187/en-us/
Brad King [Tue, 1 Dec 2009 16:08:04 +0000 (11:08 -0500)]
Remove STDC_HEADERS check from non-autoconf builds
This autoconf check is used only within its configure tests and is not
used in libarchive source code. The CMake configuration test used a
try_run(), which prevents cross-compiling without manual specification
of the result. Since the result of the test is not used anyway we
simply remove it.
Brad King [Mon, 30 Nov 2009 15:19:45 +0000 (10:19 -0500)]
Support openssl without SHA-2 hash functions
Previously we assumed that <openssl/sha.h> provides all the SHA-2 hash
functions if it exists. Some OpenSSL installations do not, so we need
to test for them at configuration time. Currently we perform the tests
only for CMake builds. We preserve the old behavior for the autotools
build by hard-coding availability, and leave a TODO comment for someone
to actually add the checks.
Brad King [Mon, 30 Nov 2009 15:19:36 +0000 (10:19 -0500)]
Fix hash function config tests with CMake
The commit "Improve portability of MD5/SHA* headers and functions" added
both autotools and CMake detection of MD5, RMD, and SHA* hash functions.
The commit "Move hashing function calling into a separate file" rewrote
the autotools logic and changed the source to use different config
macros but did not update the CMake logic. This commit updates the
CMake configuration tests to produce the result macros the code expects.
Tim Kientzle [Mon, 30 Nov 2009 00:46:08 +0000 (19:46 -0500)]
Several fixes to Windows handling in tree.c:
* Convert \ to / on entry; this allows us to remove duplicate '/' and '\' checks from a couple of places
* Rework tree_append() to make it clearer that buff != NULL by the time we get to anything interesting (found by Clang)
* After appending initial path, set the path length so it doesn't get overwritten
Tim Kientzle [Sun, 29 Nov 2009 23:09:46 +0000 (18:09 -0500)]
The fuzz tester uncovered an infinite loop in the recovery code that
searches forward for the next undamaged cpio header. This occurred
when the number of bytes returned by the next read operation happened
to be exactly the size of a cpio header. In this case, an off-by-one
error caused this code to decide that it didn't have enough bytes to
examine and then to loop around and ask for the exact same bytes again.
Tim Kientzle [Sun, 29 Nov 2009 20:35:13 +0000 (15:35 -0500)]
r1679 provides a way to gracefully handle the failure to decompress single ZISOFS entries; use that to suppress test failures in environments that lack zlib.
Tim Kientzle [Sun, 29 Nov 2009 20:33:21 +0000 (15:33 -0500)]
"Fix" this test on Win32 by suppressing tests of error handling that relies on proper error detection within archive_entry_update_pathname_utf8().
The core problem here is that Windows has several different APIs for character-set conversion. These tests rely on the POSIX-standard setlocale() to set the default character set for this process in order to then force character-conversion failures and verify the error-handling. But the Win32 APIs don't obey setlocale() so this fails. Indeed, I've found no way to programmatically override the CP_ACP code page for just the current process: I considered using CP_THREAD_ACP instead but it seems to be broken (or at least there are a lot of bloggers claiming it should never be used). It doesn't help that Windows documentation confuses "code page" with "language" (SetCurrentLocale() accepts a language code but the documentation claims it sets the code page while offering no insight into how language codes get mapped to code pages---remember that Japanese and Chinese are supported by several code pages). I've gleaned from various blogs that the default code page cannot be set to UTF-8 in any case due to some bad assumptions deep in Win32's character-conversion routines (this implies, of course, that there is a way to set the default code page, which I've not been able to find). From this, it appears that it's simply not possible to do the kind of testing I want to do here; if someone knows otherwise, please let me know.
Tim Kientzle [Sun, 29 Nov 2009 20:16:17 +0000 (15:16 -0500)]
Failure to decompress a single entry is not a FATAL problem (the entire archive is not dead), it's merely a FAILED problem (this entry is dead, but the rest of the archive may be readable).
Tim Kientzle [Thu, 19 Nov 2009 07:15:10 +0000 (02:15 -0500)]
Clang static analysis found an error return that was being
ignored. If copying data from an archive into a file on disk
fails with a fatal read error, exit with an error, since we
can't progress if the archive is broken. If it fails writing
to the file on disk, arrange for cpio to exit with an error.
Rename 'copy_data' to 'extract_data' to make it clearer that
it's only used when extracting data to disk.
Thanks to Michihiro NAKAJIMA for performing the analysis and fixing
most of the issues found.
Brad King [Wed, 18 Nov 2009 14:15:28 +0000 (09:15 -0500)]
Use _CrtSetReportMode only where available
We test for this function in <crtdbg.h> at CMake configuration time and
store the result as a HAVE__CrtSetReportMode configuration macro. We
need not perform the test for an autotools build because it supports no
platform that provides the function and the macro will be undefined.
Brad King [Wed, 18 Nov 2009 14:14:18 +0000 (09:14 -0500)]
Use ADD_TEST_28 macro to fix tests with the VS IDE
This macro simplifies creation of tests that refer to executables built
in the project. We can pass executables as arguments to a test using a
CMake 2.8 "generator expression" of the form "$<TARGET_FILE:myexe>".
The macro translates the arguments into something CMake 2.6 understands.
This change also fixes the tests so that they run correctly in build
trees created for multi-configuration build tools like the VS IDE.
These tools place executables in a per-configuration subdirectory so
references to executables in test arguments must use a test-time
substitution. The ADD_TEST_28 macro handles this automatically.