Update vendor/libarchive to 3.8.0
New features: #2088 7-zip reader: improve self-extracting archive detection #2137 zip writer: added XZ, LZMA, ZSTD and BZIP2 support #2403 zip writer: added LZMA + RISCV BCJ filter #2601 bsdtar: support --mtime and --clamp-mtime #2602 libarchive: mbedtls 3.x compatibility Security fixes: #2422 tar reader: Handle truncation in the middle of a GNU long linkname CVE-2024-57970 #2532 tar reader: fix unchecked return value in list_item_verbose() CVE-2025-25724 #2532 unzip: fix null pointer dereference CVE-2025-1632 #2568 warc: prevent signed integer overflow #2584 rar: do not skip past EOF while reading #2588 tar: fix overflow in build_ustar_entry #2598 rar: fix double free with over 4 billion nodes #2599 rar: fix heap-buffer-overflow Important bugfixes: #2399 7-zip reader: add SPARC filter support for non-LZMA compressors #2405 tar reader: ignore ustar size when pax size is present #2435 tar writer: fix bug when -s/a/b/ used more than once with b flag #2459 7-zip reader: add POWERPC filter support for non-LZMA compressors #2519 libarchive: handle ARCHIVE_FILTER_LZOP in archive_read_append_filter #2539 libarchive: add missing seeker function to archive_read_open_FILE() #2544 gzip: allow setting the original filename for gzip compressed files #2564 libarchive: improve lseek handling #2582 rar: support large headers on 32 bit systems #2587 bsdtar: don't hardlink negative inode files together #2596 rar: support large headers on 32 bit systems #2606 libarchive: support @-prefixed Unix epoch timestamps as date strings Obtained from: libarchive Vendor commit: 70ff28fcf04ec129a1d064f96e49aa57fcc90e37 CVE: CVE-2024-57970, CVE-2025-1632, CVE-2025-25724
This commit is contained in:
+2
-2
@@ -10,9 +10,9 @@ FreeBSD_task:
|
||||
BS: cmake
|
||||
matrix:
|
||||
freebsd_instance:
|
||||
image_family: freebsd-14-1
|
||||
image_family: freebsd-14-2
|
||||
freebsd_instance:
|
||||
image_family: freebsd-13-4
|
||||
image_family: freebsd-13-5
|
||||
prepare_script:
|
||||
- ./build/ci/cirrus_ci/ci.sh prepare
|
||||
configure_script:
|
||||
|
||||
+16
-14
@@ -12,9 +12,9 @@ jobs:
|
||||
matrix:
|
||||
bs: [autotools, cmake]
|
||||
steps:
|
||||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Install dependencies
|
||||
run: ./build/ci/github_actions/macos.sh prepare
|
||||
run: ./build/ci/github_actions/install-macos-dependencies.sh
|
||||
- name: Autogen
|
||||
run: ./build/ci/build.sh -a autogen
|
||||
env:
|
||||
@@ -23,29 +23,31 @@ jobs:
|
||||
run: ./build/ci/build.sh -a configure
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
# Avoid using liblzma from the Xcode 16 / MacOSX15.0.sdk, which fails RISCV filter tests.
|
||||
CMAKE_ARGS: -D LIBLZMA_LIBRARY=/opt/homebrew/lib/liblzma.dylib -D LIBLZMA_INCLUDE_DIR=/opt/homebrew/include/lzma.h
|
||||
- name: Build
|
||||
run: ./build/ci/build.sh -a build
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
MAKE_ARGS: -j
|
||||
MAKE_ARGS: -j3
|
||||
- name: Test
|
||||
run: ./build/ci/build.sh -a test
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
SKIP_OPEN_FD_ERR_TEST: 1
|
||||
IGNORE_TRAVERSALS_TEST4: 1
|
||||
MAKE_ARGS: -j
|
||||
MAKE_ARGS: -j3
|
||||
CTEST_OUTPUT_ON_FAILURE: ON
|
||||
- name: Install
|
||||
run: ./build/ci/build.sh -a install
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
MAKE_ARGS: -j
|
||||
MAKE_ARGS: -j3
|
||||
- name: Artifact
|
||||
run: ./build/ci/build.sh -a artifact
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: libarchive-macos-${{ matrix.bs }}-${{ github.sha }}
|
||||
path: libarchive.tar.xz
|
||||
@@ -57,7 +59,7 @@ jobs:
|
||||
bs: [autotools, cmake]
|
||||
crypto: [mbedtls, nettle, openssl]
|
||||
steps:
|
||||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Update apt cache
|
||||
run: sudo apt-get update
|
||||
- name: Install dependencies
|
||||
@@ -75,13 +77,13 @@ jobs:
|
||||
run: ./build/ci/build.sh -a build
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
MAKE_ARGS: -j
|
||||
MAKE_ARGS: -j4
|
||||
- name: Test
|
||||
run: ./build/ci/build.sh -a test
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
SKIP_OPEN_FD_ERR_TEST: 1
|
||||
MAKE_ARGS: -j
|
||||
MAKE_ARGS: -j4
|
||||
CTEST_OUTPUT_ON_FAILURE: ON
|
||||
- name: Install
|
||||
run: ./build/ci/build.sh -a install
|
||||
@@ -91,14 +93,14 @@ jobs:
|
||||
run: ./build/ci/build.sh -a artifact
|
||||
env:
|
||||
BS: ${{ matrix.bs }}
|
||||
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: libarchive-ubuntu-${{ matrix.bs }}-${{ matrix.crypto }}-${{ github.sha }}
|
||||
path: libarchive.tar.xz
|
||||
Ubuntu-distcheck:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Update package definitions
|
||||
run: sudo apt-get update
|
||||
- name: Install dependencies
|
||||
@@ -113,7 +115,7 @@ jobs:
|
||||
SKIP_OPEN_FD_ERR_TEST: 1
|
||||
- name: Dist-Artifact
|
||||
run: ./build/ci/build.sh -a dist-artifact
|
||||
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: libarchive-${{ github.sha }}
|
||||
path: libarchive-dist.tar
|
||||
@@ -125,7 +127,7 @@ jobs:
|
||||
matrix:
|
||||
be: [mingw-gcc, msvc]
|
||||
steps:
|
||||
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Install mingw
|
||||
if: ${{ matrix.be=='mingw-gcc' }}
|
||||
run: choco install mingw
|
||||
@@ -161,7 +163,7 @@ jobs:
|
||||
shell: cmd
|
||||
env:
|
||||
BE: ${{ matrix.be }}
|
||||
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: libarchive-windows-${{ matrix.be }}-${{ github.sha }}
|
||||
path: libarchive.zip
|
||||
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
fuzz-seconds: 600
|
||||
dry-run: false
|
||||
- name: Upload Crash
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: failure() && steps.build.outcome == 'success'
|
||||
with:
|
||||
name: artifacts
|
||||
|
||||
@@ -26,18 +26,18 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
|
||||
uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
queries: +security-and-quality
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
|
||||
uses: github/codeql-action/autobuild@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
|
||||
uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||
with:
|
||||
category: "/language:${{ matrix.language }}"
|
||||
|
||||
@@ -29,12 +29,12 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
|
||||
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
@@ -60,6 +60,6 @@ jobs:
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@c36620d31ac7c881962c3d9dd939c40ec9434f2b # v3.26.12
|
||||
uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
+68
-45
@@ -1,19 +1,6 @@
|
||||
#
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
|
||||
if(APPLE AND CMAKE_VERSION VERSION_LESS "3.17.0")
|
||||
message(WARNING "CMake>=3.17.0 required to make the generated shared library have the same Mach-O headers as autotools")
|
||||
endif()
|
||||
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
|
||||
|
||||
if(POLICY CMP0065)
|
||||
cmake_policy(SET CMP0065 NEW) #3.4 don't use `-rdynamic` with executables
|
||||
endif()
|
||||
if(POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW) #3.12.0 `find_package()`` uses ``<PackageName>_ROOT`` variables.
|
||||
endif()
|
||||
if(POLICY CMP0075)
|
||||
cmake_policy(SET CMP0075 NEW) #3.12.0 `check_include_file()`` and friends use ``CMAKE_REQUIRED_LIBRARIES``.
|
||||
endif()
|
||||
#
|
||||
PROJECT(libarchive C)
|
||||
#
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake")
|
||||
@@ -107,6 +94,9 @@ set(MACHO_CURRENT_VERSION "${MACHO_COMPATIBILITY_VERSION}.${_revision}")
|
||||
# saving and restoring the state of the variables.
|
||||
INCLUDE(CMakePushCheckState)
|
||||
|
||||
# Enable the pkg-config helpers.
|
||||
INCLUDE(FindPkgConfig)
|
||||
|
||||
# Initialize the state of the variables. This initialization is not
|
||||
# necessary but this shows you what value the variables initially have.
|
||||
SET(CMAKE_REQUIRED_DEFINITIONS)
|
||||
@@ -238,6 +228,7 @@ 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_WIN32_XMLLITE "Enable the use of the Windows XmlLite library if found" ON)
|
||||
OPTION(ENABLE_PCREPOSIX "Enable the use of the system PCREPOSIX library if found" ON)
|
||||
OPTION(ENABLE_PCRE2POSIX "Enable the use of the system PCRE2POSIX library if found" ON)
|
||||
OPTION(ENABLE_LIBGCC "Enable the use of the system LibGCC library if found" ON)
|
||||
@@ -293,18 +284,6 @@ IF(WIN32)
|
||||
SET(NTDDI_VERSION 0x06000100)
|
||||
SET(_WIN32_WINNT 0x0600)
|
||||
SET(WINVER 0x0600)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "VISTA")
|
||||
SET(NTDDI_VERSION 0x06000000)
|
||||
SET(_WIN32_WINNT 0x0600)
|
||||
SET(WINVER 0x0600)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "WS03")
|
||||
SET(NTDDI_VERSION 0x05020000)
|
||||
SET(_WIN32_WINNT 0x0502)
|
||||
SET(WINVER 0x0502)
|
||||
ELSEIF(WINDOWS_VERSION STREQUAL "WINXP")
|
||||
SET(NTDDI_VERSION 0x05010000)
|
||||
SET(_WIN32_WINNT 0x0501)
|
||||
SET(WINVER 0x0501)
|
||||
ELSE(WINDOWS_VERSION STREQUAL "WIN10")
|
||||
# Default to Windows Server 2003 API if we don't recognize the specifier
|
||||
SET(NTDDI_VERSION 0x05020000)
|
||||
@@ -378,10 +357,12 @@ ENDMACRO (GENERATE_LIST_H)
|
||||
# Generate installation rules for man pages.
|
||||
#
|
||||
MACRO (INSTALL_MAN __mans)
|
||||
FOREACH (_man ${ARGV})
|
||||
STRING(REGEX REPLACE "^.+[.]([1-9])" "\\1" _mansect ${_man})
|
||||
INSTALL(FILES ${_man} DESTINATION "share/man/man${_mansect}")
|
||||
ENDFOREACH (_man)
|
||||
IF(ENABLE_INSTALL)
|
||||
FOREACH (_man ${ARGV})
|
||||
STRING(REGEX REPLACE "^.+[.]([1-9])" "\\1" _mansect ${_man})
|
||||
INSTALL(FILES ${_man} DESTINATION "share/man/man${_mansect}")
|
||||
ENDFOREACH (_man)
|
||||
ENDIF(ENABLE_INSTALL)
|
||||
ENDMACRO (INSTALL_MAN __mans)
|
||||
#
|
||||
# Find out what macro is needed to use libraries on Windows.
|
||||
@@ -606,6 +587,7 @@ IF(ENABLE_LIBB2)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBB2 DEFAULT_MSG LIBB2_LIBRARY LIBB2_INCLUDE_DIR)
|
||||
ELSE(ENABLE_LIBB2)
|
||||
SET(LIBB2_FOUND FALSE) # Override cached value
|
||||
UNSET(LIBB2_PKGCONFIG_VERSION CACHE)
|
||||
ENDIF(ENABLE_LIBB2)
|
||||
IF(LIBB2_FOUND)
|
||||
SET(HAVE_LIBB2 1)
|
||||
@@ -618,8 +600,13 @@ IF(LIBB2_FOUND)
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${LIBB2_INCLUDE_DIR})
|
||||
CHECK_FUNCTION_EXISTS(blake2sp_init HAVE_LIBB2)
|
||||
CMAKE_POP_CHECK_STATE()
|
||||
pkg_check_modules(LIBB2 libb2)
|
||||
IF(LIBB2_VERSION)
|
||||
SET(LIBB2_PKGCONFIG_VERSION LIBB2_VERSION)
|
||||
ENDIF(LIBB2_VERSION)
|
||||
ELSE(LIBB2_FOUND)
|
||||
SET(ARCHIVE_BLAKE2 TRUE)
|
||||
UNSET(LIBB2_PKGCONFIG_VERSION CACHE)
|
||||
ENDIF(LIBB2_FOUND)
|
||||
#
|
||||
# Find LZ4
|
||||
@@ -682,6 +669,7 @@ IF(ZSTD_FOUND)
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
|
||||
CHECK_FUNCTION_EXISTS(ZSTD_decompressStream HAVE_LIBZSTD)
|
||||
CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_ZSTD_compressStream)
|
||||
CHECK_FUNCTION_EXISTS(ZSTD_minCLevel HAVE_ZSTD_minCLevel)
|
||||
#
|
||||
# TODO: test for static library.
|
||||
#
|
||||
@@ -690,7 +678,6 @@ ENDIF(ZSTD_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR ZSTD_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(CLEAR ZSTD_LIBRARY)
|
||||
|
||||
|
||||
#
|
||||
# Check headers
|
||||
#
|
||||
@@ -821,7 +808,7 @@ IF(ENABLE_MBEDTLS)
|
||||
LA_CHECK_INCLUDE_FILE("mbedtls/aes.h" HAVE_MBEDTLS_AES_H)
|
||||
LA_CHECK_INCLUDE_FILE("mbedtls/md.h" HAVE_MBEDTLS_MD_H)
|
||||
LA_CHECK_INCLUDE_FILE("mbedtls/pkcs5.h" HAVE_MBEDTLS_PKCS5_H)
|
||||
|
||||
LA_CHECK_INCLUDE_FILE("mbedtls/version.h" HAVE_MBEDTLS_VERSION_H)
|
||||
ENDIF(MBEDTLS_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR MBEDTLS_INCLUDE_DIRS)
|
||||
MARK_AS_ADVANCED(CLEAR MBEDCRYPTO_LIBRARY)
|
||||
@@ -844,7 +831,7 @@ IF(ENABLE_NETTLE)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/pbkdf2.h" HAVE_NETTLE_PBKDF2_H)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/ripemd160.h" HAVE_NETTLE_RIPEMD160_H)
|
||||
LA_CHECK_INCLUDE_FILE("nettle/sha.h" HAVE_NETTLE_SHA_H)
|
||||
|
||||
LA_CHECK_INCLUDE_FILE("nettle/version.h" HAVE_NETTLE_VERSION_H)
|
||||
ENDIF(NETTLE_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR NETTLE_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(CLEAR NETTLE_LIBRARIES)
|
||||
@@ -863,6 +850,7 @@ IF(ENABLE_OPENSSL AND NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||
LA_CHECK_INCLUDE_FILE("openssl/evp.h" HAVE_OPENSSL_EVP_H)
|
||||
LA_CHECK_INCLUDE_FILE("openssl/opensslv.h" HAVE_OPENSSL_OPENSSLV_H)
|
||||
CHECK_FUNCTION_EXISTS(PKCS5_PBKDF2_HMAC_SHA1 HAVE_PKCS5_PBKDF2_HMAC_SHA1)
|
||||
ENDIF(OPENSSL_FOUND)
|
||||
ELSE()
|
||||
@@ -1070,7 +1058,6 @@ main(int argc, char **argv)
|
||||
"${OUTPUT}\n"
|
||||
"Source file was:\n${SOURCE}\n")
|
||||
ENDIF (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
|
||||
|
||||
ENDIF(NOT DEFINED ARCHIVE_CRYPTO_${CRYPTO}_WIN)
|
||||
ENDIF(NOT ARCHIVE_CRYPTO_${CRYPTO})
|
||||
ENDFOREACH(CRYPTO)
|
||||
@@ -1163,6 +1150,7 @@ IF(ENABLE_ICONV)
|
||||
CHECK_ICONV("libiconv" "const")
|
||||
CHECK_ICONV("libiconv" "")
|
||||
IF (HAVE_ICONV)
|
||||
SET(HAVE_LIBICONV 1)
|
||||
LIST(APPEND ADDITIONAL_LIBS ${LIBICONV_PATH})
|
||||
ENDIF(HAVE_ICONV)
|
||||
ENDIF(NOT HAVE_ICONV AND LIBICONV_PATH)
|
||||
@@ -1206,6 +1194,7 @@ ELSE(ENABLE_ICONV)
|
||||
# (once enabled).
|
||||
UNSET(HAVE_LOCALE_CHARSET CACHE)
|
||||
UNSET(HAVE_ICONV CACHE)
|
||||
UNSET(HAVE_LIBICONV CACHE)
|
||||
UNSET(HAVE_ICONV_libc_ CACHE)
|
||||
UNSET(HAVE_ICONV_libc_const CACHE)
|
||||
UNSET(HAVE_ICONV_libiconv_ CACHE)
|
||||
@@ -1235,6 +1224,7 @@ IF(LIBXML2_FOUND)
|
||||
SET(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR})
|
||||
CHECK_INCLUDE_FILES("libxml/xmlreader.h" HAVE_LIBXML_XMLREADER_H)
|
||||
CHECK_INCLUDE_FILES("libxml/xmlwriter.h" HAVE_LIBXML_XMLWRITER_H)
|
||||
CHECK_INCLUDE_FILES("libxml/xmlversion.h" HAVE_LIBXML_XMLVERSION_H)
|
||||
# Test if a macro is needed for the library.
|
||||
TRY_MACRO_FOR_LIBRARY(
|
||||
"${ICONV_INCLUDE_DIR};${LIBXML2_INCLUDE_DIR}"
|
||||
@@ -1262,6 +1252,25 @@ ELSE(LIBXML2_FOUND)
|
||||
SET(HAVE_LIBEXPAT 1)
|
||||
LA_CHECK_INCLUDE_FILE("expat.h" HAVE_EXPAT_H)
|
||||
CMAKE_POP_CHECK_STATE() # Restore the state of the variables
|
||||
ELSE(EXPAT_FOUND)
|
||||
IF(WIN32 AND ENABLE_WIN32_XMLLITE)
|
||||
# Check linkage as well; versions of mingw-w64 before v11.0.0
|
||||
# do not contain an import library for xmllite.
|
||||
cmake_push_check_state()
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "xmllite")
|
||||
check_c_source_compiles("
|
||||
#include <initguid.h>
|
||||
#include <xmllite.h>
|
||||
int main() {
|
||||
return CreateXmlReader(&IID_IXmlReader, NULL, NULL);
|
||||
}
|
||||
" HAVE_XMLLITE_H)
|
||||
cmake_pop_check_state()
|
||||
IF(HAVE_XMLLITE_H)
|
||||
SET(XMLLITE_FOUND TRUE)
|
||||
LIST(APPEND ADDITIONAL_LIBS "xmllite")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF(EXPAT_FOUND)
|
||||
ENDIF(LIBXML2_FOUND)
|
||||
MARK_AS_ADVANCED(CLEAR LIBXML2_INCLUDE_DIR)
|
||||
@@ -1524,6 +1533,8 @@ CHECK_FUNCTION_EXISTS_GLIBC(strnlen HAVE_STRNLEN)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(strrchr HAVE_STRRCHR)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(symlink HAVE_SYMLINK)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(sysconf HAVE_SYSCONF)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(tcgetattr HAVE_TCGETATTR)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(tcsetattr HAVE_TCSETATTR)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(timegm HAVE_TIMEGM)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(tzset HAVE_TZSET)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(unlinkat HAVE_UNLINKAT)
|
||||
@@ -1533,9 +1544,9 @@ CHECK_FUNCTION_EXISTS_GLIBC(utimes HAVE_UTIMES)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(utimensat HAVE_UTIMENSAT)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(vfork HAVE_VFORK)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(wcrtomb HAVE_WCRTOMB)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(wcscmp HAVE_WCSCMP)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(wcscpy HAVE_WCSCPY)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(wcslen HAVE_WCSLEN)
|
||||
check_symbol_exists(wcscmp wchar.h HAVE_WCSCMP)
|
||||
check_symbol_exists(wcscpy wchar.h HAVE_WCSCPY)
|
||||
check_symbol_exists(wcslen wchar.h HAVE_WCSLEN)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(wctomb HAVE_WCTOMB)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(_fseeki64 HAVE__FSEEKI64)
|
||||
CHECK_FUNCTION_EXISTS_GLIBC(_get_timezone HAVE__GET_TIMEZONE)
|
||||
@@ -1813,11 +1824,16 @@ IF(ENABLE_XATTR)
|
||||
CHECK_LIBRARY_EXISTS(attr "setxattr" "" HAVE_LIBATTR)
|
||||
IF(HAVE_LIBATTR)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "attr")
|
||||
ELSE()
|
||||
pkg_check_modules(LIBATTR libattr)
|
||||
IF(LIBATTR_VERSION)
|
||||
SET(LIBATTR_PKGCONFIG_VERSION ${LIBATTR_VERSION})
|
||||
ENDIF(LIBATTR_VERSION)
|
||||
ELSE(HAVE_LIBATTR)
|
||||
CHECK_LIBRARY_EXISTS(gnu "setxattr" "" HAVE_LIBATTR_GNU)
|
||||
IF(HAVE_LIBATTR_GNU)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "gnu")
|
||||
ENDIF()
|
||||
UNSET(LIBATTR_PKGCONFIG_VERSION CACHE)
|
||||
ENDIF(HAVE_LIBATTR)
|
||||
CHECK_SYMBOL_EXISTS(EXTATTR_NAMESPACE_USER "sys/types.h;sys/extattr.h" HAVE_DECL_EXTATTR_NAMESPACE_USER)
|
||||
CHECK_SYMBOL_EXISTS(XATTR_NOFOLLOW "sys/xattr.h" HAVE_DECL_XATTR_NOFOLLOW)
|
||||
@@ -1935,6 +1951,12 @@ IF(ENABLE_ACL)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "acl")
|
||||
FIND_LIBRARY(ACL_LIBRARY NAMES acl)
|
||||
LIST(APPEND ADDITIONAL_LIBS ${ACL_LIBRARY})
|
||||
pkg_check_modules(LIBACL libacl)
|
||||
IF(LIBACL_VERSION)
|
||||
SET(LIBACL_PKGCONFIG_VERSION ${LIBACL_VERSION})
|
||||
ENDIF(LIBACL_VERSION)
|
||||
ELSE(HAVE_LIBACL)
|
||||
UNSET(LIBACL_PKGCONFIG_VERSION CACHE)
|
||||
ENDIF(HAVE_LIBACL)
|
||||
|
||||
CHECK_TYPE_EXISTS(acl_t "sys/types.h;sys/acl.h" HAVE_ACL_T)
|
||||
@@ -2074,6 +2096,12 @@ int main(void) { return ACL_SYNCHRONIZE; }" HAVE_DECL_ACL_SYNCHRONIZE)
|
||||
SET(CMAKE_REQUIRED_LIBRARIES "richacl")
|
||||
FIND_LIBRARY(RICHACL_LIBRARY NAMES richacl)
|
||||
LIST(APPEND ADDITIONAL_LIBS ${RICHACL_LIBRARY})
|
||||
pkg_check_modules(LIBRICHACL librichacl)
|
||||
IF(LIBRICHACL_VERSION)
|
||||
SET(LIBRICHACL_PKGCONFIG_VERSION ${LIBRICHACL_VERSION})
|
||||
ENDIF(LIBRICHACL_VERSION)
|
||||
ELSE(HAVE_LIBRICHACL)
|
||||
UNSET(LIBRICHACL_PKGCONFIG_VERSION CACHE)
|
||||
ENDIF(HAVE_LIBRICHACL)
|
||||
|
||||
CHECK_STRUCT_HAS_MEMBER("struct richace" e_type "sys/richacl.h"
|
||||
@@ -2173,7 +2201,7 @@ INCLUDE(CreatePkgConfigFile)
|
||||
#
|
||||
# Register installation of PDF documents.
|
||||
#
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
IF(WIN32 AND NOT CYGWIN AND ENABLE_INSTALL)
|
||||
#
|
||||
# On Windows platform, It's better that we install PDF documents
|
||||
# on one's computer.
|
||||
@@ -2185,7 +2213,7 @@ IF(WIN32 AND NOT CYGWIN)
|
||||
FILES_MATCHING PATTERN "*.pdf"
|
||||
)
|
||||
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doc/pdf)
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
ENDIF(WIN32 AND NOT CYGWIN AND ENABLE_INSTALL)
|
||||
#
|
||||
#
|
||||
#
|
||||
@@ -2195,11 +2223,6 @@ IF(MSVC)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
ENDIF(MSVC)
|
||||
|
||||
IF(APPLE)
|
||||
# CC_MD5_Init() functions are deprecated on macOS 10.15, but we want to use them
|
||||
ADD_DEFINITIONS(-Wno-deprecated-declarations)
|
||||
ENDIF(APPLE)
|
||||
|
||||
OPTION(DONT_FAIL_ON_CRC_ERROR "Ignore CRC errors during parsing (For fuzzing)" OFF)
|
||||
IF(DONT_FAIL_ON_CRC_ERROR)
|
||||
ADD_DEFINITIONS(-DDONT_FAIL_ON_CRC_ERROR=1)
|
||||
|
||||
@@ -20,7 +20,7 @@ the actual statements in the files are controlling.
|
||||
libarchive/mtree.5
|
||||
|
||||
* The following source files are in the public domain:
|
||||
libarchive/archive_getdate.c
|
||||
libarchive/archive_parse_date.c
|
||||
|
||||
* The following source files are triple-licensed with the ability to choose
|
||||
from CC0 1.0 Universal, OpenSSL or Apache 2.0 licenses:
|
||||
|
||||
+34
-4
@@ -118,8 +118,6 @@ libarchive_la_SOURCES= \
|
||||
libarchive/archive_entry_stat.c \
|
||||
libarchive/archive_entry_strmode.c \
|
||||
libarchive/archive_entry_xattr.c \
|
||||
libarchive/archive_getdate.c \
|
||||
libarchive/archive_getdate.h \
|
||||
libarchive/archive_hmac.c \
|
||||
libarchive/archive_hmac_private.h \
|
||||
libarchive/archive_match.c \
|
||||
@@ -129,6 +127,7 @@ libarchive_la_SOURCES= \
|
||||
libarchive/archive_options_private.h \
|
||||
libarchive/archive_pack_dev.h \
|
||||
libarchive/archive_pack_dev.c \
|
||||
libarchive/archive_parse_date.c \
|
||||
libarchive/archive_pathmatch.c \
|
||||
libarchive/archive_pathmatch.h \
|
||||
libarchive/archive_platform.h \
|
||||
@@ -197,6 +196,8 @@ libarchive_la_SOURCES= \
|
||||
libarchive/archive_string.h \
|
||||
libarchive/archive_string_composition.h \
|
||||
libarchive/archive_string_sprintf.c \
|
||||
libarchive/archive_time.c \
|
||||
libarchive/archive_time_private.h \
|
||||
libarchive/archive_util.c \
|
||||
libarchive/archive_version_details.c \
|
||||
libarchive/archive_virtual.c \
|
||||
@@ -377,10 +378,10 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_archive_clear_error.c \
|
||||
libarchive/test/test_archive_cmdline.c \
|
||||
libarchive/test/test_archive_digest.c \
|
||||
libarchive/test/test_archive_getdate.c \
|
||||
libarchive/test/test_archive_match_owner.c \
|
||||
libarchive/test/test_archive_match_path.c \
|
||||
libarchive/test/test_archive_match_time.c \
|
||||
libarchive/test/test_archive_parse_date.c \
|
||||
libarchive/test/test_archive_pathmatch.c \
|
||||
libarchive/test/test_archive_read.c \
|
||||
libarchive/test/test_archive_read_add_passphrase.c \
|
||||
@@ -411,6 +412,7 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_compat_bzip2.c \
|
||||
libarchive/test/test_compat_cpio.c \
|
||||
libarchive/test/test_compat_gtar.c \
|
||||
libarchive/test/test_compat_gtar_large.c \
|
||||
libarchive/test/test_compat_gzip.c \
|
||||
libarchive/test/test_compat_lz4.c \
|
||||
libarchive/test/test_compat_lzip.c \
|
||||
@@ -488,7 +490,9 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_read_format_gtar_filename.c \
|
||||
libarchive/test/test_read_format_gtar_gz.c \
|
||||
libarchive/test/test_read_format_gtar_lzma.c \
|
||||
libarchive/test/test_read_format_gtar_redundant_L.c \
|
||||
libarchive/test/test_read_format_gtar_sparse.c \
|
||||
libarchive/test/test_read_format_gtar_sparse_length.c \
|
||||
libarchive/test/test_read_format_gtar_sparse_skip_entry.c \
|
||||
libarchive/test/test_read_format_huge_rpm.c \
|
||||
libarchive/test/test_read_format_iso_Z.c \
|
||||
@@ -517,6 +521,7 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_read_format_rar_encryption_header.c \
|
||||
libarchive/test/test_read_format_rar_filter.c \
|
||||
libarchive/test/test_read_format_rar_invalid1.c \
|
||||
libarchive/test/test_read_format_rar_overflow.c \
|
||||
libarchive/test/test_read_format_rar5.c \
|
||||
libarchive/test/test_read_format_raw.c \
|
||||
libarchive/test/test_read_format_tar.c \
|
||||
@@ -526,6 +531,7 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_read_format_tar_empty_with_gnulabel.c \
|
||||
libarchive/test/test_read_format_tar_filename.c \
|
||||
libarchive/test/test_read_format_tar_invalid_pax_size.c \
|
||||
libarchive/test/test_read_format_tar_pax_g_large.c \
|
||||
libarchive/test/test_read_format_tar_pax_large_attr.c \
|
||||
libarchive/test/test_read_format_tbz.c \
|
||||
libarchive/test/test_read_format_tgz.c \
|
||||
@@ -627,6 +633,7 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_write_format_mtree_classic_indent.c\
|
||||
libarchive/test/test_write_format_mtree_fflags.c \
|
||||
libarchive/test/test_write_format_mtree_no_separator.c \
|
||||
libarchive/test/test_write_format_mtree_preset_digests.c \
|
||||
libarchive/test/test_write_format_mtree_quoted_filename.c\
|
||||
libarchive/test/test_write_format_pax.c \
|
||||
libarchive/test/test_write_format_raw.c \
|
||||
@@ -644,6 +651,9 @@ libarchive_test_SOURCES= \
|
||||
libarchive/test/test_write_format_zip.c \
|
||||
libarchive/test/test_write_format_zip64_stream.c \
|
||||
libarchive/test/test_write_format_zip_compression_store.c \
|
||||
libarchive/test/test_write_format_zip_compression_zstd.c \
|
||||
libarchive/test/test_write_format_zip_compression_bzip2.c \
|
||||
libarchive/test/test_write_format_zip_compression_lzmaxz.c \
|
||||
libarchive/test/test_write_format_zip_empty.c \
|
||||
libarchive/test/test_write_format_zip_empty_zip64.c \
|
||||
libarchive/test/test_write_format_zip_entry_size_unset.c \
|
||||
@@ -787,6 +797,7 @@ libarchive_test_EXTRA_DIST=\
|
||||
libarchive/test/test_read_format_7zip_copy_2.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_deflate.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_deflate_arm64.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_deflate_powerpc.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_delta_lzma1.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_delta4_lzma1.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_delta_lzma2.7z.uu \
|
||||
@@ -803,16 +814,23 @@ libarchive_test_EXTRA_DIST=\
|
||||
libarchive/test/test_read_format_7zip_lzma2.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_lzma2_arm64.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_lzma2_arm.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_lzma2_powerpc.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_lzma2_riscv.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_lzma2_sparc.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_malformed.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_malformed2.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_packinfo_digests.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_ppmd.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_sfx_elf.elf.uu \
|
||||
libarchive/test/test_read_format_7zip_sfx_modified_pe.exe.uu \
|
||||
libarchive/test/test_read_format_7zip_sfx_pe.exe.uu \
|
||||
libarchive/test/test_read_format_7zip_solid_zstd.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_symbolic_name.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_win_attrib.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_zstd_arm.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_zstd_bcj.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_zstd_nobcj.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_zstd_sparc.7z.uu \
|
||||
libarchive/test/test_read_format_7zip_zstd.7z.uu \
|
||||
libarchive/test/test_read_format_ar.ar.uu \
|
||||
libarchive/test/test_read_format_cab_1.cab.uu \
|
||||
@@ -831,12 +849,14 @@ libarchive_test_EXTRA_DIST=\
|
||||
libarchive/test/test_read_format_gtar_filename_cp866.tar.Z.uu \
|
||||
libarchive/test/test_read_format_gtar_filename_eucjp.tar.Z.uu \
|
||||
libarchive/test/test_read_format_gtar_filename_koi8r.tar.Z.uu \
|
||||
libarchive/test/test_read_format_gtar_redundant_L.tar.Z.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_length.tar.Z.uu \
|
||||
libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu \
|
||||
libarchive/test/test_read_format_huge_rpm.rpm.uu \
|
||||
libarchive/test/test_read_format_iso.iso.Z.uu \
|
||||
@@ -875,6 +895,7 @@ libarchive_test_EXTRA_DIST=\
|
||||
libarchive/test/test_read_format_rar_encryption_data.rar.uu \
|
||||
libarchive/test/test_read_format_rar_encryption_header.rar.uu \
|
||||
libarchive/test/test_read_format_rar_encryption_partially.rar.uu \
|
||||
libarchive/test/test_read_format_rar_endarc_huge.rar.uu \
|
||||
libarchive/test/test_read_format_rar_filter.rar.uu \
|
||||
libarchive/test/test_read_format_rar_invalid1.rar.uu \
|
||||
libarchive/test/test_read_format_rar_multi_lzss_blocks.rar.uu \
|
||||
@@ -882,12 +903,15 @@ libarchive_test_EXTRA_DIST=\
|
||||
libarchive/test/test_read_format_rar_multivolume.part0002.rar.uu \
|
||||
libarchive/test/test_read_format_rar_multivolume.part0003.rar.uu \
|
||||
libarchive/test/test_read_format_rar_multivolume.part0004.rar.uu \
|
||||
libarchive/test/test_read_format_rar_newsub_huge.rar.uu \
|
||||
libarchive/test/test_read_format_rar_noeof.rar.uu \
|
||||
libarchive/test/test_read_format_rar_overflow.rar.uu \
|
||||
libarchive/test/test_read_format_rar_ppmd_lzss_conversion.rar.uu \
|
||||
libarchive/test/test_read_format_rar_ppmd_use_after_free.rar.uu \
|
||||
libarchive/test/test_read_format_rar_ppmd_use_after_free2.rar.uu \
|
||||
libarchive/test/test_read_format_rar_sfx.exe.uu \
|
||||
libarchive/test/test_read_format_rar_subblock.rar.uu \
|
||||
libarchive/test/test_read_format_rar_symlink_huge.rar.uu \
|
||||
libarchive/test/test_read_format_rar_unicode.rar.uu \
|
||||
libarchive/test/test_read_format_rar_windows.rar.uu \
|
||||
libarchive/test/test_read_format_rar4_encrypted.rar.uu \
|
||||
@@ -951,11 +975,13 @@ libarchive_test_EXTRA_DIST=\
|
||||
libarchive/test/test_read_format_tar_empty_pax.tar.Z.uu \
|
||||
libarchive/test/test_read_format_tar_filename_koi8r.tar.Z.uu \
|
||||
libarchive/test/test_read_format_tar_invalid_pax_size.tar.uu \
|
||||
libarchive/test/test_read_format_tar_pax_g_large.tar.uu \
|
||||
libarchive/test/test_read_format_tar_pax_large_attr.tar.Z.uu \
|
||||
libarchive/test/test_read_format_ustar_filename_cp866.tar.Z.uu \
|
||||
libarchive/test/test_read_format_ustar_filename_eucjp.tar.Z.uu \
|
||||
libarchive/test/test_read_format_ustar_filename_koi8r.tar.Z.uu \
|
||||
libarchive/test/test_read_format_warc.warc.uu \
|
||||
libarchive/test/test_read_format_warc_incomplete.warc.uu \
|
||||
libarchive/test/test_read_format_xar_doublelink.xar.uu \
|
||||
libarchive/test/test_read_format_xar_duplicate_filename_node.xar.uu \
|
||||
libarchive/test/test_read_format_zip.zip.uu \
|
||||
@@ -1123,13 +1149,14 @@ bsdtar_test_SOURCES= \
|
||||
tar/test/test_format_newc.c \
|
||||
tar/test/test_help.c \
|
||||
tar/test/test_leading_slash.c \
|
||||
tar/test/test_list_item.c \
|
||||
tar/test/test_missing_file.c \
|
||||
tar/test/test_option_C_mtree.c \
|
||||
tar/test/test_option_C_upper.c \
|
||||
tar/test/test_option_H_upper.c \
|
||||
tar/test/test_option_L_upper.c \
|
||||
tar/test/test_option_O_upper.c \
|
||||
tar/test/test_option_P.c \
|
||||
tar/test/test_option_P_upper.c \
|
||||
tar/test/test_option_T_upper.c \
|
||||
tar/test/test_option_U_upper.c \
|
||||
tar/test/test_option_X_upper.c \
|
||||
@@ -1151,6 +1178,7 @@ bsdtar_test_SOURCES= \
|
||||
tar/test/test_option_lz4.c \
|
||||
tar/test/test_option_lzma.c \
|
||||
tar/test/test_option_lzop.c \
|
||||
tar/test/test_option_mtime.c \
|
||||
tar/test/test_option_n.c \
|
||||
tar/test/test_option_newer_than.c \
|
||||
tar/test/test_option_nodump.c \
|
||||
@@ -1208,6 +1236,7 @@ bsdtar_test_EXTRA_DIST= \
|
||||
tar/test/test_extract.tar.lzo.uu \
|
||||
tar/test/test_extract.tar.xz.uu \
|
||||
tar/test/test_leading_slash.tar.uu \
|
||||
tar/test/test_list_item.tar.uu \
|
||||
tar/test/test_option_keep_newer_files.tar.Z.uu \
|
||||
tar/test/test_option_passphrase.zip.uu \
|
||||
tar/test/test_option_s.tar.Z.uu \
|
||||
@@ -1493,6 +1522,7 @@ bsdunzip_SOURCES= \
|
||||
unzip/bsdunzip_platform.h \
|
||||
unzip/cmdline.c \
|
||||
unzip/la_getline.c \
|
||||
unzip/la_getline.h \
|
||||
unzip/la_queue.h
|
||||
|
||||
if INC_WINDOWS_FILES
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
May 20, 2025: libarchive 3.8.0 released
|
||||
|
||||
Mar 30, 2025: libarchive 3.7.9 released
|
||||
|
||||
Mar 20, 2025: libarchive 3.7.8 released
|
||||
|
||||
Oct 13, 2024: libarchive 3.7.7 released
|
||||
|
||||
Sep 23, 2024: libarchive 3.7.6 released
|
||||
|
||||
@@ -85,13 +85,14 @@ Currently, the library automatically detects and reads the following formats:
|
||||
* PWB binary cpio
|
||||
* ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives)
|
||||
* ZIPX archives (with support for bzip2, ppmd8, lzma and xz compressed entries)
|
||||
* ZIPX archives (with support for bzip2, zstd, ppmd8, lzma and xz compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
* 7-Zip archives (including archives that use zstandard compression)
|
||||
* Microsoft CAB format
|
||||
* LHA and LZH archives
|
||||
* RAR and RAR 5.0 archives (with some limitations due to RAR's proprietary status)
|
||||
* WARC archives
|
||||
* XAR archives
|
||||
|
||||
The library also detects and handles any of the following before evaluating the archive:
|
||||
@@ -120,15 +121,18 @@ The library can create archives in any of the following formats:
|
||||
* PWB binary cpio
|
||||
* shar archives
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* ZIPX archives (with bzip2, zstd, lzma or xz compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
* ISO9660 format
|
||||
* 7-Zip archives
|
||||
* 7-Zip archives (including archives that use zstandard compression)
|
||||
* WARC archives
|
||||
* XAR archives
|
||||
|
||||
When creating archives, the result can be filtered with any of the following:
|
||||
|
||||
* uuencode
|
||||
* base64
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
@@ -241,4 +245,3 @@ questions we are asked about libarchive:
|
||||
appropriate. It has many advantages over other tar formats
|
||||
(including the legacy GNU tar format) and is widely supported by
|
||||
current tar implementations.
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
PATH=/usr/local/gnu-autotools/bin/:$PATH
|
||||
export PATH
|
||||
|
||||
# Start from one level above the build directory
|
||||
if [ -f version ]; then
|
||||
@@ -49,7 +49,7 @@ perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_S\]),.*\)/$1,['"$VS"'])/' conf
|
||||
perl -p -i -e 's/(m4_define\(\[LIBARCHIVE_VERSION_N\]),.*\)/$1,['"$VN"'])/' configure.ac
|
||||
|
||||
# Remove developer CFLAGS if a release build is being made
|
||||
if [ -n "${MAKE_LIBARCHIVE_RELEASE}" ]; then
|
||||
if [ -n "${MAKE_LIBARCHIVE_RELEASE:-}" ]; then
|
||||
perl -p -i -e "s/^(DEV_CFLAGS.*)/# \$1/" Makefile.am
|
||||
perl -p -i -e 's/CMAKE_BUILD_TYPE "[A-Za-z]*"/CMAKE_BUILD_TYPE "Release"/' CMakeLists.txt
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh +v
|
||||
set -eu
|
||||
|
||||
# Start from the build directory, where the version file is located
|
||||
if [ -f build/version ]; then
|
||||
|
||||
+19
-8
@@ -12,14 +12,18 @@
|
||||
# MAKE_ARGS= # make arguments
|
||||
# DEBUG= # set -g -fsanitize=address flags
|
||||
|
||||
set -eu
|
||||
|
||||
ACTIONS=
|
||||
if [ -n "${BUILD_SYSTEM}" ]; then
|
||||
if [ -n "${BUILD_SYSTEM:-}" ]; then
|
||||
BS="${BUILD_SYSTEM}"
|
||||
fi
|
||||
|
||||
BS="${BS:-autotools}"
|
||||
MAKE="${MAKE:-make}"
|
||||
CMAKE="${CMAKE:-cmake}"
|
||||
CMAKE_ARGS="${CMAKE_ARGS:-}"
|
||||
CONFIGURE_ARGS="${CONFIGURE_ARGS:-}"
|
||||
CURDIR=`pwd`
|
||||
SRCDIR="${SRCDIR:-`pwd`}"
|
||||
RET=0
|
||||
@@ -74,7 +78,7 @@ while getopts a:b:c:d:s: opt; do
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case "${CRYPTO}" in
|
||||
case "${CRYPTO:-}" in
|
||||
mbedtls)
|
||||
CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPENSSL=OFF -DENABLE_MBEDTLS=ON"
|
||||
CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-mbedtls"
|
||||
@@ -84,15 +88,21 @@ case "${CRYPTO}" in
|
||||
CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-nettle"
|
||||
;;
|
||||
esac
|
||||
if [ -z "${MAKE_ARGS}" ]; then
|
||||
if [ -z "${MAKE_ARGS:-}" ]; then
|
||||
if [ "${BS}" = "autotools" ]; then
|
||||
MAKE_ARGS="V=1"
|
||||
elif [ "${BS}" = "cmake" ]; then
|
||||
MAKE_ARGS="VERBOSE=1"
|
||||
fi
|
||||
fi
|
||||
if [ -n "${DEBUG}" ]; then
|
||||
if [ -n "${CFLAGS}" ]; then
|
||||
if [ -d /opt/homebrew/include ]; then
|
||||
export CFLAGS="${CFLAGS:-} -I/opt/homebrew/include"
|
||||
fi
|
||||
if [ -d /opt/homebrew/lib ]; then
|
||||
export LDFLAGS="${LDFLAGS:-} -L/opt/homebrew/lib"
|
||||
fi
|
||||
if [ -n "${DEBUG:-}" ]; then
|
||||
if [ -n "${CFLAGS:-}" ]; then
|
||||
export CFLAGS="${CFLAGS} -g -fsanitize=address"
|
||||
else
|
||||
export CFLAGS="-g -fsanitize=address"
|
||||
@@ -104,7 +114,7 @@ fi
|
||||
if [ -z "${BS}" ]; then
|
||||
inputerror "Missing build system (-b) parameter"
|
||||
fi
|
||||
if [ -z "${BUILDDIR}" ]; then
|
||||
if [ -z "${BUILDDIR:-}" ]; then
|
||||
BUILDDIR="${CURDIR}/build_ci/${BS}"
|
||||
fi
|
||||
mkdir -p "${BUILDDIR}"
|
||||
@@ -141,18 +151,19 @@ for action in ${ACTIONS}; do
|
||||
;;
|
||||
esac
|
||||
RET="$?"
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \;
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \; 2>/dev/null || /bin/true
|
||||
;;
|
||||
install)
|
||||
${MAKE} ${MAKE_ARGS} install DESTDIR="${BUILDDIR}/destdir"
|
||||
RET="$?"
|
||||
cd "${BUILDDIR}/destdir" && ls -lR .
|
||||
./usr/local/bin/bsdtar --version
|
||||
;;
|
||||
distcheck)
|
||||
${MAKE} ${MAKE_ARGS} distcheck || (
|
||||
RET="$?"
|
||||
find . -name 'test-suite.log' -print -exec cat {} \;
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \;
|
||||
find ${TMPDIR:-/tmp} -path '*_test.*' -name '*.log' -print -exec cat {} \; 2>/dev/null || /bin/true
|
||||
exit "${RET}"
|
||||
)
|
||||
RET="$?"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM cirrusci/windowsservercore:2019
|
||||
|
||||
RUN choco install -y --no-progress cygwin
|
||||
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,sharutils,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel
|
||||
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM fedora:31
|
||||
|
||||
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel nettle-devel mbedtls-devel
|
||||
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel nettle-devel mbedtls-devel
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM fedora:31
|
||||
|
||||
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel groff ghostscript xz zip
|
||||
RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison pkgconf libacl-devel libasan librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel groff ghostscript xz zip
|
||||
|
||||
@@ -9,4 +9,4 @@ RUN tar -x -f zlib-1.2.11.tar.gz
|
||||
RUN cd zlib-1.2.11 && cmake -G "Visual Studio 15 2017" . && cmake --build . --target ALL_BUILD --config Release && cmake --build . --target INSTALL --config Release
|
||||
RUN del /f /q /s zlib-1.2.11 zlib-1.2.11.tar.gz
|
||||
RUN choco install -y --no-progress cygwin
|
||||
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,sharutils,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel
|
||||
RUN C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel
|
||||
|
||||
@@ -13,7 +13,7 @@ IF "%1%"=="prepare" (
|
||||
IF "%BE%"=="cygwin-gcc" (
|
||||
@ECHO ON
|
||||
choco install -y --no-progress cygwin || EXIT /b 1
|
||||
C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,sharutils,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel || EXIT /b 1
|
||||
C:\tools\cygwin\cygwinsetup.exe -q -P make,autoconf,automake,cmake,gcc-core,binutils,libtool,pkg-config,bison,zlib-devel,libbz2-devel,liblzma-devel,liblz4-devel,libiconv-devel,libxml2-devel,libzstd-devel,libssl-devel || EXIT /b 1
|
||||
@EXIT /b 0
|
||||
) ELSE IF "%BE%"=="mingw-gcc" (
|
||||
@ECHO ON
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if [ $# != 1 ]
|
||||
then
|
||||
echo "Usage: $0 prepare | test"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
UNAME=`uname`
|
||||
if [ "$1" = "prepare" ]
|
||||
then
|
||||
@@ -29,10 +37,10 @@ then
|
||||
if [ -f "/etc/debian_version" ]
|
||||
then
|
||||
apt-get -y update
|
||||
apt-get -y install build-essential locales automake libtool bison sharutils pkgconf libacl1-dev libbz2-dev zlib1g-dev liblzma-dev liblz4-dev libzstd-dev libssl-dev lrzip cmake
|
||||
apt-get -y install build-essential locales automake libtool bison pkgconf libacl1-dev libbz2-dev zlib1g-dev liblzma-dev liblz4-dev libzstd-dev libssl-dev lrzip cmake
|
||||
elif [ -f "/etc/fedora-release" ]
|
||||
then
|
||||
dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel
|
||||
dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison pkgconf libacl-devel librichacl-devel bzip2-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel
|
||||
fi
|
||||
fi
|
||||
elif [ "$1" = "test" ]
|
||||
@@ -53,6 +61,6 @@ then
|
||||
TMPDIR=/tmp_acl_nfsv4 ${BIN_SUBDIR}/libarchive_test -r "${CURDIR}/libarchive/test" -v test_acl_platform_nfs4
|
||||
fi
|
||||
else
|
||||
echo "Usage $0 prepare | test_nfsv4_acls"
|
||||
echo "Usage: $0 prepare | test"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@ECHO OFF
|
||||
SET ZLIB_VERSION=1.3
|
||||
SET BZIP2_VERSION=1ea1ac188ad4b9cb662e3f8314673c63df95a589
|
||||
SET XZ_VERSION=5.4.4
|
||||
SET XZ_VERSION=5.6.3
|
||||
IF NOT "%BE%"=="mingw-gcc" (
|
||||
IF NOT "%BE%"=="msvc" (
|
||||
ECHO Environment variable BE must be mingw-gcc or msvc
|
||||
@@ -64,7 +64,7 @@ IF "%1"=="deplibs" (
|
||||
IF "%BE%"=="mingw-gcc" (
|
||||
SET PATH=%MINGWPATH%
|
||||
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
|
||||
mingw32-make || EXIT /b 1
|
||||
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
|
||||
mingw32-make test || EXIT /b 1
|
||||
mingw32-make install || EXIT /b 1
|
||||
) ELSE IF "%BE%"=="msvc" (
|
||||
@@ -78,7 +78,7 @@ IF "%1"=="deplibs" (
|
||||
IF "%BE%"=="mingw-gcc" (
|
||||
SET PATH=%MINGWPATH%
|
||||
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" -D ENABLE_LIB_ONLY=ON -D ENABLE_SHARED_LIB=OFF -D ENABLE_STATIC_LIB=ON . || EXIT /b 1
|
||||
mingw32-make || EXIT /b 1
|
||||
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
|
||||
REM mingw32-make test || EXIT /b 1
|
||||
mingw32-make install || EXIT /b 1
|
||||
) ELSE IF "%BE%"=="msvc" (
|
||||
@@ -92,7 +92,7 @@ IF "%1"=="deplibs" (
|
||||
IF "%BE%"=="mingw-gcc" (
|
||||
SET PATH=%MINGWPATH%
|
||||
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
|
||||
mingw32-make || EXIT /b 1
|
||||
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
|
||||
mingw32-make install || EXIT /b 1
|
||||
) ELSE IF "%BE%"=="msvc" (
|
||||
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
|
||||
@@ -104,7 +104,7 @@ IF "%1"=="deplibs" (
|
||||
IF "%BE%"=="mingw-gcc" (
|
||||
SET PATH=%MINGWPATH%
|
||||
cmake -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
|
||||
mingw32-make || EXIT /b 1
|
||||
mingw32-make -j %NUMBER_OF_PROCESSORS% || EXIT /b 1
|
||||
mingw32-make install || EXIT /b 1
|
||||
) ELSE IF "%BE%"=="msvc" (
|
||||
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" . || EXIT /b 1
|
||||
@@ -120,13 +120,13 @@ IF "%1"=="deplibs" (
|
||||
) ELSE IF "%BE%"=="msvc" (
|
||||
MKDIR build_ci\cmake
|
||||
CD build_ci\cmake
|
||||
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" -D ZLIB_LIBRARY="C:/Program Files (x86)/zlib/lib/zlibstatic.lib" -D ZLIB_INCLUDE_DIR="C:/Program Files (x86)/zlib/include" -D BZIP2_LIBRARIES="C:/Program Files (x86)/bzip2/lib/bz2_static.lib" -D BZIP2_INCLUDE_DIR="C:/Program Files (x86)/bzip2/include" -D LIBLZMA_LIBRARY="C:/Program Files (x86)/xz/lib/liblzma.lib" -D LIBLZMA_INCLUDE_DIR="C:/Program Files (x86)/xz/include" -D ZSTD_LIBRARY="C:/Program Files (x86)/zstd/lib/zstd_static.lib" -D ZSTD_INCLUDE_DIR="C:/Program Files (x86)/zstd/include" ..\.. || EXIT /b 1
|
||||
cmake -G "Visual Studio 17 2022" -D CMAKE_BUILD_TYPE="Release" -D ZLIB_LIBRARY="C:/Program Files (x86)/zlib/lib/zlibstatic.lib" -D ZLIB_INCLUDE_DIR="C:/Program Files (x86)/zlib/include" -D BZIP2_LIBRARIES="C:/Program Files (x86)/bzip2/lib/bz2_static.lib" -D BZIP2_INCLUDE_DIR="C:/Program Files (x86)/bzip2/include" -D LIBLZMA_LIBRARY="C:/Program Files (x86)/xz/lib/lzma.lib" -D LIBLZMA_INCLUDE_DIR="C:/Program Files (x86)/xz/include" -D ZSTD_LIBRARY="C:/Program Files (x86)/zstd/lib/zstd_static.lib" -D ZSTD_INCLUDE_DIR="C:/Program Files (x86)/zstd/include" ..\.. || EXIT /b 1
|
||||
)
|
||||
) ELSE IF "%1%"=="build" (
|
||||
IF "%BE%"=="mingw-gcc" (
|
||||
SET PATH=%MINGWPATH%
|
||||
CD build_ci\cmake
|
||||
mingw32-make VERBOSE=1 || EXIT /b 1
|
||||
mingw32-make -j %NUMBER_OF_PROCESSORS% VERBOSE=1 || EXIT /b 1
|
||||
) ELSE IF "%BE%"=="msvc" (
|
||||
CD build_ci\cmake
|
||||
cmake --build . --target ALL_BUILD --config Release || EXIT /b 1
|
||||
@@ -150,6 +150,7 @@ IF "%1"=="deplibs" (
|
||||
CD build_ci\cmake
|
||||
cmake --build . --target INSTALL --config Release || EXIT /b 1
|
||||
)
|
||||
"C:\Program Files (x86)\libarchive\bin\bsdtar.exe" --version
|
||||
) ELSE IF "%1"=="artifact" (
|
||||
C:\windows\system32\tar.exe -c -C "C:\Program Files (x86)" --format=zip -f libarchive.zip libarchive
|
||||
) ELSE (
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
set -eux
|
||||
|
||||
# Uncommenting these adds a full minute to the CI time
|
||||
#brew update > /dev/null
|
||||
#brew upgrade > /dev/null
|
||||
|
||||
# This does an upgrade if the package is already installed
|
||||
brew install \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
pkg-config \
|
||||
cmake \
|
||||
xz \
|
||||
lz4 \
|
||||
zstd \
|
||||
libxml2 \
|
||||
openssl
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
if [ "$1" = "prepare" ]
|
||||
then
|
||||
set -x -e
|
||||
#Uncommenting these adds a full minute to the CI time
|
||||
#brew update > /dev/null
|
||||
#brew upgrade > /dev/null
|
||||
|
||||
# This does an upgrade if the package is already installed
|
||||
brew install \
|
||||
autoconf \
|
||||
automake \
|
||||
libtool \
|
||||
pkg-config \
|
||||
cmake \
|
||||
xz \
|
||||
lz4 \
|
||||
zstd \
|
||||
libxml2 \
|
||||
openssl
|
||||
fi
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
UNAME=`uname`
|
||||
CURDIR=`pwd`
|
||||
SRCDIR="${SRCDIR:-`pwd`}"
|
||||
if [ -z "${BUILDDIR}" ]; then
|
||||
BUILDDIR="${CURDIR}/build_ci/${BS}"
|
||||
fi
|
||||
mkdir -p "${BUILDDIR}"
|
||||
cd "${BUILDDIR}"
|
||||
case "$UNAME" in
|
||||
MSYS*)
|
||||
if [ "${BS}" = "msbuild" ]; then
|
||||
set -x
|
||||
cmake -G "Visual Studio 15 2017" -D CMAKE_BUILD_TYPE="Release" "${SRCDIR}"
|
||||
cmake --build . --target ALL_BUILD
|
||||
# Until fixed, we don't run tests on Windows (lots of fails + timeout)
|
||||
#export SKIP_TEST_FUZZ=1
|
||||
#cmake --build . --target RUN_TESTS
|
||||
set +x
|
||||
elif [ "${BS}" = "mingw" ]; then
|
||||
set -x
|
||||
cmake -G "MSYS Makefiles" -D CMAKE_C_COMPILER="${CC}" -D CMAKE_MAKE_PROGRAM="mingw32-make" -D CMAKE_BUILD_TYPE="Release" "${SRCDIR}"
|
||||
mingw32-make
|
||||
#export SKIP_TEST_FUZZ=1
|
||||
#mingw32-make test
|
||||
set +x
|
||||
else
|
||||
echo "Unknown or unspecified build type: ${BS}"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
#
|
||||
# Attempt to remove as many generated files as we can.
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
# xdg-open coverage/index.html
|
||||
#################################################################
|
||||
|
||||
# Find programs we need
|
||||
# Find programs we need
|
||||
FIND_PROGRAM(LCOV_EXECUTABLE lcov DOC "Full path to lcov executable")
|
||||
FIND_PROGRAM(GENHTML_EXECUTABLE genhtml DOC "Full path to genhtml executable")
|
||||
MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
|
||||
|
||||
# Check, compiler, build types and programs are available
|
||||
IF(NOT CMAKE_COMPILER_IS_GNUCC)
|
||||
IF(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
MESSAGE(FATAL_ERROR "Coverage can only be built on GCC")
|
||||
ELSEIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
MESSAGE(FATAL_ERROR "Coverage can only be built in Debug mode")
|
||||
@@ -33,7 +33,7 @@ ELSEIF(NOT LCOV_EXECUTABLE)
|
||||
MESSAGE(FATAL_ERROR "lcov executable not found")
|
||||
ELSEIF(NOT GENHTML_EXECUTABLE)
|
||||
MESSAGE(FATAL_ERROR "genhtml executable not found")
|
||||
ENDIF(NOT CMAKE_COMPILER_IS_GNUCC)
|
||||
ENDIF()
|
||||
|
||||
# Enable testing if not already done
|
||||
SET(ENABLE_TEST ON)
|
||||
|
||||
+36
-7
@@ -729,15 +729,15 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the `gcc' library (-lgcc). */
|
||||
#cmakedefine HAVE_LIBGCC 1
|
||||
|
||||
/* Define to 1 if you have the `iconv' library (-liconv). */
|
||||
#cmakedefine HAVE_LIBICONV 1
|
||||
|
||||
/* Define to 1 if you have the `lz4' library (-llz4). */
|
||||
#cmakedefine HAVE_LIBLZ4 1
|
||||
|
||||
/* Define to 1 if you have the `lzma' library (-llzma). */
|
||||
#cmakedefine HAVE_LIBLZMA 1
|
||||
|
||||
/* Define to 1 if you have the `lzmadec' library (-llzmadec). */
|
||||
#cmakedefine HAVE_LIBLZMADEC 1
|
||||
|
||||
/* Define to 1 if you have the `lzo2' library (-llzo2). */
|
||||
#cmakedefine HAVE_LIBLZO2 1
|
||||
|
||||
@@ -768,6 +768,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <libxml/xmlwriter.h> header file. */
|
||||
#cmakedefine HAVE_LIBXML_XMLWRITER_H 1
|
||||
|
||||
/* Define to 1 if you have the <libxml/xmlversion.h> header file. */
|
||||
#cmakedefine HAVE_LIBXML_XMLVERSION_H 1
|
||||
|
||||
/* Define to 1 if you have the `z' library (-lz). */
|
||||
#cmakedefine HAVE_LIBZ 1
|
||||
|
||||
@@ -777,6 +780,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the ZSTD_compressStream function. */
|
||||
#cmakedefine HAVE_ZSTD_compressStream 1
|
||||
|
||||
/* Define to 1 if you have the ZSTD_minCLevel function. */
|
||||
#cmakedefine HAVE_ZSTD_minCLevel 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
|
||||
@@ -847,9 +853,6 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <lz4.h> header file. */
|
||||
#cmakedefine HAVE_LZ4_H 1
|
||||
|
||||
/* Define to 1 if you have the <lzmadec.h> header file. */
|
||||
#cmakedefine HAVE_LZMADEC_H 1
|
||||
|
||||
/* Define to 1 if you have the <lzma.h> header file. */
|
||||
#cmakedefine HAVE_LZMA_H 1
|
||||
|
||||
@@ -871,6 +874,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <mbedtls/pkcs5.h> header file. */
|
||||
#cmakedefine HAVE_MBEDTLS_PKCS5_H 1
|
||||
|
||||
/* Define to 1 if you have the <mbedtls/pkcs5.h> header file. */
|
||||
#cmakedefine HAVE_MBEDTLS_VERSION_H 1
|
||||
|
||||
/* Define to 1 if you have the `mbrtowc' function. */
|
||||
#cmakedefine HAVE_MBRTOWC 1
|
||||
|
||||
@@ -916,6 +922,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <nettle/sha.h> header file. */
|
||||
#cmakedefine HAVE_NETTLE_SHA_H 1
|
||||
|
||||
/* Define to 1 if you have the <nettle/version.h> header file. */
|
||||
#cmakedefine HAVE_NETTLE_VERSION_H 1
|
||||
|
||||
/* Define to 1 if you have the `nl_langinfo' function. */
|
||||
#cmakedefine HAVE_NL_LANGINFO 1
|
||||
|
||||
@@ -925,6 +934,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <openssl/evp.h> header file. */
|
||||
#cmakedefine HAVE_OPENSSL_EVP_H 1
|
||||
|
||||
/* Define to 1 if you have the <openssl/opensslv.h> header file. */
|
||||
#cmakedefine HAVE_OPENSSL_OPENSSLV_H 1
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
#cmakedefine HAVE_PATHS_H 1
|
||||
|
||||
@@ -1147,7 +1159,6 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#cmakedefine HAVE_SYS_STAT_H 1
|
||||
|
||||
|
||||
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
|
||||
#cmakedefine HAVE_SYS_SYSMACROS_H 1
|
||||
|
||||
@@ -1172,6 +1183,12 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have the <sys/xattr.h> header file. */
|
||||
#cmakedefine HAVE_SYS_XATTR_H 1
|
||||
|
||||
/* Define to 1 if you have the `tcgetattr' function. */
|
||||
#cmakedefine HAVE_TCGETATTR 1
|
||||
|
||||
/* Define to 1 if you have the `tcsetattr' function. */
|
||||
#cmakedefine HAVE_TCSETATTR 1
|
||||
|
||||
/* Define to 1 if you have the `timegm' function. */
|
||||
#cmakedefine HAVE_TIMEGM 1
|
||||
|
||||
@@ -1265,6 +1282,9 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you have a working FS_IOC_GETFLAGS */
|
||||
#cmakedefine HAVE_WORKING_FS_IOC_GETFLAGS 1
|
||||
|
||||
/* Define to 1 if you have the Windows `xmllite' library (-lxmllite). */
|
||||
#cmakedefine HAVE_XMLLITE_H 1
|
||||
|
||||
/* Define to 1 if you have the <zlib.h> header file. */
|
||||
#cmakedefine HAVE_ZLIB_H 1
|
||||
|
||||
@@ -1322,6 +1342,15 @@ typedef uint64_t uintmax_t;
|
||||
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#cmakedefine TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Version number of package */
|
||||
#cmakedefine LIBATTR_PKGCONFIG_VERSION "@LIBATTR_PKGCONFIG_VERSION@"
|
||||
|
||||
/* Version number of package */
|
||||
#cmakedefine LIBACL_PKGCONFIG_VERSION "@LIBACL_PKGCONFIG_VERSION@"
|
||||
|
||||
/* Version number of package */
|
||||
#cmakedefine LIBRICHACL_PKGCONFIG_VERSION "@LIBRICHACL_PKGCONFIG_VERSION@"
|
||||
|
||||
/*
|
||||
* Some platform requires a macro to use extension functions.
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
#
|
||||
# This script exists primarily to document some of the
|
||||
@@ -8,7 +9,6 @@
|
||||
#
|
||||
|
||||
PATH=/usr/local/gnu-autotools/bin/:$PATH
|
||||
export PATH
|
||||
|
||||
# Start from one level above the build directory
|
||||
if [ -f version ]; then
|
||||
@@ -24,7 +24,7 @@ fi
|
||||
# Makefile. Effectively disable it.
|
||||
export MAKEOBJDIRPREFIX=/junk
|
||||
|
||||
set -ex
|
||||
set -x
|
||||
|
||||
#
|
||||
# Scrub the local tree before running the build tests below.
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
ID=$(docker build -q -f build/release/Dockerfile .)
|
||||
if [ -z "$ID" ]; then
|
||||
echo "Failed to build docker image"
|
||||
exit 1
|
||||
else
|
||||
docker run $ID sh -c "tar -c -f - libarchive-*" | tar -x -f -
|
||||
docker run "$ID" sh -c "tar -c -f - libarchive-*" | tar -x -f -
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
if [ $# != 1 ]
|
||||
then
|
||||
echo "Usage: $0 path/to/UnicodeData.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# This needs http://unicode.org/Public/6.0.0/ucd/UnicodeData.txt
|
||||
#
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
3007007
|
||||
3008000
|
||||
|
||||
+4
-2
@@ -33,8 +33,10 @@ IF(ENABLE_CAT)
|
||||
ENDIF(ENABLE_CAT_SHARED)
|
||||
|
||||
# Installation rules
|
||||
INSTALL(TARGETS bsdcat RUNTIME DESTINATION bin)
|
||||
INSTALL_MAN(${bsdcat_MANS})
|
||||
IF(ENABLE_INSTALL)
|
||||
INSTALL(TARGETS bsdcat RUNTIME DESTINATION bin)
|
||||
INSTALL_MAN(${bsdcat_MANS})
|
||||
ENDIF(ENABLE_INSTALL)
|
||||
ENDIF(ENABLE_CAT)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
@@ -64,7 +64,9 @@ IF(ENABLE_CAT AND ENABLE_TEST)
|
||||
COMMAND bsdcat_test -vv
|
||||
-p $<TARGET_FILE:bsdcat>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_testname})
|
||||
SET_TESTS_PROPERTIES(bsdcat_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
|
||||
|
||||
+43
-24
@@ -4,8 +4,8 @@ dnl First, define all of the version numbers up front.
|
||||
dnl In particular, this allows the version macro to be used in AC_INIT
|
||||
|
||||
dnl These first two version numbers are updated automatically on each release.
|
||||
m4_define([LIBARCHIVE_VERSION_S],[3.7.7])
|
||||
m4_define([LIBARCHIVE_VERSION_N],[3007007])
|
||||
m4_define([LIBARCHIVE_VERSION_S],[3.8.0])
|
||||
m4_define([LIBARCHIVE_VERSION_N],[3008000])
|
||||
|
||||
dnl bsdtar and bsdcpio versioning tracks libarchive
|
||||
m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
|
||||
@@ -38,7 +38,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
ARCHIVE_MINOR=$(( (LIBARCHIVE_VERSION_N() / 1000) % 1000 ))
|
||||
# Libarchive 2.7 == libtool interface 9 = 2 + 7
|
||||
# Libarchive 2.8 == libtool interface 10 = 2 + 8
|
||||
# Libarchive 2.9 == libtool interface 11 = 2 + 8
|
||||
# Libarchive 2.9 == libtool interface 11 = 2 + 9
|
||||
# Libarchive 3.0 == libtool interface 12
|
||||
# Libarchive 3.1 == libtool interface 13
|
||||
ARCHIVE_INTERFACE=`echo $((13 + ${ARCHIVE_MINOR}))`
|
||||
@@ -399,6 +399,7 @@ if test "x$with_zlib" != "xno"; then
|
||||
int main(int argc, char **argv) { inflate(NULL, 0); return 0; }
|
||||
]])],
|
||||
[AC_DEFINE([HAVE_ZLIB_H], [1], [Define to 1 if you have zlib >= 1.2.1])
|
||||
AC_DEFINE([HAVE_LIBZ], [1], [Define to 1 if you have zlib >= 1.2.1])
|
||||
AC_MSG_RESULT([found a suitable version of zlib (>= 1.2.1)])
|
||||
],
|
||||
[AC_MSG_RESULT([could not find a suitable version of zlib (>= 1.2.1)])
|
||||
@@ -441,6 +442,10 @@ AC_ARG_WITH([libb2],
|
||||
if test "x$with_libb2" != "xno"; then
|
||||
AC_CHECK_HEADERS([blake2.h])
|
||||
AC_CHECK_LIB(b2,blake2sp_init)
|
||||
BLAKE2_PC_VER=`pkg-config --modversion libb2`
|
||||
if test "x$BLAKE2_PC_VER" != "x"; then
|
||||
AC_DEFINE_UNQUOTED([LIBB2_PKGCONFIG_VERSION], ["$BLAKE2_PC_VER"], [Libb2 version coming from pkg-config.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([INC_BLAKE2], [test "x$ac_cv_lib_b2_blake2sp_init" != "xyes"])
|
||||
@@ -453,13 +458,17 @@ if test "x$with_iconv" != "xno"; then
|
||||
AC_CHECK_HEADERS([iconv.h],[],[],[#include <stdlib.h>])
|
||||
if test "x$am_cv_func_iconv" = "xyes"; then
|
||||
AC_CHECK_HEADERS([localcharset.h])
|
||||
am_save_LIBS="$LIBS"
|
||||
LIBS="${LIBS} ${LIBICONV}"
|
||||
if test -n "$LIBICONV"; then
|
||||
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
|
||||
AC_DEFINE([HAVE_LIBICONV], [1], [Define to 1 if you have the `iconv' library (-liconv).])
|
||||
|
||||
# Most platforms do not provide iconv.pc, but MSYS2 MinGW does.
|
||||
# We add it to our Requires.private only if it exists.
|
||||
PKG_CHECK_MODULES(ICONV_PC, [iconv], [
|
||||
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }iconv"
|
||||
], [true])
|
||||
fi
|
||||
AC_CHECK_FUNCS([locale_charset])
|
||||
LIBS="${am_save_LIBS}"
|
||||
if test "x$ac_cv_func_locale_charset" != "xyes"; then
|
||||
# If locale_charset() is not in libiconv, we have to find libcharset.
|
||||
AC_CHECK_LIB(charset,locale_charset)
|
||||
@@ -483,14 +492,24 @@ if test "x$with_zstd" != "xno"; then
|
||||
AC_CHECK_LIB(zstd,ZSTD_decompressStream)
|
||||
AC_CHECK_LIB(zstd,ZSTD_compressStream,
|
||||
AC_DEFINE([HAVE_ZSTD_compressStream], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.]))
|
||||
AC_CHECK_LIB(zstd,ZSTD_minCLevel,
|
||||
AC_DEFINE([HAVE_ZSTD_minCLevel], [1], [Define to 1 if you have a `zstd' library version with ZSTD_minCLevel().]))
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([lzma],
|
||||
AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma]))
|
||||
|
||||
if test "x$with_lzma" != "xno"; then
|
||||
PKG_PROG_PKG_CONFIG
|
||||
PKG_CHECK_MODULES(LZMA_PC, [liblzma], [
|
||||
CPPFLAGS="${CPPFLAGS} ${LZMA_PC_CFLAGS}"
|
||||
LIBS="${LIBS} ${LZMA_PC_LIBS}"
|
||||
AC_DEFINE(HAVE_LIBLZMA, [1], [Define to 1 if you have the `lzma' library.])
|
||||
], [
|
||||
AC_CHECK_LIB(lzma,lzma_stream_decoder)
|
||||
])
|
||||
AC_CHECK_HEADERS([lzma.h])
|
||||
AC_CHECK_LIB(lzma,lzma_stream_decoder)
|
||||
|
||||
# Some pre-release (but widely distributed) versions of liblzma
|
||||
# included a disabled version of lzma_stream_encoder_mt that
|
||||
# fools a naive AC_CHECK_LIB or AC_CHECK_FUNC, so we need
|
||||
@@ -508,19 +527,6 @@ if test "x$with_lzma" != "xno"; then
|
||||
if test "x$ac_cv_lzma_has_mt" != xno; then
|
||||
AC_DEFINE([HAVE_LZMA_STREAM_ENCODER_MT], [1], [Define to 1 if you have the `lzma_stream_encoder_mt' function.])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK(
|
||||
[whether we have ARM64 filter support in lzma],
|
||||
ac_cv_lzma_has_arm64,
|
||||
[AC_LINK_IFELSE([
|
||||
AC_LANG_PROGRAM([[#include <lzma.h>]
|
||||
[#ifndef LZMA_FILTER_ARM64]
|
||||
[#error unsupported]
|
||||
[#endif]])],
|
||||
[ac_cv_lzma_has_arm64=yes], [ac_cv_lzma_has_arm64=no])])
|
||||
if test "x$ac_cv_lzma_has_arm64" != xno; then
|
||||
AC_DEFINE([HAVE_LZMA_FILTER_ARM64], [1], [Define to 1 if you have the `LZMA_FILTER_ARM64' macro.])
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_WITH([lzo2],
|
||||
@@ -558,7 +564,7 @@ if test "x$with_xml2" != "xno"; then
|
||||
], [
|
||||
AC_CHECK_LIB(xml2,xmlInitParser)
|
||||
])
|
||||
AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h])
|
||||
AC_CHECK_HEADERS([libxml/xmlreader.h libxml/xmlwriter.h libxml/xmlversion.h])
|
||||
fi
|
||||
if test "x$ac_cv_header_libxml_xmlreader_h" != "xyes"; then
|
||||
if test "x$with_expat" != "xno"; then
|
||||
@@ -825,6 +831,7 @@ AC_CHECK_FUNCS([readpassphrase])
|
||||
AC_CHECK_FUNCS([select setenv setlocale sigaction statfs statvfs])
|
||||
AC_CHECK_FUNCS([strchr strdup strerror strncpy_s strnlen strrchr symlink])
|
||||
AC_CHECK_FUNCS([sysconf])
|
||||
AC_CHECK_FUNCS([tcgetattr tcsetattr])
|
||||
AC_CHECK_FUNCS([timegm tzset unlinkat unsetenv utime utimensat utimes vfork])
|
||||
AC_CHECK_FUNCS([wcrtomb wcscmp wcscpy wcslen wctomb wmemcmp wmemcpy wmemmove])
|
||||
AC_CHECK_FUNCS([_fseeki64 _get_timezone])
|
||||
@@ -918,6 +925,10 @@ if test "x$enable_xattr" != "xno"; then
|
||||
])
|
||||
AC_CHECK_DECLS([XATTR_NOFOLLOW], [], [], [#include <sys/xattr.h>
|
||||
])
|
||||
ATTR_PC_VER=`pkg-config --modversion libattr`
|
||||
if test "x$ATTR_PC_VER" != "x"; then
|
||||
AC_DEFINE_UNQUOTED([LIBATTR_PKGCONFIG_VERSION], ["$ATTR_PC_VER"], [Libattr version coming from pkg-config.])
|
||||
fi
|
||||
if test "x$ac_cv_header_sys_xattr_h" = "xyes" \
|
||||
-a "x$ac_cv_have_decl_XATTR_NOFOLLOW" = "xyes"; then
|
||||
# Darwin extended attributes support
|
||||
@@ -1013,7 +1024,10 @@ AC_ARG_ENABLE([acl],
|
||||
if test "x$enable_acl" != "xno"; then
|
||||
# Libacl
|
||||
AC_CHECK_LIB([acl], [acl_get_file])
|
||||
|
||||
ACL_PC_VER=`pkg-config --modversion libacl`
|
||||
if test "x$ACL_PC_VER" != "x"; then
|
||||
AC_DEFINE_UNQUOTED([LIBACL_PKGCONFIG_VERSION], ["$ACL_PC_VER"], [Libacl version coming from pkg-config.])
|
||||
fi
|
||||
AC_CHECK_TYPES([acl_t, acl_entry_t, acl_permset_t, acl_tag_t], [], [], [
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
@@ -1024,7 +1038,10 @@ if test "x$enable_acl" != "xno"; then
|
||||
])
|
||||
|
||||
AC_CHECK_LIB([richacl], [richacl_get_file])
|
||||
|
||||
RICHACL_PC_VER=`pkg-config --modversion librichacl`
|
||||
if test "x$RICHACL_PC_VER" != "x"; then
|
||||
AC_DEFINE_UNQUOTED([LIBRICHACL_PKGCONFIG_VERSION], ["$RICHACL_PC_VER"], [Librichacl version coming from pkg-config.])
|
||||
fi
|
||||
AC_CHECK_TYPES([[struct richace], [struct richacl]], [], [], [
|
||||
#if HAVE_SYS_RICHACL_H
|
||||
#include <sys/richacl.h>
|
||||
@@ -1307,6 +1324,7 @@ fi
|
||||
|
||||
if test "x$with_mbedtls" = "xyes"; then
|
||||
AC_CHECK_HEADERS([mbedtls/aes.h mbedtls/md.h mbedtls/pkcs5.h])
|
||||
AC_CHECK_HEADERS([mbedtls/version.h])
|
||||
saved_LIBS=$LIBS
|
||||
AC_CHECK_LIB(mbedcrypto,mbedtls_sha1_init)
|
||||
CRYPTO_CHECK(MD5, MBEDTLS, md5)
|
||||
@@ -1323,6 +1341,7 @@ fi
|
||||
if test "x$with_nettle" = "xyes"; then
|
||||
AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h])
|
||||
AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h])
|
||||
AC_CHECK_HEADERS([nettle/version.h])
|
||||
saved_LIBS=$LIBS
|
||||
AC_CHECK_LIB(nettle,nettle_sha1_init)
|
||||
CRYPTO_CHECK(MD5, NETTLE, md5)
|
||||
@@ -1337,7 +1356,7 @@ if test "x$with_nettle" = "xyes"; then
|
||||
fi
|
||||
|
||||
if test "x$with_openssl" != "xno"; then
|
||||
AC_CHECK_HEADERS([openssl/evp.h])
|
||||
AC_CHECK_HEADERS([openssl/evp.h openssl/opensslv.h])
|
||||
saved_LIBS=$LIBS
|
||||
LIBSREQUIRED="$LIBSREQUIRED${LIBSREQUIRED:+ }libcrypto"
|
||||
AC_CHECK_LIB(crypto,OPENSSL_config)
|
||||
|
||||
@@ -37,11 +37,11 @@ libarchive_src_files := libarchive/archive_acl.c \
|
||||
libarchive/archive_entry_stat.c \
|
||||
libarchive/archive_entry_strmode.c \
|
||||
libarchive/archive_entry_xattr.c \
|
||||
libarchive/archive_getdate.c \
|
||||
libarchive/archive_hmac.c \
|
||||
libarchive/archive_match.c \
|
||||
libarchive/archive_options.c \
|
||||
libarchive/archive_pack_dev.c \
|
||||
libarchive/archive_parse_date.c \
|
||||
libarchive/archive_pathmatch.c \
|
||||
libarchive/archive_ppmd7.c \
|
||||
libarchive/archive_random.c \
|
||||
|
||||
@@ -151,6 +151,8 @@
|
||||
#define HAVE_SYS_UTSNAME_H 1
|
||||
#define HAVE_SYS_VFS_H 1
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#define HAVE_TCGETATTR 1
|
||||
#define HAVE_TCSETATTR 1
|
||||
#define HAVE_TIME_H 1
|
||||
#define HAVE_TZSET 1
|
||||
#define HAVE_UINTMAX_T 1
|
||||
|
||||
@@ -153,6 +153,8 @@
|
||||
#define HAVE_SYS_VFS_H 1
|
||||
#define HAVE_SYS_WAIT_H 1
|
||||
#define HAVE_SYS_XATTR_H 1
|
||||
#define HAVE_TCGETATTR 1
|
||||
#define HAVE_TCSETATTR 1
|
||||
#define HAVE_TIMEGM 1
|
||||
#define HAVE_TIME_H 1
|
||||
#define HAVE_TZSET 1
|
||||
|
||||
@@ -530,9 +530,6 @@
|
||||
/* Define to 1 if you have the <lz4.h> header file. */
|
||||
/* #undef HAVE_LZ4_H */
|
||||
|
||||
/* Define to 1 if you have the <lzmadec.h> header file. */
|
||||
/* #undef HAVE_LZMADEC_H */
|
||||
|
||||
/* Define to 1 if you have the <lzma.h> header file. */
|
||||
/* #undef HAVE_LZMA_H */
|
||||
|
||||
@@ -827,6 +824,12 @@
|
||||
/* Define to 1 if you have the <sys/xattr.h> header file. */
|
||||
/* #undef HAVE_SYS_XATTR_H */
|
||||
|
||||
/* Define to 1 if you have the `tcgetattr' function. */
|
||||
/* #undef HAVE_TCGETATTR */
|
||||
|
||||
/* Define to 1 if you have the `tcsetattr' function. */
|
||||
/* #undef HAVE_TCSETATTR */
|
||||
|
||||
/* Define to 1 if you have the `timegm' function. */
|
||||
/* #undef HAVE_TIMEGM */
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ BuildRequires: libzstd-devel
|
||||
BuildRequires: lz4-devel
|
||||
BuildRequires: lzo-devel
|
||||
BuildRequires: openssl-devel
|
||||
BuildRequires: sharutils
|
||||
BuildRequires: xz-devel
|
||||
BuildRequires: zlib-devel
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
# tar comparison program
|
||||
# 2007-10-25 Jan Psota
|
||||
|
||||
|
||||
+4
-2
@@ -42,8 +42,10 @@ IF(ENABLE_CPIO)
|
||||
ENDIF(ENABLE_CPIO_SHARED)
|
||||
|
||||
# Installation rules
|
||||
INSTALL(TARGETS bsdcpio RUNTIME DESTINATION bin)
|
||||
INSTALL_MAN(${bsdcpio_MANS})
|
||||
IF(ENABLE_INSTALL)
|
||||
INSTALL(TARGETS bsdcpio RUNTIME DESTINATION bin)
|
||||
INSTALL_MAN(${bsdcpio_MANS})
|
||||
ENDIF(ENABLE_INSTALL)
|
||||
|
||||
ENDIF(ENABLE_CPIO)
|
||||
|
||||
|
||||
+1
-1
@@ -1206,7 +1206,7 @@ list_item_verbose(struct cpio *cpio, struct archive_entry *entry)
|
||||
else
|
||||
strcpy(date, "invalid mtime");
|
||||
|
||||
fprintf(out, "%s%3d %-8s %-8s %8s %12s %s",
|
||||
fprintf(out, "%s%3u %-8s %-8s %8s %12s %s",
|
||||
archive_entry_strmode(entry),
|
||||
archive_entry_nlink(entry),
|
||||
uname, gname, size, date,
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ cpio_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
return (handle);
|
||||
}
|
||||
|
||||
#define WINTIME(sec, usec) ((Int32x32To64(sec, 10000000) + EPOC_TIME) + (usec * 10))
|
||||
#define WINTIME(sec, usec) (((sec * 10000000LL) + EPOC_TIME) + (usec * 10))
|
||||
static int
|
||||
__hutimes(HANDLE handle, const struct __timeval *times)
|
||||
{
|
||||
|
||||
+1
-1
@@ -52,4 +52,4 @@ extern int utimes(const char *name, const struct __timeval *times);
|
||||
#define HAVE_UTIMES 1
|
||||
#endif
|
||||
|
||||
#endif /* CPIO_WINDOWS_H */
|
||||
#endif /* !CPIO_WINDOWS_H */
|
||||
|
||||
@@ -97,7 +97,9 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
|
||||
COMMAND bsdcpio_test -vv
|
||||
-p $<TARGET_FILE:bsdcpio>
|
||||
-r ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-s
|
||||
${_testname})
|
||||
SET_TESTS_PROPERTIES(bsdcpio_${_testname} PROPERTIES SKIP_RETURN_CODE 2)
|
||||
ENDMACRO (DEFINE_TEST _testname)
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
|
||||
|
||||
@@ -20,7 +20,7 @@ DEFINE_TEST(test_extract_cpio_absolute_paths)
|
||||
int r;
|
||||
|
||||
// Create an absolute path for a test file inside testworkdir.
|
||||
char *entry_suffix = "/cpio-noabs";
|
||||
const char *entry_suffix = "/cpio-noabs";
|
||||
size_t entry_suffix_length = strlen(entry_suffix);
|
||||
size_t testworkdir_length = strlen(testworkdir);
|
||||
size_t temp_absolute_file_name_length = testworkdir_length + entry_suffix_length;
|
||||
|
||||
@@ -189,10 +189,10 @@ DEFINE_TEST(test_format_newc)
|
||||
gid = from_hex(e + 30, 8); /* gid */
|
||||
assertEqualMem(e + 38, "00000003", 8); /* nlink */
|
||||
t = from_hex(e + 46, 8); /* mtime */
|
||||
failure("t=%#08jx now=%#08jx=%jd", (intmax_t)t, (intmax_t)now,
|
||||
failure("t=%#08jx now=%#08jx=%jd", (uintmax_t)t, (uintmax_t)now,
|
||||
(intmax_t)now);
|
||||
assert(t <= now); /* File wasn't created in future. */
|
||||
failure("t=%#08jx now - 2=%#08jx=%jd", (intmax_t)t, (intmax_t)now - 2,
|
||||
failure("t=%#08jx now - 2=%#08jx=%jd", (uintmax_t)t, (uintmax_t)now - 2,
|
||||
(intmax_t)now - 2);
|
||||
assert(t >= now - 2); /* File was created w/in last 2 secs. */
|
||||
failure("newc format stores body only with last appearance of a link\n"
|
||||
@@ -230,7 +230,7 @@ DEFINE_TEST(test_format_newc)
|
||||
assertEqualMem(e + 38, "00000001", 8); /* nlink */
|
||||
t2 = from_hex(e + 46, 8); /* mtime */
|
||||
failure("First entry created at t=%#08jx this entry created"
|
||||
" at t2=%#08jx", (intmax_t)t, (intmax_t)t2);
|
||||
" at t2=%#08jx", (uintmax_t)t, (uintmax_t)t2);
|
||||
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
||||
assertEqualMem(e + 54, "00000005", 8); /* File size */
|
||||
fs = (uint64_t)from_hex(e + 54, 8);
|
||||
@@ -266,7 +266,7 @@ DEFINE_TEST(test_format_newc)
|
||||
#endif
|
||||
t2 = from_hex(e + 46, 8); /* mtime */
|
||||
failure("First entry created at t=%#08jx this entry created at"
|
||||
"t2=%#08jx", (intmax_t)t, (intmax_t)t2);
|
||||
"t2=%#08jx", (uintmax_t)t, (uintmax_t)t2);
|
||||
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
||||
assertEqualMem(e + 54, "00000000", 8); /* File size */
|
||||
fs = (uint64_t)from_hex(e + 54, 8);
|
||||
@@ -300,7 +300,7 @@ DEFINE_TEST(test_format_newc)
|
||||
assertEqualMem(e + 38, "00000003", 8); /* nlink */
|
||||
t2 = from_hex(e + 46, 8); /* mtime */
|
||||
failure("First entry created at t=%#08jx this entry created at"
|
||||
"t2=%#08jx", (intmax_t)t, (intmax_t)t2);
|
||||
"t2=%#08jx", (uintmax_t)t, (uintmax_t)t2);
|
||||
assert(t2 == t || t2 == t + 1); /* Almost same as first entry. */
|
||||
assertEqualInt(10, from_hex(e + 54, 8)); /* File size */
|
||||
fs = (uint64_t)from_hex(e + 54, 8);
|
||||
|
||||
@@ -18,7 +18,7 @@ is_octal(const char *p, size_t l)
|
||||
return (1);
|
||||
}
|
||||
|
||||
static long long int
|
||||
static unsigned long long int
|
||||
from_octal(const char *p, size_t l)
|
||||
{
|
||||
long long int r = 0;
|
||||
@@ -117,7 +117,7 @@ DEFINE_TEST(test_option_c)
|
||||
gid = (int)from_octal(e + 30, 6);
|
||||
assertEqualMem(e + 36, "000001", 6); /* nlink */
|
||||
failure("file entries should not have rdev set (dev field was 0%o)",
|
||||
dev);
|
||||
(unsigned int)dev);
|
||||
assertEqualMem(e + 42, "000000", 6); /* rdev */
|
||||
t = from_octal(e + 48, 11); /* mtime */
|
||||
assert(t <= now); /* File wasn't created in future. */
|
||||
@@ -133,7 +133,7 @@ DEFINE_TEST(test_option_c)
|
||||
assert(is_octal(e, 76)); /* Entire header is octal digits. */
|
||||
assertEqualMem(e + 0, "070707", 6); /* Magic */
|
||||
assertEqualInt(dev, from_octal(e + 6, 6)); /* dev */
|
||||
assert(ino != from_octal(e + 12, 6)); /* ino */
|
||||
assert(ino != (int)from_octal(e + 12, 6)); /* ino */
|
||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||
/* On Windows, symbolic link and group members bits and
|
||||
* others bits do not work. */
|
||||
@@ -163,7 +163,7 @@ DEFINE_TEST(test_option_c)
|
||||
assertEqualInt(dev, from_octal(e + 6, 6));
|
||||
/* Ino must be different from first entry. */
|
||||
assert(is_octal(e + 12, 6)); /* ino */
|
||||
assert(ino != from_octal(e + 12, 6));
|
||||
assert(ino != (int)from_octal(e + 12, 6));
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* Group members bits and others bits do not work. */
|
||||
assertEqualMem(e + 18, "040777", 6); /* Mode */
|
||||
|
||||
+4
-2
@@ -1,12 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -eu
|
||||
|
||||
#
|
||||
# Simple script to repopulate the 'doc' tree from
|
||||
# the mdoc man pages stored in each project.
|
||||
#
|
||||
|
||||
script_dir=`dirname $0`
|
||||
cd "$script_dir"
|
||||
|
||||
# Collect list of man pages, relative to my subdirs
|
||||
test -d man || mkdir man
|
||||
cd man
|
||||
|
||||
@@ -38,8 +38,6 @@ SET(libarchive_SOURCES
|
||||
archive_entry_stat.c
|
||||
archive_entry_strmode.c
|
||||
archive_entry_xattr.c
|
||||
archive_getdate.c
|
||||
archive_getdate.h
|
||||
archive_hmac.c
|
||||
archive_hmac_private.h
|
||||
archive_match.c
|
||||
@@ -49,6 +47,7 @@ SET(libarchive_SOURCES
|
||||
archive_options_private.h
|
||||
archive_pack_dev.h
|
||||
archive_pack_dev.c
|
||||
archive_parse_date.c
|
||||
archive_pathmatch.c
|
||||
archive_pathmatch.h
|
||||
archive_platform.h
|
||||
@@ -117,6 +116,8 @@ SET(libarchive_SOURCES
|
||||
archive_string.h
|
||||
archive_string_composition.h
|
||||
archive_string_sprintf.c
|
||||
archive_time.c
|
||||
archive_time_private.h
|
||||
archive_util.c
|
||||
archive_version_details.c
|
||||
archive_virtual.c
|
||||
|
||||
+52
-3
@@ -34,12 +34,15 @@
|
||||
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
|
||||
*/
|
||||
/* Note: Compiler will complain if this does not match archive_entry.h! */
|
||||
#define ARCHIVE_VERSION_NUMBER 3007007
|
||||
#define ARCHIVE_VERSION_NUMBER 3008000
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stddef.h> /* for wchar_t */
|
||||
#include <stdio.h> /* For FILE * */
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
/* time_t is slated to be removed from public includes in 4.0 */
|
||||
#include <time.h> /* For time_t */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note: archive.h is for use outside of libarchive; the configuration
|
||||
@@ -63,12 +66,15 @@
|
||||
#define __LA_INT64_T_DEFINED
|
||||
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
||||
typedef __int64 la_int64_t;
|
||||
typedef unsigned __int64 la_uint64_t;
|
||||
# else
|
||||
# include <unistd.h> /* ssize_t */
|
||||
# if defined(_SCO_DS) || defined(__osf__)
|
||||
typedef long long la_int64_t;
|
||||
typedef unsigned long long la_uint64_t;
|
||||
# else
|
||||
typedef int64_t la_int64_t;
|
||||
typedef uint64_t la_uint64_t;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@@ -94,6 +100,22 @@ typedef ssize_t la_ssize_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
/* Use the platform types for time_t */
|
||||
#define __LA_TIME_T time_t
|
||||
#else
|
||||
/* Use 64-bits integer types for time_t */
|
||||
#define __LA_TIME_T la_int64_t
|
||||
#endif
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
/* Use the platform types for dev_t */
|
||||
#define __LA_DEV_T dev_t
|
||||
#else
|
||||
/* Use 64-bits integer types for dev_t */
|
||||
#define __LA_DEV_T la_int64_t
|
||||
#endif
|
||||
|
||||
/* Large file support for Android */
|
||||
#if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
|
||||
#include "android_lf.h"
|
||||
@@ -132,7 +154,7 @@ typedef ssize_t la_ssize_t;
|
||||
#define __LA_PRINTF(fmtarg, firstvararg) /* nothing */
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define __LA_DEPRECATED __attribute__((deprecated))
|
||||
#else
|
||||
# define __LA_DEPRECATED
|
||||
@@ -155,7 +177,7 @@ __LA_DECL int archive_version_number(void);
|
||||
/*
|
||||
* Textual name/version of the library, useful for version displays.
|
||||
*/
|
||||
#define ARCHIVE_VERSION_ONLY_STRING "3.7.7"
|
||||
#define ARCHIVE_VERSION_ONLY_STRING "3.8.0"
|
||||
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
|
||||
__LA_DECL const char * archive_version_string(void);
|
||||
|
||||
@@ -178,6 +200,23 @@ __LA_DECL const char * archive_liblzma_version(void);
|
||||
__LA_DECL const char * archive_bzlib_version(void);
|
||||
__LA_DECL const char * archive_liblz4_version(void);
|
||||
__LA_DECL const char * archive_libzstd_version(void);
|
||||
__LA_DECL const char * archive_liblzo2_version(void);
|
||||
__LA_DECL const char * archive_libexpat_version(void);
|
||||
__LA_DECL const char * archive_libbsdxml_version(void);
|
||||
__LA_DECL const char * archive_libxml2_version(void);
|
||||
__LA_DECL const char * archive_mbedtls_version(void);
|
||||
__LA_DECL const char * archive_nettle_version(void);
|
||||
__LA_DECL const char * archive_openssl_version(void);
|
||||
__LA_DECL const char * archive_libmd_version(void);
|
||||
__LA_DECL const char * archive_commoncrypto_version(void);
|
||||
__LA_DECL const char * archive_cng_version(void);
|
||||
__LA_DECL const char * archive_wincrypt_version(void);
|
||||
__LA_DECL const char * archive_librichacl_version(void);
|
||||
__LA_DECL const char * archive_libacl_version(void);
|
||||
__LA_DECL const char * archive_libattr_version(void);
|
||||
__LA_DECL const char * archive_libiconv_version(void);
|
||||
__LA_DECL const char * archive_libpcre_version(void);
|
||||
__LA_DECL const char * archive_libpcre2_version(void);
|
||||
|
||||
/* Declare our basic types. */
|
||||
struct archive;
|
||||
@@ -449,6 +488,8 @@ __LA_DECL int archive_read_support_format_by_code(struct archive *, int);
|
||||
__LA_DECL int archive_read_support_format_cab(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_cpio(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_empty(struct archive *);
|
||||
/* archive_read_support_format_gnutar() is an alias for historical reasons
|
||||
* of archive_read_support_format_tar(). */
|
||||
__LA_DECL int archive_read_support_format_gnutar(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_iso9660(struct archive *);
|
||||
__LA_DECL int archive_read_support_format_lha(struct archive *);
|
||||
@@ -828,6 +869,10 @@ __LA_DECL int archive_write_set_format_filter_by_ext(struct archive *a, const ch
|
||||
__LA_DECL int archive_write_set_format_filter_by_ext_def(struct archive *a, const char *filename, const char * def_ext);
|
||||
__LA_DECL int archive_write_zip_set_compression_deflate(struct archive *);
|
||||
__LA_DECL int archive_write_zip_set_compression_store(struct archive *);
|
||||
__LA_DECL int archive_write_zip_set_compression_lzma(struct archive *);
|
||||
__LA_DECL int archive_write_zip_set_compression_xz(struct archive *);
|
||||
__LA_DECL int archive_write_zip_set_compression_bzip2(struct archive *);
|
||||
__LA_DECL int archive_write_zip_set_compression_zstd(struct archive *);
|
||||
/* Deprecated; use archive_write_open2 instead */
|
||||
__LA_DECL int archive_write_open(struct archive *, void *,
|
||||
archive_open_callback *, archive_write_callback *,
|
||||
@@ -1083,6 +1128,10 @@ __LA_DECL int archive_compression(struct archive *)
|
||||
__LA_DEPRECATED;
|
||||
#endif
|
||||
|
||||
/* Parses a date string relative to the current time.
|
||||
* NOTE: This is not intended for general date parsing, and the resulting timestamp should only be used for libarchive. */
|
||||
__LA_DECL time_t archive_parse_date(time_t now, const char *datestr);
|
||||
|
||||
__LA_DECL int archive_errno(struct archive *);
|
||||
__LA_DECL const char *archive_error_string(struct archive *);
|
||||
__LA_DECL const char *archive_format_name(struct archive *);
|
||||
|
||||
@@ -1185,8 +1185,13 @@ archive_acl_from_text_w(struct archive_acl *acl, const wchar_t *text,
|
||||
/* Set remaining fields to blank. */
|
||||
for (n = fields; n < numfields; ++n)
|
||||
field[n].start = field[n].end = NULL;
|
||||
|
||||
if (field[0].start == NULL || field[0].end == NULL) {
|
||||
/* This should never happen */
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
if (field[0].start != NULL && *(field[0].start) == L'#') {
|
||||
if (*(field[0].start) == L'#') {
|
||||
/* Comment, skip entry */
|
||||
continue;
|
||||
}
|
||||
@@ -1676,7 +1681,12 @@ archive_acl_from_text_nl(struct archive_acl *acl, const char *text,
|
||||
for (n = fields; n < numfields; ++n)
|
||||
field[n].start = field[n].end = NULL;
|
||||
|
||||
if (field[0].start != NULL && *(field[0].start) == '#') {
|
||||
if (field[0].start == NULL || field[0].end == NULL) {
|
||||
/* This should never happen */
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
if (*(field[0].start) == '#') {
|
||||
/* Comment, skip entry */
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -80,4 +80,4 @@ int archive_acl_from_text_l(struct archive_acl *, const char * /* text */,
|
||||
int archive_acl_from_text_nl(struct archive_acl *, const char * /* text */,
|
||||
size_t /* size of text */, int /* type */, struct archive_string_conv *);
|
||||
|
||||
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
|
||||
#endif /* !ARCHIVE_ACL_PRIVATE_H_INCLUDED */
|
||||
|
||||
@@ -71,7 +71,7 @@ get_argument(struct archive_string *as, const char *p)
|
||||
archive_string_empty(as);
|
||||
|
||||
/* Skip beginning space characters. */
|
||||
while (*s != '\0' && *s == ' ')
|
||||
while (*s == ' ')
|
||||
s++;
|
||||
/* Copy non-space characters. */
|
||||
while (*s != '\0' && *s != ' ') {
|
||||
|
||||
@@ -64,6 +64,7 @@ typedef struct {
|
||||
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
#include <bcrypt.h>
|
||||
#define ARCHIVE_CRYPTOR_USE_CNG 1
|
||||
|
||||
/* Common in other bcrypt implementations, but missing from VS2008. */
|
||||
#ifndef BCRYPT_SUCCESS
|
||||
@@ -86,6 +87,7 @@ typedef struct {
|
||||
#include <mbedtls/aes.h>
|
||||
#include <mbedtls/md.h>
|
||||
#include <mbedtls/pkcs5.h>
|
||||
#define ARCHIVE_CRYPTOR_USE_MBED 1
|
||||
|
||||
#define AES_MAX_KEY_SIZE 32
|
||||
#define AES_BLOCK_SIZE 16
|
||||
@@ -105,6 +107,7 @@ typedef struct {
|
||||
#endif
|
||||
#include <nettle/aes.h>
|
||||
#include <nettle/version.h>
|
||||
#define ARCHIVE_CRYPTOR_USE_NETTLE 1
|
||||
|
||||
typedef struct {
|
||||
#if NETTLE_VERSION_MAJOR < 3
|
||||
@@ -125,6 +128,7 @@ typedef struct {
|
||||
|
||||
#elif defined(HAVE_LIBCRYPTO)
|
||||
#include "archive_openssl_evp_private.h"
|
||||
#define ARCHIVE_CRYPTOR_USE_OPENSSL 1
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define AES_MAX_KEY_SIZE 32
|
||||
|
||||
|
||||
+214
-130
@@ -196,6 +196,13 @@ __archive_md5final(archive_md5_ctx *ctx, void *md)
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM)
|
||||
|
||||
// These functions are available in macOS 10.4 and later, but deprecated from 10.15 onwards.
|
||||
// We need to continue supporting this feature regardless, so suppress the warnings.
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
static int
|
||||
__archive_md5init(archive_md5_ctx *ctx)
|
||||
{
|
||||
@@ -218,13 +225,46 @@ __archive_md5final(archive_md5_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_WIN)
|
||||
|
||||
static int
|
||||
__archive_md5init(archive_md5_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_MD5_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_MD5));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_md5update(archive_md5_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_md5final(archive_md5_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 16, ctx));
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_MBEDTLS)
|
||||
|
||||
static int
|
||||
__archive_md5init(archive_md5_ctx *ctx)
|
||||
{
|
||||
mbedtls_md5_init(ctx);
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_md5_starts(ctx) == 0)
|
||||
#else
|
||||
if (mbedtls_md5_starts_ret(ctx) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -234,7 +274,11 @@ static int
|
||||
__archive_md5update(archive_md5_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_md5_update(ctx, indata, insize) == 0)
|
||||
#else
|
||||
if (mbedtls_md5_update_ret(ctx, indata, insize) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -243,7 +287,11 @@ __archive_md5update(archive_md5_ctx *ctx, const void *indata,
|
||||
static int
|
||||
__archive_md5final(archive_md5_ctx *ctx, void *md)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_md5_finish(ctx, md) == 0) {
|
||||
#else
|
||||
if (mbedtls_md5_finish_ret(ctx, md) == 0) {
|
||||
#endif
|
||||
mbedtls_md5_free(ctx);
|
||||
return (ARCHIVE_OK);
|
||||
} else {
|
||||
@@ -311,31 +359,6 @@ __archive_md5final(archive_md5_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_WIN)
|
||||
|
||||
static int
|
||||
__archive_md5init(archive_md5_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_MD5_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_MD5));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_md5update(archive_md5_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_md5final(archive_md5_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 16, ctx));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int
|
||||
@@ -420,7 +443,11 @@ static int
|
||||
__archive_ripemd160init(archive_rmd160_ctx *ctx)
|
||||
{
|
||||
mbedtls_ripemd160_init(ctx);
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_ripemd160_starts(ctx) == 0)
|
||||
#else
|
||||
if (mbedtls_ripemd160_starts_ret(ctx) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -430,7 +457,11 @@ static int
|
||||
__archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_ripemd160_update(ctx, indata, insize) == 0)
|
||||
#else
|
||||
if (mbedtls_ripemd160_update_ret(ctx, indata, insize) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -439,7 +470,11 @@ __archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata,
|
||||
static int
|
||||
__archive_ripemd160final(archive_rmd160_ctx *ctx, void *md)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_ripemd160_finish(ctx, md) == 0) {
|
||||
#else
|
||||
if (mbedtls_ripemd160_finish_ret(ctx, md) == 0) {
|
||||
#endif
|
||||
mbedtls_ripemd160_free(ctx);
|
||||
return (ARCHIVE_OK);
|
||||
} else {
|
||||
@@ -605,13 +640,42 @@ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha1init(archive_sha1_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA1_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_SHA1));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha1final(archive_sha1_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 20, ctx));
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS)
|
||||
|
||||
static int
|
||||
__archive_sha1init(archive_sha1_ctx *ctx)
|
||||
{
|
||||
mbedtls_sha1_init(ctx);
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha1_starts(ctx) == 0)
|
||||
#else
|
||||
if (mbedtls_sha1_starts_ret(ctx) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -621,7 +685,11 @@ static int
|
||||
__archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha1_update(ctx, indata, insize) == 0)
|
||||
#else
|
||||
if (mbedtls_sha1_update_ret(ctx, indata, insize) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -630,7 +698,11 @@ __archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
|
||||
static int
|
||||
__archive_sha1final(archive_sha1_ctx *ctx, void *md)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha1_finish(ctx, md) == 0) {
|
||||
#else
|
||||
if (mbedtls_sha1_finish_ret(ctx, md) == 0) {
|
||||
#endif
|
||||
mbedtls_sha1_free(ctx);
|
||||
return (ARCHIVE_OK);
|
||||
} else {
|
||||
@@ -698,31 +770,6 @@ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha1init(archive_sha1_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA1_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_SHA1));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha1update(archive_sha1_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha1final(archive_sha1_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 20, ctx));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int
|
||||
@@ -873,13 +920,42 @@ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha256init(archive_sha256_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA256_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_256));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha256final(archive_sha256_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 32, ctx));
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS)
|
||||
|
||||
static int
|
||||
__archive_sha256init(archive_sha256_ctx *ctx)
|
||||
{
|
||||
mbedtls_sha256_init(ctx);
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha256_starts(ctx, 0) == 0)
|
||||
#else
|
||||
if (mbedtls_sha256_starts_ret(ctx, 0) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -889,7 +965,11 @@ static int
|
||||
__archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha256_update(ctx, indata, insize) == 0)
|
||||
#else
|
||||
if (mbedtls_sha256_update_ret(ctx, indata, insize) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -898,7 +978,11 @@ __archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
|
||||
static int
|
||||
__archive_sha256final(archive_sha256_ctx *ctx, void *md)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha256_finish(ctx, md) == 0) {
|
||||
#else
|
||||
if (mbedtls_sha256_finish_ret(ctx, md) == 0) {
|
||||
#endif
|
||||
mbedtls_sha256_free(ctx);
|
||||
return (ARCHIVE_OK);
|
||||
} else {
|
||||
@@ -962,31 +1046,6 @@ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha256init(archive_sha256_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA256_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_256));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha256update(archive_sha256_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha256final(archive_sha256_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 32, ctx));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int
|
||||
@@ -1113,13 +1172,42 @@ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha384init(archive_sha384_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA384_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_384));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha384final(archive_sha384_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 48, ctx));
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS)
|
||||
|
||||
static int
|
||||
__archive_sha384init(archive_sha384_ctx *ctx)
|
||||
{
|
||||
mbedtls_sha512_init(ctx);
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha512_starts(ctx, 1) == 0)
|
||||
#else
|
||||
if (mbedtls_sha512_starts_ret(ctx, 1) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -1129,7 +1217,11 @@ static int
|
||||
__archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha512_update(ctx, indata, insize) == 0)
|
||||
#else
|
||||
if (mbedtls_sha512_update_ret(ctx, indata, insize) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -1138,7 +1230,11 @@ __archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
|
||||
static int
|
||||
__archive_sha384final(archive_sha384_ctx *ctx, void *md)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha512_finish(ctx, md) == 0) {
|
||||
#else
|
||||
if (mbedtls_sha512_finish_ret(ctx, md) == 0) {
|
||||
#endif
|
||||
mbedtls_sha512_free(ctx);
|
||||
return (ARCHIVE_OK);
|
||||
} else {
|
||||
@@ -1202,31 +1298,6 @@ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha384init(archive_sha384_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA384_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_384));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha384update(archive_sha384_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha384final(archive_sha384_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 48, ctx));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int
|
||||
@@ -1377,13 +1448,42 @@ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha512init(archive_sha512_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA512_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_512));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 64, ctx));
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS)
|
||||
|
||||
static int
|
||||
__archive_sha512init(archive_sha512_ctx *ctx)
|
||||
{
|
||||
mbedtls_sha512_init(ctx);
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha512_starts(ctx, 0) == 0)
|
||||
#else
|
||||
if (mbedtls_sha512_starts_ret(ctx, 0) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -1393,7 +1493,11 @@ static int
|
||||
__archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha512_update(ctx, indata, insize) == 0)
|
||||
#else
|
||||
if (mbedtls_sha512_update_ret(ctx, indata, insize) == 0)
|
||||
#endif
|
||||
return (ARCHIVE_OK);
|
||||
else
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -1402,7 +1506,11 @@ __archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
|
||||
static int
|
||||
__archive_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
{
|
||||
#if MBEDTLS_VERSION_NUMBER > 0x03000000
|
||||
if (mbedtls_sha512_finish(ctx, md) == 0) {
|
||||
#else
|
||||
if (mbedtls_sha512_finish_ret(ctx, md) == 0) {
|
||||
#endif
|
||||
mbedtls_sha512_free(ctx);
|
||||
return (ARCHIVE_OK);
|
||||
} else {
|
||||
@@ -1466,31 +1574,6 @@ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
|
||||
|
||||
static int
|
||||
__archive_sha512init(archive_sha512_ctx *ctx)
|
||||
{
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
return (win_crypto_init(ctx, BCRYPT_SHA512_ALGORITHM));
|
||||
#else
|
||||
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_512));
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha512update(archive_sha512_ctx *ctx, const void *indata,
|
||||
size_t insize)
|
||||
{
|
||||
return (win_crypto_Update(ctx, indata, insize));
|
||||
}
|
||||
|
||||
static int
|
||||
__archive_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
{
|
||||
return (win_crypto_Final(md, 64, ctx));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static int
|
||||
@@ -1525,11 +1608,12 @@ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
|
||||
* 1. libc
|
||||
* 2. libc2
|
||||
* 3. libc3
|
||||
* 4. libSystem
|
||||
* 5. Nettle
|
||||
* 6. OpenSSL
|
||||
* 7. libmd
|
||||
* 8. Windows API
|
||||
* 4. libmd
|
||||
* 5. libSystem
|
||||
* 6. Windows API
|
||||
* 7. mbedTLS
|
||||
* 8. Nettle
|
||||
* 9. OpenSSL
|
||||
*/
|
||||
const struct archive_digest __archive_digest =
|
||||
{
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM) ||\
|
||||
defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
|
||||
#include <CommonCrypto/CommonDigest.h>
|
||||
#define ARCHIVE_CRYPTO_CommonCrypto 1
|
||||
#endif
|
||||
|
||||
/* mbed TLS crypto headers */
|
||||
@@ -167,6 +168,7 @@
|
||||
#if defined(HAVE_BCRYPT_H) && _WIN32_WINNT >= _WIN32_WINNT_VISTA
|
||||
/* don't use bcrypt when XP needs to be supported */
|
||||
#include <bcrypt.h>
|
||||
#define ARCHIVE_CRYPTO_CNG 1
|
||||
typedef struct {
|
||||
int valid;
|
||||
BCRYPT_ALG_HANDLE hAlg;
|
||||
@@ -175,6 +177,7 @@ typedef struct {
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
#define ARCHIVE_CRYPTO_WINCRYPT 1
|
||||
typedef struct {
|
||||
int valid;
|
||||
HCRYPTPROV cryptProv;
|
||||
@@ -190,14 +193,16 @@ typedef MD5_CTX archive_md5_ctx;
|
||||
typedef MD5_CTX archive_md5_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM)
|
||||
typedef CC_MD5_CTX archive_md5_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_WIN)
|
||||
typedef Digest_CTX archive_md5_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_MBEDTLS)
|
||||
#define ARCHIVE_CRYPTO_MBED 1
|
||||
typedef mbedtls_md5_context archive_md5_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_NETTLE)
|
||||
#define ARCHIVE_CRYPTO_NETTLE 1
|
||||
typedef struct md5_ctx archive_md5_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL)
|
||||
typedef EVP_MD_CTX *archive_md5_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_MD5_WIN)
|
||||
typedef Digest_CTX archive_md5_ctx;
|
||||
#else
|
||||
typedef unsigned char archive_md5_ctx;
|
||||
#endif
|
||||
@@ -207,8 +212,10 @@ typedef RMD160_CTX archive_rmd160_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD)
|
||||
typedef RIPEMD160_CTX archive_rmd160_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS)
|
||||
#define ARCHIVE_CRYPTO_MBED 1
|
||||
typedef mbedtls_ripemd160_context archive_rmd160_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE)
|
||||
#define ARCHIVE_CRYPTO_NETTLE 1
|
||||
typedef struct ripemd160_ctx archive_rmd160_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL)
|
||||
typedef EVP_MD_CTX *archive_rmd160_ctx;
|
||||
@@ -222,14 +229,16 @@ typedef SHA1_CTX archive_sha1_ctx;
|
||||
typedef SHA1_CTX archive_sha1_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM)
|
||||
typedef CC_SHA1_CTX archive_sha1_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
|
||||
typedef Digest_CTX archive_sha1_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS)
|
||||
#define ARCHIVE_CRYPTO_MBED 1
|
||||
typedef mbedtls_sha1_context archive_sha1_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE)
|
||||
#define ARCHIVE_CRYPTO_NETTLE 1
|
||||
typedef struct sha1_ctx archive_sha1_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL)
|
||||
typedef EVP_MD_CTX *archive_sha1_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA1_WIN)
|
||||
typedef Digest_CTX archive_sha1_ctx;
|
||||
#else
|
||||
typedef unsigned char archive_sha1_ctx;
|
||||
#endif
|
||||
@@ -244,14 +253,16 @@ typedef SHA2_CTX archive_sha256_ctx;
|
||||
typedef SHA256_CTX archive_sha256_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM)
|
||||
typedef CC_SHA256_CTX archive_sha256_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
|
||||
typedef Digest_CTX archive_sha256_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS)
|
||||
#define ARCHIVE_CRYPTO_MBED 1
|
||||
typedef mbedtls_sha256_context archive_sha256_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE)
|
||||
#define ARCHIVE_CRYPTO_NETTLE 1
|
||||
typedef struct sha256_ctx archive_sha256_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL)
|
||||
typedef EVP_MD_CTX *archive_sha256_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA256_WIN)
|
||||
typedef Digest_CTX archive_sha256_ctx;
|
||||
#else
|
||||
typedef unsigned char archive_sha256_ctx;
|
||||
#endif
|
||||
@@ -264,14 +275,16 @@ typedef SHA384_CTX archive_sha384_ctx;
|
||||
typedef SHA2_CTX archive_sha384_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM)
|
||||
typedef CC_SHA512_CTX archive_sha384_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
|
||||
typedef Digest_CTX archive_sha384_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS)
|
||||
#define ARCHIVE_CRYPTO_MBED 1
|
||||
typedef mbedtls_sha512_context archive_sha384_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE)
|
||||
#define ARCHIVE_CRYPTO_NETTLE 1
|
||||
typedef struct sha384_ctx archive_sha384_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL)
|
||||
typedef EVP_MD_CTX *archive_sha384_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA384_WIN)
|
||||
typedef Digest_CTX archive_sha384_ctx;
|
||||
#else
|
||||
typedef unsigned char archive_sha384_ctx;
|
||||
#endif
|
||||
@@ -286,14 +299,16 @@ typedef SHA2_CTX archive_sha512_ctx;
|
||||
typedef SHA512_CTX archive_sha512_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM)
|
||||
typedef CC_SHA512_CTX archive_sha512_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
|
||||
typedef Digest_CTX archive_sha512_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS)
|
||||
#define ARCHIVE_CRYPTO_MBED 1
|
||||
typedef mbedtls_sha512_context archive_sha512_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE)
|
||||
#define ARCHIVE_CRYPTO_NETTLE 1
|
||||
typedef struct sha512_ctx archive_sha512_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL)
|
||||
typedef EVP_MD_CTX *archive_sha512_ctx;
|
||||
#elif defined(ARCHIVE_CRYPTO_SHA512_WIN)
|
||||
typedef Digest_CTX archive_sha512_ctx;
|
||||
#else
|
||||
typedef unsigned char archive_sha512_ctx;
|
||||
#endif
|
||||
|
||||
@@ -195,7 +195,7 @@ add_trivial_nfs4_acl(struct archive_entry *entry)
|
||||
} else if ((mode & 0010) || (mode & 0001))
|
||||
tacl_entry[1].permset |= eperm;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
for (i = 0; i < sizeof(tacl_entry) / sizeof(tacl_entry[0]); i++) {
|
||||
if (tacl_entry[i].permset != 0) {
|
||||
archive_entry_acl_add_entry(entry,
|
||||
tacl_entry[i].type, tacl_entry[i].permset,
|
||||
|
||||
@@ -262,7 +262,7 @@ translate_acl(struct archive_read_disk *a,
|
||||
}
|
||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
||||
r = acl_get_flag_np(acl_flagset,
|
||||
acl_nfs4_flag_map[i].p_perm);
|
||||
(acl_flag_t)acl_nfs4_flag_map[i].p_perm);
|
||||
if (r == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to check flag in a NFSv4 "
|
||||
@@ -517,7 +517,7 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
|
||||
if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
|
||||
if (acl_add_flag_np(acl_flagset,
|
||||
acl_nfs4_flag_map[i].p_perm) != 0) {
|
||||
(acl_flag_t)acl_nfs4_flag_map[i].p_perm) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to add flag to "
|
||||
"NFSv4 ACL flagset");
|
||||
|
||||
+32
-22
@@ -275,7 +275,7 @@ archive_entry_new2(struct archive *a)
|
||||
* Functions for reading fields from an archive_entry.
|
||||
*/
|
||||
|
||||
time_t
|
||||
__LA_TIME_T
|
||||
archive_entry_atime(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->ae_stat.aest_atime);
|
||||
@@ -293,7 +293,7 @@ archive_entry_atime_is_set(struct archive_entry *entry)
|
||||
return (entry->ae_set & AE_SET_ATIME);
|
||||
}
|
||||
|
||||
time_t
|
||||
__LA_TIME_T
|
||||
archive_entry_birthtime(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->ae_stat.aest_birthtime);
|
||||
@@ -311,7 +311,7 @@ archive_entry_birthtime_is_set(struct archive_entry *entry)
|
||||
return (entry->ae_set & AE_SET_BIRTHTIME);
|
||||
}
|
||||
|
||||
time_t
|
||||
__LA_TIME_T
|
||||
archive_entry_ctime(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->ae_stat.aest_ctime);
|
||||
@@ -329,7 +329,7 @@ archive_entry_ctime_nsec(struct archive_entry *entry)
|
||||
return (entry->ae_stat.aest_ctime_nsec);
|
||||
}
|
||||
|
||||
dev_t
|
||||
__LA_DEV_T
|
||||
archive_entry_dev(struct archive_entry *entry)
|
||||
{
|
||||
if (entry->ae_stat.aest_dev_is_broken_down)
|
||||
@@ -345,7 +345,7 @@ archive_entry_dev_is_set(struct archive_entry *entry)
|
||||
return (entry->ae_set & AE_SET_DEV);
|
||||
}
|
||||
|
||||
dev_t
|
||||
__LA_DEV_T
|
||||
archive_entry_devmajor(struct archive_entry *entry)
|
||||
{
|
||||
if (entry->ae_stat.aest_dev_is_broken_down)
|
||||
@@ -354,7 +354,7 @@ archive_entry_devmajor(struct archive_entry *entry)
|
||||
return major(entry->ae_stat.aest_dev);
|
||||
}
|
||||
|
||||
dev_t
|
||||
__LA_DEV_T
|
||||
archive_entry_devminor(struct archive_entry *entry)
|
||||
{
|
||||
if (entry->ae_stat.aest_dev_is_broken_down)
|
||||
@@ -568,7 +568,7 @@ archive_entry_mode(struct archive_entry *entry)
|
||||
return (entry->acl.mode);
|
||||
}
|
||||
|
||||
time_t
|
||||
__LA_TIME_T
|
||||
archive_entry_mtime(struct archive_entry *entry)
|
||||
{
|
||||
return (entry->ae_stat.aest_mtime);
|
||||
@@ -667,7 +667,7 @@ archive_entry_rdev_is_set(struct archive_entry *entry)
|
||||
return (entry->ae_set & AE_SET_RDEV);
|
||||
}
|
||||
|
||||
dev_t
|
||||
__LA_DEV_T
|
||||
archive_entry_rdev(struct archive_entry *entry)
|
||||
{
|
||||
if (archive_entry_rdev_is_set(entry)) {
|
||||
@@ -681,7 +681,7 @@ archive_entry_rdev(struct archive_entry *entry)
|
||||
}
|
||||
}
|
||||
|
||||
dev_t
|
||||
__LA_DEV_T
|
||||
archive_entry_rdevmajor(struct archive_entry *entry)
|
||||
{
|
||||
if (archive_entry_rdev_is_set(entry)) {
|
||||
@@ -694,7 +694,7 @@ archive_entry_rdevmajor(struct archive_entry *entry)
|
||||
}
|
||||
}
|
||||
|
||||
dev_t
|
||||
__LA_DEV_T
|
||||
archive_entry_rdevminor(struct archive_entry *entry)
|
||||
{
|
||||
if (archive_entry_rdev_is_set(entry)) {
|
||||
@@ -984,7 +984,9 @@ void
|
||||
archive_entry_set_ino(struct archive_entry *entry, la_int64_t ino)
|
||||
{
|
||||
if (ino < 0) {
|
||||
ino = 0;
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_set &= ~AE_SET_INO;
|
||||
return;
|
||||
}
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_set |= AE_SET_INO;
|
||||
@@ -995,7 +997,9 @@ void
|
||||
archive_entry_set_ino64(struct archive_entry *entry, la_int64_t ino)
|
||||
{
|
||||
if (ino < 0) {
|
||||
ino = 0;
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_set &= ~AE_SET_INO;
|
||||
return;
|
||||
}
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_set |= AE_SET_INO;
|
||||
@@ -1088,7 +1092,7 @@ _archive_entry_copy_hardlink_l(struct archive_entry *entry,
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_atime(struct archive_entry *entry, time_t t, long ns)
|
||||
archive_entry_set_atime(struct archive_entry *entry, __LA_TIME_T t, long ns)
|
||||
{
|
||||
FIX_NS(t, ns);
|
||||
entry->stat_valid = 0;
|
||||
@@ -1105,7 +1109,7 @@ archive_entry_unset_atime(struct archive_entry *entry)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_birthtime(struct archive_entry *entry, time_t t, long ns)
|
||||
archive_entry_set_birthtime(struct archive_entry *entry, __LA_TIME_T t, long ns)
|
||||
{
|
||||
FIX_NS(t, ns);
|
||||
entry->stat_valid = 0;
|
||||
@@ -1122,7 +1126,7 @@ archive_entry_unset_birthtime(struct archive_entry *entry)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_ctime(struct archive_entry *entry, time_t t, long ns)
|
||||
archive_entry_set_ctime(struct archive_entry *entry, __LA_TIME_T t, long ns)
|
||||
{
|
||||
FIX_NS(t, ns);
|
||||
entry->stat_valid = 0;
|
||||
@@ -1139,7 +1143,7 @@ archive_entry_unset_ctime(struct archive_entry *entry)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_dev(struct archive_entry *entry, dev_t d)
|
||||
archive_entry_set_dev(struct archive_entry *entry, __LA_DEV_T d)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_set |= AE_SET_DEV;
|
||||
@@ -1148,7 +1152,7 @@ archive_entry_set_dev(struct archive_entry *entry, dev_t d)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_devmajor(struct archive_entry *entry, dev_t m)
|
||||
archive_entry_set_devmajor(struct archive_entry *entry, __LA_DEV_T m)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_set |= AE_SET_DEV;
|
||||
@@ -1157,7 +1161,7 @@ archive_entry_set_devmajor(struct archive_entry *entry, dev_t m)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_devminor(struct archive_entry *entry, dev_t m)
|
||||
archive_entry_set_devminor(struct archive_entry *entry, __LA_DEV_T m)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_set |= AE_SET_DEV;
|
||||
@@ -1243,7 +1247,7 @@ archive_entry_set_mode(struct archive_entry *entry, mode_t m)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_mtime(struct archive_entry *entry, time_t t, long ns)
|
||||
archive_entry_set_mtime(struct archive_entry *entry, __LA_TIME_T t, long ns)
|
||||
{
|
||||
FIX_NS(t, ns);
|
||||
entry->stat_valid = 0;
|
||||
@@ -1319,7 +1323,7 @@ archive_entry_set_perm(struct archive_entry *entry, mode_t p)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_rdev(struct archive_entry *entry, dev_t m)
|
||||
archive_entry_set_rdev(struct archive_entry *entry, __LA_DEV_T m)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_stat.aest_rdev = m;
|
||||
@@ -1330,7 +1334,7 @@ archive_entry_set_rdev(struct archive_entry *entry, dev_t m)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_rdevmajor(struct archive_entry *entry, dev_t m)
|
||||
archive_entry_set_rdevmajor(struct archive_entry *entry, __LA_DEV_T m)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_stat.aest_rdev_is_broken_down = 1;
|
||||
@@ -1340,7 +1344,7 @@ archive_entry_set_rdevmajor(struct archive_entry *entry, dev_t m)
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_rdevminor(struct archive_entry *entry, dev_t m)
|
||||
archive_entry_set_rdevminor(struct archive_entry *entry, __LA_DEV_T m)
|
||||
{
|
||||
entry->stat_valid = 0;
|
||||
entry->ae_stat.aest_rdev_is_broken_down = 1;
|
||||
@@ -1603,21 +1607,27 @@ archive_entry_set_digest(struct archive_entry *entry, int type,
|
||||
switch (type) {
|
||||
case ARCHIVE_ENTRY_DIGEST_MD5:
|
||||
copy_digest(entry, md5, digest);
|
||||
entry->mset_digest |= AE_MSET_DIGEST_MD5;
|
||||
break;
|
||||
case ARCHIVE_ENTRY_DIGEST_RMD160:
|
||||
copy_digest(entry, rmd160, digest);
|
||||
entry->mset_digest |= AE_MSET_DIGEST_RMD160;
|
||||
break;
|
||||
case ARCHIVE_ENTRY_DIGEST_SHA1:
|
||||
copy_digest(entry, sha1, digest);
|
||||
entry->mset_digest |= AE_MSET_DIGEST_SHA1;
|
||||
break;
|
||||
case ARCHIVE_ENTRY_DIGEST_SHA256:
|
||||
copy_digest(entry, sha256, digest);
|
||||
entry->mset_digest |= AE_MSET_DIGEST_SHA256;
|
||||
break;
|
||||
case ARCHIVE_ENTRY_DIGEST_SHA384:
|
||||
copy_digest(entry, sha384, digest);
|
||||
entry->mset_digest |= AE_MSET_DIGEST_SHA384;
|
||||
break;
|
||||
case ARCHIVE_ENTRY_DIGEST_SHA512:
|
||||
copy_digest(entry, sha512, digest);
|
||||
entry->mset_digest |= AE_MSET_DIGEST_SHA512;
|
||||
break;
|
||||
default:
|
||||
return ARCHIVE_WARN;
|
||||
|
||||
+58
-26
@@ -28,7 +28,7 @@
|
||||
#define ARCHIVE_ENTRY_H_INCLUDED
|
||||
|
||||
/* Note: Compiler will complain if this does not match archive.h! */
|
||||
#define ARCHIVE_VERSION_NUMBER 3007007
|
||||
#define ARCHIVE_VERSION_NUMBER 3008000
|
||||
|
||||
/*
|
||||
* Note: archive_entry.h is for use outside of libarchive; the
|
||||
@@ -40,8 +40,11 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stddef.h> /* for wchar_t */
|
||||
#include <stdint.h>
|
||||
#include <stdint.h> /* for C99 int64_t, etc. */
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
/* time_t is slated to be removed from public includes in 4.0 */
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#include <windows.h>
|
||||
@@ -55,12 +58,15 @@
|
||||
#define __LA_INT64_T_DEFINED
|
||||
# if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
|
||||
typedef __int64 la_int64_t;
|
||||
typedef unsigned __int64 la_uint64_t;
|
||||
# else
|
||||
#include <unistd.h>
|
||||
# if defined(_SCO_DS) || defined(__osf__)
|
||||
typedef long long la_int64_t;
|
||||
typedef unsigned long long la_uint64_t;
|
||||
# else
|
||||
typedef int64_t la_int64_t;
|
||||
typedef uint64_t la_uint64_t;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
@@ -96,6 +102,30 @@ typedef ssize_t la_ssize_t;
|
||||
# define __LA_MODE_T mode_t
|
||||
#endif
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
/* Use the platform types for time_t */
|
||||
#define __LA_TIME_T time_t
|
||||
#else
|
||||
/* Use 64-bits integer types for time_t */
|
||||
#define __LA_TIME_T la_int64_t
|
||||
#endif
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
/* Use the platform types for dev_t */
|
||||
#define __LA_DEV_T dev_t
|
||||
#else
|
||||
/* Use 64-bits integer types for dev_t */
|
||||
#define __LA_DEV_T la_int64_t
|
||||
#endif
|
||||
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
/* Libarchive 3.x used signed int64 for inode numbers */
|
||||
#define __LA_INO_T la_int64_t
|
||||
#else
|
||||
/* Switch to unsigned for libarchive 4.0 */
|
||||
#define __LA_INO_T la_uint64_t
|
||||
#endif
|
||||
|
||||
/* Large file support for Android */
|
||||
#if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
|
||||
#include "android_lf.h"
|
||||
@@ -127,7 +157,8 @@ typedef ssize_t la_ssize_t;
|
||||
# define __LA_DECL
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3 && __GNUC_MINOR__ >= 1
|
||||
#if defined(__GNUC__) && (__GNUC__ > 3 || \
|
||||
(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
# define __LA_DEPRECATED __attribute__((deprecated))
|
||||
#else
|
||||
# define __LA_DEPRECATED
|
||||
@@ -235,19 +266,19 @@ __LA_DECL struct archive_entry *archive_entry_new2(struct archive *);
|
||||
* also return NULL when implicit character set conversions fail.
|
||||
* This is usually what you want.
|
||||
*/
|
||||
__LA_DECL time_t archive_entry_atime(struct archive_entry *);
|
||||
__LA_DECL __LA_TIME_T archive_entry_atime(struct archive_entry *);
|
||||
__LA_DECL long archive_entry_atime_nsec(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_atime_is_set(struct archive_entry *);
|
||||
__LA_DECL time_t archive_entry_birthtime(struct archive_entry *);
|
||||
__LA_DECL __LA_TIME_T archive_entry_birthtime(struct archive_entry *);
|
||||
__LA_DECL long archive_entry_birthtime_nsec(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_birthtime_is_set(struct archive_entry *);
|
||||
__LA_DECL time_t archive_entry_ctime(struct archive_entry *);
|
||||
__LA_DECL __LA_TIME_T archive_entry_ctime(struct archive_entry *);
|
||||
__LA_DECL long archive_entry_ctime_nsec(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_ctime_is_set(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_dev(struct archive_entry *);
|
||||
__LA_DECL __LA_DEV_T archive_entry_dev(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_dev_is_set(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_devmajor(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_devminor(struct archive_entry *);
|
||||
__LA_DECL __LA_DEV_T archive_entry_devmajor(struct archive_entry *);
|
||||
__LA_DECL __LA_DEV_T archive_entry_devminor(struct archive_entry *);
|
||||
__LA_DECL __LA_MODE_T archive_entry_filetype(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_filetype_is_set(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_fflags(struct archive_entry *,
|
||||
@@ -264,8 +295,8 @@ __LA_DECL const char *archive_entry_hardlink(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_hardlink_utf8(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_hardlink_is_set(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_ino(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_ino64(struct archive_entry *);
|
||||
__LA_DECL __LA_INO_T archive_entry_ino(struct archive_entry *);
|
||||
__LA_DECL __LA_INO_T archive_entry_ino64(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_ino_is_set(struct archive_entry *);
|
||||
__LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *);
|
||||
__LA_DECL time_t archive_entry_mtime(struct archive_entry *);
|
||||
@@ -278,9 +309,9 @@ __LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);
|
||||
__LA_DECL __LA_MODE_T archive_entry_perm(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_perm_is_set(struct archive_entry *);
|
||||
__LA_DECL int archive_entry_rdev_is_set(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_rdev(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);
|
||||
__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);
|
||||
__LA_DECL __LA_DEV_T archive_entry_rdev(struct archive_entry *);
|
||||
__LA_DECL __LA_DEV_T archive_entry_rdevmajor(struct archive_entry *);
|
||||
__LA_DECL __LA_DEV_T archive_entry_rdevminor(struct archive_entry *);
|
||||
__LA_DECL const char *archive_entry_sourcepath(struct archive_entry *);
|
||||
__LA_DECL const wchar_t *archive_entry_sourcepath_w(struct archive_entry *);
|
||||
__LA_DECL la_int64_t archive_entry_size(struct archive_entry *);
|
||||
@@ -309,18 +340,18 @@ __LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
|
||||
* always copied.
|
||||
*/
|
||||
|
||||
__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);
|
||||
__LA_DECL void archive_entry_set_atime(struct archive_entry *, __LA_TIME_T, long);
|
||||
__LA_DECL void archive_entry_unset_atime(struct archive_entry *);
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
|
||||
#endif
|
||||
__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);
|
||||
__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, __LA_TIME_T, long);
|
||||
__LA_DECL void archive_entry_unset_birthtime(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long);
|
||||
__LA_DECL void archive_entry_set_ctime(struct archive_entry *, __LA_TIME_T, long);
|
||||
__LA_DECL void archive_entry_unset_ctime(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_dev(struct archive_entry *, __LA_DEV_T);
|
||||
__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, __LA_DEV_T);
|
||||
__LA_DECL void archive_entry_set_devminor(struct archive_entry *, __LA_DEV_T);
|
||||
__LA_DECL void archive_entry_set_filetype(struct archive_entry *, unsigned int);
|
||||
__LA_DECL void archive_entry_set_fflags(struct archive_entry *,
|
||||
unsigned long /* set */, unsigned long /* clear */);
|
||||
@@ -343,15 +374,15 @@ __LA_DECL void archive_entry_set_hardlink_utf8(struct archive_entry *, const cha
|
||||
__LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_ino(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_set_ino64(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_set_ino(struct archive_entry *, __LA_INO_T);
|
||||
__LA_DECL void archive_entry_set_ino64(struct archive_entry *, __LA_INO_T);
|
||||
__LA_DECL void archive_entry_set_link(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_link_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T);
|
||||
__LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long);
|
||||
__LA_DECL void archive_entry_set_mtime(struct archive_entry *, __LA_TIME_T, long);
|
||||
__LA_DECL void archive_entry_unset_mtime(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int);
|
||||
__LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *);
|
||||
@@ -360,9 +391,9 @@ __LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *)
|
||||
__LA_DECL void archive_entry_copy_pathname_w(struct archive_entry *, const wchar_t *);
|
||||
__LA_DECL int archive_entry_update_pathname_utf8(struct archive_entry *, const char *);
|
||||
__LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
|
||||
__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);
|
||||
__LA_DECL void archive_entry_set_rdev(struct archive_entry *, __LA_DEV_T);
|
||||
__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, __LA_DEV_T);
|
||||
__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, __LA_DEV_T);
|
||||
__LA_DECL void archive_entry_set_size(struct archive_entry *, la_int64_t);
|
||||
__LA_DECL void archive_entry_unset_size(struct archive_entry *);
|
||||
__LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);
|
||||
@@ -418,6 +449,7 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi
|
||||
#define ARCHIVE_ENTRY_DIGEST_SHA512 0x00000006
|
||||
|
||||
__LA_DECL const unsigned char * archive_entry_digest(struct archive_entry *, int /* type */);
|
||||
__LA_DECL int archive_entry_set_digest(struct archive_entry *, int, const unsigned char *);
|
||||
|
||||
/*
|
||||
* ACL routines. This used to simply store and return text-format ACL
|
||||
|
||||
@@ -24,43 +24,24 @@
|
||||
*/
|
||||
|
||||
#include "archive_platform.h"
|
||||
|
||||
#include "archive_time_private.h"
|
||||
#include "archive_private.h"
|
||||
#include "archive_entry.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
|
||||
#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
|
||||
|
||||
__inline static void
|
||||
fileTimeToUtc(const FILETIME *filetime, time_t *t, long *ns)
|
||||
{
|
||||
ULARGE_INTEGER utc;
|
||||
|
||||
utc.HighPart = filetime->dwHighDateTime;
|
||||
utc.LowPart = filetime->dwLowDateTime;
|
||||
if (utc.QuadPart >= EPOC_TIME) {
|
||||
utc.QuadPart -= EPOC_TIME;
|
||||
*t = (time_t)(utc.QuadPart / 10000000); /* milli seconds base */
|
||||
*ns = (long)(utc.QuadPart % 10000000) * 100;/* nano seconds base */
|
||||
} else {
|
||||
*t = 0;
|
||||
*ns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_copy_bhfi(struct archive_entry *entry,
|
||||
BY_HANDLE_FILE_INFORMATION *bhfi)
|
||||
{
|
||||
time_t secs;
|
||||
long nsecs;
|
||||
int64_t secs;
|
||||
uint32_t nsecs;
|
||||
|
||||
fileTimeToUtc(&bhfi->ftLastAccessTime, &secs, &nsecs);
|
||||
ntfs_to_unix(FILETIME_to_ntfs(&bhfi->ftLastAccessTime), &secs, &nsecs);
|
||||
archive_entry_set_atime(entry, secs, nsecs);
|
||||
fileTimeToUtc(&bhfi->ftLastWriteTime, &secs, &nsecs);
|
||||
ntfs_to_unix(FILETIME_to_ntfs(&bhfi->ftLastWriteTime), &secs, &nsecs);
|
||||
archive_entry_set_mtime(entry, secs, nsecs);
|
||||
fileTimeToUtc(&bhfi->ftCreationTime, &secs, &nsecs);
|
||||
ntfs_to_unix(FILETIME_to_ntfs(&bhfi->ftCreationTime), &secs, &nsecs);
|
||||
archive_entry_set_birthtime(entry, secs, nsecs);
|
||||
archive_entry_set_ctime(entry, secs, nsecs);
|
||||
archive_entry_set_dev(entry, bhfi->dwVolumeSerialNumber);
|
||||
|
||||
@@ -280,6 +280,10 @@ find_entry(struct archive_entry_linkresolver *res,
|
||||
dev_t dev;
|
||||
int64_t ino;
|
||||
|
||||
if (!archive_entry_ino_is_set(entry) || !archive_entry_dev_is_set(entry)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Free a held entry. */
|
||||
if (res->spare != NULL) {
|
||||
archive_entry_free(res->spare->canonical);
|
||||
@@ -369,6 +373,10 @@ insert_entry(struct archive_entry_linkresolver *res,
|
||||
struct links_entry *le;
|
||||
size_t hash, bucket;
|
||||
|
||||
if (!archive_entry_ino_is_set(entry) || !archive_entry_dev_is_set(entry)) {
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Add this entry to the links cache. */
|
||||
le = calloc(1, sizeof(struct links_entry));
|
||||
if (le == NULL)
|
||||
|
||||
@@ -87,4 +87,4 @@ int _archive_entry_copy_symlink_l(struct archive_entry *,
|
||||
int _archive_entry_copy_uname_l(struct archive_entry *,
|
||||
const char *, size_t, struct archive_string_conv *);
|
||||
|
||||
#endif /* ARCHIVE_ENTRY_LOCALE_H_INCLUDED */
|
||||
#endif /* !ARCHIVE_ENTRY_LOCALE_H_INCLUDED */
|
||||
|
||||
@@ -174,6 +174,13 @@ struct archive_entry {
|
||||
size_t mac_metadata_size;
|
||||
|
||||
/* Digest support. */
|
||||
#define AE_MSET_DIGEST_MD5 1
|
||||
#define AE_MSET_DIGEST_RMD160 2
|
||||
#define AE_MSET_DIGEST_SHA1 4
|
||||
#define AE_MSET_DIGEST_SHA256 8
|
||||
#define AE_MSET_DIGEST_SHA384 16
|
||||
#define AE_MSET_DIGEST_SHA512 32
|
||||
uint_least32_t mset_digest;
|
||||
struct ae_digest digest;
|
||||
|
||||
/* ACL support. */
|
||||
@@ -195,8 +202,4 @@ struct archive_entry {
|
||||
int ae_symlink_type;
|
||||
};
|
||||
|
||||
int
|
||||
archive_entry_set_digest(struct archive_entry *entry, int type,
|
||||
const unsigned char *digest);
|
||||
|
||||
#endif /* ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
|
||||
#endif /* !ARCHIVE_ENTRY_PRIVATE_H_INCLUDED */
|
||||
|
||||
@@ -116,4 +116,4 @@ struct archive_hmac {
|
||||
};
|
||||
|
||||
extern const struct archive_hmac __archive_hmac;
|
||||
#endif /* ARCHIVE_HMAC_PRIVATE_H_INCLUDED */
|
||||
#endif /* !ARCHIVE_HMAC_PRIVATE_H_INCLUDED */
|
||||
|
||||
@@ -39,10 +39,10 @@
|
||||
#include "archive.h"
|
||||
#include "archive_private.h"
|
||||
#include "archive_entry.h"
|
||||
#include "archive_getdate.h"
|
||||
#include "archive_pathmatch.h"
|
||||
#include "archive_rb.h"
|
||||
#include "archive_string.h"
|
||||
#include "archive_time_private.h"
|
||||
|
||||
struct match {
|
||||
struct match *next;
|
||||
@@ -187,7 +187,7 @@ static int time_excluded(struct archive_match *,
|
||||
struct archive_entry *);
|
||||
static int validate_time_flag(struct archive *, int, const char *);
|
||||
|
||||
#define get_date __archive_get_date
|
||||
#define get_date archive_parse_date
|
||||
|
||||
static const struct archive_rb_tree_ops rb_ops_mbs = {
|
||||
cmp_node_mbs, cmp_key_mbs
|
||||
@@ -1145,36 +1145,15 @@ set_timefilter_date_w(struct archive_match *a, int timetype,
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
|
||||
static int
|
||||
set_timefilter_find_data(struct archive_match *a, int timetype,
|
||||
DWORD ftLastWriteTime_dwHighDateTime, DWORD ftLastWriteTime_dwLowDateTime,
|
||||
DWORD ftCreationTime_dwHighDateTime, DWORD ftCreationTime_dwLowDateTime)
|
||||
const FILETIME* ftLastWriteTime, const FILETIME* ftCreationTime)
|
||||
{
|
||||
ULARGE_INTEGER utc;
|
||||
time_t ctime_sec, mtime_sec;
|
||||
long ctime_ns, mtime_ns;
|
||||
uint32_t ctime_ns, mtime_ns;
|
||||
|
||||
utc.HighPart = ftCreationTime_dwHighDateTime;
|
||||
utc.LowPart = ftCreationTime_dwLowDateTime;
|
||||
if (utc.QuadPart >= EPOC_TIME) {
|
||||
utc.QuadPart -= EPOC_TIME;
|
||||
ctime_sec = (time_t)(utc.QuadPart / 10000000);
|
||||
ctime_ns = (long)(utc.QuadPart % 10000000) * 100;
|
||||
} else {
|
||||
ctime_sec = 0;
|
||||
ctime_ns = 0;
|
||||
}
|
||||
utc.HighPart = ftLastWriteTime_dwHighDateTime;
|
||||
utc.LowPart = ftLastWriteTime_dwLowDateTime;
|
||||
if (utc.QuadPart >= EPOC_TIME) {
|
||||
utc.QuadPart -= EPOC_TIME;
|
||||
mtime_sec = (time_t)(utc.QuadPart / 10000000);
|
||||
mtime_ns = (long)(utc.QuadPart % 10000000) * 100;
|
||||
} else {
|
||||
mtime_sec = 0;
|
||||
mtime_ns = 0;
|
||||
}
|
||||
ntfs_to_unix(FILETIME_to_ntfs(ftLastWriteTime), &mtime_sec, &mtime_ns);
|
||||
ntfs_to_unix(FILETIME_to_ntfs(ftCreationTime), &ctime_sec, &ctime_ns);
|
||||
return set_timefilter(a, timetype,
|
||||
mtime_sec, mtime_ns, ctime_sec, ctime_ns);
|
||||
}
|
||||
@@ -1199,9 +1178,7 @@ set_timefilter_pathname_mbs(struct archive_match *a, int timetype,
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
FindClose(h);
|
||||
return set_timefilter_find_data(a, timetype,
|
||||
d.ftLastWriteTime.dwHighDateTime, d.ftLastWriteTime.dwLowDateTime,
|
||||
d.ftCreationTime.dwHighDateTime, d.ftCreationTime.dwLowDateTime);
|
||||
return set_timefilter_find_data(a, timetype, &d.ftLastWriteTime, &d.ftCreationTime);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -1223,9 +1200,7 @@ set_timefilter_pathname_wcs(struct archive_match *a, int timetype,
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
FindClose(h);
|
||||
return set_timefilter_find_data(a, timetype,
|
||||
d.ftLastWriteTime.dwHighDateTime, d.ftLastWriteTime.dwLowDateTime,
|
||||
d.ftCreationTime.dwHighDateTime, d.ftCreationTime.dwLowDateTime);
|
||||
return set_timefilter_find_data(a, timetype, &d.ftLastWriteTime, &d.ftCreationTime);
|
||||
}
|
||||
|
||||
#else /* _WIN32 && !__CYGWIN__ */
|
||||
@@ -1871,4 +1846,3 @@ owner_excluded(struct archive_match *a, struct archive_entry *entry)
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ parse_option(const char **str,
|
||||
int
|
||||
_archive_set_option(struct archive *a,
|
||||
const char *m, const char *o, const char *v,
|
||||
int magic, const char *fn, option_handler use_option)
|
||||
unsigned int magic, const char *fn, option_handler use_option)
|
||||
{
|
||||
const char *mp, *op, *vp;
|
||||
int r;
|
||||
@@ -97,7 +97,7 @@ _archive_set_either_option(struct archive *a, const char *m, const char *o, cons
|
||||
|
||||
int
|
||||
_archive_set_options(struct archive *a, const char *options,
|
||||
int magic, const char *fn, option_handler use_option)
|
||||
unsigned int magic, const char *fn, option_handler use_option)
|
||||
{
|
||||
int allok = 1, anyok = 0, ignore_mod_err = 0, r;
|
||||
char *data;
|
||||
|
||||
@@ -35,11 +35,11 @@ typedef int (*option_handler)(struct archive *a,
|
||||
int
|
||||
_archive_set_option(struct archive *a,
|
||||
const char *mod, const char *opt, const char *val,
|
||||
int magic, const char *fn, option_handler use_option);
|
||||
unsigned int magic, const char *fn, option_handler use_option);
|
||||
|
||||
int
|
||||
_archive_set_options(struct archive *a, const char *options,
|
||||
int magic, const char *fn, option_handler use_option);
|
||||
unsigned int magic, const char *fn, option_handler use_option);
|
||||
|
||||
int
|
||||
_archive_set_either_option(struct archive *a,
|
||||
|
||||
@@ -46,4 +46,4 @@ pack_t pack_native;
|
||||
(((y) << 12) & 0xfff00000) | \
|
||||
(((y) << 0) & 0x000000ff)))
|
||||
|
||||
#endif /* ARCHIVE_PACK_DEV_H */
|
||||
#endif /* !ARCHIVE_PACK_DEV_H */
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#define __LIBARCHIVE_BUILD 1
|
||||
#include "archive_getdate.h"
|
||||
#include "archive.h"
|
||||
|
||||
/* Basic time units. */
|
||||
#define EPOCH 1970
|
||||
@@ -820,6 +819,23 @@ RelativeMonth(time_t Start, time_t Timezone, time_t RelMonth)
|
||||
Timezone, DSTmaybe));
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses and consumes an unsigned number.
|
||||
* Returns 1 if any number is parsed. Otherwise, *value is unchanged.
|
||||
*/
|
||||
static char
|
||||
consume_unsigned_number(const char **in, time_t *value)
|
||||
{
|
||||
char c;
|
||||
if (isdigit((unsigned char)(c = **in))) {
|
||||
for (*value = 0; isdigit((unsigned char)(c = *(*in)++)); )
|
||||
*value = 10 * *value + c - '0';
|
||||
(*in)--;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Tokenizer.
|
||||
*/
|
||||
@@ -861,7 +877,8 @@ nexttoken(const char **in, time_t *value)
|
||||
&& i < sizeof(buff)-1) {
|
||||
if (*src != '.') {
|
||||
if (isupper((unsigned char)*src))
|
||||
buff[i++] = tolower((unsigned char)*src);
|
||||
buff[i++] = (char)tolower(
|
||||
(unsigned char)*src);
|
||||
else
|
||||
buff[i++] = *src;
|
||||
}
|
||||
@@ -895,10 +912,7 @@ nexttoken(const char **in, time_t *value)
|
||||
* Because '-' and '+' have other special meanings, I
|
||||
* don't deal with signed numbers here.
|
||||
*/
|
||||
if (isdigit((unsigned char)(c = **in))) {
|
||||
for (*value = 0; isdigit((unsigned char)(c = *(*in)++)); )
|
||||
*value = 10 * *value + c - '0';
|
||||
(*in)--;
|
||||
if (consume_unsigned_number(in, value)) {
|
||||
return (tUNUMBER);
|
||||
}
|
||||
|
||||
@@ -914,7 +928,7 @@ difftm (struct tm *a, struct tm *b)
|
||||
{
|
||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
||||
int days = (
|
||||
long days = (
|
||||
/* difference in day of year */
|
||||
a->tm_yday - b->tm_yday
|
||||
/* + intervening leap days */
|
||||
@@ -929,6 +943,32 @@ difftm (struct tm *a, struct tm *b)
|
||||
+ (a->tm_sec - b->tm_sec));
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses a Unix epoch timestamp (seconds).
|
||||
* This supports a subset of what GNU tar accepts from black box testing,
|
||||
* but covers common use cases.
|
||||
*/
|
||||
static time_t
|
||||
parse_unix_epoch(const char *p)
|
||||
{
|
||||
time_t epoch;
|
||||
|
||||
/* may begin with + */
|
||||
if (*p == '+') {
|
||||
p++;
|
||||
}
|
||||
|
||||
/* followed by some number */
|
||||
if (!consume_unsigned_number(&p, &epoch))
|
||||
return (time_t)-1;
|
||||
|
||||
/* ...and nothing else */
|
||||
if (*p != '\0')
|
||||
return (time_t)-1;
|
||||
|
||||
return epoch;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* The public function.
|
||||
@@ -936,7 +976,7 @@ difftm (struct tm *a, struct tm *b)
|
||||
* TODO: tokens[] array should be dynamically sized.
|
||||
*/
|
||||
time_t
|
||||
__archive_get_date(time_t now, const char *p)
|
||||
archive_parse_date(time_t now, const char *p)
|
||||
{
|
||||
struct token tokens[256];
|
||||
struct gdstate _gds;
|
||||
@@ -948,6 +988,13 @@ __archive_get_date(time_t now, const char *p)
|
||||
time_t tod;
|
||||
long tzone;
|
||||
|
||||
/*
|
||||
* @-prefixed Unix epoch timestamps (seconds)
|
||||
* Skip the complex tokenizer - We do not want to accept strings like "@tenth"
|
||||
*/
|
||||
if (*p == '@')
|
||||
return parse_unix_epoch(p + 1);
|
||||
|
||||
/* Clear out the parsed token array. */
|
||||
memset(tokens, 0, sizeof(tokens));
|
||||
/* Initialize the parser state. */
|
||||
@@ -61,6 +61,11 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* For cygwin, to avoid missing LONG, ULONG, PUCHAR, ... definitions */
|
||||
#ifdef __CYGWIN__
|
||||
#include <windef.h>
|
||||
#endif
|
||||
|
||||
/* It should be possible to get rid of this by extending the feature-test
|
||||
* macros to cover Windows API functions, probably along with non-trivial
|
||||
* refactoring of code to find structures that sit more cleanly on top of
|
||||
|
||||
@@ -50,4 +50,4 @@
|
||||
#define ARCHIVE_ACL_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#endif /* ARCHIVE_PLATFORM_ACL_H_INCLUDED */
|
||||
#endif /* !ARCHIVE_PLATFORM_ACL_H_INCLUDED */
|
||||
|
||||
@@ -42,4 +42,4 @@
|
||||
#define ARCHIVE_XATTR_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#endif /* ARCHIVE_PLATFORM_XATTR_H_INCLUDED */
|
||||
#endif /* !ARCHIVE_PLATFORM_XATTR_H_INCLUDED */
|
||||
|
||||
@@ -287,9 +287,14 @@ static void *AllocUnits(CPpmd7 *p, unsigned indx)
|
||||
return AllocUnitsRare(p, indx);
|
||||
}
|
||||
|
||||
#define MyMem12Cpy(dest, src, num) \
|
||||
{ UInt32 *d = (UInt32 *)dest; const UInt32 *s = (const UInt32 *)src; UInt32 n = num; \
|
||||
do { d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; } while(--n); }
|
||||
#define MyMem12Cpy(dest, src, num) do { \
|
||||
UInt32 *d = (UInt32 *)dest; \
|
||||
const UInt32 *s = (const UInt32 *)src; \
|
||||
UInt32 n = num; \
|
||||
do { \
|
||||
d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; \
|
||||
} while(--n); \
|
||||
} while (0)
|
||||
|
||||
static void *ShrinkUnits(CPpmd7 *p, void *oldPtr, unsigned oldNU, unsigned newNU)
|
||||
{
|
||||
|
||||
@@ -242,9 +242,14 @@ static void *AllocUnits(CPpmd8 *p, unsigned indx)
|
||||
return AllocUnitsRare(p, indx);
|
||||
}
|
||||
|
||||
#define MyMem12Cpy(dest, src, num) \
|
||||
{ UInt32 *d = (UInt32 *)dest; const UInt32 *z = (const UInt32 *)src; UInt32 n = num; \
|
||||
do { d[0] = z[0]; d[1] = z[1]; d[2] = z[2]; z += 3; d += 3; } while (--n); }
|
||||
#define MyMem12Cpy(dest, src, num) do { \
|
||||
UInt32 *d = (UInt32 *)dest; \
|
||||
const UInt32 *z = (const UInt32 *)src; \
|
||||
UInt32 n = num; \
|
||||
do { \
|
||||
d[0] = z[0]; d[1] = z[1]; d[2] = z[2]; z += 3; d += 3; \
|
||||
} while (--n); \
|
||||
} while (0)
|
||||
|
||||
static void *ShrinkUnits(CPpmd8 *p, void *oldPtr, unsigned oldNU, unsigned newNU)
|
||||
{
|
||||
@@ -341,7 +346,9 @@ static void SetSuccessor(CPpmd_State *p, CPpmd_Void_Ref v)
|
||||
(p)->SuccessorHigh = (UInt16)(((UInt32)(v) >> 16) & 0xFFFF);
|
||||
}
|
||||
|
||||
#define RESET_TEXT(offs) { p->Text = p->Base + p->AlignOffset + (offs); }
|
||||
#define RESET_TEXT(offs) do { \
|
||||
p->Text = p->Base + p->AlignOffset + (offs); \
|
||||
} while (0)
|
||||
|
||||
static void RestartModel(CPpmd8 *p)
|
||||
{
|
||||
|
||||
@@ -109,8 +109,12 @@ typedef struct
|
||||
Byte Count; /* Count to next change of Shift */
|
||||
} CPpmd_See;
|
||||
|
||||
#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \
|
||||
{ (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); }
|
||||
#define Ppmd_See_Update(p) do { \
|
||||
if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) { \
|
||||
(p)->Summ <<= 1; \
|
||||
(p)->Count = (Byte)(3 << (p)->Shift++); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -144,8 +148,12 @@ typedef
|
||||
#endif
|
||||
CPpmd_Byte_Ref;
|
||||
|
||||
#define PPMD_SetAllBitsIn256Bytes(p) \
|
||||
{ unsigned j; for (j = 0; j < 256 / sizeof(p[0]); j += 8) { \
|
||||
p[j+7] = p[j+6] = p[j+5] = p[j+4] = p[j+3] = p[j+2] = p[j+1] = p[j+0] = ~(size_t)0; }}
|
||||
#define PPMD_SetAllBitsIn256Bytes(p) do { \
|
||||
unsigned j; \
|
||||
for (j = 0; j < 256 / sizeof(p[0]); j += 8) { \
|
||||
p[j+7] = p[j+6] = p[j+5] = p[j+4] = \
|
||||
p[j+3] = p[j+2] = p[j+1] = p[j+0] = ~(size_t)0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,4 +33,4 @@
|
||||
/* Random number generator. */
|
||||
int archive_random(void *buf, size_t nbytes);
|
||||
|
||||
#endif /* ARCHIVE_RANDOM_PRIVATE_H_INCLUDED */
|
||||
#endif /* !ARCHIVE_RANDOM_PRIVATE_H_INCLUDED */
|
||||
|
||||
@@ -110,4 +110,4 @@ struct archive_rb_node *
|
||||
__archive_rb_tree_iterate(struct archive_rb_tree *,
|
||||
struct archive_rb_node *, const unsigned int);
|
||||
|
||||
#endif /* ARCHIVE_RB_H_*/
|
||||
#endif /* !ARCHIVE_RB_H_INCLUDED */
|
||||
|
||||
@@ -176,15 +176,9 @@ client_skip_proxy(struct archive_read_filter *self, int64_t request)
|
||||
return 0;
|
||||
|
||||
if (self->archive->client.skipper != NULL) {
|
||||
/* Seek requests over 1GiB are broken down into
|
||||
* multiple seeks. This avoids overflows when the
|
||||
* requests get passed through 32-bit arguments. */
|
||||
int64_t skip_limit = (int64_t)1 << 30;
|
||||
int64_t total = 0;
|
||||
for (;;) {
|
||||
int64_t get, ask = request;
|
||||
if (ask > skip_limit)
|
||||
ask = skip_limit;
|
||||
get = (self->archive->client.skipper)
|
||||
(&self->archive->archive, self->data, ask);
|
||||
total += get;
|
||||
|
||||
@@ -96,6 +96,10 @@ archive_read_append_filter(struct archive *_a, int code)
|
||||
strcpy(str, "lzip");
|
||||
r1 = archive_read_support_filter_lzip(_a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_LZOP:
|
||||
strcpy(str, "lzop");
|
||||
r1 = archive_read_support_filter_lzop(_a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_LRZIP:
|
||||
strcpy(str, "lrzip");
|
||||
r1 = archive_read_support_filter_lrzip(_a);
|
||||
|
||||
@@ -888,7 +888,7 @@ setup_sparse_fiemap(struct archive_read_disk *a,
|
||||
count = (sizeof(buff) - sizeof(*fm))/sizeof(*fe);
|
||||
fm = (struct fiemap *)buff;
|
||||
fm->fm_start = 0;
|
||||
fm->fm_length = ~0ULL;;
|
||||
fm->fm_length = ~0ULL;
|
||||
fm->fm_flags = FIEMAP_FLAG_SYNC;
|
||||
fm->fm_extent_count = count;
|
||||
do_fiemap = 1;
|
||||
|
||||
@@ -276,7 +276,7 @@ tree_dir_next_posix(struct tree *t);
|
||||
#endif
|
||||
|
||||
/* Initiate/terminate a tree traversal. */
|
||||
static struct tree *tree_open(const char *, int, int);
|
||||
static struct tree *tree_open(const char *, char, int);
|
||||
static struct tree *tree_reopen(struct tree *, const char *, int);
|
||||
static void tree_close(struct tree *);
|
||||
static void tree_free(struct tree *);
|
||||
@@ -514,7 +514,7 @@ _archive_read_close(struct archive *_a)
|
||||
|
||||
static void
|
||||
setup_symlink_mode(struct archive_read_disk *a, char symlink_mode,
|
||||
int follow_symlinks)
|
||||
char follow_symlinks)
|
||||
{
|
||||
a->symlink_mode = symlink_mode;
|
||||
a->follow_symlinks = follow_symlinks;
|
||||
@@ -778,7 +778,8 @@ _archive_read_data_block(struct archive *_a, const void **buff,
|
||||
*/
|
||||
if (t->current_sparse->offset > t->entry_total) {
|
||||
if (lseek(t->entry_fd,
|
||||
(off_t)t->current_sparse->offset, SEEK_SET) < 0) {
|
||||
(off_t)t->current_sparse->offset, SEEK_SET) !=
|
||||
t->current_sparse->offset) {
|
||||
archive_set_error(&a->archive, errno, "Seek error");
|
||||
r = ARCHIVE_FATAL;
|
||||
a->archive.state = ARCHIVE_STATE_FATAL;
|
||||
@@ -2180,7 +2181,7 @@ tree_append(struct tree *t, const char *name, size_t name_length)
|
||||
* Open a directory tree for traversal.
|
||||
*/
|
||||
static struct tree *
|
||||
tree_open(const char *path, int symlink_mode, int restore_time)
|
||||
tree_open(const char *path, char symlink_mode, int restore_time)
|
||||
{
|
||||
struct tree *t;
|
||||
|
||||
|
||||
@@ -52,10 +52,11 @@ struct archive_read_disk {
|
||||
|
||||
/*
|
||||
* Since symlink interaction changes, we need to track whether
|
||||
* we're following symlinks for the current item. 'L' mode above
|
||||
* sets this true, 'P' sets it false, 'H' changes it as we traverse.
|
||||
* we're following symlinks for the current item, governed by the above
|
||||
* symlink_mode. 'L' sets this true, 'P' sets it false, 'H' changes it
|
||||
* as we traverse.
|
||||
*/
|
||||
char follow_symlinks; /* Either 'L' or 'P'. */
|
||||
char follow_symlinks; /* Either 0 or 1. */
|
||||
|
||||
/* Directory traversals. */
|
||||
struct tree *tree;
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "archive_entry.h"
|
||||
#include "archive_private.h"
|
||||
#include "archive_read_disk_private.h"
|
||||
#include "archive_time_private.h"
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
@@ -49,7 +50,7 @@
|
||||
/* Old SDKs do not provide IO_REPARSE_TAG_SYMLINK */
|
||||
#define IO_REPARSE_TAG_SYMLINK 0xA000000CL
|
||||
#endif
|
||||
/* To deal with absolute symlink isuues */
|
||||
/* To deal with absolute symlink issues */
|
||||
#define START_ABSOLUTE_SYMLINK_REPARSE L"\\??\\"
|
||||
|
||||
/*-
|
||||
@@ -602,7 +603,7 @@ _archive_read_close(struct archive *_a)
|
||||
|
||||
static void
|
||||
setup_symlink_mode(struct archive_read_disk *a, char symlink_mode,
|
||||
int follow_symlinks)
|
||||
char follow_symlinks)
|
||||
{
|
||||
a->symlink_mode = symlink_mode;
|
||||
a->follow_symlinks = follow_symlinks;
|
||||
@@ -1983,40 +1984,20 @@ tree_dir_next_windows(struct tree *t, const wchar_t *pattern)
|
||||
}
|
||||
}
|
||||
|
||||
#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
|
||||
static void
|
||||
fileTimeToUtc(const FILETIME *filetime, time_t *t, long *ns)
|
||||
{
|
||||
ULARGE_INTEGER utc;
|
||||
|
||||
utc.HighPart = filetime->dwHighDateTime;
|
||||
utc.LowPart = filetime->dwLowDateTime;
|
||||
if (utc.QuadPart >= EPOC_TIME) {
|
||||
utc.QuadPart -= EPOC_TIME;
|
||||
/* milli seconds base */
|
||||
*t = (time_t)(utc.QuadPart / 10000000);
|
||||
/* nano seconds base */
|
||||
*ns = (long)(utc.QuadPart % 10000000) * 100;
|
||||
} else {
|
||||
*t = 0;
|
||||
*ns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
entry_copy_bhfi(struct archive_entry *entry, const wchar_t *path,
|
||||
const WIN32_FIND_DATAW *findData,
|
||||
const BY_HANDLE_FILE_INFORMATION *bhfi)
|
||||
{
|
||||
time_t secs;
|
||||
long nsecs;
|
||||
int64_t secs;
|
||||
uint32_t nsecs;
|
||||
mode_t mode;
|
||||
|
||||
fileTimeToUtc(&bhfi->ftLastAccessTime, &secs, &nsecs);
|
||||
ntfs_to_unix(FILETIME_to_ntfs(&bhfi->ftLastAccessTime), &secs, &nsecs);
|
||||
archive_entry_set_atime(entry, secs, nsecs);
|
||||
fileTimeToUtc(&bhfi->ftLastWriteTime, &secs, &nsecs);
|
||||
ntfs_to_unix(FILETIME_to_ntfs(&bhfi->ftLastWriteTime), &secs, &nsecs);
|
||||
archive_entry_set_mtime(entry, secs, nsecs);
|
||||
fileTimeToUtc(&bhfi->ftCreationTime, &secs, &nsecs);
|
||||
ntfs_to_unix(FILETIME_to_ntfs(&bhfi->ftCreationTime), &secs, &nsecs);
|
||||
archive_entry_set_birthtime(entry, secs, nsecs);
|
||||
archive_entry_set_ctime(entry, secs, nsecs);
|
||||
archive_entry_set_dev(entry, bhfi_dev(bhfi));
|
||||
|
||||
@@ -37,8 +37,10 @@
|
||||
.Nm archive_read_support_format_lha ,
|
||||
.Nm archive_read_support_format_mtree ,
|
||||
.Nm archive_read_support_format_rar ,
|
||||
.Nm archive_read_support_format_rar5 ,
|
||||
.Nm archive_read_support_format_raw ,
|
||||
.Nm archive_read_support_format_tar ,
|
||||
.Nm archive_read_support_format_warc ,
|
||||
.Nm archive_read_support_format_xar ,
|
||||
.Nm archive_read_support_format_zip
|
||||
.Nd functions for reading streaming archives
|
||||
@@ -70,10 +72,14 @@ Streaming Archive Library (libarchive, -larchive)
|
||||
.Ft int
|
||||
.Fn archive_read_support_format_rar "struct archive *"
|
||||
.Ft int
|
||||
.Fn archive_read_support_format_rar5 "struct archive *"
|
||||
.Ft int
|
||||
.Fn archive_read_support_format_raw "struct archive *"
|
||||
.Ft int
|
||||
.Fn archive_read_support_format_tar "struct archive *"
|
||||
.Ft int
|
||||
.Fn archive_read_support_format_warc "struct archive *"
|
||||
.Ft int
|
||||
.Fn archive_read_support_format_xar "struct archive *"
|
||||
.Ft int
|
||||
.Fn archive_read_support_format_zip "struct archive *"
|
||||
@@ -89,8 +95,10 @@ Streaming Archive Library (libarchive, -larchive)
|
||||
.Fn archive_read_support_format_lha ,
|
||||
.Fn archive_read_support_format_mtree ,
|
||||
.Fn archive_read_support_format_rar ,
|
||||
.Fn archive_read_support_format_rar5 ,
|
||||
.Fn archive_read_support_format_raw ,
|
||||
.Fn archive_read_support_format_tar ,
|
||||
.Fn archive_read_support_format_warc ,
|
||||
.Fn archive_read_support_format_xar ,
|
||||
.Fn archive_read_support_format_zip
|
||||
.Xc
|
||||
@@ -100,6 +108,13 @@ For example,
|
||||
.Fn archive_read_support_format_tar
|
||||
enables support for a variety of standard tar formats, old-style tar,
|
||||
ustar, pax interchange format, and many common variants.
|
||||
.Fn archive_read_support_format_zip
|
||||
enables support for both the streaming and the seeking zip readers,
|
||||
which can separately be enabled by respectively
|
||||
.Fn archive_read_support_format_zip_streamable
|
||||
and
|
||||
.Fn archive_read_support_format_zip_seekable
|
||||
.
|
||||
.It Fn archive_read_support_format_all
|
||||
Enables support for all available formats except the
|
||||
.Dq raw
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
struct read_fd_data {
|
||||
int fd;
|
||||
size_t block_size;
|
||||
int64_t size;
|
||||
char use_lseek;
|
||||
void *buffer;
|
||||
};
|
||||
@@ -95,6 +96,7 @@ archive_read_open_fd(struct archive *a, int fd, size_t block_size)
|
||||
if (S_ISREG(st.st_mode)) {
|
||||
archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
|
||||
mine->use_lseek = 1;
|
||||
mine->size = st.st_size;
|
||||
}
|
||||
#if defined(__CYGWIN__) || defined(_WIN32)
|
||||
setmode(mine->fd, O_BINARY);
|
||||
@@ -131,7 +133,7 @@ static int64_t
|
||||
file_skip(struct archive *a, void *client_data, int64_t request)
|
||||
{
|
||||
struct read_fd_data *mine = (struct read_fd_data *)client_data;
|
||||
int64_t skip = request;
|
||||
off_t skip = (off_t)request;
|
||||
int64_t old_offset, new_offset;
|
||||
int skip_bits = sizeof(skip) * 8 - 1; /* off_t is a signed type. */
|
||||
|
||||
@@ -140,20 +142,25 @@ file_skip(struct archive *a, void *client_data, int64_t request)
|
||||
|
||||
/* Reduce a request that would overflow the 'skip' variable. */
|
||||
if (sizeof(request) > sizeof(skip)) {
|
||||
int64_t max_skip =
|
||||
const int64_t max_skip =
|
||||
(((int64_t)1 << (skip_bits - 1)) - 1) * 2 + 1;
|
||||
if (request > max_skip)
|
||||
skip = max_skip;
|
||||
skip = (off_t)max_skip;
|
||||
}
|
||||
|
||||
/* Reduce request to the next smallest multiple of block_size */
|
||||
request = (request / mine->block_size) * mine->block_size;
|
||||
if (request == 0)
|
||||
/* Reduce 'skip' to the next smallest multiple of block_size */
|
||||
skip = (off_t)(((int64_t)skip / mine->block_size) * mine->block_size);
|
||||
if (skip == 0)
|
||||
return (0);
|
||||
|
||||
if (((old_offset = lseek(mine->fd, 0, SEEK_CUR)) >= 0) &&
|
||||
((new_offset = lseek(mine->fd, skip, SEEK_CUR)) >= 0))
|
||||
return (new_offset - old_offset);
|
||||
if ((old_offset = lseek(mine->fd, 0, SEEK_CUR)) >= 0) {
|
||||
if (old_offset >= mine->size ||
|
||||
skip > mine->size - old_offset) {
|
||||
/* Do not seek past end of file. */
|
||||
errno = ESPIPE;
|
||||
} else if ((new_offset = lseek(mine->fd, skip, SEEK_CUR)) >= 0)
|
||||
return (new_offset - old_offset);
|
||||
}
|
||||
|
||||
/* If seek failed once, it will probably fail again. */
|
||||
mine->use_lseek = 0;
|
||||
@@ -178,11 +185,24 @@ static int64_t
|
||||
file_seek(struct archive *a, void *client_data, int64_t request, int whence)
|
||||
{
|
||||
struct read_fd_data *mine = (struct read_fd_data *)client_data;
|
||||
off_t seek = (off_t)request;
|
||||
int64_t r;
|
||||
int seek_bits = sizeof(seek) * 8 - 1; /* off_t is a signed type. */
|
||||
|
||||
/* We use off_t here because lseek() is declared that way. */
|
||||
/* See above for notes about when off_t is less than 64 bits. */
|
||||
r = lseek(mine->fd, request, whence);
|
||||
|
||||
/* Reduce a request that would overflow the 'seek' variable. */
|
||||
if (sizeof(request) > sizeof(seek)) {
|
||||
const int64_t max_seek =
|
||||
(((int64_t)1 << (seek_bits - 1)) - 1) * 2 + 1;
|
||||
const int64_t min_seek = ~max_seek;
|
||||
if (request > max_seek)
|
||||
seek = (off_t)max_seek;
|
||||
else if (request < min_seek)
|
||||
seek = (off_t)min_seek;
|
||||
}
|
||||
|
||||
r = lseek(mine->fd, seek, whence);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -52,13 +52,15 @@
|
||||
struct read_FILE_data {
|
||||
FILE *f;
|
||||
size_t block_size;
|
||||
int64_t size;
|
||||
void *buffer;
|
||||
char can_skip;
|
||||
};
|
||||
|
||||
static int file_close(struct archive *, void *);
|
||||
static ssize_t file_read(struct archive *, void *, const void **buff);
|
||||
static int64_t file_skip(struct archive *, void *, int64_t request);
|
||||
static int FILE_close(struct archive *, void *);
|
||||
static ssize_t FILE_read(struct archive *, void *, const void **buff);
|
||||
static int64_t FILE_seek(struct archive *, void *, int64_t, int);
|
||||
static int64_t FILE_skip(struct archive *, void *, int64_t);
|
||||
|
||||
int
|
||||
archive_read_open_FILE(struct archive *a, FILE *f)
|
||||
@@ -69,7 +71,7 @@ archive_read_open_FILE(struct archive *a, FILE *f)
|
||||
void *b;
|
||||
|
||||
archive_clear_error(a);
|
||||
mine = malloc(sizeof(*mine));
|
||||
mine = calloc(1, sizeof(*mine));
|
||||
b = malloc(block_size);
|
||||
if (mine == NULL || b == NULL) {
|
||||
archive_set_error(a, ENOMEM, "No memory");
|
||||
@@ -90,22 +92,23 @@ archive_read_open_FILE(struct archive *a, FILE *f)
|
||||
archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
|
||||
/* Enable the seek optimization only for regular files. */
|
||||
mine->can_skip = 1;
|
||||
} else
|
||||
mine->can_skip = 0;
|
||||
mine->size = st.st_size;
|
||||
}
|
||||
|
||||
#if defined(__CYGWIN__) || defined(_WIN32)
|
||||
setmode(fileno(mine->f), O_BINARY);
|
||||
#endif
|
||||
|
||||
archive_read_set_read_callback(a, file_read);
|
||||
archive_read_set_skip_callback(a, file_skip);
|
||||
archive_read_set_close_callback(a, file_close);
|
||||
archive_read_set_read_callback(a, FILE_read);
|
||||
archive_read_set_skip_callback(a, FILE_skip);
|
||||
archive_read_set_seek_callback(a, FILE_seek);
|
||||
archive_read_set_close_callback(a, FILE_close);
|
||||
archive_read_set_callback_data(a, mine);
|
||||
return (archive_read_open1(a));
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
file_read(struct archive *a, void *client_data, const void **buff)
|
||||
FILE_read(struct archive *a, void *client_data, const void **buff)
|
||||
{
|
||||
struct read_FILE_data *mine = (struct read_FILE_data *)client_data;
|
||||
size_t bytes_read;
|
||||
@@ -119,16 +122,17 @@ file_read(struct archive *a, void *client_data, const void **buff)
|
||||
}
|
||||
|
||||
static int64_t
|
||||
file_skip(struct archive *a, void *client_data, int64_t request)
|
||||
FILE_skip(struct archive *a, void *client_data, int64_t request)
|
||||
{
|
||||
struct read_FILE_data *mine = (struct read_FILE_data *)client_data;
|
||||
#if HAVE_FSEEKO
|
||||
off_t skip = (off_t)request;
|
||||
#elif HAVE__FSEEKI64
|
||||
#if HAVE__FSEEKI64
|
||||
int64_t skip = request;
|
||||
#elif HAVE_FSEEKO
|
||||
off_t skip = (off_t)request;
|
||||
#else
|
||||
long skip = (long)request;
|
||||
#endif
|
||||
int64_t old_offset, new_offset;
|
||||
int skip_bits = sizeof(skip) * 8 - 1;
|
||||
|
||||
(void)a; /* UNUSED */
|
||||
@@ -144,7 +148,7 @@ file_skip(struct archive *a, void *client_data, int64_t request)
|
||||
|
||||
/* If request is too big for a long or an off_t, reduce it. */
|
||||
if (sizeof(request) > sizeof(skip)) {
|
||||
int64_t max_skip =
|
||||
const int64_t max_skip =
|
||||
(((int64_t)1 << (skip_bits - 1)) - 1) * 2 + 1;
|
||||
if (request > max_skip)
|
||||
skip = max_skip;
|
||||
@@ -152,23 +156,89 @@ file_skip(struct archive *a, void *client_data, int64_t request)
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/* fileno() isn't safe on all platforms ... see above. */
|
||||
if (lseek(fileno(mine->f), skip, SEEK_CUR) < 0)
|
||||
old_offset = lseek(fileno(mine->f), 0, SEEK_CUR);
|
||||
#elif HAVE__FSEEKI64
|
||||
if (_fseeki64(mine->f, skip, SEEK_CUR) != 0)
|
||||
old_offset = _ftelli64(mine->f);
|
||||
#elif HAVE_FSEEKO
|
||||
if (fseeko(mine->f, skip, SEEK_CUR) != 0)
|
||||
old_offset = ftello(mine->f);
|
||||
#else
|
||||
if (fseek(mine->f, skip, SEEK_CUR) != 0)
|
||||
old_offset = ftell(mine->f);
|
||||
#endif
|
||||
{
|
||||
mine->can_skip = 0;
|
||||
return (0);
|
||||
if (old_offset >= 0) {
|
||||
if (old_offset < mine->size &&
|
||||
skip <= mine->size - old_offset) {
|
||||
#ifdef __ANDROID__
|
||||
new_offset = lseek(fileno(mine->f), skip, SEEK_CUR);
|
||||
#elif HAVE__FSEEKI64
|
||||
new_offset = _fseeki64(mine->f, skip, SEEK_CUR);
|
||||
#elif HAVE_FSEEKO
|
||||
new_offset = fseeko(mine->f, skip, SEEK_CUR);
|
||||
#else
|
||||
new_offset = fseek(mine->f, skip, SEEK_CUR);
|
||||
#endif
|
||||
if (new_offset >= 0)
|
||||
return (new_offset - old_offset);
|
||||
}
|
||||
}
|
||||
return (request);
|
||||
|
||||
mine->can_skip = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Store the offset and use it in the read callback.
|
||||
*/
|
||||
static int64_t
|
||||
FILE_seek(struct archive *a, void *client_data, int64_t request, int whence)
|
||||
{
|
||||
struct read_FILE_data *mine = (struct read_FILE_data *)client_data;
|
||||
#if HAVE__FSEEKI64
|
||||
int64_t seek = request;
|
||||
#elif HAVE_FSEEKO
|
||||
off_t seek = (off_t)request;
|
||||
#else
|
||||
long seek = (long)request;
|
||||
#endif
|
||||
int seek_bits = sizeof(seek) * 8 - 1;
|
||||
(void)a; /* UNUSED */
|
||||
|
||||
/* Reduce a request that would overflow the 'seek' variable. */
|
||||
if (sizeof(request) > sizeof(seek)) {
|
||||
const int64_t max_seek =
|
||||
(((int64_t)1 << (seek_bits - 1)) - 1) * 2 + 1;
|
||||
const int64_t min_seek = ~max_seek;
|
||||
if (request > max_seek)
|
||||
seek = max_seek;
|
||||
else if (request < min_seek)
|
||||
seek = min_seek;
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/* Newer Android versions have fseeko...to meditate. */
|
||||
int64_t ret = lseek(fileno(mine->f), seek, whence);
|
||||
if (ret >= 0) {
|
||||
return ret;
|
||||
}
|
||||
#elif HAVE__FSEEKI64
|
||||
if (_fseeki64(mine->f, seek, whence) == 0) {
|
||||
return _ftelli64(mine->f);
|
||||
}
|
||||
#elif HAVE_FSEEKO
|
||||
if (fseeko(mine->f, seek, whence) == 0) {
|
||||
return ftello(mine->f);
|
||||
}
|
||||
#else
|
||||
if (fseek(mine->f, seek, whence) == 0) {
|
||||
return ftell(mine->f);
|
||||
}
|
||||
#endif
|
||||
/* If we arrive here, the input is corrupted or truncated so fail. */
|
||||
archive_set_error(a, errno, "Error seeking in FILE* pointer");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
static int
|
||||
file_close(struct archive *a, void *client_data)
|
||||
FILE_close(struct archive *a, void *client_data)
|
||||
{
|
||||
struct read_FILE_data *mine = (struct read_FILE_data *)client_data;
|
||||
|
||||
|
||||
@@ -74,6 +74,7 @@ struct read_file_data {
|
||||
size_t block_size;
|
||||
void *buffer;
|
||||
mode_t st_mode; /* Mode bits for opened file. */
|
||||
int64_t size;
|
||||
char use_lseek;
|
||||
enum fnt_e { FNT_STDIN, FNT_MBS, FNT_WCS } filename_type;
|
||||
union {
|
||||
@@ -303,7 +304,7 @@ file_open(struct archive *a, void *client_data)
|
||||
}
|
||||
if (fd < 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to open '%S'", wfilename);
|
||||
"Failed to open '%ls'", wfilename);
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
#else
|
||||
@@ -315,7 +316,7 @@ file_open(struct archive *a, void *client_data)
|
||||
if (fstat(fd, &st) != 0) {
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
if (mine->filename_type == FNT_WCS)
|
||||
archive_set_error(a, errno, "Can't stat '%S'",
|
||||
archive_set_error(a, errno, "Can't stat '%ls'",
|
||||
wfilename);
|
||||
else
|
||||
#endif
|
||||
@@ -400,8 +401,10 @@ file_open(struct archive *a, void *client_data)
|
||||
mine->st_mode = st.st_mode;
|
||||
|
||||
/* Disk-like inputs can use lseek(). */
|
||||
if (is_disk_like)
|
||||
if (is_disk_like) {
|
||||
mine->use_lseek = 1;
|
||||
mine->size = st.st_size;
|
||||
}
|
||||
|
||||
return (ARCHIVE_OK);
|
||||
fail:
|
||||
@@ -447,7 +450,7 @@ file_read(struct archive *a, void *client_data, const void **buff)
|
||||
"Error reading '%s'", mine->filename.m);
|
||||
else
|
||||
archive_set_error(a, errno,
|
||||
"Error reading '%S'", mine->filename.w);
|
||||
"Error reading '%ls'", mine->filename.w);
|
||||
}
|
||||
return (bytes_read);
|
||||
}
|
||||
@@ -479,21 +482,30 @@ file_skip_lseek(struct archive *a, void *client_data, int64_t request)
|
||||
struct read_file_data *mine = (struct read_file_data *)client_data;
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
/* We use _lseeki64() on Windows. */
|
||||
int64_t old_offset, new_offset;
|
||||
int64_t old_offset, new_offset, skip = request;
|
||||
#else
|
||||
off_t old_offset, new_offset;
|
||||
off_t old_offset, new_offset, skip = (off_t)request;
|
||||
#endif
|
||||
int skip_bits = sizeof(skip) * 8 - 1;
|
||||
|
||||
/* We use off_t here because lseek() is declared that way. */
|
||||
|
||||
/* TODO: Deal with case where off_t isn't 64 bits.
|
||||
* This shouldn't be a problem on Linux or other POSIX
|
||||
* systems, since the configuration logic for libarchive
|
||||
* tries to obtain a 64-bit off_t.
|
||||
*/
|
||||
if ((old_offset = lseek(mine->fd, 0, SEEK_CUR)) >= 0 &&
|
||||
(new_offset = lseek(mine->fd, request, SEEK_CUR)) >= 0)
|
||||
return (new_offset - old_offset);
|
||||
/* Reduce a request that would overflow the 'skip' variable. */
|
||||
if (sizeof(request) > sizeof(skip)) {
|
||||
const int64_t max_skip =
|
||||
(((int64_t)1 << (skip_bits - 1)) - 1) * 2 + 1;
|
||||
if (request > max_skip)
|
||||
skip = max_skip;
|
||||
}
|
||||
|
||||
if ((old_offset = lseek(mine->fd, 0, SEEK_CUR)) >= 0) {
|
||||
if (old_offset >= mine->size ||
|
||||
skip > mine->size - old_offset) {
|
||||
/* Do not seek past end of file. */
|
||||
errno = ESPIPE;
|
||||
} else if ((new_offset = lseek(mine->fd, skip, SEEK_CUR)) >= 0)
|
||||
return (new_offset - old_offset);
|
||||
}
|
||||
|
||||
/* If lseek() fails, don't bother trying again. */
|
||||
mine->use_lseek = 0;
|
||||
@@ -509,7 +521,7 @@ file_skip_lseek(struct archive *a, void *client_data, int64_t request)
|
||||
archive_set_error(a, errno, "Error seeking in '%s'",
|
||||
mine->filename.m);
|
||||
else
|
||||
archive_set_error(a, errno, "Error seeking in '%S'",
|
||||
archive_set_error(a, errno, "Error seeking in '%ls'",
|
||||
mine->filename.w);
|
||||
return (-1);
|
||||
}
|
||||
@@ -540,11 +552,24 @@ static int64_t
|
||||
file_seek(struct archive *a, void *client_data, int64_t request, int whence)
|
||||
{
|
||||
struct read_file_data *mine = (struct read_file_data *)client_data;
|
||||
off_t seek = (off_t)request;
|
||||
int64_t r;
|
||||
int seek_bits = sizeof(seek) * 8 - 1;
|
||||
|
||||
/* We use off_t here because lseek() is declared that way. */
|
||||
/* See above for notes about when off_t is less than 64 bits. */
|
||||
r = lseek(mine->fd, request, whence);
|
||||
|
||||
/* Reduce a request that would overflow the 'seek' variable. */
|
||||
if (sizeof(request) > sizeof(seek)) {
|
||||
const int64_t max_seek =
|
||||
(((int64_t)1 << (seek_bits - 1)) - 1) * 2 + 1;
|
||||
const int64_t min_seek = ~max_seek;
|
||||
if (request > max_seek)
|
||||
seek = (off_t)max_seek;
|
||||
else if (request < min_seek)
|
||||
seek = (off_t)min_seek;
|
||||
}
|
||||
|
||||
r = lseek(mine->fd, seek, whence);
|
||||
if (r >= 0)
|
||||
return r;
|
||||
|
||||
@@ -555,7 +580,7 @@ file_seek(struct archive *a, void *client_data, int64_t request, int whence)
|
||||
archive_set_error(a, errno, "Error seeking in '%s'",
|
||||
mine->filename.m);
|
||||
else
|
||||
archive_set_error(a, errno, "Error seeking in '%S'",
|
||||
archive_set_error(a, errno, "Error seeking in '%ls'",
|
||||
mine->filename.w);
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
@@ -37,46 +37,32 @@ archive_read_support_filter_by_code(struct archive *a, int filter_code)
|
||||
switch (filter_code) {
|
||||
case ARCHIVE_FILTER_NONE:
|
||||
return archive_read_support_filter_none(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_GZIP:
|
||||
return archive_read_support_filter_gzip(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_BZIP2:
|
||||
return archive_read_support_filter_bzip2(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_COMPRESS:
|
||||
return archive_read_support_filter_compress(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_LZMA:
|
||||
return archive_read_support_filter_lzma(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_XZ:
|
||||
return archive_read_support_filter_xz(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_UU:
|
||||
return archive_read_support_filter_uu(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_RPM:
|
||||
return archive_read_support_filter_rpm(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_LZIP:
|
||||
return archive_read_support_filter_lzip(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_LRZIP:
|
||||
return archive_read_support_filter_lrzip(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_LZOP:
|
||||
return archive_read_support_filter_lzop(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_GRZIP:
|
||||
return archive_read_support_filter_grzip(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_LZ4:
|
||||
return archive_read_support_filter_lz4(a);
|
||||
break;
|
||||
case ARCHIVE_FILTER_ZSTD:
|
||||
return archive_read_support_filter_zstd(a);
|
||||
break;
|
||||
}
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,6 @@ lz4_filter_read(struct archive_read_filter *self, const void **p)
|
||||
archive_set_error(&self->archive->archive,
|
||||
ARCHIVE_ERRNO_MISC, "Program error.");
|
||||
return (ARCHIVE_FATAL);
|
||||
break;
|
||||
}
|
||||
|
||||
while (state->stage == SELECT_STREAM) {
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
@@ -50,6 +53,7 @@
|
||||
#include "archive_ppmd7_private.h"
|
||||
#include "archive_private.h"
|
||||
#include "archive_read_private.h"
|
||||
#include "archive_time_private.h"
|
||||
#include "archive_endian.h"
|
||||
|
||||
#ifndef HAVE_ZLIB_H
|
||||
@@ -59,7 +63,26 @@
|
||||
#define _7ZIP_SIGNATURE "7z\xBC\xAF\x27\x1C"
|
||||
#define SFX_MIN_ADDR 0x27000
|
||||
#define SFX_MAX_ADDR 0x60000
|
||||
#define SFX_MAX_OFFSET (SFX_MAX_ADDR - SFX_MIN_ADDR)
|
||||
|
||||
/*
|
||||
* PE format
|
||||
*/
|
||||
#define PE_DOS_HDR_LEN 0x40
|
||||
#define PE_DOS_HDR_ELFANEW_OFFSET 0x3c
|
||||
#define PE_COFF_HDR_LEN 0x18
|
||||
#define PE_COFF_HDR_SEC_CNT_OFFSET 0x6
|
||||
#define PE_COFF_HDR_OPT_SZ_OFFSET 0x14
|
||||
#define PE_SEC_HDR_LEN 0x28
|
||||
#define PE_SEC_HDR_RAW_ADDR_OFFSET 0x14
|
||||
#define PE_SEC_HDR_RAW_SZ_OFFSET 0x10
|
||||
|
||||
/*
|
||||
* ELF format
|
||||
*/
|
||||
#define ELF_HDR_MIN_LEN 0x34
|
||||
#define ELF_HDR_EI_CLASS_OFFSET 0x04
|
||||
#define ELF_HDR_EI_DATA_OFFSET 0x05
|
||||
|
||||
/*
|
||||
* Codec ID
|
||||
@@ -83,6 +106,7 @@
|
||||
#define _7Z_ARM 0x03030501
|
||||
#define _7Z_ARMTHUMB 0x03030701
|
||||
#define _7Z_ARM64 0xa
|
||||
#define _7Z_RISCV 0xb
|
||||
#define _7Z_SPARC 0x03030805
|
||||
|
||||
#define _7Z_ZSTD 0x4F71101 /* Copied from https://github.com/mcmilk/7-Zip-zstd.git */
|
||||
@@ -144,7 +168,6 @@ struct _7z_digests {
|
||||
uint32_t *digests;
|
||||
};
|
||||
|
||||
|
||||
struct _7z_folder {
|
||||
uint64_t numCoders;
|
||||
struct _7z_coder {
|
||||
@@ -224,13 +247,13 @@ struct _7zip_entry {
|
||||
#define CRC32_IS_SET (1<<3)
|
||||
#define HAS_STREAM (1<<4)
|
||||
|
||||
time_t mtime;
|
||||
time_t atime;
|
||||
time_t ctime;
|
||||
long mtime_ns;
|
||||
long atime_ns;
|
||||
long ctime_ns;
|
||||
uint32_t mode;
|
||||
int64_t mtime;
|
||||
int64_t atime;
|
||||
int64_t ctime;
|
||||
uint32_t mtime_ns;
|
||||
uint32_t atime_ns;
|
||||
uint32_t ctime_ns;
|
||||
__LA_MODE_T mode;
|
||||
uint32_t attr;
|
||||
};
|
||||
|
||||
@@ -388,7 +411,6 @@ static int decode_encoded_header_info(struct archive_read *,
|
||||
static int decompress(struct archive_read *, struct _7zip *,
|
||||
void *, size_t *, const void *, size_t *);
|
||||
static ssize_t extract_pack_stream(struct archive_read *, size_t);
|
||||
static void fileTimeToUtc(uint64_t, time_t *, long *);
|
||||
static uint64_t folder_uncompressed_size(struct _7z_folder *);
|
||||
static void free_CodersInfo(struct _7z_coders_info *);
|
||||
static void free_Digest(struct _7z_digests *);
|
||||
@@ -424,7 +446,9 @@ static ssize_t read_stream(struct archive_read *, const void **, size_t,
|
||||
size_t);
|
||||
static int seek_pack(struct archive_read *);
|
||||
static int64_t skip_stream(struct archive_read *, size_t);
|
||||
static int skip_sfx(struct archive_read *, ssize_t);
|
||||
static int skip_sfx(struct archive_read *, const ssize_t);
|
||||
static ssize_t find_pe_overlay(struct archive_read *);
|
||||
static ssize_t find_elf_data_sec(struct archive_read *);
|
||||
static int slurp_central_directory(struct archive_read *, struct _7zip *,
|
||||
struct _7z_header_info *);
|
||||
static int setup_decode_folder(struct archive_read *, struct _7z_folder *,
|
||||
@@ -435,6 +459,8 @@ static void arm_Init(struct _7zip *);
|
||||
static size_t arm_Convert(struct _7zip *, uint8_t *, size_t);
|
||||
static size_t arm64_Convert(struct _7zip *, uint8_t *, size_t);
|
||||
static ssize_t Bcj2_Decode(struct _7zip *, uint8_t *, size_t);
|
||||
static size_t sparc_Convert(struct _7zip *, uint8_t *, size_t);
|
||||
static size_t powerpc_Convert(struct _7zip *, uint8_t *, size_t);
|
||||
|
||||
|
||||
int
|
||||
@@ -522,15 +548,17 @@ archive_read_format_7zip_bid(struct archive_read *a, int best_bid)
|
||||
* It may a 7-Zip SFX archive file. If first two bytes are
|
||||
* 'M' and 'Z' available on Windows or first four bytes are
|
||||
* "\x7F\x45LF" available on posix like system, seek the 7-Zip
|
||||
* signature. Although we will perform a seek when reading
|
||||
* a header, what we do not use __archive_read_seek() here is
|
||||
* due to a bidding performance.
|
||||
* signature. While find_pe_overlay can be performed without
|
||||
* performing a seek, find_elf_data_sec requires one,
|
||||
* thus a performance difference between the two is expected.
|
||||
*/
|
||||
if ((p[0] == 'M' && p[1] == 'Z') || memcmp(p, "\x7F\x45LF", 4) == 0) {
|
||||
ssize_t offset = SFX_MIN_ADDR;
|
||||
const ssize_t min_addr = p[0] == 'M' ? find_pe_overlay(a) :
|
||||
find_elf_data_sec(a);
|
||||
ssize_t offset = min_addr;
|
||||
ssize_t window = 4096;
|
||||
ssize_t bytes_avail;
|
||||
while (offset + window <= (SFX_MAX_ADDR)) {
|
||||
while (offset + window <= (min_addr + SFX_MAX_OFFSET)) {
|
||||
const char *buff = __archive_read_ahead(a,
|
||||
offset + window, &bytes_avail);
|
||||
if (buff == NULL) {
|
||||
@@ -580,21 +608,14 @@ check_7zip_header_in_sfx(const char *p)
|
||||
}
|
||||
|
||||
static int
|
||||
skip_sfx(struct archive_read *a, ssize_t bytes_avail)
|
||||
skip_sfx(struct archive_read *a, const ssize_t min_addr)
|
||||
{
|
||||
const void *h;
|
||||
const char *p, *q;
|
||||
size_t skip, offset;
|
||||
ssize_t bytes, window;
|
||||
|
||||
/*
|
||||
* If bytes_avail > SFX_MIN_ADDR we do not have to call
|
||||
* __archive_read_seek() at this time since we have
|
||||
* already had enough data.
|
||||
*/
|
||||
if (bytes_avail > SFX_MIN_ADDR)
|
||||
__archive_read_consume(a, SFX_MIN_ADDR);
|
||||
else if (__archive_read_seek(a, SFX_MIN_ADDR, SEEK_SET) < 0)
|
||||
if (__archive_read_seek(a, min_addr, SEEK_SET) < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
|
||||
offset = 0;
|
||||
@@ -627,7 +648,7 @@ skip_sfx(struct archive_read *a, ssize_t bytes_avail)
|
||||
(struct _7zip *)a->format->data;
|
||||
skip = p - (const char *)h;
|
||||
__archive_read_consume(a, skip);
|
||||
zip->seek_base = SFX_MIN_ADDR + offset + skip;
|
||||
zip->seek_base = min_addr + offset + skip;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
p += step;
|
||||
@@ -644,6 +665,207 @@ skip_sfx(struct archive_read *a, ssize_t bytes_avail)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
find_pe_overlay(struct archive_read *a)
|
||||
{
|
||||
const char *h;
|
||||
ssize_t bytes, max_offset, offset, sec_end;
|
||||
ssize_t opt_hdr_sz, sec_cnt;
|
||||
|
||||
for (;;) {
|
||||
/*
|
||||
* Read Dos header to find e_lfanew
|
||||
*/
|
||||
h = __archive_read_ahead(a, PE_DOS_HDR_LEN, &bytes);
|
||||
if (h == NULL || h[0] != 'M' || h[1] != 'Z') {
|
||||
break;
|
||||
}
|
||||
offset = archive_le32dec(h + PE_DOS_HDR_ELFANEW_OFFSET);
|
||||
|
||||
/*
|
||||
* Read COFF header to find opt header size and sec cnt
|
||||
*/
|
||||
if (bytes < offset + PE_COFF_HDR_LEN) {
|
||||
h = __archive_read_ahead(a, offset + PE_COFF_HDR_LEN,
|
||||
&bytes);
|
||||
if (h == NULL || h[offset] != 'P' ||
|
||||
h[offset + 1] != 'E') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
sec_cnt = archive_le16dec(
|
||||
h + offset + PE_COFF_HDR_SEC_CNT_OFFSET);
|
||||
opt_hdr_sz = archive_le16dec(
|
||||
h + offset + PE_COFF_HDR_OPT_SZ_OFFSET);
|
||||
|
||||
/*
|
||||
* Skip optional header
|
||||
*/
|
||||
if (opt_hdr_sz != 0) {
|
||||
offset += PE_COFF_HDR_LEN + opt_hdr_sz;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Traverse sec table to find max raw offset (i.e., overlay)
|
||||
*/
|
||||
if (bytes < offset + sec_cnt * PE_SEC_HDR_LEN) {
|
||||
h = __archive_read_ahead(a,
|
||||
offset + sec_cnt * PE_SEC_HDR_LEN, NULL);
|
||||
if (h == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
max_offset = offset;
|
||||
while (sec_cnt > 0) {
|
||||
sec_end = archive_le32dec(
|
||||
h + offset + PE_SEC_HDR_RAW_SZ_OFFSET) +
|
||||
archive_le32dec(
|
||||
h + offset + PE_SEC_HDR_RAW_ADDR_OFFSET);
|
||||
if (sec_end > max_offset) {
|
||||
max_offset = sec_end;
|
||||
}
|
||||
offset += PE_SEC_HDR_LEN;
|
||||
sec_cnt--;
|
||||
}
|
||||
return (max_offset);
|
||||
}
|
||||
|
||||
/*
|
||||
* If encounter any weirdness, revert to old brute-force style search
|
||||
*/
|
||||
return (SFX_MIN_ADDR);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
find_elf_data_sec(struct archive_read *a)
|
||||
{
|
||||
const char *h;
|
||||
char big_endian, format_64;
|
||||
ssize_t bytes, min_addr = SFX_MIN_ADDR;
|
||||
uint64_t e_shoff, strtab_offset, strtab_size;
|
||||
uint16_t e_shentsize, e_shnum, e_shstrndx;
|
||||
uint16_t (*dec16)(const void *);
|
||||
uint32_t (*dec32)(const void *);
|
||||
uint64_t (*dec64)(const void *);
|
||||
|
||||
for (;;) {
|
||||
/*
|
||||
* Read Elf header to find bitness & endianness
|
||||
*/
|
||||
h = __archive_read_ahead(a, ELF_HDR_MIN_LEN, &bytes);
|
||||
if (h == NULL || memcmp(h, "\x7F\x45LF", 4) != 0) {
|
||||
break;
|
||||
}
|
||||
format_64 = h[ELF_HDR_EI_CLASS_OFFSET] == 0x2;
|
||||
big_endian = h[ELF_HDR_EI_DATA_OFFSET] == 0x2;
|
||||
if (big_endian) {
|
||||
dec16 = &archive_be16dec;
|
||||
dec32 = &archive_be32dec;
|
||||
dec64 = &archive_be64dec;
|
||||
} else {
|
||||
dec16 = &archive_le16dec;
|
||||
dec32 = &archive_le32dec;
|
||||
dec64 = &archive_le64dec;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read section header table info
|
||||
*/
|
||||
if (format_64) {
|
||||
e_shoff = (*dec64)(h + 0x28);
|
||||
e_shentsize = (*dec16)(h + 0x3A);
|
||||
e_shnum = (*dec16)(h + 0x3C);
|
||||
e_shstrndx = (*dec16)(h + 0x3E);
|
||||
if (e_shnum < e_shstrndx || e_shentsize < 0x28)
|
||||
break;
|
||||
|
||||
} else {
|
||||
e_shoff = (*dec32)(h + 0x20);
|
||||
e_shentsize = (*dec16)(h + 0x2E);
|
||||
e_shnum = (*dec16)(h + 0x30);
|
||||
e_shstrndx = (*dec16)(h + 0x32);
|
||||
if (e_shnum < e_shstrndx || e_shentsize < 0x18)
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reading the section table to find strtab section
|
||||
*/
|
||||
if (__archive_read_seek(a, e_shoff, SEEK_SET) < 0) {
|
||||
break;
|
||||
}
|
||||
h = __archive_read_ahead(a, (size_t)e_shnum * (size_t)e_shentsize, NULL);
|
||||
if (h == NULL) {
|
||||
break;
|
||||
}
|
||||
if (format_64) {
|
||||
strtab_offset = (*dec64)(
|
||||
h + e_shstrndx * e_shentsize + 0x18);
|
||||
strtab_size = (*dec64)(
|
||||
h + e_shstrndx * e_shentsize + 0x20);
|
||||
} else {
|
||||
strtab_offset = (*dec32)(
|
||||
h + e_shstrndx * e_shentsize + 0x10);
|
||||
strtab_size = (*dec32)(
|
||||
h + e_shstrndx * e_shentsize + 0x14);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the STRTAB section to find the .data offset
|
||||
*/
|
||||
if (__archive_read_seek(a, strtab_offset, SEEK_SET) < 0) {
|
||||
break;
|
||||
}
|
||||
h = __archive_read_ahead(a, strtab_size, NULL);
|
||||
if (h == NULL) {
|
||||
break;
|
||||
}
|
||||
ssize_t data_sym_offset = -1;
|
||||
for (size_t offset = 0; offset < strtab_size - 6; offset++) {
|
||||
if (memcmp(h + offset, ".data\00", 6) == 0) {
|
||||
data_sym_offset = offset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (data_sym_offset == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the section with the .data name
|
||||
*/
|
||||
if (__archive_read_seek(a, e_shoff, SEEK_SET) < 0) {
|
||||
break;
|
||||
}
|
||||
h = __archive_read_ahead(a, (size_t)e_shnum * (size_t)e_shentsize, NULL);
|
||||
if (h == NULL) {
|
||||
break;
|
||||
}
|
||||
ssize_t sec_tbl_offset = 0, name_offset;
|
||||
while (e_shnum > 0) {
|
||||
name_offset = (*dec32)(h + sec_tbl_offset);
|
||||
if (name_offset == data_sym_offset) {
|
||||
if (format_64) {
|
||||
min_addr = (*dec64)(
|
||||
h + sec_tbl_offset + 0x18);
|
||||
} else {
|
||||
min_addr = (*dec32)(
|
||||
h + sec_tbl_offset + 0x10);
|
||||
}
|
||||
break;
|
||||
}
|
||||
sec_tbl_offset += e_shentsize;
|
||||
e_shnum--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
__archive_read_seek(a, 0, SEEK_SET);
|
||||
return (min_addr);
|
||||
}
|
||||
|
||||
static int
|
||||
archive_read_format_7zip_read_header(struct archive_read *a,
|
||||
struct archive_entry *entry)
|
||||
@@ -770,7 +992,7 @@ archive_read_format_7zip_read_header(struct archive_read *a,
|
||||
/* allocate for ",rdonly,hidden,system" */
|
||||
fflags_text = malloc(22 * sizeof(*fflags_text));
|
||||
if (fflags_text != NULL) {
|
||||
ptr = fflags_text;
|
||||
ptr = fflags_text;
|
||||
if (zip_entry->attr & FILE_ATTRIBUTE_READONLY) {
|
||||
strcpy(ptr, ",rdonly");
|
||||
ptr = ptr + 7;
|
||||
@@ -1109,7 +1331,9 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
|
||||
if (coder2->codec != _7Z_X86 &&
|
||||
coder2->codec != _7Z_X86_BCJ2 &&
|
||||
coder2->codec != _7Z_ARM &&
|
||||
coder2->codec != _7Z_ARM64) {
|
||||
coder2->codec != _7Z_ARM64 &&
|
||||
coder2->codec != _7Z_POWERPC &&
|
||||
coder2->codec != _7Z_SPARC) {
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Unsupported filter %lx for %lx",
|
||||
@@ -1223,6 +1447,12 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
|
||||
filters[fi].id = LZMA_FILTER_ARM64;
|
||||
fi++;
|
||||
break;
|
||||
#endif
|
||||
#ifdef LZMA_FILTER_RISCV
|
||||
case _7Z_RISCV:
|
||||
filters[fi].id = LZMA_FILTER_RISCV;
|
||||
fi++;
|
||||
break;
|
||||
#endif
|
||||
case _7Z_SPARC:
|
||||
filters[fi].id = LZMA_FILTER_SPARC;
|
||||
@@ -1396,6 +1626,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
|
||||
case _7Z_ARM:
|
||||
case _7Z_ARMTHUMB:
|
||||
case _7Z_ARM64:
|
||||
case _7Z_RISCV:
|
||||
case _7Z_SPARC:
|
||||
case _7Z_DELTA:
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
@@ -1708,6 +1939,10 @@ decompress(struct archive_read *a, struct _7zip *zip,
|
||||
*outbytes = arm_Convert(zip, buff, *outbytes);
|
||||
} else if (zip->codec2 == _7Z_ARM64) {
|
||||
*outbytes = arm64_Convert(zip, buff, *outbytes);
|
||||
} else if (zip->codec2 == _7Z_SPARC) {
|
||||
*outbytes = sparc_Convert(zip, buff, *outbytes);
|
||||
} else if (zip->codec2 == _7Z_POWERPC) {
|
||||
*outbytes = powerpc_Convert(zip, buff, *outbytes);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2841,23 +3076,6 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
|
||||
return (0);
|
||||
}
|
||||
|
||||
#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
|
||||
static void
|
||||
fileTimeToUtc(uint64_t fileTime, time_t *timep, long *ns)
|
||||
{
|
||||
|
||||
if (fileTime >= EPOC_TIME) {
|
||||
fileTime -= EPOC_TIME;
|
||||
/* milli seconds base */
|
||||
*timep = (time_t)(fileTime / 10000000);
|
||||
/* nano seconds base */
|
||||
*ns = (long)(fileTime % 10000000) * 100;
|
||||
} else {
|
||||
*timep = 0;
|
||||
*ns = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
read_Times(struct archive_read *a, struct _7z_header_info *h, int type)
|
||||
{
|
||||
@@ -2900,19 +3118,19 @@ read_Times(struct archive_read *a, struct _7z_header_info *h, int type)
|
||||
goto failed;
|
||||
switch (type) {
|
||||
case kCTime:
|
||||
fileTimeToUtc(archive_le64dec(p),
|
||||
ntfs_to_unix(archive_le64dec(p),
|
||||
&(entries[i].ctime),
|
||||
&(entries[i].ctime_ns));
|
||||
entries[i].flg |= CTIME_IS_SET;
|
||||
break;
|
||||
case kATime:
|
||||
fileTimeToUtc(archive_le64dec(p),
|
||||
ntfs_to_unix(archive_le64dec(p),
|
||||
&(entries[i].atime),
|
||||
&(entries[i].atime_ns));
|
||||
entries[i].flg |= ATIME_IS_SET;
|
||||
break;
|
||||
case kMTime:
|
||||
fileTimeToUtc(archive_le64dec(p),
|
||||
ntfs_to_unix(archive_le64dec(p),
|
||||
&(entries[i].mtime),
|
||||
&(entries[i].mtime_ns));
|
||||
entries[i].flg |= MTIME_IS_SET;
|
||||
@@ -3007,7 +3225,9 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip,
|
||||
|
||||
if ((p[0] == 'M' && p[1] == 'Z') || memcmp(p, "\x7F\x45LF", 4) == 0) {
|
||||
/* This is an executable ? Must be self-extracting... */
|
||||
r = skip_sfx(a, bytes_avail);
|
||||
const ssize_t min_addr = p[0] == 'M' ? find_pe_overlay(a) :
|
||||
find_elf_data_sec(a);
|
||||
r = skip_sfx(a, min_addr);
|
||||
if (r < ARCHIVE_WARN)
|
||||
return (r);
|
||||
if ((p = __archive_read_ahead(a, 32, &bytes_avail)) == NULL)
|
||||
@@ -4007,6 +4227,121 @@ arm64_Convert(struct _7zip *zip, uint8_t *buf, size_t size)
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
sparc_Convert(struct _7zip *zip, uint8_t *buf, size_t size)
|
||||
{
|
||||
// This function was adapted from
|
||||
// static size_t bcj_sparc(struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
// in https://git.tukaani.org/xz-embedded.git
|
||||
|
||||
/*
|
||||
* Branch/Call/Jump (BCJ) filter decoders
|
||||
*
|
||||
* Authors: Lasse Collin <lasse.collin@tukaani.org>
|
||||
* Igor Pavlov <https://7-zip.org/>
|
||||
*
|
||||
* Copyright (C) The XZ Embedded authors and contributors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this
|
||||
* software for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
size_t i;
|
||||
uint32_t instr;
|
||||
|
||||
size &= ~(size_t)3;
|
||||
|
||||
for (i = 0; i < size; i += 4) {
|
||||
instr = (uint32_t)(buf[i] << 24)
|
||||
| ((uint32_t)buf[i+1] << 16)
|
||||
| ((uint32_t)buf[i+2] << 8)
|
||||
| (uint32_t)buf[i+3];
|
||||
|
||||
if ((instr >> 22) == 0x100 || (instr >> 22) == 0x1FF) {
|
||||
instr <<= 2;
|
||||
instr -= zip->bcj_ip + (uint32_t)i;
|
||||
instr >>= 2;
|
||||
instr = ((uint32_t)0x40000000 - (instr & 0x400000))
|
||||
| 0x40000000 | (instr & 0x3FFFFF);
|
||||
|
||||
buf[i] = (uint8_t)(instr >> 24);
|
||||
buf[i+1] = (uint8_t)(instr >> 16);
|
||||
buf[i+2] = (uint8_t)(instr >> 8);
|
||||
buf[i+3] = (uint8_t)instr;
|
||||
}
|
||||
}
|
||||
|
||||
zip->bcj_ip += (uint32_t)i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static size_t
|
||||
powerpc_Convert(struct _7zip *zip, uint8_t *buf, size_t size)
|
||||
{
|
||||
// This function was adapted from
|
||||
// static size_t powerpc_code(void *simple, uint32_t now_pos, bool is_encoder, uint8_t *buffer, size_t size)
|
||||
// in https://git.tukaani.org/xz.git
|
||||
|
||||
/*
|
||||
* Filter for PowerPC (big endian) binaries
|
||||
*
|
||||
* Authors: Igor Pavlov
|
||||
* Lasse Collin
|
||||
*
|
||||
* Copyright (C) The XZ Utils authors and contributors
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this
|
||||
* software for any purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
|
||||
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
size &= ~(size_t)3;
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < size; i += 4) {
|
||||
// PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link)
|
||||
if ((buf[i] >> 2) == 0x12
|
||||
&& ((buf[i + 3] & 3) == 1)) {
|
||||
|
||||
const uint32_t src
|
||||
= (((uint32_t)(buf[i + 0]) & 3) << 24)
|
||||
| ((uint32_t)(buf[i + 1]) << 16)
|
||||
| ((uint32_t)(buf[i + 2]) << 8)
|
||||
| ((uint32_t)(buf[i + 3]) & ~UINT32_C(3));
|
||||
|
||||
uint32_t dest = src - (zip->bcj_ip + (uint32_t)(i));
|
||||
|
||||
buf[i + 0] = 0x48 | ((dest >> 24) & 0x03);
|
||||
buf[i + 1] = (dest >> 16);
|
||||
buf[i + 2] = (dest >> 8);
|
||||
buf[i + 3] &= 0x03;
|
||||
buf[i + 3] |= dest;
|
||||
}
|
||||
}
|
||||
|
||||
zip->bcj_ip += (uint32_t)i;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Brought from LZMA SDK.
|
||||
*
|
||||
@@ -4029,8 +4364,17 @@ arm64_Convert(struct _7zip *zip, uint8_t *buf, size_t size)
|
||||
|
||||
#define RC_READ_BYTE (*buffer++)
|
||||
#define RC_TEST { if (buffer == bufferLim) return SZ_ERROR_DATA; }
|
||||
#define RC_INIT2 zip->bcj2_code = 0; zip->bcj2_range = 0xFFFFFFFF; \
|
||||
{ int ii; for (ii = 0; ii < 5; ii++) { RC_TEST; zip->bcj2_code = (zip->bcj2_code << 8) | RC_READ_BYTE; }}
|
||||
#define RC_INIT2 do { \
|
||||
zip->bcj2_code = 0; \
|
||||
zip->bcj2_range = 0xFFFFFFFF; \
|
||||
{ \
|
||||
int ii; \
|
||||
for (ii = 0; ii < 5; ii++) { \
|
||||
RC_TEST; \
|
||||
zip->bcj2_code = (zip->bcj2_code << 8) | RC_READ_BYTE; \
|
||||
} \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define NORMALIZE if (zip->bcj2_range < kTopValue) { RC_TEST; zip->bcj2_range <<= 8; zip->bcj2_code = (zip->bcj2_code << 8) | RC_READ_BYTE; }
|
||||
|
||||
@@ -4177,4 +4521,3 @@ Bcj2_Decode(struct _7zip *zip, uint8_t *outBuf, size_t outSize)
|
||||
|
||||
return ((ssize_t)outPos);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,49 +41,34 @@ archive_read_support_format_by_code(struct archive *a, int format_code)
|
||||
switch (format_code & ARCHIVE_FORMAT_BASE_MASK) {
|
||||
case ARCHIVE_FORMAT_7ZIP:
|
||||
return archive_read_support_format_7zip(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_AR:
|
||||
return archive_read_support_format_ar(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_CAB:
|
||||
return archive_read_support_format_cab(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_CPIO:
|
||||
return archive_read_support_format_cpio(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_EMPTY:
|
||||
return archive_read_support_format_empty(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_ISO9660:
|
||||
return archive_read_support_format_iso9660(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_LHA:
|
||||
return archive_read_support_format_lha(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_MTREE:
|
||||
return archive_read_support_format_mtree(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_RAR:
|
||||
return archive_read_support_format_rar(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_RAR_V5:
|
||||
return archive_read_support_format_rar5(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_RAW:
|
||||
return archive_read_support_format_raw(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_TAR:
|
||||
return archive_read_support_format_tar(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_WARC:
|
||||
return archive_read_support_format_warc(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_XAR:
|
||||
return archive_read_support_format_xar(a);
|
||||
break;
|
||||
case ARCHIVE_FORMAT_ZIP:
|
||||
return archive_read_support_format_zip(a);
|
||||
break;
|
||||
}
|
||||
archive_set_error(a, ARCHIVE_ERRNO_PROGRAMMER,
|
||||
"Invalid format code specified");
|
||||
|
||||
@@ -189,6 +189,7 @@ struct cpio {
|
||||
};
|
||||
|
||||
static int64_t atol16(const char *, unsigned);
|
||||
static uint64_t atol16u(const char *, unsigned);
|
||||
static int64_t atol8(const char *, unsigned);
|
||||
static int archive_read_format_cpio_bid(struct archive_read *, int);
|
||||
static int archive_read_format_cpio_options(struct archive_read *,
|
||||
@@ -835,6 +836,7 @@ header_afiol(struct archive_read *a, struct cpio *cpio,
|
||||
struct archive_entry *entry, size_t *namelength, size_t *name_pad)
|
||||
{
|
||||
int64_t t;
|
||||
uint64_t u;
|
||||
const void *h;
|
||||
const char *header;
|
||||
|
||||
@@ -851,12 +853,12 @@ header_afiol(struct archive_read *a, struct cpio *cpio,
|
||||
|
||||
archive_entry_set_dev(entry,
|
||||
(dev_t)atol16(header + afiol_dev_offset, afiol_dev_size));
|
||||
t = atol16(header + afiol_ino_offset, afiol_ino_size);
|
||||
if (t < 0) {
|
||||
archive_set_error(&a->archive, 0, "Nonsensical ino value");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
archive_entry_set_ino(entry, t);
|
||||
u = atol16u(header + afiol_ino_offset, afiol_ino_size);
|
||||
#if ARCHIVE_VERSION_NUMBER < 4000000
|
||||
archive_entry_set_ino(entry, (int64_t)(u & INT64_MAX));
|
||||
#else
|
||||
archive_entry_set_ino(entry, u);
|
||||
#endif
|
||||
archive_entry_set_mode(entry,
|
||||
(mode_t)atol8(header + afiol_mode_offset, afiol_mode_size));
|
||||
archive_entry_set_uid(entry, atol16(header + afiol_uid_offset, afiol_uid_size));
|
||||
@@ -1030,6 +1032,12 @@ atol8(const char *p, unsigned char_cnt)
|
||||
|
||||
static int64_t
|
||||
atol16(const char *p, unsigned char_cnt)
|
||||
{
|
||||
return ((int64_t)atol16u(p, char_cnt));
|
||||
}
|
||||
|
||||
static uint64_t
|
||||
atol16u(const char *p, unsigned char_cnt)
|
||||
{
|
||||
uint64_t l;
|
||||
int digit;
|
||||
@@ -1048,7 +1056,7 @@ atol16(const char *p, unsigned char_cnt)
|
||||
l <<= 4;
|
||||
l |= digit;
|
||||
}
|
||||
return ((int64_t)l);
|
||||
return (l);
|
||||
}
|
||||
|
||||
static int
|
||||
|
||||
@@ -1429,7 +1429,7 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
|
||||
* information first, then store all file bodies. */
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Ignoring out-of-order file @%jx (%s) %jd < %jd",
|
||||
(intmax_t)file->number,
|
||||
(uintmax_t)file->number,
|
||||
iso9660->pathname.s,
|
||||
(intmax_t)file->offset,
|
||||
(intmax_t)iso9660->current_position);
|
||||
@@ -2273,7 +2273,7 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
|
||||
if (version == 1) {
|
||||
if (data_length >= 8)
|
||||
file->mode
|
||||
= toi(data, 4);
|
||||
= (__LA_MODE_T)toi(data, 4);
|
||||
if (data_length >= 16)
|
||||
file->nlinks
|
||||
= toi(data + 8, 4);
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "archive_entry_locale.h"
|
||||
#include "archive_private.h"
|
||||
#include "archive_read_private.h"
|
||||
#include "archive_time_private.h"
|
||||
#include "archive_endian.h"
|
||||
|
||||
|
||||
@@ -162,12 +163,12 @@ struct lha {
|
||||
#define ATIME_IS_SET 2
|
||||
#define UNIX_MODE_IS_SET 4
|
||||
#define CRC_IS_SET 8
|
||||
time_t birthtime;
|
||||
long birthtime_tv_nsec;
|
||||
time_t mtime;
|
||||
long mtime_tv_nsec;
|
||||
time_t atime;
|
||||
long atime_tv_nsec;
|
||||
int64_t birthtime;
|
||||
uint32_t birthtime_tv_nsec;
|
||||
int64_t mtime;
|
||||
uint32_t mtime_tv_nsec;
|
||||
int64_t atime;
|
||||
uint32_t atime_tv_nsec;
|
||||
mode_t mode;
|
||||
int64_t uid;
|
||||
int64_t gid;
|
||||
@@ -230,8 +231,6 @@ static int lha_read_file_extended_header(struct archive_read *,
|
||||
struct lha *, uint16_t *, int, uint64_t, size_t *);
|
||||
static size_t lha_check_header_format(const void *);
|
||||
static int lha_skip_sfx(struct archive_read *);
|
||||
static time_t lha_dos_time(const unsigned char *);
|
||||
static time_t lha_win_time(uint64_t, long *);
|
||||
static unsigned char lha_calcsum(unsigned char, const void *,
|
||||
int, size_t);
|
||||
static int lha_parse_linkname(struct archive_wstring *,
|
||||
@@ -819,7 +818,7 @@ lha_read_file_header_0(struct archive_read *a, struct lha *lha)
|
||||
headersum = p[H0_HEADER_SUM_OFFSET];
|
||||
lha->compsize = archive_le32dec(p + H0_COMP_SIZE_OFFSET);
|
||||
lha->origsize = archive_le32dec(p + H0_ORIG_SIZE_OFFSET);
|
||||
lha->mtime = lha_dos_time(p + H0_DOS_TIME_OFFSET);
|
||||
lha->mtime = dos_to_unix(archive_le32dec(p + H0_DOS_TIME_OFFSET));
|
||||
namelen = p[H0_NAME_LEN_OFFSET];
|
||||
extdsize = (int)lha->header_size - H0_FIXED_SIZE - namelen;
|
||||
if ((namelen > 221 || extdsize < 0) && extdsize != -2) {
|
||||
@@ -919,7 +918,7 @@ lha_read_file_header_1(struct archive_read *a, struct lha *lha)
|
||||
/* Note: An extended header size is included in a compsize. */
|
||||
lha->compsize = archive_le32dec(p + H1_COMP_SIZE_OFFSET);
|
||||
lha->origsize = archive_le32dec(p + H1_ORIG_SIZE_OFFSET);
|
||||
lha->mtime = lha_dos_time(p + H1_DOS_TIME_OFFSET);
|
||||
lha->mtime = dos_to_unix(archive_le32dec(p + H1_DOS_TIME_OFFSET));
|
||||
namelen = p[H1_NAME_LEN_OFFSET];
|
||||
/* Calculate a padding size. The result will be normally 0 only(?) */
|
||||
padding = ((int)lha->header_size) - H1_FIXED_SIZE - namelen;
|
||||
@@ -1090,7 +1089,7 @@ lha_read_file_header_3(struct archive_read *a, struct lha *lha)
|
||||
|
||||
if (archive_le16dec(p + H3_FIELD_LEN_OFFSET) != 4)
|
||||
goto invalid;
|
||||
lha->header_size =archive_le32dec(p + H3_HEADER_SIZE_OFFSET);
|
||||
lha->header_size = archive_le32dec(p + H3_HEADER_SIZE_OFFSET);
|
||||
lha->compsize = archive_le32dec(p + H3_COMP_SIZE_OFFSET);
|
||||
lha->origsize = archive_le32dec(p + H3_ORIG_SIZE_OFFSET);
|
||||
lha->mtime = archive_le32dec(p + H3_TIME_OFFSET);
|
||||
@@ -1326,16 +1325,16 @@ lha_read_file_extended_header(struct archive_read *a, struct lha *lha,
|
||||
break;
|
||||
case EXT_TIMESTAMP:
|
||||
if (datasize == (sizeof(uint64_t) * 3)) {
|
||||
lha->birthtime = lha_win_time(
|
||||
archive_le64dec(extdheader),
|
||||
ntfs_to_unix(archive_le64dec(extdheader),
|
||||
&lha->birthtime,
|
||||
&lha->birthtime_tv_nsec);
|
||||
extdheader += sizeof(uint64_t);
|
||||
lha->mtime = lha_win_time(
|
||||
archive_le64dec(extdheader),
|
||||
ntfs_to_unix(archive_le64dec(extdheader),
|
||||
&lha->mtime,
|
||||
&lha->mtime_tv_nsec);
|
||||
extdheader += sizeof(uint64_t);
|
||||
lha->atime = lha_win_time(
|
||||
archive_le64dec(extdheader),
|
||||
ntfs_to_unix(archive_le64dec(extdheader),
|
||||
&lha->atime,
|
||||
&lha->atime_tv_nsec);
|
||||
lha->setflag |= BIRTHTIME_IS_SET |
|
||||
ATIME_IS_SET;
|
||||
@@ -1716,45 +1715,6 @@ lha_parse_linkname(struct archive_wstring *linkname,
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Convert an MSDOS-style date/time into Unix-style time. */
|
||||
static time_t
|
||||
lha_dos_time(const unsigned char *p)
|
||||
{
|
||||
int msTime, msDate;
|
||||
struct tm ts;
|
||||
|
||||
msTime = archive_le16dec(p);
|
||||
msDate = archive_le16dec(p+2);
|
||||
|
||||
memset(&ts, 0, sizeof(ts));
|
||||
ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */
|
||||
ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */
|
||||
ts.tm_mday = msDate & 0x1f; /* Day of month. */
|
||||
ts.tm_hour = (msTime >> 11) & 0x1f;
|
||||
ts.tm_min = (msTime >> 5) & 0x3f;
|
||||
ts.tm_sec = (msTime << 1) & 0x3e;
|
||||
ts.tm_isdst = -1;
|
||||
return (mktime(&ts));
|
||||
}
|
||||
|
||||
/* Convert an MS-Windows-style date/time into Unix-style time. */
|
||||
static time_t
|
||||
lha_win_time(uint64_t wintime, long *ns)
|
||||
{
|
||||
#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
|
||||
|
||||
if (wintime >= EPOC_TIME) {
|
||||
wintime -= EPOC_TIME; /* 1970-01-01 00:00:00 (UTC) */
|
||||
if (ns != NULL)
|
||||
*ns = (long)(wintime % 10000000) * 100;
|
||||
return (wintime / 10000000);
|
||||
} else {
|
||||
if (ns != NULL)
|
||||
*ns = 0;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
lha_calcsum(unsigned char sum, const void *pp, int offset, size_t size)
|
||||
{
|
||||
@@ -2917,4 +2877,3 @@ lzh_decode_huffman(struct huffman *hf, unsigned rbits)
|
||||
/* This bit pattern needs to be found out at a huffman tree. */
|
||||
return (lzh_decode_huffman_tree(hf, rbits, c));
|
||||
}
|
||||
|
||||
|
||||
@@ -335,8 +335,8 @@ struct rar
|
||||
int found_first_header;
|
||||
char has_endarc_header;
|
||||
struct data_block_offsets *dbo;
|
||||
unsigned int cursor;
|
||||
unsigned int nodes;
|
||||
size_t cursor;
|
||||
size_t nodes;
|
||||
char filename_must_match;
|
||||
|
||||
/* LZSS members */
|
||||
@@ -451,7 +451,7 @@ static int read_filter(struct archive_read *, int64_t *);
|
||||
static int rar_decode_byte(struct archive_read*, uint8_t *);
|
||||
static int execute_filter(struct archive_read*, struct rar_filter *,
|
||||
struct rar_virtual_machine *, size_t);
|
||||
static int copy_from_lzss_window(struct archive_read *, void *, int64_t, int);
|
||||
static int copy_from_lzss_window(struct archive_read *, uint8_t *, int64_t, int);
|
||||
static inline void vm_write_32(struct rar_virtual_machine*, size_t, uint32_t);
|
||||
static inline uint32_t vm_read_32(struct rar_virtual_machine*, size_t);
|
||||
|
||||
@@ -475,7 +475,7 @@ static inline uint32_t vm_read_32(struct rar_virtual_machine*, size_t);
|
||||
((rar_br_has(br, (n)) || rar_br_fillup(a, br)) || rar_br_has(br, (n)))
|
||||
/* Notify how many bits we consumed. */
|
||||
#define rar_br_consume(br, n) ((br)->cache_avail -= (n))
|
||||
#define rar_br_consume_unalined_bits(br) ((br)->cache_avail &= ~7)
|
||||
#define rar_br_consume_unaligned_bits(br) ((br)->cache_avail &= ~7)
|
||||
|
||||
static const uint32_t cache_masks[] = {
|
||||
0x00000000, 0x00000001, 0x00000003, 0x00000007,
|
||||
@@ -741,11 +741,11 @@ archive_read_support_format_rar(struct archive *_a)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Until enough data has been read, we cannot tell about
|
||||
* any encrypted entries yet.
|
||||
*/
|
||||
rar->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
|
||||
/*
|
||||
* Until enough data has been read, we cannot tell about
|
||||
* any encrypted entries yet.
|
||||
*/
|
||||
rar->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
|
||||
|
||||
r = __archive_read_register_format(a,
|
||||
rar,
|
||||
@@ -768,21 +768,21 @@ archive_read_support_format_rar(struct archive *_a)
|
||||
static int
|
||||
archive_read_support_format_rar_capabilities(struct archive_read * a)
|
||||
{
|
||||
(void)a; /* UNUSED */
|
||||
return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
|
||||
| ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
|
||||
(void)a; /* UNUSED */
|
||||
return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
|
||||
| ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
|
||||
}
|
||||
|
||||
static int
|
||||
archive_read_format_rar_has_encrypted_entries(struct archive_read *_a)
|
||||
{
|
||||
if (_a && _a->format) {
|
||||
struct rar * rar = (struct rar *)_a->format->data;
|
||||
if (rar) {
|
||||
return rar->has_encrypted_entries;
|
||||
}
|
||||
}
|
||||
return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
|
||||
if (_a && _a->format) {
|
||||
struct rar * rar = (struct rar *)_a->format->data;
|
||||
if (rar) {
|
||||
return rar->has_encrypted_entries;
|
||||
}
|
||||
}
|
||||
return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
|
||||
}
|
||||
|
||||
|
||||
@@ -793,7 +793,7 @@ archive_read_format_rar_bid(struct archive_read *a, int best_bid)
|
||||
|
||||
/* If there's already a bid > 30, we'll never win. */
|
||||
if (best_bid > 30)
|
||||
return (-1);
|
||||
return (-1);
|
||||
|
||||
if ((p = __archive_read_ahead(a, 7, NULL)) == NULL)
|
||||
return (-1);
|
||||
@@ -865,7 +865,7 @@ skip_sfx(struct archive_read *a)
|
||||
}
|
||||
skip = p - (const char *)h;
|
||||
__archive_read_consume(a, skip);
|
||||
total += skip;
|
||||
total += skip;
|
||||
}
|
||||
fatal:
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
@@ -910,7 +910,7 @@ archive_read_format_rar_read_header(struct archive_read *a,
|
||||
const void *h;
|
||||
const char *p;
|
||||
struct rar *rar;
|
||||
size_t skip;
|
||||
int64_t skip;
|
||||
char head_type;
|
||||
int ret;
|
||||
unsigned flags;
|
||||
@@ -930,7 +930,7 @@ archive_read_format_rar_read_header(struct archive_read *a,
|
||||
* as well.
|
||||
*/
|
||||
if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
|
||||
rar->has_encrypted_entries = 0;
|
||||
rar->has_encrypted_entries = 0;
|
||||
}
|
||||
|
||||
/* RAR files can be generated without EOF headers, so return ARCHIVE_EOF if
|
||||
@@ -953,8 +953,11 @@ archive_read_format_rar_read_header(struct archive_read *a,
|
||||
{
|
||||
unsigned long crc32_val;
|
||||
|
||||
if ((h = __archive_read_ahead(a, 7, NULL)) == NULL)
|
||||
if ((h = __archive_read_ahead(a, 7, NULL)) == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Failed to read next header.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
p = h;
|
||||
|
||||
head_type = p[2];
|
||||
@@ -972,7 +975,7 @@ archive_read_format_rar_read_header(struct archive_read *a,
|
||||
case MAIN_HEAD:
|
||||
rar->main_flags = archive_le16dec(p + 3);
|
||||
skip = archive_le16dec(p + 5);
|
||||
if (skip < 7 + sizeof(rar->reserved1) + sizeof(rar->reserved2)) {
|
||||
if ((size_t)skip < 7 + sizeof(rar->reserved1) + sizeof(rar->reserved2)) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Invalid header size");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -984,7 +987,8 @@ archive_read_format_rar_read_header(struct archive_read *a,
|
||||
memcpy(rar->reserved2, p + 7 + sizeof(rar->reserved1),
|
||||
sizeof(rar->reserved2));
|
||||
if (rar->main_flags & MHD_ENCRYPTVER) {
|
||||
if (skip < 7 + sizeof(rar->reserved1) + sizeof(rar->reserved2)+1) {
|
||||
if ((size_t)skip <
|
||||
7 + sizeof(rar->reserved1) + sizeof(rar->reserved2) + 1) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Invalid header size");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -1053,28 +1057,30 @@ archive_read_format_rar_read_header(struct archive_read *a,
|
||||
/* Skim the entire header and compute the CRC. */
|
||||
crc32_val = 0;
|
||||
while (skip > 0) {
|
||||
size_t to_read = skip;
|
||||
if (to_read > 32 * 1024)
|
||||
to_read = 32 * 1024;
|
||||
if ((h = __archive_read_ahead(a, to_read, NULL)) == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Bad RAR file");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
p = h;
|
||||
crc32_val = crc32(crc32_val, (const unsigned char *)p, (unsigned int)to_read);
|
||||
__archive_read_consume(a, to_read);
|
||||
skip -= to_read;
|
||||
unsigned to_read;
|
||||
if (skip > 32 * 1024)
|
||||
to_read = 32 * 1024;
|
||||
else
|
||||
to_read = (unsigned)skip;
|
||||
if ((h = __archive_read_ahead(a, to_read, NULL)) == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Bad RAR file");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
p = h;
|
||||
crc32_val = crc32(crc32_val, (const unsigned char *)p, to_read);
|
||||
__archive_read_consume(a, to_read);
|
||||
skip -= to_read;
|
||||
}
|
||||
if ((crc32_val & 0xffff) != crc32_expected) {
|
||||
#ifndef DONT_FAIL_ON_CRC_ERROR
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Header CRC error");
|
||||
return (ARCHIVE_FATAL);
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Header CRC error");
|
||||
return (ARCHIVE_FATAL);
|
||||
#endif
|
||||
}
|
||||
if (head_type == ENDARC_HEAD)
|
||||
return (ARCHIVE_EOF);
|
||||
return (ARCHIVE_EOF);
|
||||
break;
|
||||
|
||||
case NEWSUB_HEAD:
|
||||
@@ -1083,7 +1089,7 @@ archive_read_format_rar_read_header(struct archive_read *a,
|
||||
break;
|
||||
|
||||
default:
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Bad RAR file");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
@@ -1098,7 +1104,7 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
|
||||
int ret;
|
||||
|
||||
if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
|
||||
rar->has_encrypted_entries = 0;
|
||||
rar->has_encrypted_entries = 0;
|
||||
}
|
||||
|
||||
if (rar->bytes_unconsumed > 0) {
|
||||
@@ -1186,7 +1192,7 @@ archive_read_format_rar_seek_data(struct archive_read *a, int64_t offset,
|
||||
int whence)
|
||||
{
|
||||
int64_t client_offset, ret;
|
||||
unsigned int i;
|
||||
size_t i;
|
||||
struct rar *rar = (struct rar *)(a->format->data);
|
||||
|
||||
if (rar->compression_method == COMPRESS_METHOD_STORE)
|
||||
@@ -1433,7 +1439,11 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
}
|
||||
|
||||
if ((h = __archive_read_ahead(a, (size_t)header_size - 7, NULL)) == NULL)
|
||||
{
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Failed to read full header content.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
/* File Header CRC check. */
|
||||
crc32_computed = crc32(crc32_computed, h, (unsigned)(header_size - 7));
|
||||
@@ -1460,8 +1470,8 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
|
||||
if (rar->file_flags & FHD_PASSWORD)
|
||||
{
|
||||
archive_entry_set_is_data_encrypted(entry, 1);
|
||||
rar->has_encrypted_entries = 1;
|
||||
archive_entry_set_is_data_encrypted(entry, 1);
|
||||
rar->has_encrypted_entries = 1;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"RAR encryption support unavailable.");
|
||||
/* Since it is only the data part itself that is encrypted we can at least
|
||||
@@ -1506,10 +1516,23 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
*/
|
||||
if (head_type == NEWSUB_HEAD) {
|
||||
size_t distance = p - (const char *)h;
|
||||
if (rar->packed_size > INT64_MAX - header_size) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Extended header size too large.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
header_size += rar->packed_size;
|
||||
if ((uintmax_t)header_size > SIZE_MAX) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unable to read extended header data.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
/* Make sure we have the extended data. */
|
||||
if ((h = __archive_read_ahead(a, (size_t)header_size - 7, NULL)) == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
if ((h = __archive_read_ahead(a, (size_t)header_size - 7, NULL)) == NULL) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Failed to read extended header data.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
p = h;
|
||||
endp = p + header_size - 7;
|
||||
p += distance;
|
||||
@@ -1670,6 +1693,8 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
!memcmp(rar->filename, rar->filename_save, filename_size + 1))
|
||||
{
|
||||
__archive_read_consume(a, header_size - 7);
|
||||
rar->br.avail_in = 0;
|
||||
rar->br.next_in = NULL;
|
||||
rar->cursor++;
|
||||
if (rar->cursor >= rar->nodes)
|
||||
{
|
||||
@@ -1689,6 +1714,12 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
}
|
||||
if (rar->dbo[rar->cursor].start_offset < 0)
|
||||
{
|
||||
if (rar->packed_size > INT64_MAX - a->filter->position)
|
||||
{
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unable to store offsets.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
rar->dbo[rar->cursor].start_offset = a->filter->position;
|
||||
rar->dbo[rar->cursor].end_offset = rar->dbo[rar->cursor].start_offset +
|
||||
rar->packed_size;
|
||||
@@ -1745,6 +1776,11 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
}
|
||||
|
||||
__archive_read_consume(a, header_size - 7);
|
||||
if (rar->packed_size > INT64_MAX - a->filter->position) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unable to store offsets.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
rar->dbo[0].start_offset = a->filter->position;
|
||||
rar->dbo[0].end_offset = rar->dbo[0].start_offset + rar->packed_size;
|
||||
|
||||
@@ -1753,7 +1789,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
case OS_MSDOS:
|
||||
case OS_OS2:
|
||||
case OS_WIN32:
|
||||
rar->mode = archive_le32dec(file_header.file_attr);
|
||||
rar->mode = (__LA_MODE_T)archive_le32dec(file_header.file_attr);
|
||||
if (rar->mode & FILE_ATTRIBUTE_DIRECTORY)
|
||||
rar->mode = AE_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
|
||||
else
|
||||
@@ -1764,7 +1800,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
case OS_UNIX:
|
||||
case OS_MAC_OS:
|
||||
case OS_BEOS:
|
||||
rar->mode = archive_le32dec(file_header.file_attr);
|
||||
rar->mode = (__LA_MODE_T)archive_le32dec(file_header.file_attr);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1780,6 +1816,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
|
||||
rar->offset_outgoing = 0;
|
||||
rar->br.cache_avail = 0;
|
||||
rar->br.avail_in = 0;
|
||||
rar->br.next_in = NULL;
|
||||
rar->crc_calculated = 0;
|
||||
rar->entry_eof = 0;
|
||||
rar->valid = 1;
|
||||
@@ -1941,8 +1978,18 @@ read_symlink_stored(struct archive_read *a, struct archive_entry *entry,
|
||||
int ret = (ARCHIVE_OK);
|
||||
|
||||
rar = (struct rar *)(a->format->data);
|
||||
if ((h = rar_read_ahead(a, (size_t)rar->packed_size, NULL)) == NULL)
|
||||
if ((uintmax_t)rar->packed_size > SIZE_MAX)
|
||||
{
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unable to read link.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if ((h = rar_read_ahead(a, (size_t)rar->packed_size, NULL)) == NULL)
|
||||
{
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Failed to read link.");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
p = h;
|
||||
|
||||
if (archive_entry_copy_symlink_l(entry,
|
||||
@@ -2224,7 +2271,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
|
||||
|
||||
ret = expand(a, &end);
|
||||
if (ret != ARCHIVE_OK)
|
||||
return (ret);
|
||||
return (ret);
|
||||
|
||||
rar->bytes_uncopied = end - start;
|
||||
rar->filters.lastend = end;
|
||||
@@ -2276,7 +2323,7 @@ parse_codes(struct archive_read *a)
|
||||
free_codes(a);
|
||||
|
||||
/* Skip to the next byte */
|
||||
rar_br_consume_unalined_bits(br);
|
||||
rar_br_consume_unaligned_bits(br);
|
||||
|
||||
/* PPMd block flag */
|
||||
if (!rar_br_read_ahead(a, br, 1))
|
||||
@@ -2332,9 +2379,9 @@ parse_codes(struct archive_read *a)
|
||||
__archive_ppmd7_functions.Ppmd7_Construct(&rar->ppmd7_context);
|
||||
|
||||
if (rar->dictionary_size == 0) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Invalid zero dictionary size");
|
||||
return (ARCHIVE_FATAL);
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
if (!__archive_ppmd7_functions.Ppmd7_Alloc(&rar->ppmd7_context,
|
||||
@@ -2803,7 +2850,7 @@ make_table(struct archive_read *a, struct huffman_code *code)
|
||||
else
|
||||
code->tablesize = code->maxlength;
|
||||
|
||||
code->table = calloc(1U << code->tablesize, sizeof(*code->table));
|
||||
code->table = calloc(((size_t)1U) << code->tablesize, sizeof(*code->table));
|
||||
|
||||
return make_table_recurse(a, code, 0, code->table, 0, code->tablesize);
|
||||
}
|
||||
@@ -2929,11 +2976,11 @@ expand(struct archive_read *a, int64_t *end)
|
||||
}
|
||||
|
||||
if ((symbol = read_next_symbol(a, &rar->maincode)) < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
goto bad_data;
|
||||
|
||||
if (symbol < 256)
|
||||
{
|
||||
lzss_emit_literal(rar, symbol);
|
||||
lzss_emit_literal(rar, (uint8_t)symbol);
|
||||
continue;
|
||||
}
|
||||
else if (symbol == 256)
|
||||
@@ -2956,14 +3003,14 @@ expand(struct archive_read *a, int64_t *end)
|
||||
else
|
||||
{
|
||||
if (parse_codes(a) != ARCHIVE_OK)
|
||||
return (ARCHIVE_FATAL);
|
||||
goto bad_data;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if(symbol==257)
|
||||
{
|
||||
if (!read_filter(a, end))
|
||||
return (ARCHIVE_FATAL);
|
||||
goto bad_data;
|
||||
continue;
|
||||
}
|
||||
else if(symbol==258)
|
||||
@@ -3048,7 +3095,7 @@ expand(struct archive_read *a, int64_t *end)
|
||||
{
|
||||
if ((lowoffsetsymbol =
|
||||
read_next_symbol(a, &rar->lowoffsetcode)) < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
goto bad_data;
|
||||
if(lowoffsetsymbol == 16)
|
||||
{
|
||||
rar->numlowoffsetrepeats = 15;
|
||||
@@ -3096,7 +3143,7 @@ expand(struct archive_read *a, int64_t *end)
|
||||
}
|
||||
|
||||
static int
|
||||
copy_from_lzss_window(struct archive_read *a, void *buffer,
|
||||
copy_from_lzss_window(struct archive_read *a, uint8_t *buffer,
|
||||
int64_t startpos, int length)
|
||||
{
|
||||
int windowoffs, firstpart;
|
||||
@@ -3111,7 +3158,7 @@ copy_from_lzss_window(struct archive_read *a, void *buffer,
|
||||
}
|
||||
if (firstpart < length) {
|
||||
memcpy(buffer, &rar->lzss.window[windowoffs], firstpart);
|
||||
memcpy(buffer, &rar->lzss.window[0], length - firstpart);
|
||||
memcpy(buffer + firstpart, &rar->lzss.window[0], length - firstpart);
|
||||
} else {
|
||||
memcpy(buffer, &rar->lzss.window[windowoffs], length);
|
||||
}
|
||||
@@ -3180,8 +3227,12 @@ static const void *
|
||||
rar_read_ahead(struct archive_read *a, size_t min, ssize_t *avail)
|
||||
{
|
||||
struct rar *rar = (struct rar *)(a->format->data);
|
||||
const void *h = __archive_read_ahead(a, min, avail);
|
||||
const void *h;
|
||||
int ret;
|
||||
|
||||
again:
|
||||
h = __archive_read_ahead(a, min, avail);
|
||||
|
||||
if (avail)
|
||||
{
|
||||
if (a->archive.read_data_is_posix_read && *avail > (ssize_t)a->archive.read_data_requested)
|
||||
@@ -3203,7 +3254,7 @@ rar_read_ahead(struct archive_read *a, size_t min, ssize_t *avail)
|
||||
rar->filename_must_match = 0;
|
||||
if (ret != (ARCHIVE_OK))
|
||||
return NULL;
|
||||
return rar_read_ahead(a, min, avail);
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
return h;
|
||||
@@ -3266,6 +3317,9 @@ parse_filter(struct archive_read *a, const uint8_t *bytes, uint16_t length, uint
|
||||
else
|
||||
blocklength = prog ? prog->oldfilterlength : 0;
|
||||
|
||||
if (blocklength > rar->dictionary_size)
|
||||
return 0;
|
||||
|
||||
registers[3] = PROGRAM_SYSTEM_GLOBAL_ADDRESS;
|
||||
registers[4] = blocklength;
|
||||
registers[5] = prog ? prog->usagecount : 0;
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "archive_entry_locale.h"
|
||||
#include "archive_ppmd7_private.h"
|
||||
#include "archive_entry_private.h"
|
||||
#include "archive_time_private.h"
|
||||
|
||||
#ifdef HAVE_BLAKE2_H
|
||||
#include <blake2.h>
|
||||
@@ -100,10 +101,12 @@ struct file_header {
|
||||
uint8_t dir : 1; /* Is this file entry a directory? */
|
||||
|
||||
/* Optional time fields. */
|
||||
uint64_t e_mtime;
|
||||
uint64_t e_ctime;
|
||||
uint64_t e_atime;
|
||||
uint32_t e_unix_ns;
|
||||
int64_t e_mtime;
|
||||
int64_t e_ctime;
|
||||
int64_t e_atime;
|
||||
uint32_t e_mtime_ns;
|
||||
uint32_t e_ctime_ns;
|
||||
uint32_t e_atime_ns;
|
||||
|
||||
/* Optional hash fields. */
|
||||
uint32_t stored_crc32;
|
||||
@@ -691,7 +694,8 @@ static int run_filter(struct archive_read* a, struct filter_info* flt) {
|
||||
default:
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unsupported filter type: 0x%x", flt->type);
|
||||
"Unsupported filter type: 0x%x",
|
||||
(unsigned int)flt->type);
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
@@ -1100,22 +1104,22 @@ static int read_consume_bits(struct archive_read* a, struct rar5* rar,
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
static int read_u32(struct archive_read* a, uint32_t* pvalue) {
|
||||
static char read_u32(struct archive_read* a, uint32_t* pvalue) {
|
||||
const uint8_t* p;
|
||||
if(!read_ahead(a, 4, &p))
|
||||
return 0;
|
||||
|
||||
*pvalue = archive_le32dec(p);
|
||||
return ARCHIVE_OK == consume(a, 4) ? 1 : 0;
|
||||
return ARCHIVE_OK == consume(a, 4);
|
||||
}
|
||||
|
||||
static int read_u64(struct archive_read* a, uint64_t* pvalue) {
|
||||
static char read_u64(struct archive_read* a, uint64_t* pvalue) {
|
||||
const uint8_t* p;
|
||||
if(!read_ahead(a, 8, &p))
|
||||
return 0;
|
||||
|
||||
*pvalue = archive_le64dec(p);
|
||||
return ARCHIVE_OK == consume(a, 8) ? 1 : 0;
|
||||
return ARCHIVE_OK == consume(a, 8);
|
||||
}
|
||||
|
||||
static int bid_standard(struct archive_read* a) {
|
||||
@@ -1293,21 +1297,15 @@ static int parse_file_extra_hash(struct archive_read* a, struct rar5* rar,
|
||||
*extra_data_size -= hash_size;
|
||||
} else {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unsupported hash type (0x%x)", (int) hash_type);
|
||||
"Unsupported hash type (0x%jx)", (uintmax_t)hash_type);
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
static uint64_t time_win_to_unix(uint64_t win_time) {
|
||||
const size_t ns_in_sec = 10000000;
|
||||
const uint64_t sec_to_unix = 11644473600LL;
|
||||
return win_time / ns_in_sec - sec_to_unix;
|
||||
}
|
||||
|
||||
static int parse_htime_item(struct archive_read* a, char unix_time,
|
||||
uint64_t* where, int64_t* extra_data_size)
|
||||
int64_t* sec, uint32_t* nsec, int64_t* extra_data_size)
|
||||
{
|
||||
if(unix_time) {
|
||||
uint32_t time_val;
|
||||
@@ -1315,13 +1313,13 @@ static int parse_htime_item(struct archive_read* a, char unix_time,
|
||||
return ARCHIVE_EOF;
|
||||
|
||||
*extra_data_size -= 4;
|
||||
*where = (uint64_t) time_val;
|
||||
*sec = (int64_t) time_val;
|
||||
} else {
|
||||
uint64_t windows_time;
|
||||
if(!read_u64(a, &windows_time))
|
||||
return ARCHIVE_EOF;
|
||||
|
||||
*where = time_win_to_unix(windows_time);
|
||||
ntfs_to_unix(windows_time, sec, nsec);
|
||||
*extra_data_size -= 8;
|
||||
}
|
||||
|
||||
@@ -1385,7 +1383,7 @@ static int parse_file_extra_version(struct archive_read* a,
|
||||
static int parse_file_extra_htime(struct archive_read* a,
|
||||
struct archive_entry* e, struct rar5* rar, int64_t* extra_data_size)
|
||||
{
|
||||
char unix_time = 0;
|
||||
char unix_time, has_unix_ns, has_mtime, has_ctime, has_atime;
|
||||
size_t flags = 0;
|
||||
size_t value_len;
|
||||
|
||||
@@ -1406,32 +1404,62 @@ static int parse_file_extra_htime(struct archive_read* a,
|
||||
}
|
||||
|
||||
unix_time = flags & IS_UNIX;
|
||||
has_unix_ns = unix_time && (flags & HAS_UNIX_NS);
|
||||
has_mtime = flags & HAS_MTIME;
|
||||
has_atime = flags & HAS_ATIME;
|
||||
has_ctime = flags & HAS_CTIME;
|
||||
rar->file.e_atime_ns = rar->file.e_ctime_ns = rar->file.e_mtime_ns = 0;
|
||||
|
||||
if(flags & HAS_MTIME) {
|
||||
if(has_mtime) {
|
||||
parse_htime_item(a, unix_time, &rar->file.e_mtime,
|
||||
extra_data_size);
|
||||
archive_entry_set_mtime(e, rar->file.e_mtime, 0);
|
||||
&rar->file.e_mtime_ns, extra_data_size);
|
||||
}
|
||||
|
||||
if(flags & HAS_CTIME) {
|
||||
if(has_ctime) {
|
||||
parse_htime_item(a, unix_time, &rar->file.e_ctime,
|
||||
extra_data_size);
|
||||
archive_entry_set_ctime(e, rar->file.e_ctime, 0);
|
||||
&rar->file.e_ctime_ns, extra_data_size);
|
||||
}
|
||||
|
||||
if(flags & HAS_ATIME) {
|
||||
if(has_atime) {
|
||||
parse_htime_item(a, unix_time, &rar->file.e_atime,
|
||||
extra_data_size);
|
||||
archive_entry_set_atime(e, rar->file.e_atime, 0);
|
||||
&rar->file.e_atime_ns, extra_data_size);
|
||||
}
|
||||
|
||||
if(flags & HAS_UNIX_NS) {
|
||||
if(!read_u32(a, &rar->file.e_unix_ns))
|
||||
if(has_mtime && has_unix_ns) {
|
||||
if(!read_u32(a, &rar->file.e_mtime_ns))
|
||||
return ARCHIVE_EOF;
|
||||
|
||||
*extra_data_size -= 4;
|
||||
}
|
||||
|
||||
if(has_ctime && has_unix_ns) {
|
||||
if(!read_u32(a, &rar->file.e_ctime_ns))
|
||||
return ARCHIVE_EOF;
|
||||
|
||||
*extra_data_size -= 4;
|
||||
}
|
||||
|
||||
if(has_atime && has_unix_ns) {
|
||||
if(!read_u32(a, &rar->file.e_atime_ns))
|
||||
return ARCHIVE_EOF;
|
||||
|
||||
*extra_data_size -= 4;
|
||||
}
|
||||
|
||||
/* The seconds and nanoseconds are either together, or separated in two
|
||||
* fields so we parse them, then set the archive_entry's times. */
|
||||
if(has_mtime) {
|
||||
archive_entry_set_mtime(e, rar->file.e_mtime, rar->file.e_mtime_ns);
|
||||
}
|
||||
|
||||
if(has_ctime) {
|
||||
archive_entry_set_ctime(e, rar->file.e_ctime, rar->file.e_ctime_ns);
|
||||
}
|
||||
|
||||
if(has_atime) {
|
||||
archive_entry_set_atime(e, rar->file.e_atime, rar->file.e_atime_ns);
|
||||
}
|
||||
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
@@ -1896,7 +1924,8 @@ static int process_head_file(struct archive_read* a, struct rar5* rar,
|
||||
} else {
|
||||
/* Unknown host OS */
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unsupported Host OS: 0x%x", (int) host_os);
|
||||
"Unsupported Host OS: 0x%jx",
|
||||
(uintmax_t)host_os);
|
||||
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
@@ -2104,8 +2133,8 @@ static int process_head_main(struct archive_read* a, struct rar5* rar,
|
||||
default:
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Unsupported extra type (0x%x)",
|
||||
(int) extra_field_id);
|
||||
"Unsupported extra type (0x%jx)",
|
||||
(uintmax_t)extra_field_id);
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
@@ -3093,7 +3122,7 @@ static int do_uncompress_block(struct archive_read* a, const uint8_t* p) {
|
||||
* can be stored in the output buffer directly.
|
||||
*
|
||||
* - Code 256 defines a new filter, which is later used to
|
||||
* ransform the data block accordingly to the filter type.
|
||||
* transform the data block accordingly to the filter type.
|
||||
* The data block needs to be fully uncompressed first.
|
||||
*
|
||||
* - Code bigger than 257 and smaller than 262 define
|
||||
@@ -3983,7 +4012,7 @@ static int do_unpack(struct archive_read* a, struct rar5* rar,
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Compression method not supported: 0x%x",
|
||||
rar->cstate.method);
|
||||
(unsigned int)rar->cstate.method);
|
||||
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
@@ -129,7 +129,11 @@ struct tar {
|
||||
int64_t entry_offset;
|
||||
int64_t entry_padding;
|
||||
int64_t entry_bytes_unconsumed;
|
||||
int64_t realsize;
|
||||
int64_t disk_size;
|
||||
int64_t GNU_sparse_realsize;
|
||||
int64_t GNU_sparse_size;
|
||||
int64_t SCHILY_sparse_realsize;
|
||||
int64_t pax_size;
|
||||
struct sparse_block *sparse_list;
|
||||
struct sparse_block *sparse_last;
|
||||
int64_t sparse_offset;
|
||||
@@ -138,6 +142,7 @@ struct tar {
|
||||
int sparse_gnu_minor;
|
||||
char sparse_gnu_attributes_seen;
|
||||
char filetype;
|
||||
char size_fields; /* Bits defined below */
|
||||
|
||||
struct archive_string localname;
|
||||
struct archive_string_conv *opt_sconv;
|
||||
@@ -148,9 +153,15 @@ struct tar {
|
||||
int compat_2x;
|
||||
int process_mac_extensions;
|
||||
int read_concatenated_archives;
|
||||
int realsize_override;
|
||||
};
|
||||
|
||||
/* Track which size fields were present in the headers */
|
||||
#define TAR_SIZE_PAX_SIZE 1
|
||||
#define TAR_SIZE_GNU_SPARSE_REALSIZE 2
|
||||
#define TAR_SIZE_GNU_SPARSE_SIZE 4
|
||||
#define TAR_SIZE_SCHILY_SPARSE_REALSIZE 8
|
||||
|
||||
|
||||
static int archive_block_is_null(const char *p);
|
||||
static char *base64_decode(const char *, size_t, size_t *);
|
||||
static int gnu_add_sparse_entry(struct archive_read *, struct tar *,
|
||||
@@ -158,36 +169,36 @@ static int gnu_add_sparse_entry(struct archive_read *, struct tar *,
|
||||
|
||||
static void gnu_clear_sparse_list(struct tar *);
|
||||
static int gnu_sparse_old_read(struct archive_read *, struct tar *,
|
||||
const struct archive_entry_header_gnutar *header, size_t *);
|
||||
const struct archive_entry_header_gnutar *header, int64_t *);
|
||||
static int gnu_sparse_old_parse(struct archive_read *, struct tar *,
|
||||
const struct gnu_sparse *sparse, int length);
|
||||
static int gnu_sparse_01_parse(struct archive_read *, struct tar *,
|
||||
const char *, size_t);
|
||||
static ssize_t gnu_sparse_10_read(struct archive_read *, struct tar *,
|
||||
size_t *);
|
||||
int64_t *);
|
||||
static int header_Solaris_ACL(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *, size_t *);
|
||||
struct archive_entry *, const void *, int64_t *);
|
||||
static int header_common(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *);
|
||||
static int header_old_tar(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *);
|
||||
static int header_pax_extension(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *, size_t *);
|
||||
struct archive_entry *, const void *, int64_t *);
|
||||
static int header_pax_global(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *h, size_t *);
|
||||
struct archive_entry *, const void *h, int64_t *);
|
||||
static int header_gnu_longlink(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *h, size_t *);
|
||||
struct archive_entry *, const void *h, int64_t *);
|
||||
static int header_gnu_longname(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *h, size_t *);
|
||||
struct archive_entry *, const void *h, int64_t *);
|
||||
static int is_mac_metadata_entry(struct archive_entry *entry);
|
||||
static int read_mac_metadata_blob(struct archive_read *,
|
||||
struct archive_entry *, size_t *);
|
||||
struct archive_entry *, int64_t *);
|
||||
static int header_volume(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *h, size_t *);
|
||||
struct archive_entry *, const void *h, int64_t *);
|
||||
static int header_ustar(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *h);
|
||||
static int header_gnutar(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const void *h, size_t *);
|
||||
struct archive_entry *, const void *h, int64_t *);
|
||||
static int archive_read_format_tar_bid(struct archive_read *, int);
|
||||
static int archive_read_format_tar_options(struct archive_read *,
|
||||
const char *, const char *);
|
||||
@@ -200,7 +211,7 @@ static int archive_read_format_tar_read_header(struct archive_read *,
|
||||
static int checksum(struct archive_read *, const void *);
|
||||
static int pax_attribute(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const char *key, size_t key_length,
|
||||
size_t value_length, size_t *unconsumed);
|
||||
size_t value_length, int64_t *unconsumed);
|
||||
static int pax_attribute_LIBARCHIVE_xattr(struct archive_entry *,
|
||||
const char *, size_t, const char *, size_t);
|
||||
static int pax_attribute_SCHILY_acl(struct archive_read *, struct tar *,
|
||||
@@ -209,20 +220,20 @@ static int pax_attribute_SUN_holesdata(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const char *, size_t);
|
||||
static void pax_time(const char *, size_t, int64_t *sec, long *nanos);
|
||||
static ssize_t readline(struct archive_read *, struct tar *, const char **,
|
||||
ssize_t limit, size_t *);
|
||||
ssize_t limit, int64_t *);
|
||||
static int read_body_to_string(struct archive_read *, struct tar *,
|
||||
struct archive_string *, const void *h, size_t *);
|
||||
struct archive_string *, const void *h, int64_t *);
|
||||
static int read_bytes_to_string(struct archive_read *,
|
||||
struct archive_string *, size_t, size_t *);
|
||||
struct archive_string *, size_t, int64_t *);
|
||||
static int64_t tar_atol(const char *, size_t);
|
||||
static int64_t tar_atol10(const char *, size_t);
|
||||
static int64_t tar_atol256(const char *, size_t);
|
||||
static int64_t tar_atol8(const char *, size_t);
|
||||
static int tar_read_header(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, size_t *);
|
||||
struct archive_entry *, int64_t *);
|
||||
static int tohex(int c);
|
||||
static char *url_decode(const char *, size_t);
|
||||
static void tar_flush_unconsumed(struct archive_read *, size_t *);
|
||||
static void tar_flush_unconsumed(struct archive_read *, int64_t *);
|
||||
|
||||
/* Sanity limits: These numbers should be low enough to
|
||||
* prevent a maliciously-crafted archive from forcing us to
|
||||
@@ -467,7 +478,7 @@ archive_read_format_tar_options(struct archive_read *a,
|
||||
* anything outstanding since we're going to do read_aheads
|
||||
*/
|
||||
static void
|
||||
tar_flush_unconsumed(struct archive_read *a, size_t *unconsumed)
|
||||
tar_flush_unconsumed(struct archive_read *a, int64_t *unconsumed)
|
||||
{
|
||||
if (*unconsumed) {
|
||||
/*
|
||||
@@ -515,7 +526,8 @@ archive_read_format_tar_read_header(struct archive_read *a,
|
||||
const char *p;
|
||||
const wchar_t *wp;
|
||||
int r;
|
||||
size_t l, unconsumed = 0;
|
||||
size_t l;
|
||||
int64_t unconsumed = 0;
|
||||
|
||||
/* Assign default device/inode values. */
|
||||
archive_entry_set_dev(entry, 1 + default_dev); /* Don't use zero. */
|
||||
@@ -529,8 +541,7 @@ archive_read_format_tar_read_header(struct archive_read *a,
|
||||
tar = (struct tar *)(a->format->data);
|
||||
tar->entry_offset = 0;
|
||||
gnu_clear_sparse_list(tar);
|
||||
tar->realsize = -1; /* Mark this as "unset" */
|
||||
tar->realsize_override = 0;
|
||||
tar->size_fields = 0; /* We don't have any size info yet */
|
||||
|
||||
/* Setup default string conversion. */
|
||||
tar->sconv = tar->opt_sconv;
|
||||
@@ -622,7 +633,7 @@ archive_read_format_tar_read_data(struct archive_read *a,
|
||||
tar->entry_padding = 0;
|
||||
*buff = NULL;
|
||||
*size = 0;
|
||||
*offset = tar->realsize;
|
||||
*offset = tar->disk_size;
|
||||
return (ARCHIVE_EOF);
|
||||
}
|
||||
|
||||
@@ -696,7 +707,7 @@ archive_read_format_tar_skip(struct archive_read *a)
|
||||
*/
|
||||
static int
|
||||
tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, size_t *unconsumed)
|
||||
struct archive_entry *entry, int64_t *unconsumed)
|
||||
{
|
||||
ssize_t bytes;
|
||||
int err = ARCHIVE_OK, err2;
|
||||
@@ -750,7 +761,7 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
* if there's no regular header, then this is
|
||||
* a premature EOF. */
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Damaged tar archive");
|
||||
"Damaged tar archive (end-of-archive within a sequence of headers)");
|
||||
return (ARCHIVE_FATAL);
|
||||
} else {
|
||||
return (ARCHIVE_EOF);
|
||||
@@ -760,7 +771,7 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated tar archive"
|
||||
" detected while reading next heaader");
|
||||
" detected while reading next header");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
*unconsumed += 512;
|
||||
@@ -787,7 +798,8 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
/* This is NOT a null block, so it must be a valid header. */
|
||||
if (!checksum(a, h)) {
|
||||
tar_flush_unconsumed(a, unconsumed);
|
||||
archive_set_error(&a->archive, EINVAL, "Damaged tar archive");
|
||||
archive_set_error(&a->archive, EINVAL,
|
||||
"Damaged tar archive (bad header checksum)");
|
||||
/* If we've read some critical information (pax headers, etc)
|
||||
* and _then_ see a bad header, we can't really recover. */
|
||||
if (eof_fatal) {
|
||||
@@ -804,6 +816,8 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
switch(header->typeflag[0]) {
|
||||
case 'A': /* Solaris tar ACL */
|
||||
if (seen_headers & seen_A_header) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Redundant 'A' header");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
seen_headers |= seen_A_header;
|
||||
@@ -813,6 +827,8 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
break;
|
||||
case 'g': /* POSIX-standard 'g' header. */
|
||||
if (seen_headers & seen_g_header) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Redundant 'g' header");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
seen_headers |= seen_g_header;
|
||||
@@ -822,27 +838,41 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
break;
|
||||
case 'K': /* Long link name (GNU tar, others) */
|
||||
if (seen_headers & seen_K_header) {
|
||||
return (ARCHIVE_FATAL);
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Damaged archive: Redundant 'K' headers may cause linknames to be incorrect");
|
||||
err = err_combine(err, ARCHIVE_WARN);
|
||||
}
|
||||
seen_headers |= seen_K_header;
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_TAR_GNUTAR;
|
||||
a->archive.archive_format_name = "GNU tar format";
|
||||
err2 = header_gnu_longlink(a, tar, entry, h, unconsumed);
|
||||
break;
|
||||
case 'L': /* Long filename (GNU tar, others) */
|
||||
if (seen_headers & seen_L_header) {
|
||||
return (ARCHIVE_FATAL);
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Damaged archive: Redundant 'L' headers may cause filenames to be incorrect");
|
||||
err = err_combine(err, ARCHIVE_WARN);
|
||||
}
|
||||
seen_headers |= seen_L_header;
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_TAR_GNUTAR;
|
||||
a->archive.archive_format_name = "GNU tar format";
|
||||
err2 = header_gnu_longname(a, tar, entry, h, unconsumed);
|
||||
break;
|
||||
case 'V': /* GNU volume header */
|
||||
if (seen_headers & seen_V_header) {
|
||||
return (ARCHIVE_FATAL);
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Redundant 'V' header");
|
||||
err = err_combine(err, ARCHIVE_WARN);
|
||||
}
|
||||
seen_headers |= seen_V_header;
|
||||
a->archive.archive_format = ARCHIVE_FORMAT_TAR_GNUTAR;
|
||||
a->archive.archive_format_name = "GNU tar format";
|
||||
err2 = header_volume(a, tar, entry, h, unconsumed);
|
||||
break;
|
||||
case 'X': /* Used by SUN tar; same as 'x'. */
|
||||
if (seen_headers & seen_x_header) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Redundant 'X'/'x' header");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
seen_headers |= seen_x_header;
|
||||
@@ -853,6 +883,8 @@ tar_read_header(struct archive_read *a, struct tar *tar,
|
||||
break;
|
||||
case 'x': /* POSIX-standard 'x' header. */
|
||||
if (seen_headers & seen_x_header) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Redundant 'x' header");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
seen_headers |= seen_x_header;
|
||||
@@ -1032,13 +1064,13 @@ archive_block_is_null(const char *p)
|
||||
*/
|
||||
static int
|
||||
header_Solaris_ACL(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
struct archive_entry *entry, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
const struct archive_entry_header_ustar *header;
|
||||
struct archive_string acl_text;
|
||||
size_t size;
|
||||
int err, acl_type;
|
||||
int64_t type;
|
||||
uint64_t type;
|
||||
char *acl, *p;
|
||||
|
||||
header = (const struct archive_entry_header_ustar *)h;
|
||||
@@ -1075,7 +1107,7 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
|
||||
}
|
||||
p++;
|
||||
}
|
||||
switch ((int)type & ~0777777) {
|
||||
switch (type & ~0777777) {
|
||||
case 01000000:
|
||||
/* POSIX.1e ACL */
|
||||
acl_type = ARCHIVE_ENTRY_ACL_TYPE_ACCESS;
|
||||
@@ -1086,8 +1118,8 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
|
||||
break;
|
||||
default:
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Malformed Solaris ACL attribute (unsupported type %o)",
|
||||
(int)type);
|
||||
"Malformed Solaris ACL attribute (unsupported type %"
|
||||
PRIo64 ")", type);
|
||||
archive_string_free(&acl_text);
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
@@ -1138,14 +1170,16 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
|
||||
*/
|
||||
static int
|
||||
header_gnu_longlink(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
struct archive_entry *entry, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
int err;
|
||||
|
||||
struct archive_string linkpath;
|
||||
archive_string_init(&linkpath);
|
||||
err = read_body_to_string(a, tar, &linkpath, h, unconsumed);
|
||||
archive_entry_set_link(entry, linkpath.s);
|
||||
if (err == ARCHIVE_OK) {
|
||||
archive_entry_set_link(entry, linkpath.s);
|
||||
}
|
||||
archive_string_free(&linkpath);
|
||||
return (err);
|
||||
}
|
||||
@@ -1170,7 +1204,7 @@ set_conversion_failed_error(struct archive_read *a,
|
||||
*/
|
||||
static int
|
||||
header_gnu_longname(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
struct archive_entry *entry, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
int err;
|
||||
struct archive_string longname;
|
||||
@@ -1191,7 +1225,7 @@ header_gnu_longname(struct archive_read *a, struct tar *tar,
|
||||
*/
|
||||
static int
|
||||
header_volume(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
struct archive_entry *entry, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
const struct archive_entry_header_ustar *header;
|
||||
int64_t size, to_consume;
|
||||
@@ -1217,7 +1251,7 @@ header_volume(struct archive_read *a, struct tar *tar,
|
||||
static int
|
||||
read_bytes_to_string(struct archive_read *a,
|
||||
struct archive_string *as, size_t size,
|
||||
size_t *unconsumed) {
|
||||
int64_t *unconsumed) {
|
||||
const void *src;
|
||||
|
||||
/* Fail if we can't make our buffer big enough. */
|
||||
@@ -1250,7 +1284,7 @@ read_bytes_to_string(struct archive_read *a,
|
||||
*/
|
||||
static int
|
||||
read_body_to_string(struct archive_read *a, struct tar *tar,
|
||||
struct archive_string *as, const void *h, size_t *unconsumed)
|
||||
struct archive_string *as, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
int64_t size;
|
||||
const struct archive_entry_header_ustar *header;
|
||||
@@ -1287,6 +1321,11 @@ read_body_to_string(struct archive_read *a, struct tar *tar,
|
||||
* allows header_old_tar and header_ustar
|
||||
* to handle filenames differently, while still putting most of the
|
||||
* common parsing into one place.
|
||||
*
|
||||
* This is called _after_ ustar, GNU tar, Schily, etc, special
|
||||
* fields have already been parsed into the `tar` structure.
|
||||
* So we can make final decisions here about how to reconcile
|
||||
* size, mode, etc, information.
|
||||
*/
|
||||
static int
|
||||
header_common(struct archive_read *a, struct tar *tar,
|
||||
@@ -1308,34 +1347,73 @@ header_common(struct archive_read *a, struct tar *tar,
|
||||
archive_entry_set_perm(entry,
|
||||
(mode_t)tar_atol(header->mode, sizeof(header->mode)));
|
||||
}
|
||||
|
||||
/* Set uid, gid, mtime if not already set */
|
||||
if (!archive_entry_uid_is_set(entry)) {
|
||||
archive_entry_set_uid(entry, tar_atol(header->uid, sizeof(header->uid)));
|
||||
}
|
||||
if (!archive_entry_gid_is_set(entry)) {
|
||||
archive_entry_set_gid(entry, tar_atol(header->gid, sizeof(header->gid)));
|
||||
}
|
||||
if (!archive_entry_mtime_is_set(entry)) {
|
||||
archive_entry_set_mtime(entry, tar_atol(header->mtime, sizeof(header->mtime)), 0);
|
||||
}
|
||||
|
||||
tar->entry_bytes_remaining = tar_atol(header->size, sizeof(header->size));
|
||||
/* Reconcile the size info. */
|
||||
/* First, how big is the file on disk? */
|
||||
if ((tar->size_fields & TAR_SIZE_GNU_SPARSE_REALSIZE) != 0) {
|
||||
/* GNU sparse format 1.0 uses `GNU.sparse.realsize`
|
||||
* to hold the size of the file on disk. */
|
||||
tar->disk_size = tar->GNU_sparse_realsize;
|
||||
} else if ((tar->size_fields & TAR_SIZE_GNU_SPARSE_SIZE) != 0
|
||||
&& (tar->sparse_gnu_major == 0)) {
|
||||
/* GNU sparse format 0.0 and 0.1 use `GNU.sparse.size`
|
||||
* to hold the size of the file on disk. */
|
||||
tar->disk_size = tar->GNU_sparse_size;
|
||||
} else if ((tar->size_fields & TAR_SIZE_SCHILY_SPARSE_REALSIZE) != 0) {
|
||||
tar->disk_size = tar->SCHILY_sparse_realsize;
|
||||
} else if ((tar->size_fields & TAR_SIZE_PAX_SIZE) != 0) {
|
||||
tar->disk_size = tar->pax_size;
|
||||
} else {
|
||||
/* There wasn't a suitable pax header, so use the ustar info */
|
||||
tar->disk_size = tar_atol(header->size, sizeof(header->size));
|
||||
}
|
||||
|
||||
if (tar->disk_size < 0) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry has negative file size");
|
||||
return (ARCHIVE_FATAL);
|
||||
} else if (tar->disk_size > entry_limit) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry size overflow");
|
||||
return (ARCHIVE_FATAL);
|
||||
} else {
|
||||
archive_entry_set_size(entry, tar->disk_size);
|
||||
}
|
||||
|
||||
/* Second, how big is the data in the archive? */
|
||||
if ((tar->size_fields & TAR_SIZE_GNU_SPARSE_SIZE) != 0
|
||||
&& (tar->sparse_gnu_major == 1)) {
|
||||
/* GNU sparse format 1.0 uses `GNU.sparse.size`
|
||||
* to hold the size of the data in the archive. */
|
||||
tar->entry_bytes_remaining = tar->GNU_sparse_size;
|
||||
} else if ((tar->size_fields & TAR_SIZE_PAX_SIZE) != 0) {
|
||||
tar->entry_bytes_remaining = tar->pax_size;
|
||||
} else {
|
||||
tar->entry_bytes_remaining
|
||||
= tar_atol(header->size, sizeof(header->size));
|
||||
}
|
||||
if (tar->entry_bytes_remaining < 0) {
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry has negative size");
|
||||
"Tar entry has negative size");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (tar->entry_bytes_remaining > entry_limit) {
|
||||
} else if (tar->entry_bytes_remaining > entry_limit) {
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry size overflow");
|
||||
"Tar entry size overflow");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (!tar->realsize_override) {
|
||||
tar->realsize = tar->entry_bytes_remaining;
|
||||
}
|
||||
archive_entry_set_size(entry, tar->realsize);
|
||||
|
||||
if (!archive_entry_mtime_is_set(entry)) {
|
||||
archive_entry_set_mtime(entry, tar_atol(header->mtime, sizeof(header->mtime)), 0);
|
||||
}
|
||||
|
||||
/* Handle the tar type flag appropriately. */
|
||||
tar->filetype = header->typeflag[0];
|
||||
@@ -1597,7 +1675,7 @@ is_mac_metadata_entry(struct archive_entry *entry) {
|
||||
*/
|
||||
static int
|
||||
read_mac_metadata_blob(struct archive_read *a,
|
||||
struct archive_entry *entry, size_t *unconsumed)
|
||||
struct archive_entry *entry, int64_t *unconsumed)
|
||||
{
|
||||
int64_t size;
|
||||
size_t msize;
|
||||
@@ -1654,7 +1732,7 @@ read_mac_metadata_blob(struct archive_read *a,
|
||||
*/
|
||||
static int
|
||||
header_pax_global(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
struct archive_entry *entry, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
const struct archive_entry_header_ustar *header;
|
||||
int64_t size, to_consume;
|
||||
@@ -1761,7 +1839,7 @@ header_ustar(struct archive_read *a, struct tar *tar,
|
||||
|
||||
static int
|
||||
header_pax_extension(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
struct archive_entry *entry, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
/* Sanity checks: The largest `x` body I've ever heard of was
|
||||
* a little over 4MB. So I doubt there has ever been a
|
||||
@@ -2154,7 +2232,7 @@ pax_attribute_SCHILY_acl(struct archive_read *a, struct tar *tar,
|
||||
}
|
||||
|
||||
static int
|
||||
pax_attribute_read_time(struct archive_read *a, size_t value_length, int64_t *ps, long *pn, size_t *unconsumed) {
|
||||
pax_attribute_read_time(struct archive_read *a, size_t value_length, int64_t *ps, long *pn, int64_t *unconsumed) {
|
||||
struct archive_string as;
|
||||
int r;
|
||||
|
||||
@@ -2183,7 +2261,7 @@ pax_attribute_read_time(struct archive_read *a, size_t value_length, int64_t *ps
|
||||
static int
|
||||
pax_attribute_read_number(struct archive_read *a, size_t value_length, int64_t *result) {
|
||||
struct archive_string as;
|
||||
size_t unconsumed = 0;
|
||||
int64_t unconsumed = 0;
|
||||
int r;
|
||||
|
||||
if (value_length > 64) {
|
||||
@@ -2197,6 +2275,7 @@ pax_attribute_read_number(struct archive_read *a, size_t value_length, int64_t *
|
||||
tar_flush_unconsumed(a, &unconsumed);
|
||||
if (r < ARCHIVE_OK) {
|
||||
archive_string_free(&as);
|
||||
*result = 0;
|
||||
return (r);
|
||||
}
|
||||
|
||||
@@ -2223,7 +2302,7 @@ pax_attribute_read_number(struct archive_read *a, size_t value_length, int64_t *
|
||||
*/
|
||||
static int
|
||||
pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *entry,
|
||||
const char *key, size_t key_length, size_t value_length, size_t *unconsumed)
|
||||
const char *key, size_t key_length, size_t value_length, int64_t *unconsumed)
|
||||
{
|
||||
int64_t t;
|
||||
long n;
|
||||
@@ -2289,10 +2368,13 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
}
|
||||
else if (key_length == 4 && memcmp(key, "size", 4) == 0) {
|
||||
/* GNU.sparse.size */
|
||||
/* This is either the size of stored entry OR the size of data on disk,
|
||||
* depending on which GNU sparse format version is in use.
|
||||
* Since pax attributes can be in any order, we may not actually
|
||||
* know at this point how to interpret this. */
|
||||
if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) {
|
||||
tar->realsize = t;
|
||||
archive_entry_set_size(entry, tar->realsize);
|
||||
tar->realsize_override = 1;
|
||||
tar->GNU_sparse_size = t;
|
||||
tar->size_fields |= TAR_SIZE_GNU_SPARSE_SIZE;
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
@@ -2360,11 +2442,10 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
return (err);
|
||||
}
|
||||
else if (key_length == 8 && memcmp(key, "realsize", 8) == 0) {
|
||||
/* GNU.sparse.realsize */
|
||||
/* GNU.sparse.realsize = size of file on disk */
|
||||
if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) {
|
||||
tar->realsize = t;
|
||||
archive_entry_set_size(entry, tar->realsize);
|
||||
tar->realsize_override = 1;
|
||||
tar->GNU_sparse_realsize = t;
|
||||
tar->size_fields |= TAR_SIZE_GNU_SPARSE_REALSIZE;
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
@@ -2545,12 +2626,12 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
}
|
||||
else if (key_length == 8 && memcmp(key, "realsize", 8) == 0) {
|
||||
if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) {
|
||||
tar->realsize = t;
|
||||
tar->realsize_override = 1;
|
||||
archive_entry_set_size(entry, tar->realsize);
|
||||
tar->SCHILY_sparse_realsize = t;
|
||||
tar->size_fields |= TAR_SIZE_SCHILY_SPARSE_REALSIZE;
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
/* TODO: Is there a SCHILY.sparse.size similar to GNU.sparse.size ? */
|
||||
else if (key_length > 6 && memcmp(key, "xattr.", 6) == 0) {
|
||||
key_length -= 6;
|
||||
key += 6;
|
||||
@@ -2717,19 +2798,8 @@ pax_attribute(struct archive_read *a, struct tar *tar, struct archive_entry *ent
|
||||
if (key_length == 4 && memcmp(key, "size", 4) == 0) {
|
||||
/* "size" is the size of the data in the entry. */
|
||||
if ((err = pax_attribute_read_number(a, value_length, &t)) == ARCHIVE_OK) {
|
||||
tar->entry_bytes_remaining = t;
|
||||
/*
|
||||
* The "size" pax header keyword always overrides the
|
||||
* "size" field in the tar header.
|
||||
* GNU.sparse.realsize, GNU.sparse.size and
|
||||
* SCHILY.realsize override this value.
|
||||
*/
|
||||
if (!tar->realsize_override) {
|
||||
archive_entry_set_size(entry,
|
||||
tar->entry_bytes_remaining);
|
||||
tar->realsize
|
||||
= tar->entry_bytes_remaining;
|
||||
}
|
||||
tar->pax_size = t;
|
||||
tar->size_fields |= TAR_SIZE_PAX_SIZE;
|
||||
}
|
||||
else if (t == INT64_MAX) {
|
||||
/* Note: pax_attr_read_number returns INT64_MAX on overflow or < 0 */
|
||||
@@ -2829,7 +2899,7 @@ pax_time(const char *p, size_t length, int64_t *ps, long *pn)
|
||||
*/
|
||||
static int
|
||||
header_gnutar(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const void *h, size_t *unconsumed)
|
||||
struct archive_entry *entry, const void *h, int64_t *unconsumed)
|
||||
{
|
||||
const struct archive_entry_header_gnutar *header;
|
||||
int64_t t;
|
||||
@@ -2841,11 +2911,6 @@ header_gnutar(struct archive_read *a, struct tar *tar,
|
||||
* filename is stored as in old-style archives.
|
||||
*/
|
||||
|
||||
/* Grab fields common to all tar variants. */
|
||||
err = header_common(a, tar, entry, h);
|
||||
if (err == ARCHIVE_FATAL)
|
||||
return (err);
|
||||
|
||||
/* Copy filename over (to ensure null termination). */
|
||||
header = (const struct archive_entry_header_gnutar *)h;
|
||||
const char *existing_pathname = archive_entry_pathname(entry);
|
||||
@@ -2894,8 +2959,6 @@ header_gnutar(struct archive_read *a, struct tar *tar,
|
||||
archive_entry_set_rdev(entry, 0);
|
||||
}
|
||||
|
||||
tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
|
||||
|
||||
/* Grab GNU-specific fields. */
|
||||
if (!archive_entry_atime_is_set(entry)) {
|
||||
t = tar_atol(header->atime, sizeof(header->atime));
|
||||
@@ -2909,10 +2972,10 @@ header_gnutar(struct archive_read *a, struct tar *tar,
|
||||
}
|
||||
|
||||
if (header->realsize[0] != 0) {
|
||||
tar->realsize
|
||||
/* Treat as a synonym for the pax GNU.sparse.realsize attr */
|
||||
tar->GNU_sparse_realsize
|
||||
= tar_atol(header->realsize, sizeof(header->realsize));
|
||||
archive_entry_set_size(entry, tar->realsize);
|
||||
tar->realsize_override = 1;
|
||||
tar->size_fields |= TAR_SIZE_GNU_SPARSE_REALSIZE;
|
||||
}
|
||||
|
||||
if (header->sparse[0].offset[0] != 0) {
|
||||
@@ -2925,6 +2988,13 @@ header_gnutar(struct archive_read *a, struct tar *tar,
|
||||
}
|
||||
}
|
||||
|
||||
/* Grab fields common to all tar variants. */
|
||||
err = header_common(a, tar, entry, h);
|
||||
if (err == ARCHIVE_FATAL)
|
||||
return (err);
|
||||
|
||||
tar->entry_padding = 0x1ff & (-tar->entry_bytes_remaining);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
@@ -2980,7 +3050,7 @@ gnu_clear_sparse_list(struct tar *tar)
|
||||
|
||||
static int
|
||||
gnu_sparse_old_read(struct archive_read *a, struct tar *tar,
|
||||
const struct archive_entry_header_gnutar *header, size_t *unconsumed)
|
||||
const struct archive_entry_header_gnutar *header, int64_t *unconsumed)
|
||||
{
|
||||
ssize_t bytes_read;
|
||||
const void *data;
|
||||
@@ -3104,8 +3174,7 @@ gnu_sparse_01_parse(struct archive_read *a, struct tar *tar, const char *p, size
|
||||
* it's not possible to support both variants. This code supports
|
||||
* the later variant at the expense of not supporting the former.
|
||||
*
|
||||
* This variant also replaced GNU.sparse.size with GNU.sparse.realsize
|
||||
* and introduced the GNU.sparse.major/GNU.sparse.minor attributes.
|
||||
* This variant also introduced the GNU.sparse.major/GNU.sparse.minor attributes.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -3115,7 +3184,7 @@ gnu_sparse_01_parse(struct archive_read *a, struct tar *tar, const char *p, size
|
||||
*/
|
||||
static int64_t
|
||||
gnu_sparse_10_atol(struct archive_read *a, struct tar *tar,
|
||||
int64_t *remaining, size_t *unconsumed)
|
||||
int64_t *remaining, int64_t *unconsumed)
|
||||
{
|
||||
int64_t l, limit, last_digit_limit;
|
||||
const char *p;
|
||||
@@ -3161,7 +3230,7 @@ gnu_sparse_10_atol(struct archive_read *a, struct tar *tar,
|
||||
* that was read.
|
||||
*/
|
||||
static ssize_t
|
||||
gnu_sparse_10_read(struct archive_read *a, struct tar *tar, size_t *unconsumed)
|
||||
gnu_sparse_10_read(struct archive_read *a, struct tar *tar, int64_t *unconsumed)
|
||||
{
|
||||
ssize_t bytes_read;
|
||||
int entries;
|
||||
@@ -3408,7 +3477,7 @@ tar_atol256(const char *_p, size_t char_cnt)
|
||||
*/
|
||||
static ssize_t
|
||||
readline(struct archive_read *a, struct tar *tar, const char **start,
|
||||
ssize_t limit, size_t *unconsumed)
|
||||
ssize_t limit, int64_t *unconsumed)
|
||||
{
|
||||
ssize_t bytes_read;
|
||||
ssize_t total_size = 0;
|
||||
|
||||
@@ -386,7 +386,8 @@ _warc_rdhdr(struct archive_read *a, struct archive_entry *entry)
|
||||
case LAST_WT:
|
||||
default:
|
||||
/* consume the content and start over */
|
||||
_warc_skip(a);
|
||||
if (_warc_skip(a) < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
goto start_over;
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
@@ -439,7 +440,9 @@ _warc_skip(struct archive_read *a)
|
||||
{
|
||||
struct warc_s *w = a->format->data;
|
||||
|
||||
__archive_read_consume(a, w->cntlen + 4U/*\r\n\r\n separator*/);
|
||||
if (__archive_read_consume(a, w->cntlen) < 0 ||
|
||||
__archive_read_consume(a, 4U/*\r\n\r\n separator*/) < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
w->cntlen = 0U;
|
||||
w->cntoff = 0U;
|
||||
return (ARCHIVE_OK);
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
#include <bsdxml.h>
|
||||
#elif HAVE_EXPAT_H
|
||||
#include <expat.h>
|
||||
#elif HAVE_XMLLITE_H
|
||||
#include <objidl.h>
|
||||
#include <initguid.h>
|
||||
#include <xmllite.h>
|
||||
#endif
|
||||
#ifdef HAVE_BZLIB_H
|
||||
#include <bzlib.h>
|
||||
@@ -56,12 +60,13 @@
|
||||
#include "archive_read_private.h"
|
||||
|
||||
#if (!defined(HAVE_LIBXML_XMLREADER_H) && \
|
||||
!defined(HAVE_BSDXML_H) && !defined(HAVE_EXPAT_H)) ||\
|
||||
!defined(HAVE_BSDXML_H) && !defined(HAVE_EXPAT_H) && \
|
||||
!defined(HAVE_XMLLITE_H)) ||\
|
||||
!defined(HAVE_ZLIB_H) || \
|
||||
!defined(ARCHIVE_HAS_MD5) || !defined(ARCHIVE_HAS_SHA1)
|
||||
/*
|
||||
* xar needs several external libraries.
|
||||
* o libxml2 or expat --- XML parser
|
||||
* o libxml2, expat or (Windows only) xmllite --- XML parser
|
||||
* o openssl or MD5/SHA1 hash function
|
||||
* o zlib
|
||||
* o bzlib2 (option)
|
||||
@@ -438,6 +443,8 @@ static void expat_start_cb(void *, const XML_Char *, const XML_Char **);
|
||||
static void expat_end_cb(void *, const XML_Char *);
|
||||
static void expat_data_cb(void *, const XML_Char *, int);
|
||||
static int expat_read_toc(struct archive_read *);
|
||||
#elif defined(HAVE_XMLLITE_H)
|
||||
static int xmllite_read_toc(struct archive_read *);
|
||||
#endif
|
||||
|
||||
int
|
||||
@@ -589,6 +596,8 @@ read_toc(struct archive_read *a)
|
||||
r = xml2_read_toc(a);
|
||||
#elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H)
|
||||
r = expat_read_toc(a);
|
||||
#elif defined(HAVE_XMLLITE_H)
|
||||
r = xmllite_read_toc(a);
|
||||
#endif
|
||||
if (r != ARCHIVE_OK)
|
||||
return (r);
|
||||
@@ -1110,17 +1119,17 @@ atohex(unsigned char *b, size_t bsize, const char *p, size_t psize)
|
||||
while (bsize && psize > 1) {
|
||||
unsigned char x;
|
||||
|
||||
if (p[0] >= 'a' && p[0] <= 'z')
|
||||
if (p[0] >= 'a' && p[0] <= 'f')
|
||||
x = (p[0] - 'a' + 0x0a) << 4;
|
||||
else if (p[0] >= 'A' && p[0] <= 'Z')
|
||||
else if (p[0] >= 'A' && p[0] <= 'F')
|
||||
x = (p[0] - 'A' + 0x0a) << 4;
|
||||
else if (p[0] >= '0' && p[0] <= '9')
|
||||
x = (p[0] - '0') << 4;
|
||||
else
|
||||
return (-1);
|
||||
if (p[1] >= 'a' && p[1] <= 'z')
|
||||
if (p[1] >= 'a' && p[1] <= 'f')
|
||||
x |= p[1] - 'a' + 0x0a;
|
||||
else if (p[1] >= 'A' && p[1] <= 'Z')
|
||||
else if (p[1] >= 'A' && p[1] <= 'F')
|
||||
x |= p[1] - 'A' + 0x0a;
|
||||
else if (p[1] >= '0' && p[1] <= '9')
|
||||
x |= p[1] - '0';
|
||||
@@ -1745,15 +1754,6 @@ decompression_cleanup(struct archive_read *a)
|
||||
#if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA)
|
||||
if (xar->lzstream_valid)
|
||||
lzma_end(&(xar->lzstream));
|
||||
#elif defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA)
|
||||
if (xar->lzstream_valid) {
|
||||
if (lzmadec_end(&(xar->lzstream)) != LZMADEC_OK) {
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Failed to clean up lzmadec decompressor");
|
||||
r = ARCHIVE_FATAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (r);
|
||||
}
|
||||
@@ -2070,7 +2070,7 @@ xml_start(struct archive_read *a, const char *name, struct xmlattr_list *list)
|
||||
if (xar->file->link > 0)
|
||||
if (add_link(a, xar, xar->file) != ARCHIVE_OK) {
|
||||
return (ARCHIVE_FATAL);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2851,7 +2851,6 @@ xml_data(void *userData, const char *s, size_t len)
|
||||
xar->file->has |= HAS_XATTR;
|
||||
archive_strncpy(&(xar->xattr->fstype), s, len);
|
||||
break;
|
||||
break;
|
||||
case FILE_ACL_DEFAULT:
|
||||
case FILE_ACL_ACCESS:
|
||||
case FILE_ACL_APPLEEXTENDED:
|
||||
@@ -3343,6 +3342,326 @@ expat_read_toc(struct archive_read *a)
|
||||
XML_ParserFree(parser);
|
||||
return (ud.state);
|
||||
}
|
||||
#endif /* defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H) */
|
||||
|
||||
#elif defined(HAVE_XMLLITE_H)
|
||||
|
||||
struct ArchiveStreamAdapter {
|
||||
const ISequentialStreamVtbl *lpVtbl; /* see asaStaticVtable */
|
||||
struct archive_read *a;
|
||||
};
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE
|
||||
asaQueryInterface(ISequentialStream *this, REFIID riid, void **ppv)
|
||||
{
|
||||
if (!IsEqualIID(riid, &IID_ISequentialStream)) {
|
||||
*ppv = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
*ppv = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* We can dispense with reference counting as we tightly manage the lifetime
|
||||
* of an ArchiveStreamAdapter.
|
||||
*/
|
||||
static ULONG STDMETHODCALLTYPE
|
||||
asaAddRef(ISequentialStream *this)
|
||||
{
|
||||
(void)this; /* UNUSED */
|
||||
return ULONG_MAX;
|
||||
}
|
||||
|
||||
static ULONG STDMETHODCALLTYPE
|
||||
asaRelease(ISequentialStream *this)
|
||||
{
|
||||
(void)this; /* UNUSED */
|
||||
return ULONG_MAX;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE
|
||||
asaRead(ISequentialStream *this, void *pv, ULONG cb, ULONG *pcbRead)
|
||||
{
|
||||
struct ArchiveStreamAdapter *asa = (struct ArchiveStreamAdapter *)this;
|
||||
struct archive_read *a;
|
||||
struct xar *xar;
|
||||
const void *d = pv;
|
||||
size_t outbytes = cb;
|
||||
size_t used = 0;
|
||||
int r;
|
||||
|
||||
a = asa->a;
|
||||
xar = (struct xar *)(a->format->data);
|
||||
|
||||
*pcbRead = 0;
|
||||
|
||||
if (xar->toc_remaining <= 0)
|
||||
return cb != 0 ? S_FALSE : S_OK;
|
||||
|
||||
r = rd_contents(a, &d, &outbytes, &used, xar->toc_remaining);
|
||||
if (r != ARCHIVE_OK)
|
||||
return E_FAIL;
|
||||
__archive_read_consume(a, used);
|
||||
xar->toc_remaining -= used;
|
||||
xar->offset += used;
|
||||
xar->toc_total += outbytes;
|
||||
PRINT_TOC(pv, outbytes);
|
||||
|
||||
*pcbRead = (ULONG)outbytes;
|
||||
return outbytes < cb ? S_FALSE : S_OK;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE
|
||||
asaWrite(ISequentialStream *this, const void *pv, ULONG cb, ULONG *pcbWritten)
|
||||
{
|
||||
(void)this; /* UNUSED */
|
||||
(void)pv; /* UNUSED */
|
||||
(void)cb; /* UNUSED */
|
||||
if (!pcbWritten) return E_INVALIDARG;
|
||||
*pcbWritten = 0;
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static const ISequentialStreamVtbl asaStaticVtable = {
|
||||
.QueryInterface = asaQueryInterface,
|
||||
.AddRef = asaAddRef,
|
||||
.Release = asaRelease,
|
||||
.Read = asaRead,
|
||||
.Write = asaWrite,
|
||||
};
|
||||
|
||||
static int
|
||||
xmllite_create_stream_adapter(struct archive_read *a,
|
||||
struct ArchiveStreamAdapter **pasa)
|
||||
{
|
||||
struct ArchiveStreamAdapter *asa =
|
||||
calloc(1, sizeof(struct ArchiveStreamAdapter));
|
||||
if (!asa) {
|
||||
archive_set_error(&(a->archive), ENOMEM, "Out of memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
asa->lpVtbl = &asaStaticVtable;
|
||||
asa->a = a;
|
||||
*pasa = asa;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
typedef HRESULT(STDMETHODCALLTYPE *xmllite_wstr_func)(IXmlReader *, LPCWSTR *,
|
||||
UINT *);
|
||||
|
||||
/*
|
||||
* Returns an narrow-char archive_string in *as after calling
|
||||
* the wide-char COM API callee() on the XmlReader reader.
|
||||
* Sets an appropriate error on the archive if it fails.
|
||||
*/
|
||||
static int
|
||||
xmllite_call_return_as(struct archive_read *a, struct archive_string *as,
|
||||
IXmlReader *reader, xmllite_wstr_func callee)
|
||||
{
|
||||
LPCWSTR wcs;
|
||||
UINT wlen;
|
||||
|
||||
if (FAILED(callee(reader, &wcs, &wlen))) {
|
||||
archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
|
||||
"Failed to read XML data");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
archive_string_init(as);
|
||||
if (archive_string_append_from_wcs(as, wcs, (size_t)wlen) < 0) {
|
||||
archive_string_free(as);
|
||||
archive_set_error(&(a->archive), ENOMEM, "Out of memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
static char *
|
||||
xmllite_call_return_mbs(struct archive_read *a, IXmlReader *reader,
|
||||
xmllite_wstr_func callee)
|
||||
{
|
||||
char *ret;
|
||||
struct archive_string as;
|
||||
|
||||
if (xmllite_call_return_as(a, &as, reader, callee) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = strdup(as.s);
|
||||
archive_string_free(&as);
|
||||
if (ret == NULL) {
|
||||
archive_set_error(&(a->archive), ENOMEM, "Out of memory");
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
xmllite_xmlattr_setup(struct archive_read *a,
|
||||
struct xmlattr_list *list, IXmlReader *reader)
|
||||
{
|
||||
struct xmlattr *attr;
|
||||
HRESULT hr;
|
||||
|
||||
list->first = NULL;
|
||||
list->last = &(list->first);
|
||||
hr = reader->lpVtbl->MoveToFirstAttribute(reader);
|
||||
/* Contrary to other checks, we're not using SUCCEEDED/FAILED
|
||||
* because MoveToNextAttribute returns *S_FALSE* (success!)
|
||||
* when it runs out of attributes.
|
||||
*/
|
||||
while (hr == S_OK) {
|
||||
/* Attributes implied as being default by the DTD are ignored */
|
||||
if (reader->lpVtbl->IsDefault(reader))
|
||||
continue;
|
||||
|
||||
attr = malloc(sizeof*(attr));
|
||||
if (attr == NULL) {
|
||||
archive_set_error(&(a->archive), ENOMEM,
|
||||
"Out of memory");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
attr->name = xmllite_call_return_mbs(a, reader,
|
||||
reader->lpVtbl->GetLocalName);
|
||||
if (attr->name == NULL) {
|
||||
free(attr);
|
||||
/* xmllite_call_return_mbs sets an appropriate error */
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
attr->value = xmllite_call_return_mbs(a, reader,
|
||||
reader->lpVtbl->GetValue);
|
||||
if (attr->value == NULL) {
|
||||
free(attr->name);
|
||||
free(attr);
|
||||
/* xmllite_call_return_mbs sets an appropriate error */
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
attr->next = NULL;
|
||||
*list->last = attr;
|
||||
list->last = &(attr->next);
|
||||
hr = reader->lpVtbl->MoveToNextAttribute(reader);
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
archive_set_error(&(a->archive), ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Failed to parse XML document");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
xmllite_read_toc(struct archive_read *a)
|
||||
{
|
||||
struct ArchiveStreamAdapter *asa = NULL;
|
||||
char *name;
|
||||
struct archive_string as;
|
||||
BOOL empty;
|
||||
XmlNodeType type;
|
||||
struct xmlattr_list list;
|
||||
IXmlReader *reader = NULL;
|
||||
int r = ARCHIVE_OK;
|
||||
|
||||
if ((r = xmllite_create_stream_adapter(a, &asa)) < 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (FAILED(CreateXmlReader(&IID_IXmlReader, (void **)&reader, NULL))) {
|
||||
r = ARCHIVE_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (FAILED(reader->lpVtbl->SetInput(reader, (IUnknown *)asa))) {
|
||||
archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
|
||||
"Failed to prepare XML stream");
|
||||
r = ARCHIVE_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
while (!reader->lpVtbl->IsEOF(reader)) {
|
||||
if (FAILED(reader->lpVtbl->Read(reader, &type))) {
|
||||
archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
|
||||
"Failed to read XML stream");
|
||||
r = ARCHIVE_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case XmlNodeType_Element:
|
||||
empty = reader->lpVtbl->IsEmptyElement(reader);
|
||||
|
||||
name = xmllite_call_return_mbs(a, reader,
|
||||
reader->lpVtbl->GetLocalName);
|
||||
if (name == NULL) {
|
||||
/* xmllite_call_return_mbs sets an appropriate error */
|
||||
r = ARCHIVE_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
r = xmllite_xmlattr_setup(a, &list, reader);
|
||||
if (r == ARCHIVE_OK) {
|
||||
r = xml_start(a, name, &list);
|
||||
}
|
||||
xmlattr_cleanup(&list);
|
||||
if (r == ARCHIVE_OK && empty) {
|
||||
xml_end(a, name);
|
||||
}
|
||||
|
||||
free(name);
|
||||
if (r != ARCHIVE_OK) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
break;
|
||||
case XmlNodeType_EndElement:
|
||||
name = xmllite_call_return_mbs(a, reader,
|
||||
reader->lpVtbl->GetLocalName);
|
||||
if (name == NULL) {
|
||||
/* xmllite_call_return_mbs sets an appropriate error */
|
||||
r = ARCHIVE_FATAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
xml_end(a, name);
|
||||
free(name);
|
||||
break;
|
||||
case XmlNodeType_Text:
|
||||
r = xmllite_call_return_as(a, &as, reader,
|
||||
reader->lpVtbl->GetValue);
|
||||
if (r != ARCHIVE_OK) {
|
||||
/* xmllite_call_return_as sets an appropriate error */
|
||||
goto out;
|
||||
}
|
||||
|
||||
xml_data(a, as.s, (int)archive_strlen(&as));
|
||||
archive_string_free(&as);
|
||||
|
||||
case XmlNodeType_None:
|
||||
case XmlNodeType_Attribute:
|
||||
case XmlNodeType_CDATA:
|
||||
case XmlNodeType_ProcessingInstruction:
|
||||
case XmlNodeType_Comment:
|
||||
case XmlNodeType_DocumentType:
|
||||
case XmlNodeType_Whitespace:
|
||||
case XmlNodeType_XmlDeclaration:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (reader)
|
||||
reader->lpVtbl->Release(reader);
|
||||
|
||||
free(asa);
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif /* defined(XMLLITE) */
|
||||
|
||||
#endif /* Support xar format */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user