From e117869ad30ae48ff0943c9497c626fddbc899ba Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Wed, 20 May 2020 16:13:02 +0000 Subject: [PATCH] Update vendor/libarchive/dist to git fc6563f5130d8a7ee1fc27c0e55baef35119f26c Libarchive 3.4.3 Relevant vendor changes: PR #1352: support negative zstd compression levels PR #1359: improve zstd version checking PR #1348: support RHT.security.selinux from GNU tar PR #1357: support for archives compressed with pzstd PR #1367: fix issues in acl tests PR #1372: child handling cleanup PR #1378: fix memory leak from passphrase callback --- CMakeLists.txt | 29 +- Makefile.am | 7 +- NEWS | 6 + README.md | 2 +- build/ci/github_actions/ci.cmd | 2 +- build/cmake/CreatePkgConfigFile.cmake | 4 +- build/version | 2 +- configure.ac | 2 +- contrib/oss-fuzz/corpus.zip | Bin 0 -> 4675 bytes contrib/oss-fuzz/libarchive_fuzzer.cc | 49 ++ contrib/oss-fuzz/oss-fuzz-build.sh | 16 + libarchive/archive.h | 2 +- libarchive/archive_digest.c | 534 ++++++------------ libarchive/archive_entry.c | 6 +- libarchive/archive_entry_stat.3 | 4 +- libarchive/archive_read_add_passphrase.c | 4 + libarchive/archive_read_disk_posix.c | 46 +- .../archive_read_support_filter_program.c | 23 +- libarchive/archive_read_support_filter_zstd.c | 4 + libarchive/archive_read_support_format_rar5.c | 6 - libarchive/archive_read_support_format_tar.c | 18 + libarchive/archive_write_add_filter_program.c | 26 +- libarchive/archive_write_add_filter_zstd.c | 79 ++- libarchive/archive_write_set_options.3 | 3 +- libarchive/filter_fork.h | 9 +- libarchive/filter_fork_posix.c | 10 +- libarchive/filter_fork_windows.c | 17 +- libarchive/test/CMakeLists.txt | 3 +- libarchive/test/test_acl_platform_nfs4.c | 2 + libarchive/test/test_acl_platform_posix1e.c | 4 +- libarchive/test/test_compat_zstd.c | 3 + libarchive/test/test_compat_zstd_2.tar.zst.uu | 8 + ...test_read_pax_xattr_rht_security_selinux.c | 62 ++ ...read_pax_xattr_rht_security_selinux.tar.uu | 231 ++++++++ ...y_xattr.c => test_read_pax_xattr_schily.c} | 4 +- ...r.uu => test_read_pax_xattr_schily.tar.uu} | 2 +- libarchive/test/test_write_filter_zstd.c | 3 + tar/bsdtar.1 | 3 +- 38 files changed, 754 insertions(+), 481 deletions(-) create mode 100644 contrib/oss-fuzz/corpus.zip create mode 100644 contrib/oss-fuzz/libarchive_fuzzer.cc create mode 100755 contrib/oss-fuzz/oss-fuzz-build.sh create mode 100644 libarchive/test/test_compat_zstd_2.tar.zst.uu create mode 100644 libarchive/test/test_read_pax_xattr_rht_security_selinux.c create mode 100644 libarchive/test/test_read_pax_xattr_rht_security_selinux.tar.uu rename libarchive/test/{test_read_pax_schily_xattr.c => test_read_pax_xattr_schily.c} (96%) rename libarchive/test/{test_read_pax_schily_xattr.tar.uu => test_read_pax_xattr_schily.tar.uu} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a9f3d19ac0e..b2634da6fa59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ endif() # RelWithDebInfo : Release build with Debug Info # MinSizeRel : Release Min Size build IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Type" FORCE) + SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE) ENDIF(NOT CMAKE_BUILD_TYPE) # Set a value type to properly display CMAKE_BUILD_TYPE on GUI if the # value type is "UNINITIALIZED". @@ -157,32 +157,32 @@ IF (MSVC) # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug" # Enable level 4 C4062: The enumerate has no associated handler in a switch # statement and there is no default that can catch it. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4062") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14062") # Enable level 4 C4254: A larger bit field was assigned to a smaller bit # field. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4254") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14254") # Enable level 4 C4295: An array was initialized but the last character in # the array is not a null; accessing the array may # produce unexpected results. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4295") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14295") # Enable level 4 C4296: An unsigned variable was used in a comparison # operation with zero. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4296") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14296") # Enable level 4 C4389: An operation involved signed and unsigned variables. # This could result in a loss of data. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4389") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14389") # Enable level 4 C4505: The given function is local and not referenced in # the body of the module; therefore, the function is # dead code. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4505") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14505") # Enable level 4 C4514: The optimizer removed an inline function that is not # called. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4514") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14514") # Enable level 4 C4702: Unreachable code. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4702") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14702") # Enable level 4 C4706: The test value in a conditional expression was the # result of an assignment. - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /we4706") + SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /w14706") # /Oi option enables built-in functions. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Oi") ################################################################# @@ -1449,9 +1449,13 @@ CHECK_C_SOURCE_COMPILES( "#include \nint main() { return major(256); }" MAJOR_IN_SYSMACROS) +IF(ENABLE_LZMA) CHECK_C_SOURCE_COMPILES( "#include \n#if LZMA_VERSION < 50020000\n#error unsupported\n#endif\nint main(void){lzma_stream_encoder_mt(0, 0); return 0;}" HAVE_LZMA_STREAM_ENCODER_MT) +ELSE() + SET(HAVE_LZMA_STREAM_ENCODER_MT 0) +ENDIF(ENABLE_LZMA) IF(HAVE_STRERROR_R) SET(HAVE_DECL_STRERROR_R 1) @@ -2036,6 +2040,11 @@ 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) + IF(ENABLE_TEST) ADD_CUSTOM_TARGET(run_all_tests) ENDIF(ENABLE_TEST) diff --git a/Makefile.am b/Makefile.am index 78d674d5d066..d526daa7356b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -539,7 +539,8 @@ libarchive_test_SOURCES= \ libarchive/test/test_read_format_zip_zip64.c \ libarchive/test/test_read_format_zip_with_invalid_traditional_eocd.c \ libarchive/test/test_read_large.c \ - libarchive/test/test_read_pax_schily_xattr.c \ + libarchive/test/test_read_pax_xattr_rht_security_selinux.c \ + libarchive/test/test_read_pax_xattr_schily.c \ libarchive/test/test_read_pax_truncated.c \ libarchive/test/test_read_position.c \ libarchive/test/test_read_set_format.c \ @@ -701,6 +702,7 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_compat_zip_7.xps.uu \ libarchive/test/test_compat_zip_8.zip.uu \ libarchive/test/test_compat_zstd_1.tar.zst.uu \ + libarchive/test/test_compat_zstd_2.tar.zst.uu \ libarchive/test/test_fuzz.cab.uu \ libarchive/test/test_fuzz.lzh.uu \ libarchive/test/test_fuzz_1.iso.Z.uu \ @@ -946,7 +948,8 @@ libarchive_test_EXTRA_DIST=\ libarchive/test/test_read_large_splitted_rar_ac.uu \ libarchive/test/test_read_large_splitted_rar_ad.uu \ libarchive/test/test_read_large_splitted_rar_ae.uu \ - libarchive/test/test_read_pax_schily_xattr.tar.uu \ + libarchive/test/test_read_pax_xattr_rht_security_selinux.tar.uu \ + libarchive/test/test_read_pax_xattr_schily.tar.uu \ libarchive/test/test_read_splitted_rar_aa.uu \ libarchive/test/test_read_splitted_rar_ab.uu \ libarchive/test/test_read_splitted_rar_ac.uu \ diff --git a/NEWS b/NEWS index 15360f5d9d00..47e2dd6a4d7b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +May 20, 2020: libarchive 3.4.3 released + +Apr 30, 2020: Support for pzstd compressed files + +Apr 16, 2020: Support for RHT.security.selinux tar extended attribute + Feb 11, 2020: libarchive 3.4.2 released Jan 23, 2020: Important fixes for writing XAR archives diff --git a/README.md b/README.md index 2912b3d0a61e..56cd723daa47 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ know about any errors or omissions you find. ## Supported Formats -Currently, the library automatically detects and reads the following fomats: +Currently, the library automatically detects and reads the following formats: * Old V7 tar archives * POSIX ustar * GNU tar format (including GNU long filenames, long link names, and sparse files) diff --git a/build/ci/github_actions/ci.cmd b/build/ci/github_actions/ci.cmd index c3826ba08797..84818b5054aa 100755 --- a/build/ci/github_actions/ci.cmd +++ b/build/ci/github_actions/ci.cmd @@ -1,7 +1,7 @@ @ECHO OFF SET ZLIB_VERSION=1.2.11 SET BZIP2_VERSION=b7a672291188a6469f71dd13ad14f2f9a7344fc8 -SET XZ_VERSION=292a5c0f9c9b3a66f5a5c652dc46381836d4537f +SET XZ_VERSION=2327a461e1afce862c22269b80d3517801103c1b IF NOT "%BE%"=="mingw-gcc" ( IF NOT "%BE%"=="msvc" ( ECHO Environment variable BE must be mingw-gcc or msvc diff --git a/build/cmake/CreatePkgConfigFile.cmake b/build/cmake/CreatePkgConfigFile.cmake index fc8529a571f2..bc5a43f72af1 100644 --- a/build/cmake/CreatePkgConfigFile.cmake +++ b/build/cmake/CreatePkgConfigFile.cmake @@ -24,10 +24,10 @@ ENDFOREACH() # thus there's a good chance it'll make some binutils versions unhappy... # This only affects Libs.private (looked up for static builds) though. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in - ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc + ${CMAKE_CURRENT_BINARY_DIR}/build/pkgconfig/libarchive.pc @ONLY) # And install it, of course ;). IF(ENABLE_INSTALL) - INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/build/pkgconfig/libarchive.pc DESTINATION "lib/pkgconfig") ENDIF() diff --git a/build/version b/build/version index c4da5ab09945..2e3400d77cb2 100644 --- a/build/version +++ b/build/version @@ -1 +1 @@ -3004003dev +3004003 diff --git a/configure.ac b/configure.ac index 1f533665565b..3720296bbf1e 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ 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.4.3dev]) +m4_define([LIBARCHIVE_VERSION_S],[3.4.3]) m4_define([LIBARCHIVE_VERSION_N],[3004003]) dnl bsdtar and bsdcpio versioning tracks libarchive diff --git a/contrib/oss-fuzz/corpus.zip b/contrib/oss-fuzz/corpus.zip new file mode 100644 index 0000000000000000000000000000000000000000..4e9e249582461cae90991f3505ac6fee622be046 GIT binary patch literal 4675 zcmeHLc|4T)AAe@XI0n1U(&0?5+&N1np>bu#5yN0)9OFukjgewq5vy!cj;xJD?lWy$ zD3x_p6xz1rjL0q4;`e=qZN|~=Kfm99zsKt{^UO2zyr0ke^Z9<>pU)T02*tz)K@cnC zlbD3d5pbej1fMEtS9U^v&dy|cC&v?(7Hkkod{2fwYypAn5Q6Cg3W8`as&R)gb&6bi zIm0qJb1YKddsyjl5t%U5FgJa3tSwgmNRenD|F=Cc#}g%znJ2dXaI)#6h9yJ2M_LXdGaK0scb}1~3|`CARy6bJ$p* zRYtB<8X>YwhCOWS2nkH@{YUR0nL&J^Kr~3qs?!v|lQgfFforg> z^Lq66cOGrpJE3t4%$0);{+ zfJ5-Mg5U7m8LV&eFJpG{KH}m&cqZ`Be>(c|Dm3H=e@@r;81uSAsHpti`&jOSk+F}a z4VORuQ0bX~iM*vDEpzaG-u32hOm9>-bP+9{ChC-5Yuw&1OsvdM7Wt%ofTFr@RKLv3 zv`&immDTZ{`hw5IqIDN)1TW73ja2QY?{MwP%A+x{1`Tg*P zYz=$1-?P;XoU7Wr<-C*ky)1a#;&%Mi6D2~xma-I+M;-CrA0(0}Z4<55u}6;tR#?av zC3Rd$?$tO~AhM+AFDJJ3kNM*HoHvi1c6irU36GrvRJ)gci(f8TSYm;o&;`%G`VS3) zGYER)+R@P&($Lz{ly6^9vf!obEt-;{+azrIqF1)(`HyE*Vgfr25^X3q&g7^wLvL<% z?f->!@$KOckvAUJc1v*{{k8XW>xKB*pgEt*H^;b>mPi(Em z#EPm4UsdlNRA<>nR609ej%{tUdeZj!#E{GudFBoUS6$;YiQtggN#%k!gc4p)FIvS3UL9+a zMrpjcRWrL%I^QU@vn2QQQgngcgv@aC6(JebkajhXw%N$HkNI~D(i0!&d4-iK zZ5EeP-_DqJ&gsfA_oZ2}U^K7o z-mRI7(Tu4!*hjp+yBlHW}fuaz=7_vaMJ-LrbX! ztSo-~gp`bF^PcyZ1|KI<`3Vgi5tGCKVMcULC_aAw!MRR?n3kCt#gN2b7LxJ0{ z(NjWoqq(jMiU78Cu1i32o^Gmg1aJ%7q2P`vg6vg?fFkKdu|Nn~bA%vUbKlY(OhuiD znFxZJ1zb#HL~-KF4W30CM%xP{I1)@g zMNYO0HERW^h$abyBo3HxBrhp6brjVYpWIJk2tK^1-aQ)Gn*`j*S<7IhC4Qxmf1Hk) zbnWg>?BP+wxpn)K$j&Y#5}D*ii|k?ZO9!RF=pqq)O}UIuqA4n84IHN|C? z=5zfN+-qJ)xDsyh6!%!XRgftpqF18i)gz`MM18LipI8!K1OIp5F1qv0FT9X*wha|L zeH@QMGcnMO19U^5_HJziRAFQPTaf)7edSjtGAqCqwsnlbLW9es& znGOT3OR|6<{kV6Dy+yvw43b(I^yt&+z`TR!PvCd3eVI-J=}HMFZCxxD)v4AtVDuh% zRj!YOL=juSt^NxAH@YED$k7gxxN3OxvAbl48Wmk_+VR%R_%{jDT_lsKogxW~$FADn zL&qde^YO7393ux8RWCeu+SQVmSr{H|gQ$v2ixApU?CVkxu6M>?p($HgP-0ZC*#2FE z$()y8c$)+_^gv2Gya_xGvW^=@Nqi=_L5L8qfFiya;mWBH&}M;G1RMJJ-3$`Wc|#?0 z0ek`5m-S7h_|Sys1xP7u>lo5|I9&MfGPVPE!y3f2x@2f~f2HXEr{g-#2!RwrtqkfL zof7~qLJ%B?tT6Ztt~^T%G=$nDjW{DvxZps5KSS`I3V&dz78pHP^&QCtT!oDuJU{<0 z^q+5B9#Rzwi{f6*NJu$~ck55mXlxl9T1>N8bT&C+MpgO5FFpa(NVLXzq57FLRh`Tr zHBn)`9kU;Ept*2B@EuN=7t;A3A(AAf#+5k0eCTml*+qg_Y_fw~L8Dj2+C3X1+6#aQN0p`*UkfZfMH}~0j9}3q zQ#3Hz&I+Jyva4bwx^bdpL~8|GCmI@Uz65BS%$AI3aDvxPN{ncFU~$mUXmiuQGu=3! zFro>9EzJrVJgoqzS@?-;8J}tY3Ts&HSI3t}Kv^ zU6T>*6x%8qt%m}%P5LJz(~V7u5sd^MNsHUxEeZf`(w-Or;k2$*bw)rR_EkVw +#include +#include + +#include "archive.h" + +struct Buffer { + const uint8_t *buf; + size_t len; +}; + +ssize_t reader_callback(struct archive *a, void *client_data, + const void **block) { + Buffer *buffer = reinterpret_cast(client_data); + *block = buffer->buf; + ssize_t len = buffer->len; + buffer->len = 0; + return len; +} + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) { + int ret; + ssize_t r; + struct archive *a = archive_read_new(); + + archive_read_support_filter_all(a); + archive_read_support_format_all(a); + + Buffer buffer = {buf, len}; + archive_read_open(a, &buffer, NULL, reader_callback, NULL); + + std::vector data_buffer(getpagesize(), 0); + struct archive_entry *entry; + while(1) { + ret = archive_read_next_header(a, &entry); + if (ret == ARCHIVE_EOF || ret == ARCHIVE_FATAL) + break; + if (ret == ARCHIVE_RETRY) + continue; + while ((r = archive_read_data(a, data_buffer.data(), + data_buffer.size())) > 0) + ; + if (r == ARCHIVE_FATAL) + break; + } + + archive_read_free(a); + return 0; +} diff --git a/contrib/oss-fuzz/oss-fuzz-build.sh b/contrib/oss-fuzz/oss-fuzz-build.sh new file mode 100755 index 000000000000..83d8470b13f3 --- /dev/null +++ b/contrib/oss-fuzz/oss-fuzz-build.sh @@ -0,0 +1,16 @@ +# build the project +./build/autogen.sh +./configure +make -j$(nproc) all + +# build seed +cp $SRC/libarchive/contrib/oss-fuzz/corpus.zip\ + $OUT/libarchive_fuzzer_seed_corpus.zip + +# build fuzzer(s) +$CXX $CXXFLAGS -Ilibarchive \ + $SRC/libarchive/contrib/oss-fuzz/libarchive_fuzzer.cc \ + -o $OUT/libarchive_fuzzer $LIB_FUZZING_ENGINE \ + .libs/libarchive.a -Wl,-Bstatic -lbz2 -llzo2 \ + -lxml2 -llzma -lz -lcrypto -llz4 -licuuc \ + -licudata -Wl,-Bdynamic diff --git a/libarchive/archive.h b/libarchive/archive.h index b984ef3f8e03..9791eb3876ea 100644 --- a/libarchive/archive.h +++ b/libarchive/archive.h @@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void); /* * Textual name/version of the library, useful for version displays. */ -#define ARCHIVE_VERSION_ONLY_STRING "3.4.3dev" +#define ARCHIVE_VERSION_ONLY_STRING "3.4.3" #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING __LA_DECL const char * archive_version_string(void); diff --git a/libarchive/archive_digest.c b/libarchive/archive_digest.c index 34c58ac94942..410df01563df 100644 --- a/libarchive/archive_digest.c +++ b/libarchive/archive_digest.c @@ -109,14 +109,14 @@ win_crypto_Final(unsigned char *buf, size_t bufsize, Digest_CTX *ctx) #if defined(ARCHIVE_CRYPTO_MD5_LIBC) static int -__archive_libc_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { MD5Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { MD5Update(ctx, indata, insize); @@ -124,7 +124,7 @@ __archive_libc_md5update(archive_md5_ctx *ctx, const void *indata, } static int -__archive_libc_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { MD5Final(md, ctx); return (ARCHIVE_OK); @@ -133,14 +133,14 @@ __archive_libc_md5final(archive_md5_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_MD5_LIBMD) static int -__archive_libmd_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { MD5Init(ctx); return (ARCHIVE_OK); } static int -__archive_libmd_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { MD5Update(ctx, indata, insize); @@ -148,7 +148,7 @@ __archive_libmd_md5update(archive_md5_ctx *ctx, const void *indata, } static int -__archive_libmd_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { MD5Final(md, ctx); return (ARCHIVE_OK); @@ -157,14 +157,14 @@ __archive_libmd_md5final(archive_md5_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) static int -__archive_libsystem_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { CC_MD5_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libsystem_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { CC_MD5_Update(ctx, indata, insize); @@ -172,7 +172,7 @@ __archive_libsystem_md5update(archive_md5_ctx *ctx, const void *indata, } static int -__archive_libsystem_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { CC_MD5_Final(md, ctx); return (ARCHIVE_OK); @@ -181,7 +181,7 @@ __archive_libsystem_md5final(archive_md5_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_MD5_MBEDTLS) static int -__archive_mbedtls_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { mbedtls_md5_init(ctx); if (mbedtls_md5_starts_ret(ctx) == 0) @@ -191,7 +191,7 @@ __archive_mbedtls_md5init(archive_md5_ctx *ctx) } static int -__archive_mbedtls_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { if (mbedtls_md5_update_ret(ctx, indata, insize) == 0) @@ -201,7 +201,7 @@ __archive_mbedtls_md5update(archive_md5_ctx *ctx, const void *indata, } static int -__archive_mbedtls_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { if (mbedtls_md5_finish_ret(ctx, md) == 0) { mbedtls_md5_free(ctx); @@ -215,14 +215,14 @@ __archive_mbedtls_md5final(archive_md5_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_MD5_NETTLE) static int -__archive_nettle_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { md5_init(ctx); return (ARCHIVE_OK); } static int -__archive_nettle_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { md5_update(ctx, insize, indata); @@ -230,7 +230,7 @@ __archive_nettle_md5update(archive_md5_ctx *ctx, const void *indata, } static int -__archive_nettle_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { md5_digest(ctx, MD5_DIGEST_SIZE, md); return (ARCHIVE_OK); @@ -239,7 +239,7 @@ __archive_nettle_md5final(archive_md5_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL) static int -__archive_openssl_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { if ((*ctx = EVP_MD_CTX_new()) == NULL) return (ARCHIVE_FAILED); @@ -248,7 +248,7 @@ __archive_openssl_md5init(archive_md5_ctx *ctx) } static int -__archive_openssl_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { EVP_DigestUpdate(*ctx, indata, insize); @@ -256,7 +256,7 @@ __archive_openssl_md5update(archive_md5_ctx *ctx, const void *indata, } static int -__archive_openssl_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { /* HACK: archive_write_set_format_xar.c is finalizing empty contexts, so * this is meant to cope with that. Real fix is probably to fix @@ -273,20 +273,20 @@ __archive_openssl_md5final(archive_md5_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_MD5_WIN) static int -__archive_windowsapi_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { return (win_crypto_init(ctx, CALG_MD5)); } static int -__archive_windowsapi_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { return (win_crypto_Update(ctx, indata, insize)); } static int -__archive_windowsapi_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { return (win_crypto_Final(md, 16, ctx)); } @@ -294,14 +294,14 @@ __archive_windowsapi_md5final(archive_md5_ctx *ctx, void *md) #else static int -__archive_stub_md5init(archive_md5_ctx *ctx) +__archive_md5init(archive_md5_ctx *ctx) { (void)ctx; /* UNUSED */ return (ARCHIVE_FAILED); } static int -__archive_stub_md5update(archive_md5_ctx *ctx, const void *indata, +__archive_md5update(archive_md5_ctx *ctx, const void *indata, size_t insize) { (void)ctx; /* UNUSED */ @@ -311,7 +311,7 @@ __archive_stub_md5update(archive_md5_ctx *ctx, const void *indata, } static int -__archive_stub_md5final(archive_md5_ctx *ctx, void *md) +__archive_md5final(archive_md5_ctx *ctx, void *md) { (void)ctx; /* UNUSED */ (void)md; /* UNUSED */ @@ -324,14 +324,14 @@ __archive_stub_md5final(archive_md5_ctx *ctx, void *md) #if defined(ARCHIVE_CRYPTO_RMD160_LIBC) static int -__archive_libc_ripemd160init(archive_rmd160_ctx *ctx) +__archive_ripemd160init(archive_rmd160_ctx *ctx) { RMD160Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, +__archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, size_t insize) { RMD160Update(ctx, indata, insize); @@ -339,7 +339,7 @@ __archive_libc_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, } static int -__archive_libc_ripemd160final(archive_rmd160_ctx *ctx, void *md) +__archive_ripemd160final(archive_rmd160_ctx *ctx, void *md) { RMD160Final(md, ctx); return (ARCHIVE_OK); @@ -348,14 +348,14 @@ __archive_libc_ripemd160final(archive_rmd160_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD) static int -__archive_libmd_ripemd160init(archive_rmd160_ctx *ctx) +__archive_ripemd160init(archive_rmd160_ctx *ctx) { RIPEMD160_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libmd_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, +__archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, size_t insize) { RIPEMD160_Update(ctx, indata, insize); @@ -363,7 +363,7 @@ __archive_libmd_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, } static int -__archive_libmd_ripemd160final(archive_rmd160_ctx *ctx, void *md) +__archive_ripemd160final(archive_rmd160_ctx *ctx, void *md) { RIPEMD160_Final(md, ctx); return (ARCHIVE_OK); @@ -372,7 +372,7 @@ __archive_libmd_ripemd160final(archive_rmd160_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS) static int -__archive_mbedtls_ripemd160init(archive_rmd160_ctx *ctx) +__archive_ripemd160init(archive_rmd160_ctx *ctx) { mbedtls_ripemd160_init(ctx); if (mbedtls_ripemd160_starts_ret(ctx) == 0) @@ -382,7 +382,7 @@ __archive_mbedtls_ripemd160init(archive_rmd160_ctx *ctx) } static int -__archive_mbedtls_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, +__archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, size_t insize) { if (mbedtls_ripemd160_update_ret(ctx, indata, insize) == 0) @@ -392,7 +392,7 @@ __archive_mbedtls_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, } static int -__archive_mbedtls_ripemd160final(archive_rmd160_ctx *ctx, void *md) +__archive_ripemd160final(archive_rmd160_ctx *ctx, void *md) { if (mbedtls_ripemd160_finish_ret(ctx, md) == 0) { mbedtls_ripemd160_free(ctx); @@ -406,14 +406,14 @@ __archive_mbedtls_ripemd160final(archive_rmd160_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE) static int -__archive_nettle_ripemd160init(archive_rmd160_ctx *ctx) +__archive_ripemd160init(archive_rmd160_ctx *ctx) { ripemd160_init(ctx); return (ARCHIVE_OK); } static int -__archive_nettle_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, +__archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, size_t insize) { ripemd160_update(ctx, insize, indata); @@ -421,7 +421,7 @@ __archive_nettle_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, } static int -__archive_nettle_ripemd160final(archive_rmd160_ctx *ctx, void *md) +__archive_ripemd160final(archive_rmd160_ctx *ctx, void *md) { ripemd160_digest(ctx, RIPEMD160_DIGEST_SIZE, md); return (ARCHIVE_OK); @@ -430,7 +430,7 @@ __archive_nettle_ripemd160final(archive_rmd160_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL) static int -__archive_openssl_ripemd160init(archive_rmd160_ctx *ctx) +__archive_ripemd160init(archive_rmd160_ctx *ctx) { if ((*ctx = EVP_MD_CTX_new()) == NULL) return (ARCHIVE_FAILED); @@ -439,7 +439,7 @@ __archive_openssl_ripemd160init(archive_rmd160_ctx *ctx) } static int -__archive_openssl_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, +__archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, size_t insize) { EVP_DigestUpdate(*ctx, indata, insize); @@ -447,7 +447,7 @@ __archive_openssl_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, } static int -__archive_openssl_ripemd160final(archive_rmd160_ctx *ctx, void *md) +__archive_ripemd160final(archive_rmd160_ctx *ctx, void *md) { if (*ctx) { EVP_DigestFinal(*ctx, md, NULL); @@ -460,14 +460,14 @@ __archive_openssl_ripemd160final(archive_rmd160_ctx *ctx, void *md) #else static int -__archive_stub_ripemd160init(archive_rmd160_ctx *ctx) +__archive_ripemd160init(archive_rmd160_ctx *ctx) { (void)ctx; /* UNUSED */ return (ARCHIVE_FAILED); } static int -__archive_stub_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, +__archive_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, size_t insize) { (void)ctx; /* UNUSED */ @@ -477,7 +477,7 @@ __archive_stub_ripemd160update(archive_rmd160_ctx *ctx, const void *indata, } static int -__archive_stub_ripemd160final(archive_rmd160_ctx *ctx, void *md) +__archive_ripemd160final(archive_rmd160_ctx *ctx, void *md) { (void)ctx; /* UNUSED */ (void)md; /* UNUSED */ @@ -490,14 +490,14 @@ __archive_stub_ripemd160final(archive_rmd160_ctx *ctx, void *md) #if defined(ARCHIVE_CRYPTO_SHA1_LIBC) static int -__archive_libc_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { SHA1Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { SHA1Update(ctx, indata, insize); @@ -505,7 +505,7 @@ __archive_libc_sha1update(archive_sha1_ctx *ctx, const void *indata, } static int -__archive_libc_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { SHA1Final(md, ctx); return (ARCHIVE_OK); @@ -514,14 +514,14 @@ __archive_libc_sha1final(archive_sha1_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD) static int -__archive_libmd_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { SHA1_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libmd_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { SHA1_Update(ctx, indata, insize); @@ -529,7 +529,7 @@ __archive_libmd_sha1update(archive_sha1_ctx *ctx, const void *indata, } static int -__archive_libmd_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { SHA1_Final(md, ctx); return (ARCHIVE_OK); @@ -538,14 +538,14 @@ __archive_libmd_sha1final(archive_sha1_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) static int -__archive_libsystem_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { CC_SHA1_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libsystem_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { CC_SHA1_Update(ctx, indata, insize); @@ -553,7 +553,7 @@ __archive_libsystem_sha1update(archive_sha1_ctx *ctx, const void *indata, } static int -__archive_libsystem_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { CC_SHA1_Final(md, ctx); return (ARCHIVE_OK); @@ -562,7 +562,7 @@ __archive_libsystem_sha1final(archive_sha1_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS) static int -__archive_mbedtls_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { mbedtls_sha1_init(ctx); if (mbedtls_sha1_starts_ret(ctx) == 0) @@ -572,7 +572,7 @@ __archive_mbedtls_sha1init(archive_sha1_ctx *ctx) } static int -__archive_mbedtls_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { if (mbedtls_sha1_update_ret(ctx, indata, insize) == 0) @@ -582,7 +582,7 @@ __archive_mbedtls_sha1update(archive_sha1_ctx *ctx, const void *indata, } static int -__archive_mbedtls_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { if (mbedtls_sha1_finish_ret(ctx, md) == 0) { mbedtls_sha1_free(ctx); @@ -596,14 +596,14 @@ __archive_mbedtls_sha1final(archive_sha1_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE) static int -__archive_nettle_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { sha1_init(ctx); return (ARCHIVE_OK); } static int -__archive_nettle_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { sha1_update(ctx, insize, indata); @@ -611,7 +611,7 @@ __archive_nettle_sha1update(archive_sha1_ctx *ctx, const void *indata, } static int -__archive_nettle_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { sha1_digest(ctx, SHA1_DIGEST_SIZE, md); return (ARCHIVE_OK); @@ -620,7 +620,7 @@ __archive_nettle_sha1final(archive_sha1_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) static int -__archive_openssl_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { if ((*ctx = EVP_MD_CTX_new()) == NULL) return (ARCHIVE_FAILED); @@ -629,7 +629,7 @@ __archive_openssl_sha1init(archive_sha1_ctx *ctx) } static int -__archive_openssl_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { EVP_DigestUpdate(*ctx, indata, insize); @@ -637,7 +637,7 @@ __archive_openssl_sha1update(archive_sha1_ctx *ctx, const void *indata, } static int -__archive_openssl_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { /* HACK: archive_write_set_format_xar.c is finalizing empty contexts, so * this is meant to cope with that. Real fix is probably to fix @@ -654,20 +654,20 @@ __archive_openssl_sha1final(archive_sha1_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA1_WIN) static int -__archive_windowsapi_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { return (win_crypto_init(ctx, CALG_SHA1)); } static int -__archive_windowsapi_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { return (win_crypto_Update(ctx, indata, insize)); } static int -__archive_windowsapi_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { return (win_crypto_Final(md, 20, ctx)); } @@ -675,14 +675,14 @@ __archive_windowsapi_sha1final(archive_sha1_ctx *ctx, void *md) #else static int -__archive_stub_sha1init(archive_sha1_ctx *ctx) +__archive_sha1init(archive_sha1_ctx *ctx) { (void)ctx; /* UNUSED */ return (ARCHIVE_FAILED); } static int -__archive_stub_sha1update(archive_sha1_ctx *ctx, const void *indata, +__archive_sha1update(archive_sha1_ctx *ctx, const void *indata, size_t insize) { (void)ctx; /* UNUSED */ @@ -692,7 +692,7 @@ __archive_stub_sha1update(archive_sha1_ctx *ctx, const void *indata, } static int -__archive_stub_sha1final(archive_sha1_ctx *ctx, void *md) +__archive_sha1final(archive_sha1_ctx *ctx, void *md) { (void)ctx; /* UNUSED */ (void)md; /* UNUSED */ @@ -705,14 +705,14 @@ __archive_stub_sha1final(archive_sha1_ctx *ctx, void *md) #if defined(ARCHIVE_CRYPTO_SHA256_LIBC) static int -__archive_libc_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { SHA256_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { SHA256_Update(ctx, indata, insize); @@ -720,7 +720,7 @@ __archive_libc_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_libc_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { SHA256_Final(md, ctx); return (ARCHIVE_OK); @@ -729,14 +729,14 @@ __archive_libc_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC2) static int -__archive_libc2_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { SHA256Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc2_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { SHA256Update(ctx, indata, insize); @@ -744,7 +744,7 @@ __archive_libc2_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_libc2_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { SHA256Final(md, ctx); return (ARCHIVE_OK); @@ -753,14 +753,14 @@ __archive_libc2_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3) static int -__archive_libc3_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { SHA256Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc3_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { SHA256Update(ctx, indata, insize); @@ -768,7 +768,7 @@ __archive_libc3_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_libc3_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { SHA256Final(md, ctx); return (ARCHIVE_OK); @@ -777,14 +777,14 @@ __archive_libc3_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD) static int -__archive_libmd_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { SHA256_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libmd_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { SHA256_Update(ctx, indata, insize); @@ -792,7 +792,7 @@ __archive_libmd_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_libmd_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { SHA256_Final(md, ctx); return (ARCHIVE_OK); @@ -801,14 +801,14 @@ __archive_libmd_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) static int -__archive_libsystem_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { CC_SHA256_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libsystem_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { CC_SHA256_Update(ctx, indata, insize); @@ -816,7 +816,7 @@ __archive_libsystem_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_libsystem_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { CC_SHA256_Final(md, ctx); return (ARCHIVE_OK); @@ -825,7 +825,7 @@ __archive_libsystem_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS) static int -__archive_mbedtls_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { mbedtls_sha256_init(ctx); if (mbedtls_sha256_starts_ret(ctx, 0) == 0) @@ -835,7 +835,7 @@ __archive_mbedtls_sha256init(archive_sha256_ctx *ctx) } static int -__archive_mbedtls_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { if (mbedtls_sha256_update_ret(ctx, indata, insize) == 0) @@ -845,7 +845,7 @@ __archive_mbedtls_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_mbedtls_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { if (mbedtls_sha256_finish_ret(ctx, md) == 0) { mbedtls_sha256_free(ctx); @@ -859,14 +859,14 @@ __archive_mbedtls_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE) static int -__archive_nettle_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { sha256_init(ctx); return (ARCHIVE_OK); } static int -__archive_nettle_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { sha256_update(ctx, insize, indata); @@ -874,7 +874,7 @@ __archive_nettle_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_nettle_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { sha256_digest(ctx, SHA256_DIGEST_SIZE, md); return (ARCHIVE_OK); @@ -883,7 +883,7 @@ __archive_nettle_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) static int -__archive_openssl_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { if ((*ctx = EVP_MD_CTX_new()) == NULL) return (ARCHIVE_FAILED); @@ -892,7 +892,7 @@ __archive_openssl_sha256init(archive_sha256_ctx *ctx) } static int -__archive_openssl_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { EVP_DigestUpdate(*ctx, indata, insize); @@ -900,7 +900,7 @@ __archive_openssl_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_openssl_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { if (*ctx) { EVP_DigestFinal(*ctx, md, NULL); @@ -913,20 +913,20 @@ __archive_openssl_sha256final(archive_sha256_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA256_WIN) static int -__archive_windowsapi_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { return (win_crypto_init(ctx, CALG_SHA_256)); } static int -__archive_windowsapi_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { return (win_crypto_Update(ctx, indata, insize)); } static int -__archive_windowsapi_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { return (win_crypto_Final(md, 32, ctx)); } @@ -934,14 +934,14 @@ __archive_windowsapi_sha256final(archive_sha256_ctx *ctx, void *md) #else static int -__archive_stub_sha256init(archive_sha256_ctx *ctx) +__archive_sha256init(archive_sha256_ctx *ctx) { (void)ctx; /* UNUSED */ return (ARCHIVE_FAILED); } static int -__archive_stub_sha256update(archive_sha256_ctx *ctx, const void *indata, +__archive_sha256update(archive_sha256_ctx *ctx, const void *indata, size_t insize) { (void)ctx; /* UNUSED */ @@ -951,7 +951,7 @@ __archive_stub_sha256update(archive_sha256_ctx *ctx, const void *indata, } static int -__archive_stub_sha256final(archive_sha256_ctx *ctx, void *md) +__archive_sha256final(archive_sha256_ctx *ctx, void *md) { (void)ctx; /* UNUSED */ (void)md; /* UNUSED */ @@ -964,14 +964,14 @@ __archive_stub_sha256final(archive_sha256_ctx *ctx, void *md) #if defined(ARCHIVE_CRYPTO_SHA384_LIBC) static int -__archive_libc_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { SHA384_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { SHA384_Update(ctx, indata, insize); @@ -979,7 +979,7 @@ __archive_libc_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_libc_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { SHA384_Final(md, ctx); return (ARCHIVE_OK); @@ -988,14 +988,14 @@ __archive_libc_sha384final(archive_sha384_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC2) static int -__archive_libc2_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { SHA384Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc2_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { SHA384Update(ctx, indata, insize); @@ -1003,7 +1003,7 @@ __archive_libc2_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_libc2_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { SHA384Final(md, ctx); return (ARCHIVE_OK); @@ -1012,14 +1012,14 @@ __archive_libc2_sha384final(archive_sha384_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA384_LIBC3) static int -__archive_libc3_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { SHA384Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc3_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { SHA384Update(ctx, indata, insize); @@ -1027,7 +1027,7 @@ __archive_libc3_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_libc3_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { SHA384Final(md, ctx); return (ARCHIVE_OK); @@ -1036,14 +1036,14 @@ __archive_libc3_sha384final(archive_sha384_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM) static int -__archive_libsystem_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { CC_SHA384_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libsystem_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { CC_SHA384_Update(ctx, indata, insize); @@ -1051,7 +1051,7 @@ __archive_libsystem_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_libsystem_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { CC_SHA384_Final(md, ctx); return (ARCHIVE_OK); @@ -1060,7 +1060,7 @@ __archive_libsystem_sha384final(archive_sha384_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS) static int -__archive_mbedtls_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { mbedtls_sha512_init(ctx); if (mbedtls_sha512_starts_ret(ctx, 1) == 0) @@ -1070,7 +1070,7 @@ __archive_mbedtls_sha384init(archive_sha384_ctx *ctx) } static int -__archive_mbedtls_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { if (mbedtls_sha512_update_ret(ctx, indata, insize) == 0) @@ -1080,7 +1080,7 @@ __archive_mbedtls_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_mbedtls_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { if (mbedtls_sha512_finish_ret(ctx, md) == 0) { mbedtls_sha512_free(ctx); @@ -1094,14 +1094,14 @@ __archive_mbedtls_sha384final(archive_sha384_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE) static int -__archive_nettle_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { sha384_init(ctx); return (ARCHIVE_OK); } static int -__archive_nettle_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { sha384_update(ctx, insize, indata); @@ -1109,7 +1109,7 @@ __archive_nettle_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_nettle_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { sha384_digest(ctx, SHA384_DIGEST_SIZE, md); return (ARCHIVE_OK); @@ -1118,7 +1118,7 @@ __archive_nettle_sha384final(archive_sha384_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) static int -__archive_openssl_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { if ((*ctx = EVP_MD_CTX_new()) == NULL) return (ARCHIVE_FAILED); @@ -1127,7 +1127,7 @@ __archive_openssl_sha384init(archive_sha384_ctx *ctx) } static int -__archive_openssl_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { EVP_DigestUpdate(*ctx, indata, insize); @@ -1135,7 +1135,7 @@ __archive_openssl_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_openssl_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { if (*ctx) { EVP_DigestFinal(*ctx, md, NULL); @@ -1148,20 +1148,20 @@ __archive_openssl_sha384final(archive_sha384_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA384_WIN) static int -__archive_windowsapi_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { return (win_crypto_init(ctx, CALG_SHA_384)); } static int -__archive_windowsapi_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { return (win_crypto_Update(ctx, indata, insize)); } static int -__archive_windowsapi_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { return (win_crypto_Final(md, 48, ctx)); } @@ -1169,14 +1169,14 @@ __archive_windowsapi_sha384final(archive_sha384_ctx *ctx, void *md) #else static int -__archive_stub_sha384init(archive_sha384_ctx *ctx) +__archive_sha384init(archive_sha384_ctx *ctx) { (void)ctx; /* UNUSED */ return (ARCHIVE_FAILED); } static int -__archive_stub_sha384update(archive_sha384_ctx *ctx, const void *indata, +__archive_sha384update(archive_sha384_ctx *ctx, const void *indata, size_t insize) { (void)ctx; /* UNUSED */ @@ -1186,7 +1186,7 @@ __archive_stub_sha384update(archive_sha384_ctx *ctx, const void *indata, } static int -__archive_stub_sha384final(archive_sha384_ctx *ctx, void *md) +__archive_sha384final(archive_sha384_ctx *ctx, void *md) { (void)ctx; /* UNUSED */ (void)md; /* UNUSED */ @@ -1199,14 +1199,14 @@ __archive_stub_sha384final(archive_sha384_ctx *ctx, void *md) #if defined(ARCHIVE_CRYPTO_SHA512_LIBC) static int -__archive_libc_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { SHA512_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { SHA512_Update(ctx, indata, insize); @@ -1214,7 +1214,7 @@ __archive_libc_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_libc_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { SHA512_Final(md, ctx); return (ARCHIVE_OK); @@ -1223,14 +1223,14 @@ __archive_libc_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC2) static int -__archive_libc2_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { SHA512Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc2_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { SHA512Update(ctx, indata, insize); @@ -1238,7 +1238,7 @@ __archive_libc2_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_libc2_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { SHA512Final(md, ctx); return (ARCHIVE_OK); @@ -1247,14 +1247,14 @@ __archive_libc2_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3) static int -__archive_libc3_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { SHA512Init(ctx); return (ARCHIVE_OK); } static int -__archive_libc3_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { SHA512Update(ctx, indata, insize); @@ -1262,7 +1262,7 @@ __archive_libc3_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_libc3_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { SHA512Final(md, ctx); return (ARCHIVE_OK); @@ -1271,14 +1271,14 @@ __archive_libc3_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD) static int -__archive_libmd_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { SHA512_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libmd_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { SHA512_Update(ctx, indata, insize); @@ -1286,7 +1286,7 @@ __archive_libmd_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_libmd_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { SHA512_Final(md, ctx); return (ARCHIVE_OK); @@ -1295,14 +1295,14 @@ __archive_libmd_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM) static int -__archive_libsystem_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { CC_SHA512_Init(ctx); return (ARCHIVE_OK); } static int -__archive_libsystem_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { CC_SHA512_Update(ctx, indata, insize); @@ -1310,7 +1310,7 @@ __archive_libsystem_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_libsystem_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { CC_SHA512_Final(md, ctx); return (ARCHIVE_OK); @@ -1319,7 +1319,7 @@ __archive_libsystem_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS) static int -__archive_mbedtls_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { mbedtls_sha512_init(ctx); if (mbedtls_sha512_starts_ret(ctx, 0) == 0) @@ -1329,7 +1329,7 @@ __archive_mbedtls_sha512init(archive_sha512_ctx *ctx) } static int -__archive_mbedtls_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { if (mbedtls_sha512_update_ret(ctx, indata, insize) == 0) @@ -1339,7 +1339,7 @@ __archive_mbedtls_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_mbedtls_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { if (mbedtls_sha512_finish_ret(ctx, md) == 0) { mbedtls_sha512_free(ctx); @@ -1353,14 +1353,14 @@ __archive_mbedtls_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE) static int -__archive_nettle_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { sha512_init(ctx); return (ARCHIVE_OK); } static int -__archive_nettle_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { sha512_update(ctx, insize, indata); @@ -1368,7 +1368,7 @@ __archive_nettle_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_nettle_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { sha512_digest(ctx, SHA512_DIGEST_SIZE, md); return (ARCHIVE_OK); @@ -1377,7 +1377,7 @@ __archive_nettle_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL) static int -__archive_openssl_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { if ((*ctx = EVP_MD_CTX_new()) == NULL) return (ARCHIVE_FAILED); @@ -1386,7 +1386,7 @@ __archive_openssl_sha512init(archive_sha512_ctx *ctx) } static int -__archive_openssl_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { EVP_DigestUpdate(*ctx, indata, insize); @@ -1394,7 +1394,7 @@ __archive_openssl_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_openssl_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { if (*ctx) { EVP_DigestFinal(*ctx, md, NULL); @@ -1407,20 +1407,20 @@ __archive_openssl_sha512final(archive_sha512_ctx *ctx, void *md) #elif defined(ARCHIVE_CRYPTO_SHA512_WIN) static int -__archive_windowsapi_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { return (win_crypto_init(ctx, CALG_SHA_512)); } static int -__archive_windowsapi_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { return (win_crypto_Update(ctx, indata, insize)); } static int -__archive_windowsapi_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { return (win_crypto_Final(md, 64, ctx)); } @@ -1428,14 +1428,14 @@ __archive_windowsapi_sha512final(archive_sha512_ctx *ctx, void *md) #else static int -__archive_stub_sha512init(archive_sha512_ctx *ctx) +__archive_sha512init(archive_sha512_ctx *ctx) { (void)ctx; /* UNUSED */ return (ARCHIVE_FAILED); } static int -__archive_stub_sha512update(archive_sha512_ctx *ctx, const void *indata, +__archive_sha512update(archive_sha512_ctx *ctx, const void *indata, size_t insize) { (void)ctx; /* UNUSED */ @@ -1445,7 +1445,7 @@ __archive_stub_sha512update(archive_sha512_ctx *ctx, const void *indata, } static int -__archive_stub_sha512final(archive_sha512_ctx *ctx, void *md) +__archive_sha512final(archive_sha512_ctx *ctx, void *md) { (void)ctx; /* UNUSED */ (void)md; /* UNUSED */ @@ -1468,224 +1468,32 @@ __archive_stub_sha512final(archive_sha512_ctx *ctx, void *md) const struct archive_digest __archive_digest = { /* MD5 */ -#if defined(ARCHIVE_CRYPTO_MD5_LIBC) - &__archive_libc_md5init, - &__archive_libc_md5update, - &__archive_libc_md5final, -#elif defined(ARCHIVE_CRYPTO_MD5_LIBMD) - &__archive_libmd_md5init, - &__archive_libmd_md5update, - &__archive_libmd_md5final, -#elif defined(ARCHIVE_CRYPTO_MD5_LIBSYSTEM) - &__archive_libsystem_md5init, - &__archive_libsystem_md5update, - &__archive_libsystem_md5final, -#elif defined(ARCHIVE_CRYPTO_MD5_MBEDTLS) - &__archive_mbedtls_md5init, - &__archive_mbedtls_md5update, - &__archive_mbedtls_md5final, -#elif defined(ARCHIVE_CRYPTO_MD5_NETTLE) - &__archive_nettle_md5init, - &__archive_nettle_md5update, - &__archive_nettle_md5final, -#elif defined(ARCHIVE_CRYPTO_MD5_OPENSSL) - &__archive_openssl_md5init, - &__archive_openssl_md5update, - &__archive_openssl_md5final, -#elif defined(ARCHIVE_CRYPTO_MD5_WIN) - &__archive_windowsapi_md5init, - &__archive_windowsapi_md5update, - &__archive_windowsapi_md5final, -#elif !defined(ARCHIVE_MD5_COMPILE_TEST) - &__archive_stub_md5init, - &__archive_stub_md5update, - &__archive_stub_md5final, -#endif + &__archive_md5init, + &__archive_md5update, + &__archive_md5final, /* RIPEMD160 */ -#if defined(ARCHIVE_CRYPTO_RMD160_LIBC) - &__archive_libc_ripemd160init, - &__archive_libc_ripemd160update, - &__archive_libc_ripemd160final, -#elif defined(ARCHIVE_CRYPTO_RMD160_LIBMD) - &__archive_libmd_ripemd160init, - &__archive_libmd_ripemd160update, - &__archive_libmd_ripemd160final, -#elif defined(ARCHIVE_CRYPTO_RMD160_MBEDTLS) - &__archive_mbedtls_ripemd160init, - &__archive_mbedtls_ripemd160update, - &__archive_mbedtls_ripemd160final, -#elif defined(ARCHIVE_CRYPTO_RMD160_NETTLE) - &__archive_nettle_ripemd160init, - &__archive_nettle_ripemd160update, - &__archive_nettle_ripemd160final, -#elif defined(ARCHIVE_CRYPTO_RMD160_OPENSSL) - &__archive_openssl_ripemd160init, - &__archive_openssl_ripemd160update, - &__archive_openssl_ripemd160final, -#elif !defined(ARCHIVE_RMD160_COMPILE_TEST) - &__archive_stub_ripemd160init, - &__archive_stub_ripemd160update, - &__archive_stub_ripemd160final, -#endif + &__archive_ripemd160init, + &__archive_ripemd160update, + &__archive_ripemd160final, /* SHA1 */ -#if defined(ARCHIVE_CRYPTO_SHA1_LIBC) - &__archive_libc_sha1init, - &__archive_libc_sha1update, - &__archive_libc_sha1final, -#elif defined(ARCHIVE_CRYPTO_SHA1_LIBMD) - &__archive_libmd_sha1init, - &__archive_libmd_sha1update, - &__archive_libmd_sha1final, -#elif defined(ARCHIVE_CRYPTO_SHA1_LIBSYSTEM) - &__archive_libsystem_sha1init, - &__archive_libsystem_sha1update, - &__archive_libsystem_sha1final, -#elif defined(ARCHIVE_CRYPTO_SHA1_MBEDTLS) - &__archive_mbedtls_sha1init, - &__archive_mbedtls_sha1update, - &__archive_mbedtls_sha1final, -#elif defined(ARCHIVE_CRYPTO_SHA1_NETTLE) - &__archive_nettle_sha1init, - &__archive_nettle_sha1update, - &__archive_nettle_sha1final, -#elif defined(ARCHIVE_CRYPTO_SHA1_OPENSSL) - &__archive_openssl_sha1init, - &__archive_openssl_sha1update, - &__archive_openssl_sha1final, -#elif defined(ARCHIVE_CRYPTO_SHA1_WIN) - &__archive_windowsapi_sha1init, - &__archive_windowsapi_sha1update, - &__archive_windowsapi_sha1final, -#elif !defined(ARCHIVE_SHA1_COMPILE_TEST) - &__archive_stub_sha1init, - &__archive_stub_sha1update, - &__archive_stub_sha1final, -#endif + &__archive_sha1init, + &__archive_sha1update, + &__archive_sha1final, /* SHA256 */ -#if defined(ARCHIVE_CRYPTO_SHA256_LIBC) - &__archive_libc_sha256init, - &__archive_libc_sha256update, - &__archive_libc_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_LIBC2) - &__archive_libc2_sha256init, - &__archive_libc2_sha256update, - &__archive_libc2_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_LIBC3) - &__archive_libc3_sha256init, - &__archive_libc3_sha256update, - &__archive_libc3_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_LIBMD) - &__archive_libmd_sha256init, - &__archive_libmd_sha256update, - &__archive_libmd_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_LIBSYSTEM) - &__archive_libsystem_sha256init, - &__archive_libsystem_sha256update, - &__archive_libsystem_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_MBEDTLS) - &__archive_mbedtls_sha256init, - &__archive_mbedtls_sha256update, - &__archive_mbedtls_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_NETTLE) - &__archive_nettle_sha256init, - &__archive_nettle_sha256update, - &__archive_nettle_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_OPENSSL) - &__archive_openssl_sha256init, - &__archive_openssl_sha256update, - &__archive_openssl_sha256final, -#elif defined(ARCHIVE_CRYPTO_SHA256_WIN) - &__archive_windowsapi_sha256init, - &__archive_windowsapi_sha256update, - &__archive_windowsapi_sha256final, -#elif !defined(ARCHIVE_SHA256_COMPILE_TEST) - &__archive_stub_sha256init, - &__archive_stub_sha256update, - &__archive_stub_sha256final, -#endif + &__archive_sha256init, + &__archive_sha256update, + &__archive_sha256final, /* SHA384 */ -#if defined(ARCHIVE_CRYPTO_SHA384_LIBC) - &__archive_libc_sha384init, - &__archive_libc_sha384update, - &__archive_libc_sha384final, -#elif defined(ARCHIVE_CRYPTO_SHA384_LIBC2) - &__archive_libc2_sha384init, - &__archive_libc2_sha384update, - &__archive_libc2_sha384final, -#elif defined(ARCHIVE_CRYPTO_SHA384_LIBC3) - &__archive_libc3_sha384init, - &__archive_libc3_sha384update, - &__archive_libc3_sha384final, -#elif defined(ARCHIVE_CRYPTO_SHA384_LIBSYSTEM) - &__archive_libsystem_sha384init, - &__archive_libsystem_sha384update, - &__archive_libsystem_sha384final, -#elif defined(ARCHIVE_CRYPTO_SHA384_MBEDTLS) - &__archive_mbedtls_sha384init, - &__archive_mbedtls_sha384update, - &__archive_mbedtls_sha384final, -#elif defined(ARCHIVE_CRYPTO_SHA384_NETTLE) - &__archive_nettle_sha384init, - &__archive_nettle_sha384update, - &__archive_nettle_sha384final, -#elif defined(ARCHIVE_CRYPTO_SHA384_OPENSSL) - &__archive_openssl_sha384init, - &__archive_openssl_sha384update, - &__archive_openssl_sha384final, -#elif defined(ARCHIVE_CRYPTO_SHA384_WIN) - &__archive_windowsapi_sha384init, - &__archive_windowsapi_sha384update, - &__archive_windowsapi_sha384final, -#elif !defined(ARCHIVE_SHA384_COMPILE_TEST) - &__archive_stub_sha384init, - &__archive_stub_sha384update, - &__archive_stub_sha384final, -#endif + &__archive_sha384init, + &__archive_sha384update, + &__archive_sha384final, /* SHA512 */ -#if defined(ARCHIVE_CRYPTO_SHA512_LIBC) - &__archive_libc_sha512init, - &__archive_libc_sha512update, - &__archive_libc_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_LIBC2) - &__archive_libc2_sha512init, - &__archive_libc2_sha512update, - &__archive_libc2_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_LIBC3) - &__archive_libc3_sha512init, - &__archive_libc3_sha512update, - &__archive_libc3_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_LIBMD) - &__archive_libmd_sha512init, - &__archive_libmd_sha512update, - &__archive_libmd_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_LIBSYSTEM) - &__archive_libsystem_sha512init, - &__archive_libsystem_sha512update, - &__archive_libsystem_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_MBEDTLS) - &__archive_mbedtls_sha512init, - &__archive_mbedtls_sha512update, - &__archive_mbedtls_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_NETTLE) - &__archive_nettle_sha512init, - &__archive_nettle_sha512update, - &__archive_nettle_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_OPENSSL) - &__archive_openssl_sha512init, - &__archive_openssl_sha512update, - &__archive_openssl_sha512final -#elif defined(ARCHIVE_CRYPTO_SHA512_WIN) - &__archive_windowsapi_sha512init, - &__archive_windowsapi_sha512update, - &__archive_windowsapi_sha512final -#elif !defined(ARCHIVE_SHA512_COMPILE_TEST) - &__archive_stub_sha512init, - &__archive_stub_sha512update, - &__archive_stub_sha512final -#endif + &__archive_sha512init, + &__archive_sha512update, + &__archive_sha512final }; diff --git a/libarchive/archive_entry.c b/libarchive/archive_entry.c index a15e98c28425..124600c983d8 100644 --- a/libarchive/archive_entry.c +++ b/libarchive/archive_entry.c @@ -353,7 +353,7 @@ archive_entry_devminor(struct archive_entry *entry) return minor(entry->ae_stat.aest_dev); } -mode_t +__LA_MODE_T archive_entry_filetype(struct archive_entry *entry) { return (AE_IFMT & entry->acl.mode); @@ -525,7 +525,7 @@ archive_entry_ino64(struct archive_entry *entry) return (entry->ae_stat.aest_ino); } -mode_t +__LA_MODE_T archive_entry_mode(struct archive_entry *entry) { return (entry->acl.mode); @@ -598,7 +598,7 @@ _archive_entry_pathname_l(struct archive_entry *entry, return (archive_mstring_get_mbs_l(&entry->ae_pathname, p, len, sc)); } -mode_t +__LA_MODE_T archive_entry_perm(struct archive_entry *entry) { return (~AE_IFMT & entry->acl.mode); diff --git a/libarchive/archive_entry_stat.3 b/libarchive/archive_entry_stat.3 index aa5c8e03f9f9..29a53f75607f 100644 --- a/libarchive/archive_entry_stat.3 +++ b/libarchive/archive_entry_stat.3 @@ -215,9 +215,9 @@ and set and unset the size, respectively. .Pp The number of references (hardlinks) can be obtained by calling -.Fn archive_entry_nlinks +.Fn archive_entry_nlink and set with -.Fn archive_entry_set_nlinks . +.Fn archive_entry_set_nlink . .Ss Identifying unique files The functions .Fn archive_entry_dev diff --git a/libarchive/archive_read_add_passphrase.c b/libarchive/archive_read_add_passphrase.c index cf821b5d483c..f0b1ab93300f 100644 --- a/libarchive/archive_read_add_passphrase.c +++ b/libarchive/archive_read_add_passphrase.c @@ -57,6 +57,10 @@ insert_passphrase_to_head(struct archive_read *a, { p->next = a->passphrases.first; a->passphrases.first = p; + if (&a->passphrases.first == a->passphrases.last) { + a->passphrases.last = &p->next; + p->next = NULL; + } } static struct archive_read_passphrase * diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c index 52fec7bb42c8..2898206951d5 100644 --- a/libarchive/archive_read_disk_posix.c +++ b/libarchive/archive_read_disk_posix.c @@ -1658,7 +1658,7 @@ static int setup_current_filesystem(struct archive_read_disk *a) { struct tree *t = a->tree; - struct statvfs sfs; + struct statvfs svfs; int r, xr = 0; t->current_filesystem->synthetic = -1; @@ -1667,16 +1667,16 @@ setup_current_filesystem(struct archive_read_disk *a) return (ARCHIVE_FAILED); } if (tree_current_is_symblic_link_target(t)) { - r = statvfs(tree_current_access_path(t), &sfs); + r = statvfs(tree_current_access_path(t), &svfs); if (r == 0) xr = get_xfer_size(t, -1, tree_current_access_path(t)); } else { #ifdef HAVE_FSTATVFS - r = fstatvfs(tree_current_dir_fd(t), &sfs); + r = fstatvfs(tree_current_dir_fd(t), &svfs); if (r == 0) xr = get_xfer_size(t, tree_current_dir_fd(t), NULL); #else - r = statvfs(".", &sfs); + r = statvfs(".", &svfs); if (r == 0) xr = get_xfer_size(t, -1, "."); #endif @@ -1688,30 +1688,30 @@ setup_current_filesystem(struct archive_read_disk *a) } else if (xr == 1) { /* Usually come here unless NetBSD supports _PC_REC_XFER_ALIGN * for pathconf() function. */ - t->current_filesystem->xfer_align = sfs.f_frsize; + t->current_filesystem->xfer_align = svfs.f_frsize; t->current_filesystem->max_xfer_size = -1; #if defined(HAVE_STRUCT_STATVFS_F_IOSIZE) - t->current_filesystem->min_xfer_size = sfs.f_iosize; - t->current_filesystem->incr_xfer_size = sfs.f_iosize; + t->current_filesystem->min_xfer_size = svfs.f_iosize; + t->current_filesystem->incr_xfer_size = svfs.f_iosize; #else - t->current_filesystem->min_xfer_size = sfs.f_bsize; - t->current_filesystem->incr_xfer_size = sfs.f_bsize; + t->current_filesystem->min_xfer_size = svfs.f_bsize; + t->current_filesystem->incr_xfer_size = svfs.f_bsize; #endif } - if (sfs.f_flag & ST_LOCAL) + if (svfs.f_flag & ST_LOCAL) t->current_filesystem->remote = 0; else t->current_filesystem->remote = 1; #if defined(ST_NOATIME) - if (sfs.f_flag & ST_NOATIME) + if (svfs.f_flag & ST_NOATIME) t->current_filesystem->noatime = 1; else #endif t->current_filesystem->noatime = 0; /* Set maximum filename length. */ - t->current_filesystem->name_max = sfs.f_namemax; + t->current_filesystem->name_max = svfs.f_namemax; return (ARCHIVE_OK); } @@ -1840,7 +1840,7 @@ setup_current_filesystem(struct archive_read_disk *a) #if defined(HAVE_STATVFS) if (svfs.f_flag & ST_NOATIME) #else - if (sfs.f_flag & ST_NOATIME) + if (sfs.f_flags & ST_NOATIME) #endif t->current_filesystem->noatime = 1; else @@ -1864,7 +1864,7 @@ static int setup_current_filesystem(struct archive_read_disk *a) { struct tree *t = a->tree; - struct statvfs sfs; + struct statvfs svfs; int r, xr = 0; t->current_filesystem->synthetic = -1;/* Not supported */ @@ -1883,7 +1883,7 @@ setup_current_filesystem(struct archive_read_disk *a) "openat failed"); return (ARCHIVE_FAILED); } - r = fstatvfs(fd, &sfs); + r = fstatvfs(fd, &svfs); if (r == 0) xr = get_xfer_size(t, fd, NULL); close(fd); @@ -1892,13 +1892,13 @@ setup_current_filesystem(struct archive_read_disk *a) archive_set_error(&a->archive, errno, "fchdir failed"); return (ARCHIVE_FAILED); } - r = statvfs(tree_current_access_path(t), &sfs); + r = statvfs(tree_current_access_path(t), &svfs); if (r == 0) xr = get_xfer_size(t, -1, tree_current_access_path(t)); #endif } else { #ifdef HAVE_FSTATVFS - r = fstatvfs(tree_current_dir_fd(t), &sfs); + r = fstatvfs(tree_current_dir_fd(t), &svfs); if (r == 0) xr = get_xfer_size(t, tree_current_dir_fd(t), NULL); #else @@ -1906,7 +1906,7 @@ setup_current_filesystem(struct archive_read_disk *a) archive_set_error(&a->archive, errno, "fchdir failed"); return (ARCHIVE_FAILED); } - r = statvfs(".", &sfs); + r = statvfs(".", &svfs); if (r == 0) xr = get_xfer_size(t, -1, "."); #endif @@ -1918,14 +1918,14 @@ setup_current_filesystem(struct archive_read_disk *a) return (ARCHIVE_FAILED); } else if (xr == 1) { /* pathconf(_PC_REX_*) operations are not supported. */ - t->current_filesystem->xfer_align = sfs.f_frsize; + t->current_filesystem->xfer_align = svfs.f_frsize; t->current_filesystem->max_xfer_size = -1; - t->current_filesystem->min_xfer_size = sfs.f_bsize; - t->current_filesystem->incr_xfer_size = sfs.f_bsize; + t->current_filesystem->min_xfer_size = svfs.f_bsize; + t->current_filesystem->incr_xfer_size = svfs.f_bsize; } #if defined(ST_NOATIME) - if (sfs.f_flag & ST_NOATIME) + if (svfs.f_flag & ST_NOATIME) t->current_filesystem->noatime = 1; else #endif @@ -1933,7 +1933,7 @@ setup_current_filesystem(struct archive_read_disk *a) #if defined(USE_READDIR_R) /* Set maximum filename length. */ - t->current_filesystem->name_max = sfs.f_namemax; + t->current_filesystem->name_max = svfs.f_namemax; #endif return (ARCHIVE_OK); } diff --git a/libarchive/archive_read_support_filter_program.c b/libarchive/archive_read_support_filter_program.c index b8bf12886f34..bf5b6f2b3c8b 100644 --- a/libarchive/archive_read_support_filter_program.c +++ b/libarchive/archive_read_support_filter_program.c @@ -400,7 +400,7 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd) static const size_t out_buf_len = 65536; char *out_buf; const char *prefix = "Program: "; - pid_t child; + int ret; size_t l; l = strlen(prefix) + strlen(cmd) + 1; @@ -426,9 +426,9 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd) state->out_buf = out_buf; state->out_buf_len = out_buf_len; - child = __archive_create_child(cmd, &state->child_stdin, - &state->child_stdout); - if (child == -1) { + ret = __archive_create_child(cmd, &state->child_stdin, + &state->child_stdout, &state->child); + if (ret != ARCHIVE_OK) { free(state->out_buf); archive_string_free(&state->description); free(state); @@ -437,21 +437,6 @@ __archive_read_program(struct archive_read_filter *self, const char *cmd) cmd); return (ARCHIVE_FATAL); } -#if defined(_WIN32) && !defined(__CYGWIN__) - state->child = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, child); - if (state->child == NULL) { - child_stop(self, state); - free(state->out_buf); - archive_string_free(&state->description); - free(state); - archive_set_error(&self->archive->archive, EINVAL, - "Can't initialize filter; unable to run program \"%s\"", - cmd); - return (ARCHIVE_FATAL); - } -#else - state->child = child; -#endif self->data = state; self->read = program_filter_read; diff --git a/libarchive/archive_read_support_filter_zstd.c b/libarchive/archive_read_support_filter_zstd.c index c8bb36be703c..af7eeb7c1e24 100644 --- a/libarchive/archive_read_support_filter_zstd.c +++ b/libarchive/archive_read_support_filter_zstd.c @@ -119,6 +119,8 @@ zstd_bidder_bid(struct archive_read_filter_bidder *self, /* Zstd frame magic values */ const unsigned zstd_magic = 0xFD2FB528U; + const unsigned zstd_magic_skippable_start = 0x184D2A50U; + const unsigned zstd_magic_skippable_mask = 0xFFFFFFF0; (void) self; /* UNUSED */ @@ -129,6 +131,8 @@ zstd_bidder_bid(struct archive_read_filter_bidder *self, prefix = archive_le32dec(buffer); if (prefix == zstd_magic) return (32); + if ((prefix & zstd_magic_skippable_mask) == zstd_magic_skippable_start) + return (32); return (0); } diff --git a/libarchive/archive_read_support_format_rar5.c b/libarchive/archive_read_support_format_rar5.c index 82729bdcdb3c..7a308a8d8a72 100644 --- a/libarchive/archive_read_support_format_rar5.c +++ b/libarchive/archive_read_support_format_rar5.c @@ -3084,12 +3084,6 @@ static int do_uncompress_block(struct archive_read* a, const uint8_t* p) { continue; } - - /* The program counter shouldn't reach here. */ - archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, - "Unsupported block code: 0x%x", num); - - return ARCHIVE_FATAL; } return ARCHIVE_OK; diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index c63d46fc0ce2..96d8101844fb 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -1796,6 +1796,16 @@ pax_attribute_schily_xattr(struct archive_entry *entry, return 0; } +static int +pax_attribute_rht_security_selinux(struct archive_entry *entry, + const char *value, size_t value_length) +{ + archive_entry_xattr_add_entry(entry, "security.selinux", + value, value_length); + + return 0; +} + static int pax_attribute_acl(struct archive_read *a, struct tar *tar, struct archive_entry *entry, const char *value, int type) @@ -1966,6 +1976,14 @@ pax_attribute(struct archive_read *a, struct tar *tar, if (memcmp(key, "LIBARCHIVE.xattr.", 17) == 0) pax_attribute_xattr(entry, key, value); break; + case 'R': + /* GNU tar uses RHT.security header to store SELinux xattrs + * SCHILY.xattr.security.selinux == RHT.security.selinux */ + if (strcmp(key, "RHT.security.selinux") == 0) { + pax_attribute_rht_security_selinux(entry, value, + value_length); + } + break; case 'S': /* We support some keys used by the "star" archiver */ if (strcmp(key, "SCHILY.acl.access") == 0) { diff --git a/libarchive/archive_write_add_filter_program.c b/libarchive/archive_write_add_filter_program.c index a4bc1d90eda8..c096e7227ba4 100644 --- a/libarchive/archive_write_add_filter_program.c +++ b/libarchive/archive_write_add_filter_program.c @@ -196,10 +196,6 @@ __archive_write_program_free(struct archive_write_program_data *data) { if (data) { -#if defined(_WIN32) && !defined(__CYGWIN__) - if (data->child) - CloseHandle(data->child); -#endif free(data->program_name); free(data->child_buf); free(data); @@ -211,7 +207,7 @@ int __archive_write_program_open(struct archive_write_filter *f, struct archive_write_program_data *data, const char *cmd) { - pid_t child; + int ret; if (data->child_buf == NULL) { data->child_buf_len = 65536; @@ -225,27 +221,13 @@ __archive_write_program_open(struct archive_write_filter *f, } } - child = __archive_create_child(cmd, &data->child_stdin, - &data->child_stdout); - if (child == -1) { + ret = __archive_create_child(cmd, &data->child_stdin, + &data->child_stdout, &data->child); + if (ret != ARCHIVE_OK) { archive_set_error(f->archive, EINVAL, "Can't launch external program: %s", cmd); return (ARCHIVE_FATAL); } -#if defined(_WIN32) && !defined(__CYGWIN__) - data->child = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, child); - if (data->child == NULL) { - close(data->child_stdin); - data->child_stdin = -1; - close(data->child_stdout); - data->child_stdout = -1; - archive_set_error(f->archive, EINVAL, - "Can't launch external program: %s", cmd); - return (ARCHIVE_FATAL); - } -#else - data->child = child; -#endif return (ARCHIVE_OK); } diff --git a/libarchive/archive_write_add_filter_zstd.c b/libarchive/archive_write_add_filter_zstd.c index 4c91551ed3e1..c74a35cded20 100644 --- a/libarchive/archive_write_add_filter_zstd.c +++ b/libarchive/archive_write_add_filter_zstd.c @@ -59,6 +59,16 @@ struct private_data { #endif }; +/* If we don't have the library use default range values (zstdcli.c v1.4.0) */ +#define CLEVEL_MIN -99 +#define CLEVEL_STD_MIN 0 /* prior to 1.3.4 and more recent without using --fast */ +#define CLEVEL_DEFAULT 3 +#define CLEVEL_STD_MAX 19 /* without using --ultra */ +#define CLEVEL_MAX 22 + +#define MINVER_NEGCLEVEL 10304 +#define MINVER_MINCLEVEL 10306 + static int archive_compressor_zstd_options(struct archive_write_filter *, const char *, const char *); static int archive_compressor_zstd_open(struct archive_write_filter *); @@ -96,7 +106,7 @@ archive_write_add_filter_zstd(struct archive *_a) f->free = &archive_compressor_zstd_free; f->code = ARCHIVE_FILTER_ZSTD; f->name = "zstd"; - data->compression_level = 3; /* Default level used by the zstd CLI */ + data->compression_level = CLEVEL_DEFAULT; #if HAVE_ZSTD_H && HAVE_LIBZSTD data->cstream = ZSTD_createCStream(); if (data->cstream == NULL) { @@ -135,6 +145,31 @@ archive_compressor_zstd_free(struct archive_write_filter *f) return (ARCHIVE_OK); } +static int string_is_numeric (const char* value) +{ + size_t len = strlen(value); + size_t i; + + if (len == 0) { + return (ARCHIVE_WARN); + } + else if (len == 1 && !(value[0] >= '0' && value[0] <= '9')) { + return (ARCHIVE_WARN); + } + else if (!(value[0] >= '0' && value[0] <= '9') && + value[0] != '-' && value[0] != '+') { + return (ARCHIVE_WARN); + } + + for (i = 1; i < len; i++) { + if (!(value[i] >= '0' && value[i] <= '9')) { + return (ARCHIVE_WARN); + } + } + + return (ARCHIVE_OK); +} + /* * Set write options. */ @@ -146,12 +181,25 @@ archive_compressor_zstd_options(struct archive_write_filter *f, const char *key, if (strcmp(key, "compression-level") == 0) { int level = atoi(value); -#if HAVE_ZSTD_H && HAVE_LIBZSTD - if (level < 1 || level > ZSTD_maxCLevel()) { -#else /* If we don't have the library, hard-code the max level */ - if (level < 1 || level > 22) { + int minimum = CLEVEL_MIN; + int maximum = CLEVEL_MAX; + if (string_is_numeric(value) != ARCHIVE_OK) { + return (ARCHIVE_WARN); + } +#if HAVE_ZSTD_H && HAVE_LIBZSTD + maximum = ZSTD_maxCLevel(); +#if ZSTD_VERSION_NUMBER >= MINVER_MINCLEVEL + if (ZSTD_versionNumber() >= MINVER_MINCLEVEL) { + minimum = ZSTD_minCLevel(); + } + else #endif + if (ZSTD_versionNumber() < MINVER_NEGCLEVEL) { + minimum = CLEVEL_STD_MIN; + } +#endif + if (level < minimum || level > maximum) { return (ARCHIVE_WARN); } data->compression_level = level; @@ -297,7 +345,26 @@ archive_compressor_zstd_open(struct archive_write_filter *f) int r; archive_string_init(&as); - archive_string_sprintf(&as, "zstd -%d", data->compression_level); + /* --no-check matches library default */ + archive_strcpy(&as, "zstd --no-check"); + + if (data->compression_level < CLEVEL_STD_MIN) { + struct archive_string as2; + archive_string_init(&as2); + archive_string_sprintf(&as2, " --fast=%d", -data->compression_level); + archive_string_concat(&as, &as2); + archive_string_free(&as2); + } else { + struct archive_string as2; + archive_string_init(&as2); + archive_string_sprintf(&as2, " -%d", data->compression_level); + archive_string_concat(&as, &as2); + archive_string_free(&as2); + } + + if (data->compression_level > CLEVEL_STD_MAX) { + archive_strcat(&as, " --ultra"); + } f->write = archive_compressor_zstd_write; r = __archive_write_program_open(f, data->pdata, as.s); diff --git a/libarchive/archive_write_set_options.3 b/libarchive/archive_write_set_options.3 index cffe571e90a6..d4a52e322ea8 100644 --- a/libarchive/archive_write_set_options.3 +++ b/libarchive/archive_write_set_options.3 @@ -255,7 +255,8 @@ If supported, the default value is read from .Bl -tag -compact -width indent .It Cm compression-level The value is interpreted as a decimal integer specifying the -compression level. Supported values are from 1 to 22. +compression level. Supported values depend on the library version, +common values are from 1 to 22. .El .It Format 7zip .Bl -tag -compact -width indent diff --git a/libarchive/filter_fork.h b/libarchive/filter_fork.h index 908e7cdd4ddd..2bf290c4d9e4 100644 --- a/libarchive/filter_fork.h +++ b/libarchive/filter_fork.h @@ -32,8 +32,13 @@ #error This header is only to be used internally to libarchive. #endif -pid_t -__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout); +int +__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout, +#if defined(_WIN32) && !defined(__CYGWIN__) + HANDLE *out_child); +#else + pid_t *out_child); +#endif void __archive_check_child(int in, int out); diff --git a/libarchive/filter_fork_posix.c b/libarchive/filter_fork_posix.c index 02dbd4bb4362..ac255c4f8b20 100644 --- a/libarchive/filter_fork_posix.c +++ b/libarchive/filter_fork_posix.c @@ -72,8 +72,9 @@ __FBSDID("$FreeBSD: head/lib/libarchive/filter_fork.c 182958 2008-09-12 05:33:00 #include "filter_fork.h" -pid_t -__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) +int +__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout, + pid_t *out_child) { pid_t child; int stdin_pipe[2], stdout_pipe[2], tmp; @@ -177,7 +178,8 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) fcntl(*child_stdout, F_SETFL, O_NONBLOCK); __archive_cmdline_free(cmdline); - return child; + *out_child = child; + return ARCHIVE_OK; #if HAVE_POSIX_SPAWNP actions_inited: @@ -192,7 +194,7 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) close(stdin_pipe[1]); state_allocated: __archive_cmdline_free(cmdline); - return -1; + return ARCHIVE_FAILED; } void diff --git a/libarchive/filter_fork_windows.c b/libarchive/filter_fork_windows.c index ad271fe68a15..8d11179f307e 100644 --- a/libarchive/filter_fork_windows.c +++ b/libarchive/filter_fork_windows.c @@ -31,8 +31,9 @@ #include "filter_fork.h" -pid_t -__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) +int +__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout, + HANDLE *out_child) { HANDLE childStdout[2], childStdin[2],childStderr; SECURITY_ATTRIBUTES secAtts; @@ -44,6 +45,7 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) char *arg0, *ext; int i, l; DWORD fl, fl_old; + HANDLE child; childStdout[0] = childStdout[1] = INVALID_HANDLE_VALUE; childStdin[0] = childStdin[1] = INVALID_HANDLE_VALUE; @@ -154,13 +156,20 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) *child_stdout = _open_osfhandle((intptr_t)childStdout[0], _O_RDONLY); *child_stdin = _open_osfhandle((intptr_t)childStdin[1], _O_WRONLY); + child = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, + childInfo.dwProcessId); + if (child == NULL) // INVALID_HANDLE_VALUE ? + goto fail; + + *out_child = child; + CloseHandle(childStdout[1]); CloseHandle(childStdin[0]); archive_string_free(&cmdline); archive_string_free(&fullpath); __archive_cmdline_free(acmd); - return (childInfo.dwProcessId); + return ARCHIVE_OK; fail: if (childStdout[0] != INVALID_HANDLE_VALUE) @@ -176,7 +185,7 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout) archive_string_free(&cmdline); archive_string_free(&fullpath); __archive_cmdline_free(acmd); - return (-1); + return ARCHIVE_FAILED; } void diff --git a/libarchive/test/CMakeLists.txt b/libarchive/test/CMakeLists.txt index df34d3e3200b..4be5bf4cd963 100644 --- a/libarchive/test/CMakeLists.txt +++ b/libarchive/test/CMakeLists.txt @@ -191,7 +191,8 @@ IF(ENABLE_TEST) test_read_format_zip_zip64.c test_read_format_zip_with_invalid_traditional_eocd.c test_read_large.c - test_read_pax_schily_xattr.c + test_read_pax_xattr_rht_security_selinux.c + test_read_pax_xattr_schily.c test_read_pax_truncated.c test_read_position.c test_read_set_format.c diff --git a/libarchive/test/test_acl_platform_nfs4.c b/libarchive/test/test_acl_platform_nfs4.c index 410582bfc7b5..ae4bb5a10125 100644 --- a/libarchive/test/test_acl_platform_nfs4.c +++ b/libarchive/test/test_acl_platform_nfs4.c @@ -634,9 +634,11 @@ acl_match(acl_entry_t aclent, struct myacl_t *myacl) case ACL_ENTRY_TYPE_AUDIT: if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_AUDIT) return (0); + break; case ACL_ENTRY_TYPE_ALARM: if (myacl->type != ARCHIVE_ENTRY_ACL_TYPE_ALARM) return (0); + break; default: return (0); } diff --git a/libarchive/test/test_acl_platform_posix1e.c b/libarchive/test/test_acl_platform_posix1e.c index 801a7acfc85e..c34f7c2e299d 100644 --- a/libarchive/test/test_acl_platform_posix1e.c +++ b/libarchive/test/test_acl_platform_posix1e.c @@ -364,8 +364,8 @@ DEFINE_TEST(test_acl_platform_posix1e_read) struct archive *a; struct archive_entry *ae; int n, fd, flags, dflags; - char *func, *acl_text; - const char *acl1_text, *acl2_text, *acl3_text; + char *acl_text; + const char *func, *acl1_text, *acl2_text, *acl3_text; #if ARCHIVE_ACL_SUNOS void *aclp; int aclcnt; diff --git a/libarchive/test/test_compat_zstd.c b/libarchive/test/test_compat_zstd.c index 1d63a2845ff5..134775816a94 100644 --- a/libarchive/test/test_compat_zstd.c +++ b/libarchive/test/test_compat_zstd.c @@ -79,4 +79,7 @@ DEFINE_TEST(test_compat_zstd) /* This sample was compressed as 3 separate streams with a zstd skippable * frame placed in the middle */ compat_zstd("test_compat_zstd_1.tar.zst"); + + /* The same sample compressed with pzstd */ + compat_zstd("test_compat_zstd_2.tar.zst"); } diff --git a/libarchive/test/test_compat_zstd_2.tar.zst.uu b/libarchive/test/test_compat_zstd_2.tar.zst.uu new file mode 100644 index 000000000000..6c3636c13812 --- /dev/null +++ b/libarchive/test/test_compat_zstd_2.tar.zst.uu @@ -0,0 +1,8 @@ +begin 664 test_compat_zstd_2.tar.zst +M4"I-&`0```"J````*+4O_018[00`\L41%I`I!%(KMV]N7BR&@9(I29\:P8D9 +ML"GMK=GZS(ZZ!!ZT[%K7J3*`"W$0PR(Y((0".0A!DE`,:6K4D_ZNQG_J=DP. +M&<:1G$L?`/U!!?M`/3*@&,!$`:C[!RHC`TH`#!.`8O]`%61`!UAQ`E"Z#U1& +M!E0#@C0`=?Q`961`"<#N`;(9'$PC'ZA$`A16ZL#%$IP``!*"=UWAE$]@"$B5 +"Q>,` +` +end diff --git a/libarchive/test/test_read_pax_xattr_rht_security_selinux.c b/libarchive/test/test_read_pax_xattr_rht_security_selinux.c new file mode 100644 index 000000000000..609e8d03bf7b --- /dev/null +++ b/libarchive/test/test_read_pax_xattr_rht_security_selinux.c @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2016 IBM Corporation + * Copyright (c) 2003-2007 Tim Kientzle + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * This test case's code has been derived from test_entry.c + */ +#include "test.h" + +DEFINE_TEST(test_read_pax_xattr_rht_security_selinux) +{ + struct archive *a; + struct archive_entry *ae; + const char *refname = "test_read_pax_xattr_rht_security_selinux.tar"; + const char *xname; /* For xattr tests. */ + const void *xval; /* For xattr tests. */ + size_t xsize; /* For xattr tests. */ + const char *string; + + assert((a = archive_read_new()) != NULL); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + + extract_reference_file(refname); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_open_filename(a, refname, 10240)); + + assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualInt(1, archive_entry_xattr_count(ae)); + assertEqualInt(1, archive_entry_xattr_reset(ae)); + + assertEqualInt(0, archive_entry_xattr_next(ae, &xname, &xval, &xsize)); + assertEqualString(xname, "security.selinux"); + string = "system_u:object_r:admin_home_t:s0"; + assertEqualMem(xval, string, xsize); + assertEqualInt((int)xsize, strlen(string)); + + /* Close the archive. */ + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_free(a)); +} diff --git a/libarchive/test/test_read_pax_xattr_rht_security_selinux.tar.uu b/libarchive/test/test_read_pax_xattr_rht_security_selinux.tar.uu new file mode 100644 index 000000000000..495efbcf11ee --- /dev/null +++ b/libarchive/test/test_read_pax_xattr_rht_security_selinux.tar.uu @@ -0,0 +1,231 @@ +begin 664 test_read_pax_xattr_rht_security_selinux.tar +M+B]087A(96%D97)S+C$V-C0O=&5S="YT>'0````````````````````````` +M```````````````````````````````````````````````````````````` +M`````````````#`P,#`V-#0`,#`P,#`P,``P,#`P,#`P`#`P,#`P,#`P,C(R +M`#$S-#8T-S``````````````````````````````` +M```````````````````````````````````````````````````````````` +M``````````````````````````````````````````!U