100 Commits
Author SHA1 Message Date
Brad King b5fce10e32 7zip: Fix out-of-bounds access on ELF 64-bit header
The ELF specification's `Elf64_Ehdr` type is 64 bytes [1].
`find_elf_data_sec` accesses the last field, `e_shstrndx`.
Make sure we read enough data to populate it.

[1] https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html
2026-02-27 16:31:52 -05:00
Brad King d4cf95cdac archive_write: Fix crash on failure to convert WCS/UTF-8 pathname to MBS
If an entry pathname is set only by WCS or UTF-8, it may not have any
MBS representation in the archive's hdrcharset.  Do not crash or create
an archive with an empty pathname.  Furthermore, the entry pathname may
not have any MBS representation in the current locale.  Do not report a
`(null)` pathname in the error message.
2026-02-05 20:40:23 -05:00
Brad King 84bda647d2 archive_string_append_from_wcs: Fix silently lossy conversions on Windows
On Windows, since commit ae54394104 (Implement a string conversion
interface..., 2011-05-09, v3.0.0a~398), `archive_string_append_from_wcs`
no longer returns an error on use of replacement characters in non-C
locales.  Restore the error to avoid silent use of replacement
characters, and for consistency across platforms.
2026-02-05 19:26:43 -05:00
Brad King 3aabd7ad8d archive_string_conversion_charset_name: Fix calls for current locale
Some code paths may call `archive_string_conversion_charset_name(sconv)`
with `sconv == NULL` when converting to/from the current locale.
2026-02-05 19:26:43 -05:00
Brad King 00690bbf99 archive_mstring_get_mbs_l: Restore error on failure to convert from WCS/UTF-8
Prior to commit c30f279475 (Complete support for UTF8 encoding
conversion, 2020-05-31, v3.5.0~32^2), `archive_mstring_get_mbs_l` returned
an error on failure to convert WCS to MBS.  Restore the error so callers
can distinguish conversion failure from having no string in any form.

