Commit c206211a authored by LibArchive Upstream's avatar LibArchive Upstream Committed by Brad King

LibArchive 2017-02-19 (100ee75a)

Code extracted from:

    https://github.com/libarchive/libarchive.git

at commit 100ee75a01f1f785fc681f616db49a33405f8bf3 (v3.3.0).
parent 2b94d71d
......@@ -179,13 +179,15 @@ include(CTest)
OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
OPTION(ENABLE_LZMA "Enable the use of the system found LZMA library if found" ON)
OPTION(ENABLE_ZLIB "Enable the use of the system found ZLIB library if found" ON)
OPTION(ENABLE_BZip2 "Enable the use of the system found BZip2 library if found" ON)
OPTION(ENABLE_LIBXML2 "Enable the use of the system found libxml2 library if found" ON)
OPTION(ENABLE_EXPAT "Enable the use of the system found EXPAT library if found" ON)
OPTION(ENABLE_PCREPOSIX "Enable the use of the system found PCREPOSIX library if found" ON)
OPTION(ENABLE_LibGCC "Enable the use of the system found LibGCC library if found" ON)
OPTION(ENABLE_LZO "Enable the use of the system LZO library if found" OFF)
OPTION(ENABLE_LZMA "Enable the use of the system LZMA library if found" ON)
OPTION(ENABLE_ZLIB "Enable the use of the system ZLIB library if found" ON)
OPTION(ENABLE_BZip2 "Enable the use of the system BZip2 library if found" ON)
OPTION(ENABLE_LIBXML2 "Enable the use of the system libxml2 library if found" ON)
OPTION(ENABLE_EXPAT "Enable the use of the system EXPAT library if found" ON)
OPTION(ENABLE_PCREPOSIX "Enable the use of the system PCREPOSIX library if found" ON)
OPTION(ENABLE_LibGCC "Enable the use of the system LibGCC library if found" ON)
# CNG is used for encrypt/decrypt Zip archives on Windows.
OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON)
......@@ -274,7 +276,7 @@ INCLUDE(CheckHeaderDirent)
INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckStructMember)
INCLUDE(CheckStructHasMember)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckTypeExists)
INCLUDE(CheckTypeSize)
......@@ -452,46 +454,44 @@ MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES)
# Find LZMA
#
IF(ENABLE_LZMA)
FIND_PACKAGE(LZMA)
FIND_PACKAGE(LibLZMA)
ELSE()
SET(LZMA_FOUND FALSE) # Override cached value
SET(LZMADEC_FOUND FALSE) # Override cached value
SET(LIBZMA_FOUND FALSE) # Override cached value
ENDIF()
IF(LZMA_FOUND)
IF(LIBLZMA_FOUND)
SET(HAVE_LIBLZMA 1)
SET(HAVE_LZMA_H 1)
INCLUDE_DIRECTORIES(${LZMA_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${LZMA_LIBRARIES})
INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIRS})
LIST(APPEND ADDITIONAL_LIBS ${LIBLZMA_LIBRARIES})
# Test if a macro is needed for the library.
TRY_MACRO_FOR_LIBRARY(
"${LZMA_INCLUDE_DIR}" "${LZMA_LIBRARIES}"
"${LIBLZMA_INCLUDE_DIRS}" "${LIBLZMA_LIBRARIES}"
COMPILES
"#include <lzma.h>\nint main() {return (int)lzma_version_number(); }"
"WITHOUT_LZMA_API_STATIC;LZMA_API_STATIC")
IF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC)
ADD_DEFINITIONS(-DLZMA_API_STATIC)
ENDIF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC)
ELSEIF(LZMADEC_FOUND)
SET(HAVE_LIBLZMADEC 1)
SET(HAVE_LZMADEC_H 1)
INCLUDE_DIRECTORIES(${LZMADEC_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${LZMADEC_LIBRARIES})
ELSE(LZMA_FOUND)
ELSE(LIBLZMA_FOUND)
# LZMA not found and will not be used.
ENDIF(LZMA_FOUND)
ENDIF(LIBLZMA_FOUND)
#
# Find LZO2
#
IF (LZO2_INCLUDE_DIR)
# Already in cache, be silent
SET(LZO2_FIND_QUIETLY TRUE)
ENDIF (LZO2_INCLUDE_DIR)
FIND_PATH(LZO2_INCLUDE_DIR lzo/lzoconf.h)
FIND_LIBRARY(LZO2_LIBRARY NAMES lzo2 liblzo2)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZO2 DEFAULT_MSG LZO2_LIBRARY LZO2_INCLUDE_DIR)
IF(ENABLE_LZO)
IF (LZO2_INCLUDE_DIR)
# Already in cache, be silent
SET(LZO2_FIND_QUIETLY TRUE)
ENDIF (LZO2_INCLUDE_DIR)
FIND_PATH(LZO2_INCLUDE_DIR lzo/lzoconf.h)
FIND_LIBRARY(LZO2_LIBRARY NAMES lzo2 liblzo2)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZO2 DEFAULT_MSG LZO2_LIBRARY LZO2_INCLUDE_DIR)
ELSE(ENABLE_LZO)
SET(LIBZMA_FOUND FALSE) # Override cached value
ENDIF(ENABLE_LZO)
IF(LZO2_FOUND)
SET(HAVE_LIBLZO2 1)
SET(HAVE_LZO_LZOCONF_H 1)
......@@ -614,7 +614,7 @@ IF(ENABLE_CNG)
ELSE(ENABLE_CNG)
UNSET(HAVE_BCRYPT_H CACHE)
ENDIF(ENABLE_CNG)
# Following files need windwos.h, so we should test it after windows.h test.
# Following files need windows.h, so we should test it after windows.h test.
LA_CHECK_INCLUDE_FILE("wincrypt.h" HAVE_WINCRYPT_H)
LA_CHECK_INCLUDE_FILE("winioctl.h" HAVE_WINIOCTL_H)
......@@ -1274,6 +1274,14 @@ CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE)
CMAKE_POP_CHECK_STATE() # Restore the state of the variables
CHECK_C_SOURCE_COMPILES(
"#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct vfsconf v; return sizeof(v);}"
HAVE_STRUCT_VFSCONF)
CHECK_C_SOURCE_COMPILES(
"#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct xvfsconf v; return sizeof(v);}"
HAVE_STRUCT_XVFSCONF)
# Make sure we have the POSIX version of readdir_r, not the
# older 2-argument version.
CHECK_C_SOURCE_COMPILES(
......@@ -1299,6 +1307,10 @@ CHECK_C_SOURCE_COMPILES(
"#include <sys/sysmacros.h>\nint main() { return major(256); }"
MAJOR_IN_SYSMACROS)
CHECK_C_SOURCE_COMPILES(
"#include <lzma.h>\n#if LZMA_VERSION < 50020000\n#error unsupported\n#endif\nint main(void){lzma_stream_encoder_mt(0, 0); return 0;}"
HAVE_LZMA_STREAM_ENCODER_MT)
IF(HAVE_STRERROR_R)
SET(HAVE_DECL_STRERROR_R 1)
ENDIF(HAVE_STRERROR_R)
......@@ -1332,47 +1344,47 @@ CHECK_SYMBOL_EXISTS(SSIZE_MAX "limits.h" HAVE_DECL_SSIZE_MAX)
# Check struct members
#
# Check for tm_gmtoff in struct tm
CHECK_STRUCT_MEMBER("struct tm" tm_gmtoff
CHECK_STRUCT_HAS_MEMBER("struct tm" tm_gmtoff
"time.h" HAVE_STRUCT_TM_TM_GMTOFF)
CHECK_STRUCT_MEMBER("struct tm" __tm_gmtoff
CHECK_STRUCT_HAS_MEMBER("struct tm" __tm_gmtoff
"time.h" HAVE_STRUCT_TM___TM_GMTOFF)
# Check for f_namemax in struct statfs
CHECK_STRUCT_MEMBER("struct statfs" f_namemax
CHECK_STRUCT_HAS_MEMBER("struct statfs" f_namemax
"sys/param.h;sys/mount.h" HAVE_STRUCT_STATFS_F_NAMEMAX)
# Check for birthtime in struct stat
CHECK_STRUCT_MEMBER("struct stat" st_birthtime
CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtime
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIME)
# Check for high-resolution timestamps in struct stat
CHECK_STRUCT_MEMBER("struct stat" st_birthtimespec.tv_nsec
CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtimespec.tv_nsec
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC)
CHECK_STRUCT_MEMBER("struct stat" st_mtimespec.tv_nsec
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
CHECK_STRUCT_MEMBER("struct stat" st_mtim.tv_nsec
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
CHECK_STRUCT_MEMBER("struct stat" st_mtime_n
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_n
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_N)
CHECK_STRUCT_MEMBER("struct stat" st_umtime
CHECK_STRUCT_HAS_MEMBER("struct stat" st_umtime
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_UMTIME)
CHECK_STRUCT_MEMBER("struct stat" st_mtime_usec
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_usec
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_USEC)
# Check for block size support in struct stat
CHECK_STRUCT_MEMBER("struct stat" st_blksize
CHECK_STRUCT_HAS_MEMBER("struct stat" st_blksize
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BLKSIZE)
# Check for st_flags in struct stat (BSD fflags)
CHECK_STRUCT_MEMBER("struct stat" st_flags
CHECK_STRUCT_HAS_MEMBER("struct stat" st_flags
"sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_FLAGS)
IF(HAVE_SYS_STATVFS_H)
CHECK_STRUCT_MEMBER("struct statvfs" f_iosize
CHECK_STRUCT_HAS_MEMBER("struct statvfs" f_iosize
"sys/types.h;sys/statvfs.h" HAVE_STRUCT_STATVFS_F_IOSIZE)
ENDIF()
#
#
CHECK_STRUCT_MEMBER("struct tm" tm_sec
CHECK_STRUCT_HAS_MEMBER("struct tm" tm_sec
"sys/types.h;sys/time.h;time.h" TIME_WITH_SYS_TIME)
#
......@@ -1592,16 +1604,36 @@ IF(ENABLE_ACL)
# test for specific permissions in a permset.) Linux uses the obvious
# name, FreeBSD adds _np to mark it as "non-Posix extension."
# Test for both as a double-check that we really have POSIX-style ACL support.
CHECK_FUNCTION_EXISTS(acl_get_fd_np HAVE_ACL_GET_FD_NP)
CHECK_FUNCTION_EXISTS(acl_get_perm HAVE_ACL_GET_PERM)
CHECK_FUNCTION_EXISTS(acl_get_perm_np HAVE_ACL_GET_PERM_NP)
CHECK_FUNCTION_EXISTS(acl_get_link HAVE_ACL_GET_LINK)
CHECK_FUNCTION_EXISTS(acl_get_link_np HAVE_ACL_GET_LINK_NP)
CHECK_FUNCTION_EXISTS(acl_is_trivial_np HAVE_ACL_IS_TRIVIAL_NP)
CHECK_FUNCTION_EXISTS(acl_set_link_np HAVE_ACL_SET_LINK_NP)
CHECK_SYMBOL_EXISTS(ACL_TYPE_NFS4 "${INCLUDES}" HAVE_ACL_TYPE_NFS4)
# MacOS has an acl.h that isn't POSIX. It can be detected by
# checking for ACL_USER
CHECK_SYMBOL_EXISTS(ACL_USER "${INCLUDES}" HAVE_ACL_USER)
CHECK_C_SOURCE_COMPILES("#include <sys/types.h>
#include <sys/acl.h>
int main(void) { return ACL_TYPE_EXTENDED; }" HAVE_ACL_TYPE_EXTENDED)
# Solaris and derivates ACLs
CHECK_LIBRARY_EXISTS(sec "acl_get" "" HAVE_LIBSEC)
IF(HAVE_LIBSEC)
SET(CMAKE_REQUIRED_LIBRARIES "sec")
FIND_LIBRARY(SEC_LIBRARY NAMES sec)
LIST(APPEND ADDITIONAL_LIBS ${SEC_LIBRARY})
ENDIF(HAVE_LIBSEC)
#
CHECK_TYPE_EXISTS(aclent_t "${INCLUDES}" HAVE_ACLENT_T)
CHECK_TYPE_EXISTS(ace_t "${INCLUDES}" HAVE_ACE_T)
CHECK_FUNCTION_EXISTS(acl_get HAVE_FACL_GET)
CHECK_FUNCTION_EXISTS(facl_get HAVE_FACL_GET)
CHECK_FUNCTION_EXISTS(acl_set HAVE_FACL_SET)
CHECK_FUNCTION_EXISTS(facl_set HAVE_FACL_SET)
ELSE(ENABLE_ACL)
# If someone runs cmake, then disables ACL support, we need
# to forcibly override the cached values for these.
......@@ -1616,7 +1648,15 @@ ELSE(ENABLE_ACL)
SET(HAVE_ACL_SET_FD FALSE)
SET(HAVE_ACL_SET_FD_NP FALSE)
SET(HAVE_ACL_SET_FILE FALSE)
SET(HAVE_ACL_TYPE_NFS4 FALSE)
SET(HAVE_ACL_USER FALSE)
SET(HAVE_ACL_TYPE_EXTENDED FALSE)
SET(HAVE_ACL_GET FALSE)
SET(HAVE_ACLENT_T FALSE)
SET(HAVE_ACE_T FALSE)
SET(HAVE_FACL_GET FALSE)
SET(HAVE_ACL_SET FALSE)
SET(HAVE_FACL_SET FALSE)
ENDIF(ENABLE_ACL)
#
......
# - Check if the given struct or class has the specified member variable
# CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE)
#
# STRUCT - the name of the struct or class you are interested in
# MEMBER - the member which existence you want to check
# HEADER - the header(s) where the prototype should be declared
# VARIABLE - variable to store the result
#
# The following variables may be set before calling this macro to
# modify the way the check is run:
#
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
INCLUDE(CheckCSourceCompiles)
MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
SET(_INCLUDE_FILES)
FOREACH (it ${_HEADER})
SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
ENDFOREACH (it)
SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
${_INCLUDE_FILES}
int main()
{
static ${_STRUCT} tmp;
if (sizeof(tmp.${_MEMBER}))
return 0;
return 0;
}
")
CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
ENDMACRO (CHECK_STRUCT_MEMBER)
# - Find lzma and lzmadec
# Find the native LZMA includes and library
#
# LZMA_INCLUDE_DIR - where to find lzma.h, etc.
# LZMA_LIBRARIES - List of libraries when using liblzma.
# LZMA_FOUND - True if liblzma found.
# LZMADEC_INCLUDE_DIR - where to find lzmadec.h, etc.
# LZMADEC_LIBRARIES - List of libraries when using liblzmadec.
# LZMADEC_FOUND - True if liblzmadec found.
IF (LZMA_INCLUDE_DIR)
# Already in cache, be silent
SET(LZMA_FIND_QUIETLY TRUE)
ENDIF (LZMA_INCLUDE_DIR)
FIND_PATH(LZMA_INCLUDE_DIR lzma.h)
FIND_LIBRARY(LZMA_LIBRARY NAMES lzma liblzma)
# handle the QUIETLY and REQUIRED arguments and set LZMA_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZMA DEFAULT_MSG LZMA_LIBRARY LZMA_INCLUDE_DIR)
IF(LZMA_FOUND)
SET( LZMA_LIBRARIES ${LZMA_LIBRARY} )
ELSE(LZMA_FOUND)
SET( LZMA_LIBRARIES )
IF (LZMADEC_INCLUDE_DIR)
# Already in cache, be silent
SET(LZMADEC_FIND_QUIETLY TRUE)
ENDIF (LZMADEC_INCLUDE_DIR)
FIND_PATH(LZMADEC_INCLUDE_DIR lzmadec.h)
FIND_LIBRARY(LZMADEC_LIBRARY NAMES lzmadec )
# handle the QUIETLY and REQUIRED arguments and set LZMADEC_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LZMADEC DEFAULT_MSG LZMADEC_LIBRARY
LZMADEC_INCLUDE_DIR)
IF(LZMADEC_FOUND)
SET( LZMADEC_LIBRARIES ${LZMADEC_LIBRARY} )
ELSE(LZMADEC_FOUND)
SET( LZMADEC_LIBRARIES )
ENDIF(LZMADEC_FOUND)
ENDIF(LZMA_FOUND)
......@@ -293,6 +293,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `acl_create_entry' function. */
#cmakedefine HAVE_ACL_CREATE_ENTRY 1
/* Define to 1 if you have the `acl_get_fd_np' function. */
#cmakedefine HAVE_ACL_GET_FD_NP 1
/* Define to 1 if you have the `acl_get_link' function. */
#cmakedefine HAVE_ACL_GET_LINK 1
......@@ -323,6 +326,12 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the `acl_set_file' function. */
#cmakedefine HAVE_ACL_SET_FILE 1
/* True for FreeBSD with NFSv4 ACL support */
#cmakedefine HAVE_ACL_TYPE_NFS4 1
/* True for MacOS ACL support */
#cmakedefine HAVE_ACL_TYPE_EXTENDED 1
/* True for systems with POSIX ACL support */
#cmakedefine HAVE_ACL_USER 1
......@@ -721,6 +730,9 @@ typedef uint64_t uintmax_t;
/* Define to 1 if you have the <lzma.h> header file. */
#cmakedefine HAVE_LZMA_H 1
/* Define to 1 if you have a working `lzma_stream_encoder_mt' function. */
#cmakedefine HAVE_LZMA_STREAM_ENCODER_MT 1
/* Define to 1 if you have the <lzo/lzo1x.h> header file. */
#cmakedefine HAVE_LZO_LZO1X_H 1
......@@ -923,6 +935,12 @@ typedef uint64_t uintmax_t;
/* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */
#cmakedefine HAVE_STRUCT_TM___TM_GMTOFF 1
/* Define to 1 if you have `struct vfsconf'. */
#cmakedefine HAVE_STRUCT_VFSCONF 1
/* Define to 1 if you have `struct xvfsconf'. */
#cmakedefine HAVE_STRUCT_XVFSCONF 1
/* Define to 1 if you have the `symlink' function. */
#cmakedefine HAVE_SYMLINK 1
......
......@@ -38,6 +38,8 @@ SET(libarchive_SOURCES
archive_hmac.c
archive_hmac_private.h
archive_match.c
archive_openssl_evp_private.h
archive_openssl_hmac_private.h
archive_options.c
archive_options_private.h
archive_pack_dev.h
......@@ -166,15 +168,33 @@ SET(libarchive_MANS
archive_entry_time.3
archive_read.3
archive_read_add_passphrase.3
archive_read_data.3
archive_read_disk.3
archive_read_extract.3
archive_read_filter.3
archive_read_format.3
archive_read_free.3
archive_read_header.3
archive_read_new.3
archive_read_open.3
archive_read_set_options.3
archive_util.3
archive_write.3
archive_write_blocksize.3
archive_write_data.3
archive_write_disk.3
archive_write_filter.3
archive_write_finish_entry.3
archive_write_format.3
archive_write_free.3
archive_write_header.3
archive_write_new.3
archive_write_open.3
archive_write_set_options.3
archive_write_set_passphrase.3
cpio.5
libarchive.3
libarchive_changes.3
libarchive_internals.3
libarchive-formats.5
mtree.5
......
......@@ -36,7 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
#define ARCHIVE_VERSION_NUMBER 3002001
#define ARCHIVE_VERSION_NUMBER 3003000
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
......@@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
#define ARCHIVE_VERSION_ONLY_STRING "3.2.1"
#define ARCHIVE_VERSION_ONLY_STRING "3.3.0"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);
......@@ -373,7 +373,7 @@ typedef const char *archive_passphrase_callback(struct archive *,
* 4) Repeatedly call archive_read_next_header to get information about
* successive archive entries. Call archive_read_data to extract
* data for entries of interest.
* 5) Call archive_read_finish to end processing.
* 5) Call archive_read_free to end processing.
*/
__LA_DECL struct archive *archive_read_new(void);
......@@ -562,7 +562,7 @@ __LA_DECL la_int64_t archive_read_header_position(struct archive *);
* we cannot say whether there are encrypted entries, then
* ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
* In general, this function will return values below zero when the
* reader is uncertain or totally uncapable of encryption support.
* reader is uncertain or totally incapable of encryption support.
* When this function returns 0 you can be sure that the reader
* supports encryption detection but no encrypted entries have
* been found yet.
......@@ -984,12 +984,12 @@ __LA_DECL int archive_read_disk_can_descend(struct archive *);
__LA_DECL int archive_read_disk_current_filesystem(struct archive *);
__LA_DECL int archive_read_disk_current_filesystem_is_synthetic(struct archive *);
__LA_DECL int archive_read_disk_current_filesystem_is_remote(struct archive *);
/* Request that the access time of the entry visited by travesal be restored. */
/* Request that the access time of the entry visited by traversal be restored. */
__LA_DECL int archive_read_disk_set_atime_restored(struct archive *);
/*
* Set behavior. The "flags" argument selects optional behavior.
*/
/* Request that the access time of the entry visited by travesal be restored.
/* Request that the access time of the entry visited by traversal be restored.
* This is the same as archive_read_disk_set_atime_restored. */
#define ARCHIVE_READDISK_RESTORE_ATIME (0x0001)
/* Default: Do not skip an entry which has nodump flags. */
......@@ -1124,7 +1124,7 @@ __LA_DECL int archive_match_time_excluded(struct archive *,
/*
* Flags to tell a matching type of time stamps. These are used for
* following functinos.
* following functions.
*/
/* Time flag: mtime to be tested. */
#define ARCHIVE_MATCH_MTIME (0x0100)
......@@ -1144,7 +1144,7 @@ __LA_DECL int archive_match_include_date(struct archive *, int _flag,
const char *_datestr);
__LA_DECL int archive_match_include_date_w(struct archive *, int _flag,
const wchar_t *_datestr);
/* Set inclusion time by a particluar file. */
/* Set inclusion time by a particular file. */
__LA_DECL int archive_match_include_file_time(struct archive *,
int _flag, const char *_pathname);
__LA_DECL int archive_match_include_file_time_w(struct archive *,
......
This diff is collapsed.
......@@ -56,6 +56,7 @@ struct archive_acl {
void archive_acl_clear(struct archive_acl *);
void archive_acl_copy(struct archive_acl *, struct archive_acl *);
int archive_acl_count(struct archive_acl *, int);
int archive_acl_types(struct archive_acl *);
int archive_acl_reset(struct archive_acl *, int);
int archive_acl_next(struct archive *, struct archive_acl *, int,
int *, int *, int *, int *, const char **);
......@@ -66,22 +67,17 @@ int archive_acl_add_entry_w_len(struct archive_acl *,
int archive_acl_add_entry_len(struct archive_acl *,
int, int, int, int, const char *, size_t);
const wchar_t *archive_acl_text_w(struct archive *, struct archive_acl *, int);
int archive_acl_text_l(struct archive_acl *, int, const char **, size_t *,
wchar_t *archive_acl_to_text_w(struct archive_acl *, ssize_t *, int,
struct archive *);
char *archive_acl_to_text_l(struct archive_acl *, ssize_t *, int,
struct archive_string_conv *);
/*
* Private ACL parser. This is private because it handles some
* very weird formats that clients should not be messing with.
* Clients should only deal with their platform-native formats.
* Because of the need to support many formats cleanly, new arguments
* are likely to get added on a regular basis. Clients who try to use
* this interface are likely to be surprised when it changes.
* ACL text parser.
*/
int archive_acl_parse_w(struct archive_acl *,
const wchar_t *, int /* type */);
int archive_acl_parse_l(struct archive_acl *,
const char *, int /* type */,
struct archive_string_conv *);
int archive_acl_from_text_w(struct archive_acl *, const wchar_t * /* wtext */,
int /* type */);
int archive_acl_from_text_l(struct archive_acl *, const char * /* text */,
int /* type */, struct archive_string_conv *);
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
......@@ -302,6 +302,8 @@ aes_ctr_release(archive_crypto_ctx *ctx)
static int
aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
{
if ((ctx->ctx = EVP_CIPHER_CTX_new()) == NULL)
return -1;
switch (key_len) {
case 16: ctx->type = EVP_aes_128_ecb(); break;
......@@ -314,7 +316,7 @@ aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len)
memcpy(ctx->key, key, key_len);
memset(ctx->nonce, 0, sizeof(ctx->nonce));
ctx->encr_pos = AES_BLOCK_SIZE;
EVP_CIPHER_CTX_init(&ctx->ctx);
EVP_CIPHER_CTX_init(ctx->ctx);
return 0;
}
......@@ -324,10 +326,10 @@ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
int outl = 0;
int r;
r = EVP_EncryptInit_ex(&ctx->ctx, ctx->type, NULL, ctx->key, NULL);
r = EVP_EncryptInit_ex(ctx->ctx, ctx->type, NULL, ctx->key, NULL);
if (r == 0)
return -1;
r = EVP_EncryptUpdate(&ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
r = EVP_EncryptUpdate(ctx->ctx, ctx->encr_buf, &outl, ctx->nonce,
AES_BLOCK_SIZE);
if (r == 0 || outl != AES_BLOCK_SIZE)
return -1;
......@@ -337,7 +339,7 @@ aes_ctr_encrypt_counter(archive_crypto_ctx *ctx)
static int
aes_ctr_release(archive_crypto_ctx *ctx)
{
EVP_CIPHER_CTX_cleanup(&ctx->ctx);
EVP_CIPHER_CTX_free(ctx->ctx);
memset(ctx->key, 0, ctx->key_len);
memset(ctx->nonce, 0, sizeof(ctx->nonce));
return 0;
......
......@@ -99,12 +99,12 @@ typedef struct {
} archive_crypto_ctx;
#elif defined(HAVE_LIBCRYPTO)
#include <openssl/evp.h>
#include "archive_openssl_evp_private.h"
#define AES_BLOCK_SIZE 16
#define AES_MAX_KEY_SIZE 32
typedef struct {
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX *ctx;
const EVP_CIPHER *type;
uint8_t key[AES_MAX_KEY_SIZE];
unsigned key_len;
......
......@@ -207,7 +207,9 @@ __archive_nettle_md5final(archive_md5_ctx *ctx, void *md)
static int
__archive_openssl_md5init(archive_md5_ctx *ctx)
{
EVP_DigestInit(ctx, EVP_md5());
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_md5());
return (ARCHIVE_OK);
}
......@@ -215,7 +217,7 @@ static int
__archive_openssl_md5update(archive_md5_ctx *ctx, const void *indata,
size_t insize)
{
EVP_DigestUpdate(ctx, indata, insize);
EVP_DigestUpdate(*ctx, indata, insize);
return (ARCHIVE_OK);
}
......@@ -226,8 +228,11 @@ __archive_openssl_md5final(archive_md5_ctx *ctx, void *md)
* this is meant to cope with that. Real fix is probably to fix
* archive_write_set_format_xar.c
*/
if (ctx->digest)
EVP_DigestFinal(ctx, md, NULL);
if (*ctx) {
EVP_DigestFinal(*ctx, md, NULL);
EVP_MD_CTX_free(*ctx);
*ctx = NULL;
}
return (ARCHIVE_OK);
}
......@@ -359,7 +364,9 @@ __archive_nettle_ripemd160final(archive_rmd160_ctx *ctx, void *md)
static int
__archive_openssl_ripemd160init(archive_rmd160_ctx *ctx)
{
EVP_DigestInit(ctx, EVP_ripemd160());
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_ripemd160());
return (ARCHIVE_OK);
}
......@@ -367,14 +374,18 @@ static int
__archive_openssl_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
size_t insize)
{
EVP_DigestUpdate(ctx, indata, insize);
EVP_DigestUpdate(*ctx, indata, insize);
return (ARCHIVE_OK);
}
static int
__archive_openssl_ripemd160final(archive_rmd160_ctx *ctx, void *md)
{
EVP_DigestFinal(ctx, md, NULL);
if (*ctx) {
EVP_DigestFinal(*ctx, md, NULL);
EVP_MD_CTX_free(*ctx);
*ctx = NULL;
}
return (ARCHIVE_OK);
}
......@@ -509,7 +520,9 @@ __archive_nettle_sha1final(archive_sha1_ctx *ctx, void *md)
static int
__archive_openssl_sha1init(archive_sha1_ctx *ctx)
{
EVP_DigestInit(ctx, EVP_sha1());
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_sha1());
return (ARCHIVE_OK);
}
......@@ -517,7 +530,7 @@ static int
__archive_openssl_sha1update(archive_sha1_ctx *ctx, const void *indata,
size_t insize)
{
EVP_DigestUpdate(ctx, indata, insize);
EVP_DigestUpdate(*ctx, indata, insize);
return (ARCHIVE_OK);
}
......@@ -528,8 +541,11 @@ __archive_openssl_sha1final(archive_sha1_ctx *ctx, void *md)
* this is meant to cope with that. Real fix is probably to fix
* archive_write_set_format_xar.c
*/
if (ctx->digest)
EVP_DigestFinal(ctx, md, NULL);
if (*ctx) {
EVP_DigestFinal(*ctx, md, NULL);
EVP_MD_CTX_free(*ctx);
*ctx = NULL;
}
return (ARCHIVE_OK);
}
......@@ -733,7 +749,9 @@ __archive_nettle_sha256final(archive_sha256_ctx *ctx, void *md)
static int
__archive_openssl_sha256init(archive_sha256_ctx *ctx)
{
EVP_DigestInit(ctx, EVP_sha256());
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_sha256());
return (ARCHIVE_OK);
}
......@@ -741,14 +759,18 @@ static int
__archive_openssl_sha256update(archive_sha256_ctx *ctx, const void *indata,
size_t insize)
{
EVP_DigestUpdate(ctx, indata, insize);
EVP_DigestUpdate(*ctx, indata, insize);
return (ARCHIVE_OK);
}
static int
__archive_openssl_sha256final(archive_sha256_ctx *ctx, void *md)
{
EVP_DigestFinal(ctx, md, NULL);
if (*ctx) {
EVP_DigestFinal(*ctx, md, NULL);
EVP_MD_CTX_free(*ctx);