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.
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.
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.
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
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.
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.
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.
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.
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.
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.
Avoid repeating the signature declaration in every source that uses it.
While at it, constify internal __archive_get_date implementation to
keep signatures consistent.
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.
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.
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.
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
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.
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.
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.
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.
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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