On Windows, `archive_mstring_get_mbs_l` from WCS with `sconv != NULL`
internally calls `archive_string_append_from_wcs_in_codepage` more than
once, with both `sconv != NULL` and `sconv == NULL`.  Due to another bug
in the `sconv == NULL` case, we cannot enable all test combinations yet.
2026-02-05 19:26:43 -05:00
Brad King eacdc8d99c archive_string_append_from_wcs: add test case for conversion failure 2026-02-05 18:53:28 -05:00
Brad King 2d987e725f parse_date: handle dates in 2038 and beyond if time_t is big enough 2025-09-26 17:48:56 -04:00
Brad King 7c3980367e tar: fix memory leaks when processing symlinks or parsing pax headers (#2338)
Fix memory leaks introduced by #2127:

* `struct tar` member `entry_linkpath` was moved at the same time as
   other members were removed, but its cleanup was accidentally removed
   with the others.

* `header_pax_extension` local variable `attr_name` was not cleaned up.

Resolves #2336
2024-09-20 14:11:43 +02:00
Brad King 14b851936d windows: include archive_platform.h first in blake2s sources
Move the inclusion added by commit 90978db1 (windows: make sure we use
the right calling convention for libc, 2021-10-13, v3.6.0~39^2~1) to be
first.  This is our convention in all other `.c` sources.  It ensures
that our configured `_WIN32_WINNT` value is defined before including any
system headers.
2022-02-16 07:32:57 -05:00
Brad King 578a8a1bf1 Merge pull request #1522 from bradking/no-u_char
Use uint8_t instead of u_char
2021-04-06 14:11:36 -04:00
Brad King a4e76bdf94 Use uint8_t instead of u_char
The latter is not a standard type.
2021-04-05 10:10:48 -04:00
Brad King 2b8c3abeb3 Fix possible heap-buffer-overflow in archive_string_append_from_wcs on Windows
Fix `archive_string_append_from_wcs_in_codepage` to account for the
already-used portion of the buffer when computing the size of the
remaining buffer for `WideCharToMultiByte` output.
2020-02-06 15:00:05 -05:00
Brad King 824956c40d libarchive: Fix detection of 'major' on Solaris 11.4
In `archive_pack_dev.c` there is code checking the `HAVE_MAJOR` macro,
but it is not computed.  Port the equivalent logic from
`archive_entry.c` to define the macro.
2020-01-30 09:49:22 -05:00
Brad King 748a1942dc b64encode: avoid name conflict with Solaris built-in function
Solaris 11.4 has a built-in function named `b64_encode`.  Add a
`la_` prefix to our internal function to avoid conflict.
2019-05-21 07:43:39 -04:00
Brad King 47bec12b98 Do not use nanosecond file time APIs on macOS < 10.13
The SDK for macOS 10.13 adds `futimens` and `utimensat` so our checks
for these symbols may pass.  However, the symbols are not available at
runtime on older macOS versions.  Instead on macOS we can check for
availability based on the deployment target version.
2017-09-20 11:26:21 -04:00
Brad King bb29029333 Define bcrypt macro not available in Win 7 SDK
VS 2010 comes with the Win 7 SDK and its bcrypt.h does not define the
`BCRYPT_HASH_REUSABLE_FLAG` macro.  Provide the definition locally if
it is not available.
2017-02-24 07:33:32 -05:00
Brad King 8d49d9b913 Avoid using C99 declaration-after-statement syntax
Add a dedicated `{}` block to contain a local variable instead.
2017-02-24 07:14:26 -05:00
Brad King c19ad305ef Avoid using ssize_t in public header
This type is not available on Windows compilers, so define `la_ssize_t`
for use in `archive_entry.h` as we do in `archive.h` already.
2017-02-20 09:23:40 -05:00
Brad King acd1d96d3e Check for EVP_CIPHER_CTX_new failure (#836)
If this OpenSSL function fails to allocate memory it returns NULL.
2016-12-06 17:35:14 +01:00
Brad King e291f7eca5 Merge branch 'openssl-1.1'
Pull-request: #826
2016-12-05 11:17:53 -05:00
Brad King aa8f770839 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.
2016-11-21 13:56:54 -05:00
Brad King 2699babc95 Fix spelling typos in comments
The Debian package checker tool (lintian) detected a few typos.

Reported-by: Felix Geyer <fgeyer@debian.org>
2016-05-02 10:56:28 -04:00
Brad King c7fcc6b295 Use CommonCrypto APIs on OS X only when available
Use each CommonCrypto API only when using an OS X SDK version new enough
to provide it.
2015-10-26 10:20:51 -04:00
Brad King 844b006283 Do not use pthread.h API without header 2015-10-26 10:20:50 -04:00
Brad King 345be3839e Define O_CLOEXEC when missing in archive_random.c
We do this several other sources already.
2015-10-26 10:20:50 -04:00
Brad King 3c445f393b Forward declare __archive_get_date in a dedicated internal header
Avoid repeating the signature declaration in every source that uses it.
While at it, constify internal __archive_get_date implementation to
keep signatures consistent.
2015-10-26 10:20:47 -04:00
Brad King 5474f3cf62 Use macros for ZIP format integer constants
Define ZIP_4GB_MAX and ZIP_4GB_MAX_UNCOMPRESSED macros to hold the "LL"
integer literals.  This improves readability and improves portability of
the integer literals.
2015-10-26 10:17:50 -04:00
Brad King 2fe3bcb8c9 Invert logic of ternary pointer checks
A PGI compiler warning is triggered by expressions like

  ptr == NULL ? NULL : ptr

that the PGI compiler handles incorrectly.  It chooses the pointer type
of the first option (void*) and warns about conversion of the second
without a cast.  Flip the expression logic to

  ptr != NULL ? ptr : NULL

to help the compiler choose the proper result type.
2015-10-26 10:17:49 -04:00
Brad King 72afc6f0e8 Improve readability of ternary expression checking for empty string
In expressions of the form

    m != NULL && m[0] == '\0' ? NULL : m

the goal is to get a `NULL` pointer if `m` is either `NULL` or an empty
string.  This is not clear because in the `m == NULL` case we use the
`m` side to get `NULL` instead of an explicit `NULL`.  Clarify the
intent by using the form

    (m != NULL && m[0] != '\0') ? m : NULL;

instead.
2015-10-26 10:17:49 -04:00
Brad King a81ffc0723 Guard inclusion of bcrypt.h with HAVE_BCRYPT_H
We already use this guard everywhere except one inclusion.
2015-10-26 10:14:39 -04:00
Brad King 25439c86ed Improve argument names of xmemmem
AIX system headers define the symbol 'hz' as a preprocessor macro.
Rename the arguments to avoid this name and be more readable.

Suggested-by: Joerg Sonnenberger
2015-10-26 09:21:59 -04:00
Brad King a2004af247 Avoid non-portable u_int8_t
Use uint8_t that we prepare in config.h instead.
2015-10-26 09:17:13 -04:00
Brad King fc07e16eff Avoid trailing , in enum for ISO C90 compatiblity 2015-10-26 09:17:13 -04:00
Brad King cecac1996c Workaround missing byte swap symbol on VS 7.1 Debug builds
The VS 7.1 MS C Debug runtime library does not export _byteswap_ushort.
2015-10-26 08:59:26 -04:00
Brad King 7f3fc93072 Port main library code to OSF operating system
Add preprocessor conditionals using '__osf__' as needed to build the
main library.  Do not try to port the tests or executables yet.
2015-10-26 08:59:26 -04:00
Brad King 4db7019c93 Update 'inline' portability for old IBM and Sun compilers 2015-10-26 08:59:26 -04:00
Brad King a46ec9a0bc Avoid using 'uint8_t' as bitfield type
The IBM XL compiler does not like it.  Use plain 'unsigned' instead.
2015-10-26 08:59:26 -04:00
Brad King 1696105057 Avoid using name 'u_long'
The system headers on some platforms define a 'u_long' type so we cannot
use the name.  Spell out 'unsigned long' instead.
2015-10-26 08:59:26 -04:00
Brad King 963983ab5b Avoid left-shift overflow of signed integer
In libarchive/archive_write_set_format_zip.c there are two calls to
archive_le32enc whose second argument is of the form

 archive_entry_mode(zip->entry) << 16

However, the return type from archive_entry_mode may be a signed integer
so the shift may overflow.  Since the second argument of archive_le32enc
expects uint32_t anyway, simply cast to that prior to shifting.
2015-10-26 08:59:26 -04:00
Brad King e091ed9a17 Fix typo in archive_write_add_filter_lzop.c comment 2015-10-26 08:59:26 -04:00
Brad King 20afd34b6a Fix typo in archive_write_set_format_mtree.c comment 2015-10-26 08:59:26 -04:00
Brad King 3ce2e63be6 Fix typo in archive_write_set_options.3 2015-10-26 08:59:25 -04:00
Brad King 58a482eb85 Define ARCHIVE_VERSION_NUMBER before first use 2015-10-26 08:58:27 -04:00
Brad King c06c997e53 README: Update issue tracker link to refer to GitHub issues
Also mention this in the NEWS file.
2015-04-11 12:32:05 -04:00
Brad King 1572069fe8 INSTALL: Update Wiki link to refer to GitHub wiki 2015-04-11 12:32:03 -04:00
Brad King 6893cc548f Fix compilation on Tru64 with F_SETTIMES
The parent commit left a typo in the conditional code path for Tru64.
Add the missing '.'.
2014-06-09 10:34:32 -04:00
Brad King da3ec55e71 Do not require LibXml2 to configure
In commit 033fc31e (Allow fine grained control over dependancies,
2013-05-16, committed 2013-12-12) the find_package(LibXml2) line was
accidentally given a REQUIRED specifier.  Remove it now.
2014-01-13 09:36:15 -05:00
Brad King 07686034ef libarchive: Use ARCHIVE_LITERAL_ULL to add ULL integer suffix
The macro maps to an implementation that works on older compilers when
necessary.  Convert the 0ULL literal introduced by commit 6cf33c93
(Issue 320:  Rewrite (again) to avoid the left shift that CLang dislikes
so much, 2013-12-07) to use the macro.
2013-12-09 14:09:16 -05:00
Brad King 14fa5039e8 Avoid struct init with variable
Compilers such as Borland and MIPSpro do not like struct initialization
with variables.  Initialize using assignment instead.
2013-09-26 08:58:24 -04:00
Brad King 72c91bc18d Merge branch 'simplify-link-flags' 2013-09-25 08:37:31 -04:00
Brad King e8a4ce62f6 Merge branch 'no-signed-shift' 2013-09-25 08:37:26 -04:00
Brad King d354cc9ea7 Simplify passing of linker flags to try_compile calls
In commit d7bd02b6 (Modify CHECK_C_SOURCE_* checks to fix builds using
Visual Studio 12, 2013-02-01), commit e3d14342 (Set use of /SAFESEH linker
flag for all LIBARCHIVE_CHECK_C_SOURCE_* checks, 2013-02-01), and commit
58dc42aa (Fix checks for crypto algorithms in Visual Studio builds,
2013-02-01) we introduced and used custom copies of the CMake
CheckCSource(Compiles|Runs) modules in order to pass linker flags to
try_compile calls.  CMake has an issue tracker entry about passing
CMAKE_*_LINKER_FLAGS to try_compile calls:

  http://www.cmake.org/Bug/view.php?id=14066

Discussion there suggests a much simpler workaround: pass the flags
through the LDFLAGS environment variable.  Remove our custom check
macros and use the simpler workaround instead.
2013-07-30 11:48:35 -04:00
Brad King 6ca5f688d2 archive_read_disk_windows.c: Fix typo in allocation error message
s/direcotry/directory/
2012-07-31 15:45:43 -04:00
Brad King 184c8dc0de Rename isoent_rr_move_dir parameter isoent => curent
The PGI compiler confuses parameter name "isoent" with "struct isoent".
Rename the parameter to "curent" to avoid confusion.

SVN-Revision: 4136
2012-03-19 08:58:37 +09:00
Brad King 5c5955ca10 Replace integer constant LL suffix with cast to int64_t
The LL suffix is not portable.  Use an explicit cast instead.

SVN-Revision: 4127
2012-03-19 08:58:26 +09:00
Brad King d7e16a49c2 Declare mbstate_t and wcrtomb for Borland
The Borland C++ 5.81 runtime library provides wcrtomb but only the C++
header <cwchar> actually declares the API.  Since this is C code we
cannot use the header, so declare it ourselves.

SVN-Revision: 4126
2012-03-18 05:11:33 +09:00
Brad King 267dc00cd7 Implement custom lseek for Borland
Restore Windows 64-bit lseek removed by upstream svn revision 3826
(Cast away __la_lseek(), use _lseeki64() instead, 2011-11-21).  We
need it on Borland.

SVN-Revision: 4125
2012-03-18 05:02:37 +09:00
Brad King aef4de52db Fix typo in CheckFileOffsetBits
s/Cheking/Checking/

Author: Rolf Eike Beer <eike@sf-mail.de>

SVN-Revision: 4124
2012-03-18 04:37:00 +09:00
Brad King ed8db4da0c Include linux/types.h before linux/fiemap.h
Some Linux API versions do not perform this inclusion automatically,
so types like __u64 needed by the latter are not available.

SVN-Revision: 4135
2012-03-11 14:12:52 +09:00
Brad King e51aa00f87 Define _XOPEN_SOURCE=500 on HP-UX
The HP-UX <wchar.h> header provides 'mbstate_t' in C89/C90 mode only if
_XOPEN_SOURCE is defined to exactly 500.  Type 'mbstate_t' was
introduced in C89/C90 Normative Amendment 1, aka C94/C95, adding support
international character sets.  It is part of C99 but not C89/C90.

SVN-Revision: 4134
2012-03-11 14:09:25 +09:00
Brad King 2a8a2e20cc Cleanup after ZLIB_WINAPI check
Clear CMAKE_REQUIRED_(INCLUDES|LIBRARIES) so that the rest of the checks
after this one do not try to link zlib.

SVN-Revision: 4133
2012-03-11 14:08:34 +09:00
Brad King a2f8c9b7bb Check for 'struct statvfs' member 'f_iosize'
Configure the result as definition HAVE_STRUCT_STATVFS_F_IOSIZE and use
the member only if it exists.  At least one platform (IRIX) provides
struct statvfs without this member.

SVN-Revision: 4132
2012-03-11 14:07:40 +09:00
Brad King 6a616be86f Fix Windows NT API usage in VS 6
VS 6 warns verbosely when WINVER >= 0x0500.  Avoid defining WINVER and
_WIN32_WINNT to higher than 0x0400 on VS 6.  Provide missing API
declarations in archive_windows.h when we do not get them from
<windows.h>.  Provide GetVolumePathNameW because VS 6 does not declare
it regardless of the API version.

SVN-Revision: 4129
2012-03-11 14:06:10 +09:00
Brad King 2eb7827d53 Merge libarchive 3.0
This commit was manufactured during conversion from SVN
to merge the libarchive 3.0 branch.
2012-01-30 01:19:37 -05:00
Brad King 247d951a4a Merge libarchive 2.8
This commit was manufactured during conversion from SVN
to merge the libarchive 2.8 branch.
2012-01-19 03:53:59 -05:00
Brad King d5c2c3f25b Rename isoent_rr_move_dir parameter isoent => curent
The PGI compiler confuses parameter name "isoent" with "struct isoent".
Rename the parameter to "curent" to avoid confusion.

SVN-Revision: 4136
2012-01-11 08:16:05 -05:00
Brad King f63533fa8f Include linux/types.h before linux/fiemap.h
Some Linux API versions do not perform this inclusion automatically,
so types like __u64 needed by the latter are not available.

SVN-Revision: 4135
2012-01-11 08:15:59 -05:00
Brad King 1914cf5d06 Define _XOPEN_SOURCE=500 on HP-UX
The HP-UX <wchar.h> header provides 'mbstate_t' in C89/C90 mode only if
_XOPEN_SOURCE is defined to exactly 500.  Type 'mbstate_t' was
introduced in C89/C90 Normative Amendment 1, aka C94/C95, adding support
international character sets.  It is part of C99 but not C89/C90.

SVN-Revision: 4134
2012-01-11 08:15:53 -05:00
Brad King 868abbdad9 Cleanup after ZLIB_WINAPI check
Clear CMAKE_REQUIRED_(INCLUDES|LIBRARIES) so that the rest of the checks
after this one do not try to link zlib.

SVN-Revision: 4133
2012-01-11 08:15:49 -05:00
Brad King 19c22e92c1 Check for 'struct statvfs' member 'f_iosize'
Configure the result as definition HAVE_STRUCT_STATVFS_F_IOSIZE and use
the member only if it exists.  At least one platform (IRIX) provides
struct statvfs without this member.

SVN-Revision: 4132
2012-01-11 08:15:42 -05:00
Brad King 997b6bf794 Do not use ST_NOATIME if not defined
Use the same pattern already used elsewhere in archive_read_disk_posix.c
to use ST_NOATIME only when defined.

SVN-Revision: 4131
2012-01-11 08:15:36 -05:00
Brad King 339bb07094 Fix var decl after statement in archive_string.c
When HAVE_MBRTOWC is true we declare an extra local variable.  Move the
unused argument cast to the end of the invalid_mbs function.

SVN-Revision: 4130
2012-01-11 08:15:31 -05:00
Brad King 6989e43840 Fix Windows NT API usage in VS 6
VS 6 warns verbosely when WINVER >= 0x0500.  Avoid defining WINVER and
_WIN32_WINNT to higher than 0x0400 on VS 6.  Provide missing API
declarations in archive_windows.h when we do not get them from
<windows.h>.  Provide GetVolumePathNameW because VS 6 does not declare
it regardless of the API version.

SVN-Revision: 4129
2012-01-11 08:15:25 -05:00
Brad King 0889d99f11 Cast mode constants to mode_t in case it is signed
At least one compiler (Borland) defines mode_t as just "short" which is
signed.  This breaks code like

  switch(archive_entry_filetype(e)) {
    case AE_IFREG:
    ...
  }

if AE_IFREG and other constants have a longer signed type (int) because
sign extension of the mode_t return type from archive_entry_filetype
changes its value.  Avoid the problem by ensuring the type of the
constants matches mode_t.

SVN-Revision: 4128
2012-01-11 08:15:20 -05:00
Brad King 066da99412 Replace integer constant LL suffix with cast to int64_t
The LL suffix is not portable.  Use an explicit cast instead.

SVN-Revision: 4127
2012-01-11 08:15:14 -05:00
Brad King 1d75f2b936 Declare mbstate_t and wcrtomb for Borland
The Borland C++ 5.81 runtime library provides wcrtomb but only the C++
header <cwchar> actually declares the API.  Since this is C code we
cannot use the header, so declare it ourselves.

SVN-Revision: 4126
2012-01-11 08:15:09 -05:00
Brad King 127c687a88 Implement custom lseek for Borland
Restore Windows 64-bit lseek removed by upstream svn revision 3826
(Cast away __la_lseek(), use _lseeki64() instead, 2011-11-21).  We
need it on Borland.

SVN-Revision: 4125
2012-01-11 08:15:03 -05:00
Brad King 5319e55f45 Fix typo in CheckFileOffsetBits
s/Cheking/Checking/

Author: Rolf Eike Beer <eike@sf-mail.de>

SVN-Revision: 4124
2012-01-11 08:14:57 -05:00
Brad King 6b8c67f228 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.

SVN-Revision: 1751
2009-12-16 08:52:05 -05:00
Brad King fc239d4a61 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.

SVN-Revision: 1750
2009-12-16 08:32:27 -05:00
Brad King 30f98f03b4 Merge libarchive 2.7
This commit was manufactured during conversion from SVN
to merge the libarchive 2.7 branch.
2009-12-06 19:19:28 -05:00
Brad King 128fef46c6 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.

SVN-Revision: 1692
2009-12-01 11:08:04 -05:00
Brad King 1ee74d95f0 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.

SVN-Revision: 1691
2009-11-30 10:19:45 -05:00
Brad King 69f00c7b2b 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.

SVN-Revision: 1690
2009-11-30 10:19:36 -05:00
Brad King 3f7c4c6407 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.

SVN-Revision: 1673
2009-11-18 09:15:28 -05:00
Brad King 09a663f110 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.

SVN-Revision: 1672
2009-11-18 09:14:18 -05:00
Brad King bc44b006fd Create ADD_TEST_28 macro to approximate CMake 2.8
CMake 2.8 provides a new ADD_TEST(NAME) signature that simplifies
creation of tests that refer to executables built in the project.  We
create an ADD_TEST_28 macro to approximate the new signature but work
with CMake 2.6.

SVN-Revision: 1671
2009-11-18 09:14:08 -05:00
Brad King d8dabfb757 Require CMake 2.6.3 or higher
Previously we required CMake 2.6.1 or higher, but CMake 2.6.3 provides
component-wise VERSION_LESS, VERSION_GREATER, and VERSION_EQUAL tests in
the if() command and the CMAKE_VERSION variable.  Once the running CMake
is known to be 2.6.3 or higher, tests against its version are simple.

We also use the FATAL_ERROR option to CMAKE_MINIMUM_REQUIRED() to ensure
that CMake 2.4 gives up with an error immediately.

SVN-Revision: 1670
2009-11-18 09:14:00 -05:00
Brad King 5a1e844ecb Put local include dir first
We configure a header file called "config.h" so the local include
directory should go first to avoid conflicts from system headers.

SVN-Revision: 1663
2009-11-16 11:35:12 -05:00
Brad King 0d99fcd16b Convert CRLF -> LF newlines
We fix the newlines in libarchive/archive_read_support_format_raw.c to
have UNIX newlines like all other sources.

SVN-Revision: 1662
2009-11-16 11:35:06 -05:00
Brad King 003ae2f276 Add try-compile for 'major'
We define MAJOR_IN_MKDEV and MAJOR_IN_SYSMACROS from CMake by checking
sys/mkdev.h and sys/sysmacros.h for 'major'.  Previously these macros
were left unconfigured for CMake builds.

SVN-Revision: 1661
2009-11-16 11:29:46 -05:00
Brad King deb76321d1 Include test.h first in test main.c sources
This change makes the main.c source for each test executable consistent
with the other test sources.  It also ensures that config.h (through
test.h) is included before system headers, thus configuring system
header feature macros correctly.

SVN-Revision: 1660
2009-11-16 11:29:40 -05:00
Brad King 39a0107926 Add missing include <limits.h>
In archive_read_support_format_ar.c we use SIZE_MAX.  On some platforms
the constant is defined in <limits.h> so we should include it.

SVN-Revision: 1659
2009-11-16 11:29:31 -05:00
Brad King 26b399c3f7 Initialize passwd/group lookup result
The "result" argument to functions get(pwu|grg)id_r and get(pw|gr)name_r
does not appear in the signatures provided on older platforms.  We set
the pointer to the result memory in case the function ignores it, thus
ensuring initialization.

SVN-Revision: 1658
2009-11-16 11:29:18 -05:00
Brad King 87599157fd Use consistent function storage class
Functions declared 'static' should be defined 'static' too.

SVN-Revision: 1657
2009-11-16 11:29:10 -05:00
Brad King b16468499e Extract ACL octal digit using mask of type 'int'
In archive_read_support_format_tar.c we mask a mode with ~0777777 to
erase the non-ACL octal digits.  The mode is represented by int64_t so
the compiler sign-extends the our literal mask from type int to int64_t
for application of the & operator.

Unfortunately the resulting int64_t type is not allowed in switch() on
some old compilers (like HP).  Since we are looking only for values that
fit in an int after the mask anyway, we might as well cast to int for
the entire mask operation.  This also avoids depending on the compiler
to preserve the intention of the mask with sign-extension, making the
code easier to understand anyway.

SVN-Revision: 1656
2009-11-16 11:28:59 -05:00
Brad King 159c809bfb Simplify try-compile for SIZE_MAX
This constant may be defined in one of a few headers that we always
include anyway.  It is simpler and more reliable to look for the
constant in all the possible headers at once.  Otherwise we would need
to store the result for each header in a separate cache entry.

SVN-Revision: 1655
2009-11-16 11:28:51 -05:00
Brad King 0866bff009 Fix Borland integer constants
Some versions of Borland provide <stdint.h>, so we use it when possible.
However, the 64-bit signed and unsigned integer min/max constants cause
overflow warnings from Borland itself!  For these constants we fall back
on our default definitions.

SVN-Revision: 1647
2009-11-11 12:13:34 -05:00
Brad King a30e831a19 Borland does not prefix strdup, setmode, or umask
Although MSVC and some other Windows compilers provide these functions
prefixed with '_', the Borland compiler does not.

SVN-Revision: 1646
2009-11-11 09:20:44 -05:00
Brad King 02ac6f7690 Borland signature of _open has no mode
SVN-Revision: 1645
2009-11-11 09:20:38 -05:00