mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
deps: update zlib to 1.4-ec453dc
PR-URL: https://github.com/nodejs/node/pull/67475 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
1 parent
750db585ae
commit
bc6dd4081f
37 files changed
+885
-544
No files matched your search
Vendored
+150
-35
@@ -1,9 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.12...3.31)
|
||||
cmake_minimum_required(VERSION 3.15...3.31)
|
||||
|
||||
project(
|
||||
zlib
|
||||
LANGUAGES C
|
||||
VERSION 1.3.2.1
|
||||
VERSION 1.4
|
||||
HOMEPAGE_URL "https://zlib.net/"
|
||||
DESCRIPTION "a general-purpose lossless data-compression library")
|
||||
|
||||
@@ -23,8 +23,8 @@ option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON)
|
||||
option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
|
||||
option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
|
||||
option(ZLIB_INSTALL "Enable installation of zlib" ON)
|
||||
option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in"
|
||||
OFF)
|
||||
set(ZLIB_PREFIX "" CACHE STRING
|
||||
"prefix for all types and library functions, see zconf.h.in")
|
||||
mark_as_advanced(ZLIB_PREFIX)
|
||||
|
||||
get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
@@ -35,7 +35,7 @@ if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
|
||||
endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(CheckTypeSize)
|
||||
@@ -44,12 +44,16 @@ include(GNUInstallDirs)
|
||||
|
||||
set(CPACK_INCLUDED TRUE)
|
||||
|
||||
set(Z_PREFIX "${ZLIB_PREFIX}")
|
||||
|
||||
#
|
||||
# Create zconf.h.cmakein
|
||||
#
|
||||
if(NOT ZLIB_CONF_WRITTEN)
|
||||
set(Z_PREFIX ${ZLIB_PREFIX})
|
||||
set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
|
||||
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245)
|
||||
file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
|
||||
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
|
||||
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX @Z_PREFIX@\n")
|
||||
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
|
||||
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
|
||||
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244)
|
||||
@@ -149,6 +153,73 @@ if (ENABLE_SIMD_OPTIMIZATIONS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Create zlib.def.cmakein
|
||||
#
|
||||
if(NOT ZLIB_DEF_WRITTEN)
|
||||
file(STRINGS "${zlib_SOURCE_DIR}/win32/zlib.def" ZLIB_DEF_LINES)
|
||||
|
||||
set(ZLIB_DEF_OUT "")
|
||||
|
||||
foreach(line IN LISTS ZLIB_DEF_LINES)
|
||||
if(line MATCHES "^;")
|
||||
string(APPEND ZLIB_DEF_OUT "${line}\n")
|
||||
elseif(line MATCHES "^(LIBRARY|EXPORTS|DESCRIPTION)")
|
||||
string(APPEND ZLIB_DEF_OUT "${line}\n")
|
||||
elseif(line MATCHES "^ *$")
|
||||
string(APPEND ZLIB_DEF_OUT "\n")
|
||||
elseif(line MATCHES "^ *[A-Za-z_][A-Za-z0-9_]*")
|
||||
string(REGEX REPLACE "^ +" "" sym "${line}")
|
||||
string(APPEND ZLIB_DEF_OUT
|
||||
" @ZLIB_PREFIX@${sym}\n")
|
||||
else()
|
||||
string(APPEND ZLIB_DEF_OUT "${line}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(WRITE
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/zlib.def.cmakein"
|
||||
"${ZLIB_DEF_OUT}"
|
||||
)
|
||||
|
||||
set(ZLIB_DEF_WRITTEN
|
||||
TRUE
|
||||
CACHE BOOL "zlib.def.cmakein was created")
|
||||
mark_as_advanced(ZLIB_DEF_WRITTEN)
|
||||
endif(NOT ZLIB_DEF_WRITTEN)
|
||||
|
||||
#
|
||||
#Create zlib.map
|
||||
#
|
||||
if(NOT ZLIB_MAP_WRITTEN)
|
||||
file(STRINGS "${zlib_SOURCE_DIR}/zlib.map" ZLIB_MAP_CONTENT)
|
||||
set(ZLIB_MAP_OUT "")
|
||||
|
||||
foreach(line IN LISTS ZLIB_MAP_CONTENT)
|
||||
if(line MATCHES "^ *[A-Za-z_][A-Za-z0-9_]* *; *$")
|
||||
if(line MATCHES "^ *\\* *; *$")
|
||||
string(APPEND ZLIB_MAP_OUT "${line}\n")
|
||||
else()
|
||||
string(REGEX REPLACE "^ +" "" sym "${line}")
|
||||
string(APPEND ZLIB_MAP_OUT
|
||||
" @ZLIB_PREFIX@${sym}\n")
|
||||
endif()
|
||||
else()
|
||||
string(APPEND ZLIB_MAP_OUT "${line}\n")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(WRITE
|
||||
"${zlib_BINARY_DIR}/zlib.map.cmakein"
|
||||
"${ZLIB_MAP_OUT}"
|
||||
)
|
||||
|
||||
set(ZLIB_MAP_WRITTEN
|
||||
TRUE
|
||||
CACHE BOOL "zlib.map.cmakein was created")
|
||||
mark_as_advanced(ZLIB_MAP_WRITTEN)
|
||||
endif(NOT ZLIB_MAP_WRITTEN)
|
||||
|
||||
#
|
||||
# Check to see if we have large file support
|
||||
#
|
||||
@@ -159,7 +230,7 @@ unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
#
|
||||
# Check for fseeko
|
||||
#
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
check_symbol_exists(fseeko stdio.h HAVE_FSEEKO)
|
||||
|
||||
#
|
||||
# Check for stdarg.h
|
||||
@@ -190,8 +261,21 @@ check_c_source_compiles(
|
||||
|
||||
unset(CMAKE_COMPILE_FLAGS)
|
||||
set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(pc_includedir "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
else()
|
||||
set(pc_includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||
set(pc_libdir "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(pc_libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
|
||||
configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
|
||||
configure_file(${zlib_BINARY_DIR}/zlib.def.cmakein ${zlib_BINARY_DIR}/zlib.def)
|
||||
configure_file(${zlib_BINARY_DIR}/zlib.map.cmakein ${zlib_BINARY_DIR}/zlib.map)
|
||||
|
||||
# ============================================================================
|
||||
# zlib
|
||||
@@ -293,9 +377,12 @@ endif()
|
||||
|
||||
if(ZLIB_BUILD_SHARED)
|
||||
add_library(
|
||||
zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}
|
||||
$<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
|
||||
zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS}
|
||||
${ZLIB_PRIVATE_HDRS}
|
||||
$<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib-cmake.rc>
|
||||
$<$<BOOL:${MSVC}>:${zlib_BINARY_DIR}/zlib.def>)
|
||||
add_library(ZLIB::ZLIB ALIAS zlib)
|
||||
|
||||
target_include_directories(
|
||||
zlib
|
||||
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
|
||||
@@ -304,37 +391,48 @@ if(ZLIB_BUILD_SHARED)
|
||||
target_compile_definitions(
|
||||
zlib
|
||||
PRIVATE ZLIB_BUILD
|
||||
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
|
||||
$<$<NOT:$<BOOL:${HAVE_FSEEKO}>>:NO_FSEEKO>
|
||||
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
|
||||
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
|
||||
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
|
||||
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
|
||||
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
|
||||
$<$<BOOL:${ZLIB_PREFIX}>:Z_PREFIX=${ZLIB_PREFIX}>)
|
||||
|
||||
set(INSTALL_VERSION ${zlib_VERSION})
|
||||
|
||||
if(NOT CYGWIN)
|
||||
if(CYGWIN)
|
||||
set_target_properties(zlib PROPERTIES PREFIX "lib")
|
||||
else(CYGWIN)
|
||||
set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR}
|
||||
VERSION ${INSTALL_VERSION})
|
||||
endif(NOT CYGWIN)
|
||||
endif(CYGWIN)
|
||||
|
||||
set_target_properties(zlib
|
||||
PROPERTIES
|
||||
DEFINE_SYMBOL ZLIB_DLL
|
||||
EXPORT_NAME ZLIB
|
||||
PUBLIC_HEADER "${ZLIB_PUBLIC_HDRS}")
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(zlib PROPERTIES OUTPUT_NAME libz)
|
||||
else(MSVC)
|
||||
set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
|
||||
endif(MSVC)
|
||||
|
||||
set_target_properties(
|
||||
zlib
|
||||
PROPERTIES DEFINE_SYMBOL ZLIB_DLL
|
||||
EXPORT_NAME ZLIB
|
||||
OUTPUT_NAME z)
|
||||
if(UNIX
|
||||
AND NOT APPLE
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL SunOS))
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL "AIX")
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL "SunOS"))
|
||||
# On unix-like platforms the library is almost always called libz
|
||||
set_target_properties(
|
||||
zlib
|
||||
PROPERTIES LINK_FLAGS
|
||||
"-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
|
||||
"-Wl,--version-script,\"${zlib_BINARY_DIR}/zlib.map\"")
|
||||
endif(
|
||||
UNIX
|
||||
AND NOT APPLE
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL SunOS))
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL "AIX")
|
||||
AND NOT (CMAKE_SYSTEM_NAME STREQUAL "SunOS"))
|
||||
endif(ZLIB_BUILD_SHARED)
|
||||
|
||||
if(ZLIB_BUILD_STATIC)
|
||||
@@ -349,14 +447,31 @@ if(ZLIB_BUILD_STATIC)
|
||||
target_compile_definitions(
|
||||
zlibstatic
|
||||
PRIVATE ZLIB_BUILD
|
||||
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
|
||||
$<$<NOT:$<BOOL:${HAVE_FSEEKO}>>:NO_FSEEKO>
|
||||
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
|
||||
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
|
||||
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
|
||||
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
|
||||
set_target_properties(
|
||||
zlibstatic PROPERTIES EXPORT_NAME ZLIBSTATIC OUTPUT_NAME
|
||||
z${zlib_static_suffix})
|
||||
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
|
||||
$<$<BOOL:${ZLIB_PREFIX}>:Z_PREFIX=${ZLIB_PREFIX}>)
|
||||
|
||||
if(CYGWIN)
|
||||
set_target_properties(zlibstatic PROPERTIES PREFIX "lib")
|
||||
endif(CYGWIN)
|
||||
|
||||
if(MSVC)
|
||||
set_target_properties(zlibstatic
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_NAME libz${zlib_static_suffix})
|
||||
else(MSVC)
|
||||
set_target_properties(zlibstatic
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_NAME z${zlib_static_suffix})
|
||||
endif(MSVC)
|
||||
|
||||
set_target_properties(zlibstatic
|
||||
PROPERTIES
|
||||
EXPORT_NAME ZLIBSTATIC
|
||||
PUBLIC_HEADER "${ZLIB_PUBLIC_HDRS}")
|
||||
endif(ZLIB_BUILD_STATIC)
|
||||
|
||||
if(ZLIB_INSTALL)
|
||||
@@ -367,7 +482,10 @@ if(ZLIB_INSTALL)
|
||||
EXPORT zlibSharedExport
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
PUBLIC_HEADER
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
COMPONENT Development)
|
||||
install(
|
||||
EXPORT zlibSharedExport
|
||||
FILE ZLIB-shared.cmake
|
||||
@@ -391,7 +509,8 @@ if(ZLIB_INSTALL)
|
||||
EXPORT zlibStaticExport
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(
|
||||
EXPORT zlibStaticExport
|
||||
FILE ZLIB-static.cmake
|
||||
@@ -412,10 +531,6 @@ if(ZLIB_INSTALL)
|
||||
install(FILES ${zlib_BINARY_DIR}/ZLIBConfig.cmake
|
||||
${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
|
||||
install(
|
||||
FILES ${ZLIB_PUBLIC_HDRS}
|
||||
COMPONENT Development
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
install(
|
||||
FILES zlib.3
|
||||
COMPONENT Docs
|
||||
|
||||
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
ZLIB DATA COMPRESSION LIBRARY
|
||||
|
||||
zlib 1.3.2.1 is a general purpose data compression library. All the code is
|
||||
zlib 1.4 is a general purpose data compression library. All the code is
|
||||
thread safe (though see the FAQ for caveats). The data format used by the zlib
|
||||
library is described by RFCs (Request for Comments) 1950 to 1952 at
|
||||
https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate
|
||||
@@ -31,7 +31,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||
issue of Dr. Dobb's Journal; a copy of the article is available at
|
||||
https://zlib.net/nelson/ .
|
||||
|
||||
The changes made in version 1.3.2.1 are documented in the file ChangeLog.
|
||||
The changes made in version 1.4 are documented in the file ChangeLog.
|
||||
|
||||
Unsupported third party contributions are provided in directory contrib/ .
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -1,10 +1,10 @@
|
||||
Name: zlib
|
||||
Short Name: zlib
|
||||
URL: https://github.com/madler/zlib
|
||||
Version: 1.3.2
|
||||
Revision: 09a1572aa624e5ddb6c075dc013880de70b1b9b9
|
||||
Version: 1.4
|
||||
Revision: 99623ef7097352da7993ba614161fd6a311e046e
|
||||
Update Mechanism: Manual (https://crbug.com/422348588)
|
||||
CPEPrefix: cpe:/a:zlib:zlib:1.3.2
|
||||
CPEPrefix: cpe:/a:zlib:zlib:1.4
|
||||
Security Critical: yes
|
||||
Shipped: yes
|
||||
License: Zlib
|
||||
@@ -15,7 +15,7 @@ Description:
|
||||
"A massively spiffy yet delicately unobtrusive compression library."
|
||||
|
||||
zlib is a free, general-purpose, legally unencumbered lossless data-compression
|
||||
library. zlib implements the "deflate" compression algorithm described by RFC
|
||||
library. zlib implements the "deflate" compression algorithm described by RFC
|
||||
1951, which combines the LZ77 (Lempel-Ziv) algorithm with Huffman coding. zlib
|
||||
also implements the zlib (RFC 1950) and gzip (RFC 1952) wrapper formats.
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -28,8 +28,8 @@ int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
|
||||
const uInt max = (uInt)-1;
|
||||
z_size_t left;
|
||||
|
||||
if ((sourceLen > 0 && source == NULL) ||
|
||||
destLen == NULL || (*destLen > 0 && dest == NULL))
|
||||
if ((sourceLen > 0 && source == Z_NULL) ||
|
||||
destLen == Z_NULL || (*destLen > 0 && dest == Z_NULL))
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
left = *destLen;
|
||||
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
Change in 1.01e (12 feb 05)
|
||||
- Fix in zipOpen2 for globalcomment (Rolf Kalbermatter)
|
||||
- Fix possible memory leak in unzip.c (Zoran Stevanovic)
|
||||
|
||||
Change in 1.01b (20 may 04)
|
||||
- Integrate patch from Debian package (submited by Mark Brown)
|
||||
- Add tools mztools from Xavier Roche
|
||||
|
||||
Change in 1.01 (8 may 04)
|
||||
- fix buffer overrun risk in unzip.c (Xavier Roche)
|
||||
- fix a minor buffer insecurity in minizip.c (Mike Whittaker)
|
||||
|
||||
Change in 1.00: (10 sept 03)
|
||||
- rename to 1.00
|
||||
- cosmetic code change
|
||||
|
||||
Change in 0.22: (19 May 03)
|
||||
- crypting support (unless you define NOCRYPT)
|
||||
- append file in existing zipfile
|
||||
|
||||
Change in 0.21: (10 Mar 03)
|
||||
- bug fixes
|
||||
|
||||
Change in 0.17: (27 Jan 02)
|
||||
- bug fixes
|
||||
|
||||
Change in 0.16: (19 Jan 02)
|
||||
- Support of ioapi for virtualize zip file access
|
||||
|
||||
Change in 0.15: (19 Mar 98)
|
||||
- fix memory leak in minizip.c
|
||||
|
||||
Change in 0.14: (10 Mar 98)
|
||||
- fix bugs in minizip.c sample for zipping big file
|
||||
- fix problem in month in date handling
|
||||
- fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for
|
||||
comment handling
|
||||
|
||||
Change in 0.13: (6 Mar 98)
|
||||
- fix bugs in zip.c
|
||||
- add real minizip sample
|
||||
|
||||
Change in 0.12: (4 Mar 98)
|
||||
- add zip.c and zip.h for creates .zip file
|
||||
- fix change_file_date in miniunz.c for Unix (Jean-loup Gailly)
|
||||
- fix miniunz.c for file without specific record for directory
|
||||
|
||||
Change in 0.11: (3 Mar 98)
|
||||
- fix bug in unzGetCurrentFileInfo for get extra field and comment
|
||||
- enhance miniunz sample, remove the bad unztst.c sample
|
||||
|
||||
Change in 0.10: (2 Mar 98)
|
||||
- fix bug in unzReadCurrentFile
|
||||
- rename unzip* to unz* function and structure
|
||||
- remove Windows-like hungary notation variable name
|
||||
- modify some structure in unzip.h
|
||||
- add somes comment in source
|
||||
- remove unzipGetcCurrentFile function
|
||||
- replace ZUNZEXPORT by ZEXPORT
|
||||
- add unzGetLocalExtrafield for get the local extrafield info
|
||||
- add a new sample, miniunz.c
|
||||
|
||||
Change in 0.4: (25 Feb 98)
|
||||
- suppress the type unzipFileInZip.
|
||||
Only on file in the zipfile can be open at the same time
|
||||
- fix somes typo in code
|
||||
- added tm_unz structure in unzip_file_info (date/time in readable format)
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
Name: ZIP file API for reading file entries in a ZIP archive
|
||||
Short Name: minizip
|
||||
URL: https://github.com/madler/zlib/tree/master/contrib/minizip
|
||||
Version: 1.3.2
|
||||
Revision: 09a1572aa624e5ddb6c075dc013880de70b1b9b9
|
||||
Version: 1.4
|
||||
Revision: 99623ef7097352da7993ba614161fd6a311e046e
|
||||
Update Mechanism: Manual
|
||||
License: Zlib
|
||||
License File: //third_party/zlib/LICENSE
|
||||
|
||||
Vendored
+127
-112
@@ -1,56 +1,59 @@
|
||||
/* skipset.h -- set operations using a skiplist
|
||||
// Copyright (C) 2024-2026 Mark Adler
|
||||
// See MiniZip_info.txt for the license.
|
||||
Copyright (C) 2024-2026 Mark Adler
|
||||
See MiniZip_info.txt for the license.
|
||||
*/
|
||||
|
||||
// This implements a skiplist set, i.e. just keys, no data, with ~O(log n) time
|
||||
// insert and search operations. The application defines the type of a key, and
|
||||
// provides a function to compare two keys.
|
||||
/*
|
||||
This implements a skiplist set, i.e. just keys, no data, with ~O(log n) time
|
||||
insert and search operations. The application defines the type of a key, and
|
||||
provides a function to compare two keys.
|
||||
|
||||
// This header is not definitions of functions found in another source file --
|
||||
// it creates the set functions, with the application's key type, right where
|
||||
// the #include is. Before this header is #included, these must be defined:
|
||||
//
|
||||
// 1. A macro or typedef for set_key_t, the type of a key.
|
||||
// 2. A macro or function set_cmp(a, b) to compare two keys. The return values
|
||||
// are < 0 for a < b, 0 for a == b, and > 0 for a > b.
|
||||
// 3. A macro or function set_drop(s, k) to release the key k's resources, if
|
||||
// any, when doing a set_end() or set_clear(). s is a pointer to the set
|
||||
// that key is in, for use with set_free() if desired.
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// typedef int set_key_t;
|
||||
// #define set_cmp(a, b) ((a) < (b) ? -1 : (a) == (b) ? 0 : 1)
|
||||
// #define set_drop(s, k)
|
||||
// #include "skipset.h"
|
||||
//
|
||||
// int test(void) { // return 0: good, 1: bad, -1: out of memory
|
||||
// set_t set;
|
||||
// if (setjmp(set.env))
|
||||
// return -1;
|
||||
// set_start(&set);
|
||||
// set_insert(&set, 2);
|
||||
// set_insert(&set, 1);
|
||||
// set_insert(&set, 7);
|
||||
// int bad = !set_found(&set, 2);
|
||||
// bad = bad || set_found(&set, 5);
|
||||
// set_end(&set);
|
||||
// return bad;
|
||||
// }
|
||||
//
|
||||
// Interface summary (see more details below):
|
||||
// - set_t is the type of the set being operated on (a set_t pointer is passed)
|
||||
// - set_start() initializes a new, empty set (initialize set.env first)
|
||||
// - set_insert() inserts a new key into the set, or not if it's already there
|
||||
// - set_found() determines whether or not a key is in the set
|
||||
// - set_end() ends the use of the set, freeing all memory
|
||||
// - set_clear() empties the set, equivalent to set_end() and then set_start()
|
||||
// - set_ok() checks if set appears to be usable, i.e. started and not ended
|
||||
//
|
||||
// Auxiliary functions available to the application:
|
||||
// - set_alloc() allocates memory with optional tracking (#define SET_TRACK)
|
||||
// - set_free() deallocates memory allocated by set_alloc()
|
||||
// - set_rand() returns 32 random bits (seeded by set_start()) */
|
||||
This header is not definitions of functions found in another source file --
|
||||
it creates the set functions, with the application's key type, right where
|
||||
the #include is. Before this header is #included, these must be defined:
|
||||
|
||||
1. A macro or typedef for set_key_t, the type of a key.
|
||||
2. A macro or function set_cmp(a, b) to compare two keys. The return values
|
||||
are < 0 for a < b, 0 for a == b, and > 0 for a > b.
|
||||
3. A macro or function set_drop(s, k) to release the key k's resources, if
|
||||
any, when doing a set_end() or set_clear(). s is a pointer to the set
|
||||
that key is in, for use with set_free() if desired.
|
||||
|
||||
Example usage:
|
||||
|
||||
typedef int set_key_t;
|
||||
#define set_cmp(a, b) ((a) < (b) ? -1 : (a) == (b) ? 0 : 1)
|
||||
#define set_drop(s, k)
|
||||
#include "skipset.h"
|
||||
|
||||
int test(void) { // return 0: good, 1: bad, -1: out of memory
|
||||
set_t set;
|
||||
if (setjmp(set.env))
|
||||
return -1;
|
||||
set_start(&set);
|
||||
set_insert(&set, 2);
|
||||
set_insert(&set, 1);
|
||||
set_insert(&set, 7);
|
||||
int bad = !set_found(&set, 2);
|
||||
bad = bad || set_found(&set, 5);
|
||||
set_end(&set);
|
||||
return bad;
|
||||
}
|
||||
|
||||
Interface summary (see more details below):
|
||||
- set_t is the type of the set being operated on (a set_t pointer is passed)
|
||||
- set_start() initializes a new, empty set (initialize set.env first)
|
||||
- set_insert() inserts a new key into the set, or not if it's already there
|
||||
- set_found() determines whether or not a key is in the set
|
||||
- set_end() ends the use of the set, freeing all memory
|
||||
- set_clear() empties the set, equivalent to set_end() and then set_start()
|
||||
- set_ok() checks if set appears to be usable, i.e. started and not ended
|
||||
|
||||
Auxiliary functions available to the application:
|
||||
- set_alloc() allocates memory with optional tracking (#define SET_TRACK)
|
||||
- set_free() deallocates memory allocated by set_alloc()
|
||||
- set_rand() returns 32 random bits (seeded by set_start())
|
||||
*/
|
||||
|
||||
#ifndef SKIPSET_H
|
||||
#define SKIPSET_H
|
||||
@@ -63,38 +66,44 @@
|
||||
#include <assert.h> /* assert.h */
|
||||
#include "ints.h" /* i16_t, ui32_t, ui64_t */
|
||||
|
||||
/* Structures and functions below noted as "--private--" should not be used by
|
||||
// the application. set_t is partially private and partially public -- see the
|
||||
// comments there.
|
||||
/*
|
||||
Structures and functions below noted as "--private--" should not be used by
|
||||
the application. set_t is partially private and partially public -- see the
|
||||
comments there.
|
||||
|
||||
// There is no POSIX random() in MSVC, and rand() is awful. For portability, we
|
||||
// cannot rely on a library function for random numbers. Instead we use the
|
||||
// fast and effective algorithm below, invented by Melissa O'Neill.
|
||||
There is no POSIX random() in MSVC, and rand() is awful. For portability, we
|
||||
cannot rely on a library function for random numbers. Instead we use the
|
||||
fast and effective algorithm below, invented by Melissa O'Neill.
|
||||
*/
|
||||
|
||||
// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org
|
||||
// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
|
||||
// --private-- Random number generator state. */
|
||||
/*
|
||||
*Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org
|
||||
Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
|
||||
--private-- Random number generator state.
|
||||
*/
|
||||
typedef struct {
|
||||
ui64_t state; /* 64-bit generator state */
|
||||
ui64_t inc; /* 63-bit sequence id */
|
||||
} set_rand_t;
|
||||
/* --private-- Initialize the state *gen using seed and seq. seed seeds the
|
||||
// advancing 64-bit state. seq is a sequence selection constant. */
|
||||
void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) {
|
||||
advancing 64-bit state. seq is a sequence selection constant. */
|
||||
static void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) {
|
||||
gen->inc = (seq << 1) | 1;
|
||||
gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc;
|
||||
}
|
||||
/* Start a unique random number sequence using bits from noise sources. */
|
||||
void set_uniq(set_rand_t *gen, const void *ptr) {
|
||||
static void set_uniq(set_rand_t *gen, const void *ptr) {
|
||||
set_seed(gen, ((ui64_t)(ptrdiff_t)ptr << 32) ^
|
||||
((ui64_t)time(NULL) << 12) ^ clock(), 0);
|
||||
}
|
||||
/* Return 32 random bits, advancing the state *gen. */
|
||||
ui32_t set_rand(set_rand_t *gen) {
|
||||
static ui32_t set_rand(set_rand_t *gen) {
|
||||
ui32_t mix;
|
||||
int rot;
|
||||
ui64_t state = gen->state;
|
||||
gen->state = state * 6364136223846793005ULL + gen->inc;
|
||||
ui32_t mix = (ui32_t)(((state >> 18) ^ state) >> 27);
|
||||
int rot = state >> 59;
|
||||
mix = (ui32_t)(((state >> 18) ^ state) >> 27);
|
||||
rot = state >> 59;
|
||||
return (mix >> rot) | (mix << ((-rot) & 31));
|
||||
}
|
||||
/* End of PCG32 code. */
|
||||
@@ -109,7 +118,7 @@ struct set_node_s {
|
||||
};
|
||||
|
||||
/* A set. The application sets env, may use gen with set_rand(), and may read
|
||||
// allocs and memory. The remaining variables are --private-- . */
|
||||
allocs and memory. The remaining variables are --private-- . */
|
||||
typedef struct set_s {
|
||||
set_node_t *head; /* skiplist head -- no key, just links */
|
||||
set_node_t *path; /* right[] is path to key from set_found() */
|
||||
@@ -120,15 +129,15 @@ typedef struct set_s {
|
||||
jmp_buf env; /* setjmp() environment for allocation errors */
|
||||
#ifdef SET_TRACK
|
||||
size_t allocs; /* number of allocations */
|
||||
size_t memory; /* total amount of allocated memory (>= requests) */
|
||||
size_t memory; /* total size of allocated memory (>= requests) */
|
||||
#endif
|
||||
} set_t;
|
||||
|
||||
/* Memory allocation and deallocation. set_alloc(set, ptr, size) returns a
|
||||
// pointer to an allocation of size bytes if ptr is NULL, or the previous
|
||||
// allocation ptr resized to size bytes. set_alloc() will never return NULL.
|
||||
// set_free(set, ptr) frees an allocation created by set_alloc(). These may be
|
||||
// used by the application. e.g. if allocation tracking is desired. */
|
||||
pointer to an allocation of size bytes if ptr is NULL, or the previous
|
||||
allocation ptr resized to size bytes. set_alloc() will never return NULL.
|
||||
set_free(set, ptr) frees an allocation created by set_alloc(). These may be
|
||||
used by the application. e.g. if allocation tracking is desired. */
|
||||
#ifdef SET_TRACK
|
||||
/* Track the number of allocations and the total backing memory size. */
|
||||
# if defined(_WIN32)
|
||||
@@ -146,11 +155,11 @@ typedef struct set_s {
|
||||
# elif defined(__NetBSD__)
|
||||
# include <jemalloc/jemalloc.h>
|
||||
# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr)
|
||||
# else // e.g. OpenBSD
|
||||
# else /* e.g. OpenBSD */
|
||||
# define SET_ALLOC_SIZE(ptr) 0
|
||||
# endif
|
||||
// With tracking.
|
||||
void *set_alloc(set_t *set, void *ptr, size_t size) {
|
||||
/* With tracking. */
|
||||
static void *set_alloc(set_t *set, void *ptr, size_t size) {
|
||||
size_t had = ptr == NULL ? 0 : SET_ALLOC_SIZE(ptr);
|
||||
void *mem = realloc(ptr, size);
|
||||
if (mem == NULL)
|
||||
@@ -159,7 +168,7 @@ void *set_alloc(set_t *set, void *ptr, size_t size) {
|
||||
set->memory += SET_ALLOC_SIZE(mem) - had;
|
||||
return mem;
|
||||
}
|
||||
void set_free(set_t *set, void *ptr) {
|
||||
static void set_free(set_t *set, void *ptr) {
|
||||
if (ptr != NULL) {
|
||||
set->allocs--;
|
||||
set->memory -= SET_ALLOC_SIZE(ptr);
|
||||
@@ -168,23 +177,24 @@ void set_free(set_t *set, void *ptr) {
|
||||
}
|
||||
#else
|
||||
/* Without tracking. */
|
||||
void *set_alloc(set_t *set, void *ptr, size_t size) {
|
||||
static void *set_alloc(set_t *set, void *ptr, size_t size) {
|
||||
void *mem = realloc(ptr, size);
|
||||
if (mem == NULL)
|
||||
longjmp(set->env, ENOMEM);
|
||||
return mem;
|
||||
}
|
||||
void set_free(set_t *set, void *ptr) {
|
||||
static void set_free(set_t *set, void *ptr) {
|
||||
(void)set;
|
||||
free(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* --private-- Grow node's array right[] as needed to be able to hold at least
|
||||
// want links. If fill is true, assure that the first want links are filled in,
|
||||
// setting them to set->head if not previously filled in. Otherwise it is
|
||||
// assumed that the first want links are about to be filled in. */
|
||||
void set_grow(set_t *set, set_node_t *node, int want, int fill) {
|
||||
want links. If fill is true, assure that the first want links are filled in,
|
||||
setting them to set->head if not previously filled in. Otherwise it is
|
||||
assumed that the first want links are about to be filled in. */
|
||||
static void set_grow(set_t *set, set_node_t *node, int want, int fill) {
|
||||
int i;
|
||||
if (node->size < want) {
|
||||
int more = node->size ? node->size : 1;
|
||||
while (more < want)
|
||||
@@ -193,7 +203,6 @@ void set_grow(set_t *set, set_node_t *node, int want, int fill) {
|
||||
(size_t)more * sizeof(set_node_t *));
|
||||
node->size = (i16_t)more;
|
||||
}
|
||||
int i;
|
||||
if (fill)
|
||||
for (i = node->fill; i < want; i++)
|
||||
node->right[i] = set->head;
|
||||
@@ -201,7 +210,7 @@ void set_grow(set_t *set, set_node_t *node, int want, int fill) {
|
||||
}
|
||||
|
||||
/* --private-- Return a new node. key is left uninitialized. */
|
||||
set_node_t *set_node(set_t *set) {
|
||||
static set_node_t *set_node(set_t *set) {
|
||||
set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t));
|
||||
node->size = 0;
|
||||
node->fill = 0;
|
||||
@@ -210,7 +219,7 @@ set_node_t *set_node(set_t *set) {
|
||||
}
|
||||
|
||||
/* --private-- Free the list linked from head, along with the keys. */
|
||||
void set_sweep(set_t *set) {
|
||||
static void set_sweep(set_t *set) {
|
||||
set_node_t *step = set->head->right[0];
|
||||
while (step != set->head) {
|
||||
set_node_t *next = step->right[0]; /* save link to next node */
|
||||
@@ -222,12 +231,12 @@ void set_sweep(set_t *set) {
|
||||
}
|
||||
|
||||
/* Initialize a new set. set->env must be initialized using setjmp() before
|
||||
// set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a
|
||||
// memory allocation failure during any of the operations. (See setjmp.h and
|
||||
// errno.h.) The set can still be used if this happens, assuming that it didn't
|
||||
// happen during set_start(). Whether set_start() completed or not, set_end()
|
||||
// can be used to free the set's memory after a longjmp(). */
|
||||
void set_start(set_t *set) {
|
||||
set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a
|
||||
memory allocation failure during any of the operations. (See setjmp.h and
|
||||
errno.h.) The set can still be used if this happens, assuming that it didn't
|
||||
happen during set_start(). Whether set_start() completed or not, set_end()
|
||||
can be used to free the set's memory after a longjmp(). */
|
||||
SKIPSET_EXPORT void set_start(set_t *set) {
|
||||
#ifdef SET_TRACK
|
||||
set->allocs = 0;
|
||||
set->memory = 0;
|
||||
@@ -235,7 +244,7 @@ void set_start(set_t *set) {
|
||||
set->head = set->path = set->node = NULL; /* in case set_node() fails */
|
||||
set->path = set_node(set);
|
||||
set->head = set_node(set);
|
||||
set_grow(set, set->head, 1, 1); /* one link back to head for an empty set */
|
||||
set_grow(set, set->head, 1, 1); /* one link back to head for empty set */
|
||||
*(unsigned char *)&set->head->key = 137; /* set id */
|
||||
set->depth = 0;
|
||||
set_uniq(&set->gen, set);
|
||||
@@ -243,34 +252,36 @@ void set_start(set_t *set) {
|
||||
}
|
||||
|
||||
/* Return true if *set appears to be in a usable state. If *set has been zeroed
|
||||
// out, then set_ok(set) will be false and set_end(set) will be safe. */
|
||||
int set_ok(set_t *set) {
|
||||
out, then set_ok(set) will be false and set_end(set) will be safe. */
|
||||
SKIPSET_EXPORT int set_ok(set_t *set) {
|
||||
return set->head != NULL &&
|
||||
set->head->right != NULL &&
|
||||
*(unsigned char *)&set->head->key == 137;
|
||||
}
|
||||
|
||||
#if 0 /* not used in minizip */
|
||||
/* Empty the set. This frees the memory used for the previous set contents.
|
||||
// After set_clear(), *set is ready for use, as if after a set_start(). */
|
||||
void set_clear(set_t *set) {
|
||||
After set_clear(), *set is ready for use, as if after a set_start(). */
|
||||
SKIPSET_EXPORT void set_clear(set_t *set) {
|
||||
assert(set_ok(set) && "improper use");
|
||||
|
||||
/* Free all the keys and their nodes. */
|
||||
set_sweep(set);
|
||||
|
||||
/* Leave the head and path allocations as is. Clear their contents, with
|
||||
// head pointing to itself and setting depth to zero, for an empty set. */
|
||||
head pointing to itself and setting depth to zero, for an empty set. */
|
||||
set->head->right[0] = set->head;
|
||||
set->head->fill = 1;
|
||||
set->path->fill = 0;
|
||||
set->depth = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Done using the set -- free all allocations. The only operation on *set
|
||||
// permitted after this is set_start(). Though another set_end() would do no
|
||||
// harm. This can be done at any time after a set_start(), or after a longjmp()
|
||||
// on any allocation failure, including during a set_start(). */
|
||||
void set_end(set_t *set) {
|
||||
permitted after this is set_start(). Though another set_end() would do no
|
||||
harm. This can be done at any time after a set_start(), or after a longjmp()
|
||||
on any allocation failure, including during a set_start(). */
|
||||
SKIPSET_EXPORT void set_end(set_t *set) {
|
||||
if (set->head != NULL) {
|
||||
/* Empty the set and free the head node. */
|
||||
if (set->head->right != NULL) {
|
||||
@@ -296,13 +307,16 @@ void set_end(set_t *set) {
|
||||
}
|
||||
|
||||
/* Look for key. Return 1 if found or 0 if not. This also puts the path to get
|
||||
// there in set->path, for use by set_insert(). */
|
||||
int set_found(set_t *set, set_key_t key) {
|
||||
there in set->path, for use by set_insert(). */
|
||||
SKIPSET_EXPORT int set_found(set_t *set, set_key_t key) {
|
||||
set_node_t *head, *here;
|
||||
int i;
|
||||
assert(set_ok(set) && "improper use");
|
||||
|
||||
/* Start at depth and work down and right as determined by key comparisons. */
|
||||
set_node_t *head = set->head, *here = head;
|
||||
int i = set->depth;
|
||||
/* Start at depth. Work down and right as determined by key comparisons. */
|
||||
head = set->head;
|
||||
here = head;
|
||||
i = set->depth;
|
||||
set_grow(set, set->path, i + 1, 0);
|
||||
do {
|
||||
while (here->right[i] != head &&
|
||||
@@ -316,8 +330,11 @@ int set_found(set_t *set, set_key_t key) {
|
||||
return here != head && set_cmp(here->key, key) == 0;
|
||||
}
|
||||
|
||||
/* Insert the key key. Return 0 on success, or 1 if key is already in the set. */
|
||||
int set_insert(set_t *set, set_key_t key) {
|
||||
/* Insert the key key. Return 0 on success, or 1 if it's already in the set. */
|
||||
SKIPSET_EXPORT int set_insert(set_t *set, set_key_t key) {
|
||||
int level = 0;
|
||||
int bit;
|
||||
int i;
|
||||
assert(set_ok(set) && "improper use");
|
||||
|
||||
if (set_found(set, key))
|
||||
@@ -325,13 +342,12 @@ int set_insert(set_t *set, set_key_t key) {
|
||||
return 1;
|
||||
|
||||
/* Randomly generate a new level-- level 0 with probability 1/2, 1 with
|
||||
// probability 1/4, 2 with probability 1/8, etc. */
|
||||
int level = 0;
|
||||
probability 1/4, 2 with probability 1/8, etc. */
|
||||
for (;;) {
|
||||
if (set->ran == 1)
|
||||
/* Ran out. Get another 32 random bits. */
|
||||
set->ran = set_rand(&set->gen) | (1ULL << 32);
|
||||
int bit = set->ran & 1;
|
||||
bit = set->ran & 1;
|
||||
set->ran >>= 1;
|
||||
if (bit)
|
||||
break;
|
||||
@@ -347,11 +363,10 @@ int set_insert(set_t *set, set_key_t key) {
|
||||
}
|
||||
|
||||
/* Make a new node for the provided key, and insert it in the lists up to
|
||||
// and including level. */
|
||||
and including level. */
|
||||
set->node = set_node(set);
|
||||
set->node->key = key;
|
||||
set_grow(set, set->node, level + 1, 0);
|
||||
int i;
|
||||
for (i = 0; i <= level; i++) {
|
||||
set->node->right[i] = set->path->right[i]->right[i];
|
||||
set->path->right[i]->right[i] = set->node;
|
||||
|
||||
Vendored
+7
-9
@@ -1320,13 +1320,12 @@ extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCase
|
||||
|
||||
|
||||
/*
|
||||
///////////////////////////////////////////
|
||||
// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
|
||||
// I need random access
|
||||
//
|
||||
// Further optimization could be realized by adding an ability
|
||||
// to cache the directory in memory. The goal being a single
|
||||
// comprehensive file read to put the file I need in a memory.
|
||||
Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
|
||||
I need random access
|
||||
|
||||
Further optimization could be realized by adding an ability
|
||||
to cache the directory in memory. The goal being a single
|
||||
comprehensive file read to put the file I need in a memory.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -1395,8 +1394,7 @@ extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) {
|
||||
}
|
||||
|
||||
/*
|
||||
// Unzip Helper Functions - should be here?
|
||||
///////////////////////////////////////////
|
||||
Unzip Helper Functions - should be here?
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Vendored
+46
-40
@@ -128,7 +128,8 @@ typedef struct linkedlist_data_s
|
||||
|
||||
|
||||
/* zipAlreadyThere() set functions for a set of zero-terminated strings, and
|
||||
// a block_t type for reading the central directory datablocks. */
|
||||
a block_t type for reading the central directory datablocks. */
|
||||
#define SKIPSET_EXPORT static
|
||||
typedef char *set_key_t;
|
||||
#define set_cmp(a, b) strcmp(a, b)
|
||||
#define set_drop(s, k) set_free(s, k)
|
||||
@@ -286,18 +287,18 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
|
||||
}
|
||||
|
||||
/* zipAlreadyThere() operations. "set" in the zip internal structure keeps the
|
||||
// set of names that are in the under-construction central directory so far. A
|
||||
// skipset provides ~O(log n) time insertion and searching. Central directory
|
||||
// records, stored in a linked list of allocated memory datablocks, is read
|
||||
// through "block" in the zip internal structure.
|
||||
set of names that are in the under-construction central directory so far. A
|
||||
skipset provides ~O(log n) time insertion and searching. Central directory
|
||||
records, stored in a linked list of allocated memory datablocks, is read
|
||||
through "block" in the zip internal structure.
|
||||
|
||||
// The block_*() functions support extracting the central directory file names
|
||||
// from the datablocks. They are designed to support a growing directory by
|
||||
// automatically continuing once more data has been appended to the linked
|
||||
// datablocks.
|
||||
The block_*() functions support extracting the central directory file names
|
||||
from the datablocks. They are designed to support a growing directory by
|
||||
automatically continuing once more data has been appended to the linked
|
||||
datablocks.
|
||||
|
||||
// Initialize *block to the head of list. This should only be called once the
|
||||
// list has at least some data in it, i.e. list->first_block is not NULL. */
|
||||
Initialize *block to the head of list. This should only be called once the
|
||||
list has at least some data in it, i.e. list->first_block is not NULL. */
|
||||
local void block_init(block_t *block, linkedlist_data *list) {
|
||||
block->node = list->first_block;
|
||||
block->next = block->node->data;
|
||||
@@ -305,8 +306,8 @@ local void block_init(block_t *block, linkedlist_data *list) {
|
||||
}
|
||||
|
||||
/* Mark *block as bad, with all subsequent reads returning end, even if more
|
||||
// data is added to the datablocks. This is invoked if the central directory is
|
||||
// invalid, so there is no longer any point in attempting to interpret it. */
|
||||
data is added to the datablocks. This is invoked if the central directory is
|
||||
invalid, so there is no longer any point in attempting to interpret it. */
|
||||
local void block_stop(block_t *block) {
|
||||
block->left = 0;
|
||||
block->next = NULL;
|
||||
@@ -357,7 +358,7 @@ local int block_get(block_t *block) {
|
||||
}
|
||||
|
||||
/* Return a 16-bit unsigned little-endian value from block, or a negative value
|
||||
// if the end is reached. */
|
||||
if the end is reached. */
|
||||
local long block_get2(block_t *block) {
|
||||
int low = block_get(block);
|
||||
int high = block_get(block);
|
||||
@@ -367,6 +368,7 @@ local long block_get2(block_t *block) {
|
||||
/* Read up to len bytes from block into buf. Return the number of bytes read. */
|
||||
local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
|
||||
size_t need = len;
|
||||
size_t take;
|
||||
while (need) {
|
||||
if (block->left == 0) {
|
||||
/* Get a byte to update and step through the linked list as needed. */
|
||||
@@ -378,7 +380,7 @@ local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
|
||||
need--;
|
||||
continue;
|
||||
}
|
||||
size_t take = need > block->left ? block->left : need;
|
||||
take = need > block->left ? block->left : need;
|
||||
memcpy(buf, block->next, take);
|
||||
block->next += take;
|
||||
block->left -= take;
|
||||
@@ -389,7 +391,7 @@ local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
|
||||
}
|
||||
|
||||
/* Skip n bytes in block. Return 0 on success or -1 if there are less than n
|
||||
// bytes to the end. */
|
||||
bytes to the end. */
|
||||
local int block_skip(block_t *block, size_t n) {
|
||||
while (n > block->left) {
|
||||
n -= block->left;
|
||||
@@ -405,9 +407,10 @@ local int block_skip(block_t *block, size_t n) {
|
||||
}
|
||||
|
||||
/* Process the next central directory record at *block. Return the allocated,
|
||||
// zero-terminated file name, or NULL for end of input or invalid data. If
|
||||
// invalid, *block is marked bad. This uses *set for the allocation of memory. */
|
||||
zero-terminated file name, or NULL for end of input or invalid data. If
|
||||
invalid, *block is marked bad. This uses *set for the allocation of memory. */
|
||||
local char *block_central_name(block_t *block, set_t *set) {
|
||||
unsigned flen, xlen, clen;
|
||||
char *name = NULL;
|
||||
for (;;) {
|
||||
if (block_end(block))
|
||||
@@ -421,11 +424,11 @@ local char *block_central_name(block_t *block, set_t *set) {
|
||||
break;
|
||||
|
||||
/* Go through the remaining fixed-length portion of the record,
|
||||
// extracting the lengths of the three variable-length fields. */
|
||||
extracting the lengths of the three variable-length fields. */
|
||||
block_skip(block, 24);
|
||||
unsigned flen = (unsigned)block_get2(block); /* file name length */
|
||||
unsigned xlen = (unsigned)block_get2(block); /* extra length */
|
||||
unsigned clen = (unsigned)block_get2(block); /* comment length */
|
||||
flen = (unsigned)block_get2(block); /* file name length */
|
||||
xlen = (unsigned)block_get2(block); /* extra length */
|
||||
clen = (unsigned)block_get2(block); /* comment length */
|
||||
if (block_skip(block, 12) == -1)
|
||||
/* Premature end of the record. */
|
||||
break;
|
||||
@@ -440,9 +443,9 @@ local char *block_central_name(block_t *block, set_t *set) {
|
||||
/* Check for embedded nuls in the name. */
|
||||
if (memchr(name, 0, flen) != NULL) {
|
||||
/* This name can never match the zero-terminated name provided to
|
||||
// zipAlreadyThere(), so we discard it and go back to get another
|
||||
// name. (Who the heck is putting nuls inside their zip file entry
|
||||
// names anyway?) */
|
||||
zipAlreadyThere(), so we discard it and go back to get another
|
||||
name. (Who the heck is putting nuls inside their zip file entry
|
||||
names anyway?) */
|
||||
set_free(set, name);
|
||||
continue;
|
||||
}
|
||||
@@ -453,16 +456,19 @@ local char *block_central_name(block_t *block, set_t *set) {
|
||||
}
|
||||
|
||||
/* Invalid signature or premature end of the central directory record.
|
||||
// Abandon trying to process the central directory. */
|
||||
Abandon trying to process the central directory. */
|
||||
set_free(set, name);
|
||||
block_stop(block);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Return 0 if name is not in the central directory so far, 1 if it is, -1 if
|
||||
// the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if
|
||||
// file is NULL. */
|
||||
the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if
|
||||
file is NULL. */
|
||||
extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
|
||||
size_t len;
|
||||
char *copy;
|
||||
int found;
|
||||
zip64_internal *zip = file;
|
||||
if (zip == NULL)
|
||||
return ZIP_PARAMERROR;
|
||||
@@ -476,14 +482,14 @@ extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
|
||||
}
|
||||
if (!set_ok(&zip->set)) {
|
||||
/* This is the first time here with some central directory content. We
|
||||
// construct this set of names only on demand. Prepare set and block. */
|
||||
construct this set of names only on demand. Prepare set and block. */
|
||||
set_start(&zip->set);
|
||||
block_init(&zip->block, &zip->central_dir);
|
||||
}
|
||||
|
||||
/* Update the set of names from the current central directory contents.
|
||||
// This reads any new central directory records since the last time we were
|
||||
// here. */
|
||||
This reads any new central directory records since the last time we were
|
||||
here. */
|
||||
for (;;) {
|
||||
char *there = block_central_name(&zip->block, &zip->set);
|
||||
if (there == NULL) {
|
||||
@@ -496,15 +502,15 @@ extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
|
||||
/* Add there to the set. */
|
||||
if (set_insert(&zip->set, there))
|
||||
/* There's already a duplicate in the central directory! We'll just
|
||||
// let this be and carry on. */
|
||||
let this be and carry on. */
|
||||
set_free(&zip->set, there);
|
||||
}
|
||||
|
||||
/* Return true if name is in the central directory. */
|
||||
size_t len = strlen(name);
|
||||
char *copy = set_alloc(&zip->set, NULL, len + 1);
|
||||
len = strlen(name);
|
||||
copy = set_alloc(&zip->set, NULL, len + 1);
|
||||
memcpy(copy, name, len + 1);
|
||||
int found = set_found(&zip->set, copy);
|
||||
found = set_found(&zip->set, copy);
|
||||
set_free(&zip->set, copy);
|
||||
return found;
|
||||
}
|
||||
@@ -939,7 +945,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
|
||||
err=ZIP_ERRNO;
|
||||
|
||||
/* TODO..
|
||||
// read the comment from the standard central header. */
|
||||
read the comment from the standard central header. */
|
||||
size_comment = 0;
|
||||
}
|
||||
else
|
||||
@@ -1334,8 +1340,8 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
|
||||
if ((comment!=NULL) && (strlen(comment)>0xffff))
|
||||
return ZIP_PARAMERROR;
|
||||
/* The extra field length must fit in 16 bits. If the member also requires
|
||||
// a Zip64 extra block, that will also need to fit within that 16-bit
|
||||
// length, but that will be checked for later. */
|
||||
a Zip64 extra block, that will also need to fit within that 16-bit
|
||||
length, but that will be checked for later. */
|
||||
if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
@@ -1927,8 +1933,8 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
|
||||
}
|
||||
|
||||
/* Update how much extra free space we got in the memory buffer
|
||||
// and increase the centralheader size so the new ZIP64 fields are included
|
||||
// ( 4 below is the size of HeaderID and DataSize field ) */
|
||||
and increase the centralheader size so the new ZIP64 fields are included
|
||||
( 4 below is the size of HeaderID and DataSize field ) */
|
||||
zi->ci.size_centralExtraFree -= datasize + 4;
|
||||
zi->ci.size_centralheader += datasize + 4;
|
||||
|
||||
|
||||
+46
-14
@@ -133,6 +133,14 @@ int ZEXPORT inflateReset(z_streamp strm) {
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
if (state->wbits != state->reqbits) {
|
||||
if (state->window != Z_NULL) {
|
||||
ZFREE(strm, state->window);
|
||||
state->window = Z_NULL;
|
||||
}
|
||||
state->wbits = state->reqbits;
|
||||
}
|
||||
state->wrap = state->reqwrap;
|
||||
state->wsize = 0;
|
||||
state->whave = 0;
|
||||
state->wnext = 0;
|
||||
@@ -171,8 +179,8 @@ int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
|
||||
}
|
||||
|
||||
/* update state and reset the rest of it */
|
||||
state->wrap = wrap;
|
||||
state->wbits = (unsigned)windowBits;
|
||||
state->reqwrap = state->wrap = wrap;
|
||||
state->reqbits = state->wbits = (unsigned)windowBits;
|
||||
return inflateReset(strm);
|
||||
}
|
||||
|
||||
@@ -665,13 +673,13 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||
}
|
||||
DROPBITS(4);
|
||||
len = BITS(4) + 8;
|
||||
if (state->wbits == 0)
|
||||
state->wbits = len;
|
||||
if (len > 15 || len > state->wbits) {
|
||||
strm->msg = (char *)"invalid window size";
|
||||
if (len > 15 || (state->wbits != 0 && len > state->wbits)) {
|
||||
strm->msg = (z_const char *)"invalid window size";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
if (state->wbits == 0)
|
||||
state->wbits = len;
|
||||
state->dmax = 1U << len;
|
||||
state->flags = 0; /* indicate zlib header */
|
||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||
@@ -828,6 +836,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||
case DICT:
|
||||
if (state->havedict == 0) {
|
||||
RESTORE();
|
||||
strm->total_in += in - strm->avail_in;
|
||||
return Z_NEED_DICT;
|
||||
}
|
||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||
@@ -1037,7 +1046,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||
/* fallthrough */
|
||||
case LEN:
|
||||
if (have >= INFLATE_FAST_MIN_INPUT &&
|
||||
left >= INFLATE_FAST_MIN_OUTPUT) {
|
||||
left >= INFLATE_FAST_MIN_OUTPUT &&
|
||||
bits < 8) {
|
||||
RESTORE();
|
||||
inflate_fast_chunk_(strm, out);
|
||||
LOAD();
|
||||
@@ -1337,7 +1347,8 @@ int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
||||
int ret;
|
||||
|
||||
/* check state */
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
if (inflateStateCheck(strm) || dictionary == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
if (state->wrap != 0 && state->mode != DICT)
|
||||
return Z_STREAM_ERROR;
|
||||
@@ -1442,15 +1453,23 @@ int ZEXPORT inflateSync(z_streamp strm) {
|
||||
|
||||
/* return no joy or set up to restart inflate() on a new block */
|
||||
if (state->have != 4) return Z_DATA_ERROR;
|
||||
if (state->flags == -1)
|
||||
state->wrap = 0; /* if no header yet, treat as raw */
|
||||
else
|
||||
state->wrap &= ~4; /* no point in computing a check value now */
|
||||
flags = state->flags;
|
||||
in = strm->total_in; out = strm->total_out;
|
||||
inflateReset(strm);
|
||||
strm->total_in = in; strm->total_out = out;
|
||||
state->flags = flags;
|
||||
if (flags == -1)
|
||||
state->wrap = 0; /* if no header yet, treat as raw */
|
||||
else
|
||||
state->wrap &= ~4; /* no point in computing a check value now */
|
||||
if (state->wbits == 0) {
|
||||
/* we never got to see a header for the window size -- set to max */
|
||||
if (state->window != Z_NULL) {
|
||||
ZFREE(strm, state->window);
|
||||
state->window = Z_NULL;
|
||||
}
|
||||
state->wbits = 15;
|
||||
}
|
||||
state->mode = TYPE;
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -1478,14 +1497,22 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
|
||||
unsigned wsize;
|
||||
|
||||
/* check input */
|
||||
if (inflateStateCheck(source) || dest == Z_NULL)
|
||||
if (dest == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (inflateStateCheck(source)) {
|
||||
dest->state = Z_NULL;
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
state = (struct inflate_state FAR *)source->state;
|
||||
|
||||
/* allocate space */
|
||||
copy = (struct inflate_state FAR *)
|
||||
ZALLOC(source, 1, sizeof(struct inflate_state));
|
||||
if (copy == Z_NULL) return Z_MEM_ERROR;
|
||||
if (copy == Z_NULL) {
|
||||
dest->state = Z_NULL;
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
zmemzero(copy, sizeof(struct inflate_state));
|
||||
window = Z_NULL;
|
||||
if (state->window != Z_NULL) {
|
||||
window = (unsigned char FAR *)ZALLOC(
|
||||
@@ -1493,6 +1520,7 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
|
||||
sizeof(unsigned char));
|
||||
if (window == Z_NULL) {
|
||||
ZFREE(source, copy);
|
||||
dest->state = Z_NULL;
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -1540,6 +1568,10 @@ int ZEXPORT inflateValidate(z_streamp strm, int check) {
|
||||
state->wrap |= 4;
|
||||
else
|
||||
state->wrap &= ~4;
|
||||
if (check && state->reqwrap)
|
||||
state->reqwrap |= 4;
|
||||
else
|
||||
state->reqwrap &= ~4;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -757,7 +757,7 @@ uLong ZEXPORT crc32_z(uLong crc, const unsigned char FAR *buf, z_size_t len) {
|
||||
#endif
|
||||
|
||||
/* Initialize the CRC for each braid. */
|
||||
crc0 = crc;
|
||||
crc0 = (z_crc_t)crc;
|
||||
#if N > 1
|
||||
crc1 = 0;
|
||||
#if N > 2
|
||||
|
||||
Vendored
+74
-44
@@ -71,7 +71,7 @@
|
||||
#endif
|
||||
|
||||
const char deflate_copyright[] =
|
||||
" deflate 1.3.2.1 Copyright 1995-2026 Jean-loup Gailly and Mark Adler ";
|
||||
" deflate 1.4 Copyright 1995-2026 Jean-loup Gailly and Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
@@ -475,7 +475,6 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
|
||||
s->status = INIT_STATE; /* to pass state test in deflateReset() */
|
||||
|
||||
s->wrap = wrap;
|
||||
s->gzhead = Z_NULL;
|
||||
s->w_bits = (uInt)windowBits;
|
||||
s->w_size = 1 << s->w_bits;
|
||||
s->w_mask = s->w_size - 1;
|
||||
@@ -626,7 +625,8 @@ int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
||||
return Z_STREAM_ERROR;
|
||||
s = strm->state;
|
||||
wrap = s->wrap;
|
||||
if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead)
|
||||
if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead ||
|
||||
(wrap == 0 && (long)s->strstart != s->block_start))
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
/* when using zlib wrappers, compute Adler-32 for provided dictionary */
|
||||
@@ -725,7 +725,20 @@ int ZEXPORT deflateResetKeep(z_streamp strm) {
|
||||
adler32(0L, Z_NULL, 0);
|
||||
s->last_flush = -2;
|
||||
|
||||
_tr_init(s);
|
||||
s->gzhead = Z_NULL;
|
||||
|
||||
{
|
||||
/* Retain the hash work done for level 0. */
|
||||
uInt matches = s->level == 0 ? s->matches : 0;
|
||||
_tr_init(s);
|
||||
s->matches = matches;
|
||||
}
|
||||
|
||||
/* Keep the window and the hash, but drop what was left unfinished */
|
||||
s->block_start = (long)s->strstart;
|
||||
s->lookahead = 0;
|
||||
s->match_length = s->prev_length = MIN_MATCH-1;
|
||||
s->match_available = 0;
|
||||
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -737,6 +750,7 @@ local void lm_init(deflate_state *s) {
|
||||
s->window_size = (ulg)2L*s->w_size;
|
||||
|
||||
CLEAR_HASH(s);
|
||||
s->matches = 0; /* the hash is clear */
|
||||
|
||||
/* Set the default configuration parameters:
|
||||
*/
|
||||
@@ -799,18 +813,23 @@ int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
|
||||
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
|
||||
deflate_state *s;
|
||||
int put;
|
||||
int need;
|
||||
|
||||
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
s = strm->state;
|
||||
#ifdef LIT_MEM
|
||||
if (bits < 0 || bits > 16 ||
|
||||
(uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3))
|
||||
if (bits < 0 || bits > 16)
|
||||
return Z_BUF_ERROR;
|
||||
#else
|
||||
if (bits < 0 || bits > 16 ||
|
||||
s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
|
||||
if (s->pending_out != s->pending_buf) {
|
||||
/* move partially flushed pending output to buffer start */
|
||||
Bytef *to = s->pending_buf, *from = s->pending_out;
|
||||
ulg n = s->pending;
|
||||
while (n--)
|
||||
*to++ = *from++;
|
||||
s->pending_out = s->pending_buf;
|
||||
}
|
||||
need = (s->bi_valid + bits) >> 3;
|
||||
if (s->pending_buf_size - s->pending < (ulg)need)
|
||||
return Z_BUF_ERROR;
|
||||
#endif
|
||||
do {
|
||||
put = Buf_size - s->bi_valid;
|
||||
if (put > bits)
|
||||
@@ -1395,46 +1414,50 @@ int ZEXPORT deflateEnd(z_streamp strm) {
|
||||
*/
|
||||
int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
|
||||
#ifdef MAXSEG_64K
|
||||
(void)dest;
|
||||
(void)source;
|
||||
if (dest != Z_NULL)
|
||||
dest->state = Z_NULL;
|
||||
return Z_STREAM_ERROR;
|
||||
#else
|
||||
deflate_state *ds;
|
||||
deflate_state *ss;
|
||||
|
||||
|
||||
if (deflateStateCheck(source) || dest == Z_NULL) {
|
||||
if (dest == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (deflateStateCheck(source)) {
|
||||
dest->state = Z_NULL;
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
|
||||
ss = source->state;
|
||||
|
||||
zmemcpy(dest, source, sizeof(z_stream));
|
||||
|
||||
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
|
||||
if (ds == Z_NULL) return Z_MEM_ERROR;
|
||||
zmemzero(ds, sizeof(deflate_state));
|
||||
dest->state = (struct internal_state FAR *) ds;
|
||||
zmemcpy(ds, ss, sizeof(deflate_state));
|
||||
ds->strm = dest;
|
||||
|
||||
ds->window = (Bytef *) ZALLOC(dest,
|
||||
ds->w_size + WINDOW_PADDING,
|
||||
2*sizeof(Byte));
|
||||
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
|
||||
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
|
||||
#ifdef LIT_MEM
|
||||
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 5);
|
||||
#else
|
||||
ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
|
||||
#endif
|
||||
|
||||
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
|
||||
ds->pending_buf == Z_NULL) {
|
||||
deflateEnd (dest);
|
||||
ds = (deflate_state *) ZALLOC(source, 1, sizeof(deflate_state));
|
||||
if (ds == Z_NULL) {
|
||||
dest->state = Z_NULL;
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
/* following zmemcpy do not work for 16-bit MSDOS */
|
||||
zmemcpy(ds, ss, sizeof(deflate_state));
|
||||
ds->window = (Bytef *) ZALLOC(source, ds->w_size + WINDOW_PADDING, 2*sizeof(Byte));
|
||||
ds->prev = (Posf *) ZALLOC(source, ds->w_size, sizeof(Pos));
|
||||
ds->head = (Posf *) ZALLOC(source, ds->hash_size, sizeof(Pos));
|
||||
ds->pending_buf = (uchf *) ZALLOC(source, ds->lit_bufsize, LIT_BUFS);
|
||||
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
|
||||
ds->pending_buf == Z_NULL) {
|
||||
TRY_FREE(source, ds->pending_buf);
|
||||
TRY_FREE(source, ds->head);
|
||||
TRY_FREE(source, ds->prev);
|
||||
TRY_FREE(source, ds->window);
|
||||
ZFREE(source, ds);
|
||||
dest->state = Z_NULL;
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
|
||||
/* copy the stream and attach the new state */
|
||||
zmemcpy(dest, source, sizeof(z_stream));
|
||||
dest->state = (struct internal_state FAR *) ds;
|
||||
ds->strm = dest;
|
||||
|
||||
/* following zmemcpy's do not work for 16-bit MSDOS */
|
||||
zmemcpy(ds->window, ss->window, ss->high_water);
|
||||
zmemcpy(ds->prev, ss->prev,
|
||||
(ss->slid || ss->strstart - ss->insert > ds->w_size ? ds->w_size :
|
||||
@@ -1766,7 +1789,10 @@ local void check_match(deflate_state *s, IPos start, IPos match, int length) {
|
||||
/* Same but force premature exit if necessary. */
|
||||
#define FLUSH_BLOCK(s, last) { \
|
||||
FLUSH_BLOCK_ONLY(s, last); \
|
||||
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
|
||||
if (s->strm->avail_out == 0) { \
|
||||
if (!(last)) return need_more; \
|
||||
if (s->pending != 0 || s->wrap != 0) return finish_started; \
|
||||
} \
|
||||
}
|
||||
|
||||
/* Maximum stored block length in deflate format (not including header). */
|
||||
@@ -1801,7 +1827,7 @@ local block_state deflate_stored(deflate_state *s, int flush) {
|
||||
* possible. If flushing, copy the remaining available input to next_out as
|
||||
* stored blocks, if there is enough space.
|
||||
*/
|
||||
int last = 0;
|
||||
int last = 0, all;
|
||||
unsigned len, left, have;
|
||||
unsigned used = s->strm->avail_in;
|
||||
do {
|
||||
@@ -1816,11 +1842,14 @@ local block_state deflate_stored(deflate_state *s, int flush) {
|
||||
/* maximum stored block length that will fit in avail_out: */
|
||||
have = s->strm->avail_out - have;
|
||||
left = (unsigned)(s->strstart - s->block_start); /* window bytes */
|
||||
if (len > (ulg)left + s->strm->avail_in)
|
||||
if (left < len && s->strm->avail_in < len - left)
|
||||
len = left + s->strm->avail_in; /* limit len to the input */
|
||||
if (len > have)
|
||||
len = have; /* limit len to the output */
|
||||
|
||||
/* all is true if len is all of the available input */
|
||||
all = len >= left && len - left == s->strm->avail_in;
|
||||
|
||||
/* If the stored block would be less than min_block in length, or if
|
||||
* unable to copy all of the available input when flushing, then try
|
||||
* copying to the window and the pending buffer instead. Also don't
|
||||
@@ -1828,13 +1857,13 @@ local block_state deflate_stored(deflate_state *s, int flush) {
|
||||
*/
|
||||
if (len < min_block && ((len == 0 && flush != Z_FINISH) ||
|
||||
flush == Z_NO_FLUSH ||
|
||||
len != left + s->strm->avail_in))
|
||||
!all))
|
||||
break;
|
||||
|
||||
/* Make a dummy stored block in pending to get the header bytes,
|
||||
* including any pending bits. This also updates the debugging counts.
|
||||
*/
|
||||
last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
|
||||
last = flush == Z_FINISH && all ? 1 : 0;
|
||||
_tr_stored_block(s, (char *)0, 0L, last);
|
||||
|
||||
/* Replace the lengths in the dummy stored block with len. */
|
||||
@@ -2178,7 +2207,8 @@ local block_state deflate_slow(deflate_state *s, int flush) {
|
||||
uInt max_insert = s->strstart + s->lookahead - MIN_MATCH;
|
||||
/* Do not insert strings in hash table beyond this. */
|
||||
|
||||
check_match(s, s->strstart - 1, s->prev_match, (int)s->prev_length);
|
||||
check_match(s, s->strstart - 1, s->prev_match,
|
||||
(int)s->prev_length);
|
||||
|
||||
_tr_tally_dist(s, s->strstart - 1 - s->prev_match,
|
||||
s->prev_length - MIN_MATCH, bflush);
|
||||
|
||||
Vendored
+2
@@ -230,9 +230,11 @@ typedef struct internal_state {
|
||||
*/
|
||||
|
||||
#ifdef LIT_MEM
|
||||
# define LIT_BUFS 5
|
||||
ushf *d_buf; /* buffer for distances */
|
||||
uchf *l_buf; /* buffer for literals/lengths */
|
||||
#else
|
||||
# define LIT_BUFS 4
|
||||
uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||
#endif
|
||||
|
||||
|
||||
Vendored
+24
-6
@@ -92,8 +92,10 @@
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
# endif
|
||||
# elif !defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L
|
||||
/* Otherwise if C89/90, assume no C99 snprintf() or vsnprintf() */
|
||||
# elif (!defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L) && \
|
||||
(!defined(__cplusplus) || __cplusplus < 201103L)
|
||||
/* Otherwise if C89/90 (and not C++11 or later), assume no C99 snprintf() or
|
||||
vsnprintf() */
|
||||
# ifndef NO_snprintf
|
||||
# define NO_snprintf
|
||||
# endif
|
||||
@@ -128,17 +130,26 @@
|
||||
# include <windows.h>
|
||||
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
|
||||
#else
|
||||
# include <errno.h>
|
||||
# ifndef NO_STRERROR
|
||||
# include <errno.h>
|
||||
# define zstrerror() strerror(errno)
|
||||
# else
|
||||
# define zstrerror() "stdio error (consult errno)"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* some environments don't define EWOULDBLOCK */
|
||||
#ifndef EWOULDBLOCK
|
||||
# define EWOULDBLOCK EAGAIN
|
||||
#ifdef EAGAIN
|
||||
# ifdef EWOULDBLOCK
|
||||
# define BLOCKED(e) ((e) == EAGAIN || (e) == EWOULDBLOCK)
|
||||
# else
|
||||
# define BLOCKED(e) ((e) == EAGAIN)
|
||||
# endif
|
||||
#else
|
||||
# ifdef EWOULDBLOCK
|
||||
# define BLOCKED(e) ((e) == EWOULDBLOCK)
|
||||
# else
|
||||
# define BLOCKED(e) (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
@@ -219,3 +230,10 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
|
||||
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||
unsigned ZLIB_INTERNAL gz_intmax(void);
|
||||
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||
|
||||
/* largest value representable in z_off64_t */
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
#define GZ_OFF_MAX \
|
||||
((((z_off64_t)1 << (sizeof(z_off64_t) * CHAR_BIT - 2)) - 1) * 2 + 1)
|
||||
Vendored
+37
-37
@@ -71,9 +71,9 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
|
||||
/* Reset gzip file state */
|
||||
local void gz_reset(gz_statep state) {
|
||||
state->x.have = 0; /* no output data available */
|
||||
state->past = 0; /* have not read past end yet */
|
||||
if (state->mode == GZ_READ) { /* for reading ... */
|
||||
state->eof = 0; /* not at end of file */
|
||||
state->past = 0; /* have not read past end yet */
|
||||
state->how = LOOK; /* look for gzip header */
|
||||
state->junk = -1; /* mark first member */
|
||||
}
|
||||
@@ -91,9 +91,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
gz_statep state;
|
||||
z_size_t len;
|
||||
int oflag = 0;
|
||||
#ifdef O_EXCL
|
||||
int exclusive = 0;
|
||||
#endif
|
||||
|
||||
/* check input */
|
||||
if (path == NULL || mode == NULL)
|
||||
@@ -139,11 +137,9 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
oflag |= O_CLOEXEC;
|
||||
break;
|
||||
#endif
|
||||
#ifdef O_EXCL
|
||||
case 'x':
|
||||
exclusive = 1;
|
||||
break;
|
||||
#endif
|
||||
case 'f':
|
||||
state->strategy = Z_FILTERED;
|
||||
break;
|
||||
@@ -199,10 +195,21 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
/* if reading, direct == 1 for auto-detect, -1 for gzip only; if writing or
|
||||
appending, direct == 0 for gzip, 1 for transparent (copy in to out) */
|
||||
|
||||
#ifndef O_EXCL
|
||||
if (exclusive && state->mode != GZ_READ && fd < 0) {
|
||||
/* exclusive creation request can't be honored -- fail out */
|
||||
free(state);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* save the path name for error messages */
|
||||
#ifdef WIDECHAR
|
||||
if (fd == -2)
|
||||
if (fd == -2) {
|
||||
len = wcstombs(NULL, path, 0);
|
||||
if (len == (z_size_t)-1)
|
||||
len = 0; /* not representable in the current locale */
|
||||
}
|
||||
else
|
||||
#endif
|
||||
len = strlen((const char *)path);
|
||||
@@ -213,9 +220,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
}
|
||||
#ifdef WIDECHAR
|
||||
if (fd == -2) {
|
||||
if (len)
|
||||
wcstombs(state->path, path, len + 1);
|
||||
else
|
||||
if (len == 0 || wcstombs(state->path, path, len + 1) != len)
|
||||
*(state->path) = 0;
|
||||
}
|
||||
else
|
||||
@@ -224,7 +229,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||
(void)snprintf(state->path, len + 1, "%s", (const char *)path);
|
||||
#else
|
||||
strcpy(state->path, path);
|
||||
strcpy(state->path, (const char *)path);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -258,9 +263,9 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
if (oflag & O_NONBLOCK)
|
||||
fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
|
||||
#endif
|
||||
#ifdef O_CLOEXEC
|
||||
#if defined(O_CLOEXEC) && defined(FD_CLOEXEC)
|
||||
if (oflag & O_CLOEXEC)
|
||||
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | O_CLOEXEC);
|
||||
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
|
||||
#endif
|
||||
state->fd = fd;
|
||||
}
|
||||
@@ -302,7 +307,7 @@ gzFile ZEXPORT gzdopen(int fd, const char *mode) {
|
||||
char *path; /* identifier for error messages */
|
||||
gzFile gz;
|
||||
|
||||
if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
|
||||
if (fd < 0 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
|
||||
return NULL;
|
||||
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||
(void)snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd);
|
||||
@@ -369,7 +374,7 @@ int ZEXPORT gzrewind(gzFile file) {
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
|
||||
unsigned n;
|
||||
z_off64_t ret;
|
||||
z_off64_t ret, pos;
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
@@ -387,18 +392,19 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
|
||||
if (whence != SEEK_SET && whence != SEEK_CUR)
|
||||
return -1;
|
||||
|
||||
/* normalize offset to a SEEK_CUR specification */
|
||||
if (whence == SEEK_SET)
|
||||
offset -= state->x.pos;
|
||||
else {
|
||||
offset += state->past ? 0 : state->skip;
|
||||
state->skip = 0;
|
||||
}
|
||||
/* compute the absolute position */
|
||||
pos = whence == SEEK_SET ? 0 :
|
||||
state->x.pos + (state->past ? 0 : state->skip);
|
||||
if (offset > GZ_OFF_MAX - pos)
|
||||
return -1; /* would overflow z_off64_t */
|
||||
if (offset < -pos)
|
||||
return -1; /* before start of file */
|
||||
pos += offset;
|
||||
|
||||
/* if within raw area while reading, just go there */
|
||||
if (state->mode == GZ_READ && state->how == COPY &&
|
||||
state->x.pos + offset >= 0) {
|
||||
ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
|
||||
if (state->mode == GZ_READ && state->how == COPY) {
|
||||
ret = LSEEK(state->fd, pos - state->x.pos - (z_off64_t)state->x.have,
|
||||
SEEK_CUR);
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
state->x.have = 0;
|
||||
@@ -407,20 +413,18 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
|
||||
state->skip = 0;
|
||||
gz_error(state, Z_OK, NULL);
|
||||
state->strm.avail_in = 0;
|
||||
state->x.pos += offset;
|
||||
return state->x.pos;
|
||||
state->x.pos = pos;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/* calculate skip amount, rewinding if needed for back seek when reading */
|
||||
if (offset < 0) {
|
||||
/* rewind if needed for back seek when reading */
|
||||
if (pos < state->x.pos) {
|
||||
if (state->mode != GZ_READ) /* writing -- can't go backwards */
|
||||
return -1;
|
||||
offset += state->x.pos;
|
||||
if (offset < 0) /* before start of file! */
|
||||
return -1;
|
||||
if (gzrewind(file) == -1) /* rewind, then skip to offset */
|
||||
if (gzrewind(file) == -1) /* rewind, then skip to pos */
|
||||
return -1;
|
||||
}
|
||||
offset = pos - state->x.pos;
|
||||
|
||||
/* if reading, skip what's in output buffer (one less gzgetc() check) */
|
||||
if (state->mode == GZ_READ) {
|
||||
@@ -434,7 +438,7 @@ z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
|
||||
|
||||
/* request skip (if not zero) */
|
||||
state->skip = offset;
|
||||
return state->x.pos + offset;
|
||||
return pos;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
@@ -563,10 +567,6 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
|
||||
state->msg = NULL;
|
||||
}
|
||||
|
||||
/* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */
|
||||
if (err != Z_OK && err != Z_BUF_ERROR && !state->again)
|
||||
state->x.have = 0;
|
||||
|
||||
/* set error code, and if no message, then done */
|
||||
state->err = err;
|
||||
if (msg == NULL)
|
||||
|
||||
Vendored
+100
-41
@@ -33,7 +33,7 @@ local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
|
||||
*have += (unsigned)ret;
|
||||
} while (*have < len);
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
if (BLOCKED(errno)) {
|
||||
state->again = 1;
|
||||
if (*have != 0)
|
||||
return 0;
|
||||
@@ -125,6 +125,13 @@ local int gz_look(gz_statep state) {
|
||||
if we're looking for a gzip member after the first one, which is not at
|
||||
the start, then proceed directly to look for a gzip member next */
|
||||
if (state->direct == -1 || state->junk == 0) {
|
||||
/* wait for input before committing to another gzip member */
|
||||
if (state->junk == 0 && strm->avail_in == 0) {
|
||||
if (gz_avail(state) == -1)
|
||||
return -1;
|
||||
if (strm->avail_in == 0)
|
||||
return 0;
|
||||
}
|
||||
inflateReset(strm);
|
||||
state->how = GZIP;
|
||||
state->junk = state->junk != -1;
|
||||
@@ -153,7 +160,7 @@ local int gz_look(gz_statep state) {
|
||||
strm->next_in[2] == 8 && strm->next_in[3] < 32) {
|
||||
inflateReset(strm);
|
||||
state->how = GZIP;
|
||||
state->junk = 1;
|
||||
state->junk = 0;
|
||||
state->direct = 0;
|
||||
return 0;
|
||||
}
|
||||
@@ -248,6 +255,11 @@ local int gz_decomp(gz_statep state) {
|
||||
local int gz_fetch(gz_statep state) {
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
/* after a serious error, only what is already in the output buffer is
|
||||
delivered -- don't try to decompress any more */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
|
||||
return -1;
|
||||
|
||||
do {
|
||||
switch(state->how) {
|
||||
case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */
|
||||
@@ -276,32 +288,46 @@ local int gz_fetch(gz_statep state) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Apply as much of a pending skip request as the output already available in
|
||||
state->x allows. */
|
||||
local void gz_skip_have(gz_statep state) {
|
||||
unsigned n;
|
||||
|
||||
n = GT_OFF(state->x.have) ||
|
||||
(z_off64_t)state->x.have > state->skip ?
|
||||
(unsigned)state->skip : state->x.have;
|
||||
state->x.have -= n;
|
||||
state->x.next += n;
|
||||
state->x.pos += n;
|
||||
state->skip -= n;
|
||||
}
|
||||
|
||||
/* Skip state->skip (> 0) uncompressed bytes of output. Return -1 on error, 0
|
||||
on success. */
|
||||
local int gz_skip(gz_statep state) {
|
||||
unsigned n;
|
||||
|
||||
/* skip over len bytes or reach end-of-file, whichever comes first */
|
||||
do {
|
||||
/* skip over whatever is in output buffer */
|
||||
if (state->x.have) {
|
||||
n = GT_OFF(state->x.have) ||
|
||||
(z_off64_t)state->x.have > state->skip ?
|
||||
(unsigned)state->skip : state->x.have;
|
||||
state->x.have -= n;
|
||||
state->x.next += n;
|
||||
state->x.pos += n;
|
||||
state->skip -= n;
|
||||
}
|
||||
if (state->x.have)
|
||||
gz_skip_have(state);
|
||||
|
||||
/* output buffer empty -- return if we're at the end of the input */
|
||||
else if (state->eof && state->strm.avail_in == 0)
|
||||
else if (state->eof && state->strm.avail_in == 0) {
|
||||
if (state->how == GZIP && state->err == Z_OK)
|
||||
gz_error(state, Z_BUF_ERROR, "unexpected end of file");
|
||||
state->skip = 0;
|
||||
state->past = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* need more data to skip -- load up output buffer */
|
||||
else {
|
||||
/* get more output, looking for header if required */
|
||||
if (gz_fetch(state) == -1)
|
||||
/* get more output, looking for header if required. If the fetch
|
||||
stalled but provided some output, consume it before returning
|
||||
so that x.have > 0 always implies the data is at the current
|
||||
logical position (x.pos), as assumed by the gzgetc() fast path
|
||||
in zlib.h and gzread.c */
|
||||
if (gz_fetch(state) == -1 && state->x.have == 0)
|
||||
return -1;
|
||||
}
|
||||
} while (state->skip);
|
||||
@@ -349,8 +375,11 @@ local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
|
||||
}
|
||||
|
||||
/* output buffer empty -- return if we're at the end of the input */
|
||||
else if (state->eof && state->strm.avail_in == 0)
|
||||
else if (state->eof && state->strm.avail_in == 0) {
|
||||
if (state->how == GZIP && state->err == Z_OK)
|
||||
gz_error(state, Z_BUF_ERROR, "unexpected end of file");
|
||||
break;
|
||||
}
|
||||
|
||||
/* need output data -- for small len or new stream load up our output
|
||||
buffer, so that gzgetc() can be fast */
|
||||
@@ -403,15 +432,21 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
|
||||
if (state->mode != GZ_READ)
|
||||
return -1;
|
||||
|
||||
/* check that there was no (serious) error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
|
||||
/* check that there was no (serious) error -- if there was, deliver any
|
||||
data read before the error until it is exhausted, and only then return
|
||||
the error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
|
||||
state->x.have == 0)
|
||||
return -1;
|
||||
gz_error(state, Z_OK, NULL);
|
||||
if (state->again)
|
||||
gz_error(state, Z_OK, NULL);
|
||||
|
||||
/* since an int is returned, make sure len fits in one, otherwise return
|
||||
with an error (this avoids a flaw in the interface) */
|
||||
with an error (this avoids a flaw in the interface) -- keep a pending
|
||||
serious error, which is the one the caller needs to see */
|
||||
if ((int)len < 0) {
|
||||
gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
|
||||
if (state->err == Z_OK || state->err == Z_BUF_ERROR)
|
||||
gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -448,15 +483,22 @@ z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
|
||||
if (state->mode != GZ_READ)
|
||||
return 0;
|
||||
|
||||
/* check that there was no (serious) error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
|
||||
/* check that there was no (serious) error -- if there was, deliver any
|
||||
data read before the error until it is exhausted, and only then return
|
||||
the error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
|
||||
state->x.have == 0)
|
||||
return 0;
|
||||
gz_error(state, Z_OK, NULL);
|
||||
if (state->again)
|
||||
gz_error(state, Z_OK, NULL);
|
||||
|
||||
/* compute bytes to read -- error on overflow */
|
||||
/* compute bytes to read -- error on overflow, keeping a pending serious
|
||||
error, which is the one the caller needs to see */
|
||||
len = nitems * size;
|
||||
if (size && len / size != nitems) {
|
||||
gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
|
||||
if (state->err == Z_OK || state->err == Z_BUF_ERROR)
|
||||
gz_error(state, Z_STREAM_ERROR,
|
||||
"request does not fit in a size_t");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -485,10 +527,14 @@ int ZEXPORT gzgetc(gzFile file) {
|
||||
if (state->mode != GZ_READ)
|
||||
return -1;
|
||||
|
||||
/* check that there was no (serious) error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
|
||||
/* check that there was no (serious) error -- if there was, deliver any
|
||||
data read before the error until it is exhausted, and only then return
|
||||
the error, as the gzgetc() macro does */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
|
||||
state->x.have == 0)
|
||||
return -1;
|
||||
gz_error(state, Z_OK, NULL);
|
||||
if (state->again)
|
||||
gz_error(state, Z_OK, NULL);
|
||||
|
||||
/* try output buffer (no need to check for skip request) */
|
||||
if (state->x.have) {
|
||||
@@ -520,10 +566,15 @@ int ZEXPORT gzungetc(int c, gzFile file) {
|
||||
if (state->how == LOOK && state->x.have == 0)
|
||||
(void)gz_look(state);
|
||||
|
||||
/* check that there was no (serious) error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
|
||||
/* check that there was no (serious) error -- a character can still be
|
||||
pushed back after one, since it is data that was read before the
|
||||
error, and it will be returned before the error is signaled -- but only
|
||||
if there is an output buffer to put it in */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
|
||||
state->size == 0)
|
||||
return -1;
|
||||
gz_error(state, Z_OK, NULL);
|
||||
if (state->again)
|
||||
gz_error(state, Z_OK, NULL);
|
||||
|
||||
/* process a skip request */
|
||||
if (state->skip && gz_skip(state) == -1)
|
||||
@@ -545,7 +596,8 @@ int ZEXPORT gzungetc(int c, gzFile file) {
|
||||
|
||||
/* if no room, give up (must have already done a gzungetc()) */
|
||||
if (state->x.have == (state->size << 1)) {
|
||||
gz_error(state, Z_DATA_ERROR, "out of room to push characters");
|
||||
if (state->err == Z_OK || state->err == Z_BUF_ERROR)
|
||||
gz_error(state, Z_DATA_ERROR, "out of room to push characters");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -581,10 +633,14 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
|
||||
if (state->mode != GZ_READ)
|
||||
return NULL;
|
||||
|
||||
/* check that there was no (serious) error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again)
|
||||
/* check that there was no (serious) error -- if there was, deliver any
|
||||
data read before the error until it is exhausted, and only then return
|
||||
the error */
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR && !state->again &&
|
||||
state->x.have == 0)
|
||||
return NULL;
|
||||
gz_error(state, Z_OK, NULL);
|
||||
if (state->again)
|
||||
gz_error(state, Z_OK, NULL);
|
||||
|
||||
/* process a skip request */
|
||||
if (state->skip && gz_skip(state) == -1)
|
||||
@@ -596,8 +652,9 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
|
||||
left = (unsigned)len - 1;
|
||||
if (left) do {
|
||||
/* assure that something is in the output buffer */
|
||||
if (state->x.have == 0 && gz_fetch(state) == -1)
|
||||
break; /* error */
|
||||
if (state->x.have == 0 && gz_fetch(state) == -1 &&
|
||||
state->x.have == 0)
|
||||
break; /* error, and nothing left to return */
|
||||
if (state->x.have == 0) { /* end of file */
|
||||
state->past = 1; /* read past end */
|
||||
break; /* return what we have */
|
||||
@@ -621,7 +678,7 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
|
||||
/* append a terminating zero to the string (we don't check for a zero in
|
||||
the contents, let the user worry about that) -- return the terminated
|
||||
string, or if nothing was read, NULL */
|
||||
if (buf == str)
|
||||
if (buf == str && len > 1)
|
||||
return NULL;
|
||||
buf[0] = 0;
|
||||
return str;
|
||||
@@ -638,8 +695,10 @@ int ZEXPORT gzdirect(gzFile file) {
|
||||
|
||||
/* if the state is not known, but we can find out, then do so (this is
|
||||
mainly for right after a gzopen() or gzdopen()) */
|
||||
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
|
||||
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) {
|
||||
(void)gz_look(state);
|
||||
gz_skip_have(state); /* apply skip to current buffer */
|
||||
}
|
||||
|
||||
/* return 1 if transparent, 0 if processing a gzip stream */
|
||||
return state->direct == 1;
|
||||
|
||||
Vendored
+44
-9
@@ -41,8 +41,8 @@ local int gz_init(gz_statep state) {
|
||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
strm->next_in = NULL;
|
||||
}
|
||||
strm->next_in = NULL;
|
||||
|
||||
/* mark state as initialized */
|
||||
state->size = state->want;
|
||||
@@ -79,7 +79,7 @@ local int gz_comp(gz_statep state, int flush) {
|
||||
put = strm->avail_in > max ? max : strm->avail_in;
|
||||
writ = (int)write(state->fd, strm->next_in, put);
|
||||
if (writ < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
if (BLOCKED(errno))
|
||||
state->again = 1;
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
@@ -114,7 +114,7 @@ local int gz_comp(gz_statep state, int flush) {
|
||||
(unsigned)(strm->next_out - state->x.next);
|
||||
writ = (int)write(state->fd, state->x.next, put);
|
||||
if (writ < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
if (BLOCKED(errno))
|
||||
state->again = 1;
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
@@ -156,6 +156,11 @@ local int gz_zero(gz_statep state) {
|
||||
unsigned n;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
/* allocate memory if this is the first time through -- the input buffer
|
||||
must exist before it is zeroed below */
|
||||
if (state->size == 0 && gz_init(state) == -1)
|
||||
return -1;
|
||||
|
||||
/* consume whatever's left in the input buffer */
|
||||
if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
return -1;
|
||||
@@ -175,8 +180,14 @@ local int gz_zero(gz_statep state) {
|
||||
n -= strm->avail_in;
|
||||
state->x.pos += n;
|
||||
state->skip -= n;
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
/* discard any unconsumed zero fill -- it was not yet accounted
|
||||
for in state->skip, so it will be generated again when the
|
||||
operation is retried */
|
||||
strm->avail_in = 0;
|
||||
strm->next_in = state->in;
|
||||
return -1;
|
||||
}
|
||||
} while (state->skip);
|
||||
return 0;
|
||||
}
|
||||
@@ -242,9 +253,13 @@ local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
|
||||
n -= state->strm.avail_in;
|
||||
state->x.pos += n;
|
||||
len -= n;
|
||||
if (ret == -1)
|
||||
if (ret == -1) {
|
||||
state->strm.avail_in = 0;
|
||||
state->strm.next_in = state->in;
|
||||
return state->again ? put - len : 0;
|
||||
}
|
||||
} while (len);
|
||||
state->strm.next_in = state->in;
|
||||
}
|
||||
|
||||
/* input was all buffered or compressed */
|
||||
@@ -371,9 +386,10 @@ int ZEXPORT gzputs(gzFile file, const char *s) {
|
||||
return len && put == 0 ? -1 : (int)put;
|
||||
}
|
||||
|
||||
#if (((!defined(STDC) && !defined(Z_HAVE_STDARG_H)) || !defined(NO_vsnprintf)) && \
|
||||
(defined(STDC) || defined(Z_HAVE_STDARG_H) || !defined(NO_snprintf))) || \
|
||||
defined(ZLIB_INSECURE)
|
||||
#if (((!defined(STDC) && !defined(Z_HAVE_STDARG_H)) || \
|
||||
!defined(NO_vsnprintf)) && \
|
||||
(defined(STDC) || defined(Z_HAVE_STDARG_H) || \
|
||||
!defined(NO_snprintf))) || defined(ZLIB_INSECURE)
|
||||
/* If the second half of the input buffer is occupied, write out the contents.
|
||||
If there is any input remaining due to a non-blocking stall on write, move
|
||||
it to the start of the buffer. Return true if this did not open up the
|
||||
@@ -383,7 +399,8 @@ local int gz_vacate(gz_statep state) {
|
||||
z_streamp strm;
|
||||
|
||||
strm = &(state->strm);
|
||||
if (strm->next_in + strm->avail_in <= state->in + state->size)
|
||||
if (strm->next_in == NULL ||
|
||||
strm->next_in + strm->avail_in <= state->in + state->size)
|
||||
return 0;
|
||||
(void)gz_comp(state, Z_NO_FLUSH);
|
||||
if (strm->avail_in == 0) {
|
||||
@@ -443,6 +460,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
|
||||
a Z_BUF_ERROR to let the application know that this gzprintf()
|
||||
needs to be retried. */
|
||||
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
|
||||
return state->err;
|
||||
}
|
||||
if (!state->again)
|
||||
return state->err;
|
||||
@@ -478,6 +496,14 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
|
||||
|
||||
/* write out buffer if more than half is occupied */
|
||||
ret = gz_vacate(state);
|
||||
if (ret) {
|
||||
/* discard unwritten formatted output */
|
||||
strm->avail_in -= (unsigned)len;
|
||||
state->x.pos -= len;
|
||||
if (state->again)
|
||||
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
|
||||
return state->err;
|
||||
}
|
||||
if (state->err && !state->again)
|
||||
return state->err;
|
||||
return len;
|
||||
@@ -551,6 +577,7 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
|
||||
a Z_BUF_ERROR to let the application know that this gzprintf()
|
||||
needs to be retried. */
|
||||
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
|
||||
return state->err;
|
||||
}
|
||||
if (!state->again)
|
||||
return state->err;
|
||||
@@ -591,6 +618,14 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
|
||||
|
||||
/* write out buffer if more than half is occupied */
|
||||
ret = gz_vacate(state);
|
||||
if (ret) {
|
||||
/* discard unwritten formatted output */
|
||||
strm->avail_in -= (unsigned)len;
|
||||
state->x.pos -= len;
|
||||
if (state->again)
|
||||
gz_error(state, Z_BUF_ERROR, "stalled write on gzprintf");
|
||||
return state->err;
|
||||
}
|
||||
if (state->err && !state->again)
|
||||
return state->err;
|
||||
return (int)len;
|
||||
|
||||
Vendored
+44
-13
@@ -127,6 +127,14 @@ int ZEXPORT inflateReset(z_streamp strm) {
|
||||
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
if (state->wbits != state->reqbits) {
|
||||
if (state->window != Z_NULL) {
|
||||
ZFREE(strm, state->window);
|
||||
state->window = Z_NULL;
|
||||
}
|
||||
state->wbits = state->reqbits;
|
||||
}
|
||||
state->wrap = state->reqwrap;
|
||||
state->wsize = 0;
|
||||
state->whave = 0;
|
||||
state->wnext = 0;
|
||||
@@ -165,8 +173,8 @@ int ZEXPORT inflateReset2(z_streamp strm, int windowBits) {
|
||||
}
|
||||
|
||||
/* update state and reset the rest of it */
|
||||
state->wrap = wrap;
|
||||
state->wbits = (unsigned)windowBits;
|
||||
state->reqwrap = state->wrap = wrap;
|
||||
state->reqbits = state->wbits = (unsigned)windowBits;
|
||||
return inflateReset(strm);
|
||||
}
|
||||
|
||||
@@ -538,13 +546,13 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||
}
|
||||
DROPBITS(4);
|
||||
len = BITS(4) + 8;
|
||||
if (state->wbits == 0)
|
||||
state->wbits = len;
|
||||
if (len > 15 || len > state->wbits) {
|
||||
if (len > 15 || (state->wbits != 0 && len > state->wbits)) {
|
||||
strm->msg = (z_const char *)"invalid window size";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
if (state->wbits == 0)
|
||||
state->wbits = len;
|
||||
state->dmax = 1U << len;
|
||||
state->flags = 0; /* indicate zlib header */
|
||||
Tracev((stderr, "inflate: zlib header ok\n"));
|
||||
@@ -701,6 +709,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||
case DICT:
|
||||
if (state->havedict == 0) {
|
||||
RESTORE();
|
||||
strm->total_in += in - strm->avail_in;
|
||||
return Z_NEED_DICT;
|
||||
}
|
||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||
@@ -914,7 +923,8 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
|
||||
/* fallthrough */
|
||||
case LEN:
|
||||
if (have >= INFLATE_FAST_MIN_INPUT &&
|
||||
left >= INFLATE_FAST_MIN_OUTPUT) {
|
||||
left >= INFLATE_FAST_MIN_OUTPUT &&
|
||||
bits < 8) {
|
||||
RESTORE();
|
||||
inflate_fast(strm, out);
|
||||
LOAD();
|
||||
@@ -1193,7 +1203,8 @@ int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary,
|
||||
int ret;
|
||||
|
||||
/* check state */
|
||||
if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
|
||||
if (inflateStateCheck(strm) || dictionary == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
if (state->wrap != 0 && state->mode != DICT)
|
||||
return Z_STREAM_ERROR;
|
||||
@@ -1298,15 +1309,23 @@ int ZEXPORT inflateSync(z_streamp strm) {
|
||||
|
||||
/* return no joy or set up to restart inflate() on a new block */
|
||||
if (state->have != 4) return Z_DATA_ERROR;
|
||||
if (state->flags == -1)
|
||||
state->wrap = 0; /* if no header yet, treat as raw */
|
||||
else
|
||||
state->wrap &= ~4; /* no point in computing a check value now */
|
||||
flags = state->flags;
|
||||
in = strm->total_in; out = strm->total_out;
|
||||
inflateReset(strm);
|
||||
strm->total_in = in; strm->total_out = out;
|
||||
state->flags = flags;
|
||||
if (flags == -1)
|
||||
state->wrap = 0; /* if no header yet, treat as raw */
|
||||
else
|
||||
state->wrap &= ~4; /* no point in computing a check value now */
|
||||
if (state->wbits == 0) {
|
||||
/* we never got to see a header for the window size -- set to max */
|
||||
if (state->window != Z_NULL) {
|
||||
ZFREE(strm, state->window);
|
||||
state->window = Z_NULL;
|
||||
}
|
||||
state->wbits = 15;
|
||||
}
|
||||
state->mode = TYPE;
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -1333,14 +1352,21 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
|
||||
unsigned char FAR *window;
|
||||
|
||||
/* check input */
|
||||
if (inflateStateCheck(source) || dest == Z_NULL)
|
||||
if (dest == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
if (inflateStateCheck(source)) {
|
||||
dest->state = Z_NULL;
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
state = (struct inflate_state FAR *)source->state;
|
||||
|
||||
/* allocate space */
|
||||
copy = (struct inflate_state FAR *)
|
||||
ZALLOC(source, 1, sizeof(struct inflate_state));
|
||||
if (copy == Z_NULL) return Z_MEM_ERROR;
|
||||
if (copy == Z_NULL) {
|
||||
dest->state = Z_NULL;
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
zmemzero(copy, sizeof(struct inflate_state));
|
||||
window = Z_NULL;
|
||||
if (state->window != Z_NULL) {
|
||||
@@ -1348,6 +1374,7 @@ int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) {
|
||||
ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
|
||||
if (window == Z_NULL) {
|
||||
ZFREE(source, copy);
|
||||
dest->state = Z_NULL;
|
||||
return Z_MEM_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -1393,6 +1420,10 @@ int ZEXPORT inflateValidate(z_streamp strm, int check) {
|
||||
state->wrap |= 4;
|
||||
else
|
||||
state->wrap &= ~4;
|
||||
if (check && state->reqwrap)
|
||||
state->reqwrap |= 4;
|
||||
else
|
||||
state->reqwrap &= ~4;
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+3
-1
@@ -85,6 +85,7 @@ struct inflate_state {
|
||||
int last; /* true if processing last block */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
||||
bit 2 true to validate check value */
|
||||
int reqwrap; /* requested wrap */
|
||||
int havedict; /* true if dictionary provided */
|
||||
int flags; /* gzip header method and flags, 0 if zlib, or
|
||||
-1 if raw or no header yet */
|
||||
@@ -93,7 +94,8 @@ struct inflate_state {
|
||||
unsigned long total; /* protected copy of output count */
|
||||
gz_headerp head; /* where to save gzip header information */
|
||||
/* sliding window */
|
||||
unsigned wbits; /* log base 2 of requested window size */
|
||||
unsigned reqbits; /* requested log base 2 of window size */
|
||||
unsigned wbits; /* current log base 2 of window size */
|
||||
unsigned wsize; /* window size or zero if not using window */
|
||||
unsigned whave; /* valid bytes in the window */
|
||||
unsigned wnext; /* window write index */
|
||||
|
||||
Vendored
+2
-2
@@ -23,7 +23,7 @@
|
||||
#define MAXBITS 15
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.3.2.1 Copyright 1995-2026 Mark Adler ";
|
||||
" inflate 1.4 Copyright 1995-2026 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
@@ -71,7 +71,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 68, 193};
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 71, 77};
|
||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
|
||||
Vendored
+8
-2
@@ -46,8 +46,14 @@ typedef struct {
|
||||
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
||||
changed, then these maximum sizes would be need to be recalculated and
|
||||
updated. */
|
||||
#define ENOUGH_LENS 1332
|
||||
#define ENOUGH_DISTS 592
|
||||
#ifndef PKZIP_BUG_WORKAROUND
|
||||
# define ENOUGH_LENS 1332
|
||||
# define ENOUGH_DISTS 592
|
||||
#else
|
||||
/* That workaround permits 288 literal/length codes and 32 distance codes. */
|
||||
# define ENOUGH_LENS 1334
|
||||
# define ENOUGH_DISTS 594
|
||||
#endif
|
||||
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
|
||||
|
||||
/* Type of code to build for inflate_table() */
|
||||
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
|
||||
index 782d32469ae5d..a38881dca90a2 100644
|
||||
--- a/contrib/minizip/ioapi.c
|
||||
+++ b/contrib/minizip/ioapi.c
|
||||
@@ -14,7 +14,7 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
-#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || (defined(__ANDROID_API__) && __ANDROID_API__ < 24)
|
||||
+#if defined(__APPLE__) || defined(__Fuchsia__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || (defined(__ANDROID_API__) && __ANDROID_API__ < 24)
|
||||
/* In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions */
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c
|
||||
index 08536e94b8a28..bbd7773e67146 100644
|
||||
--- a/contrib/minizip/iowin32.c
|
||||
+++ b/contrib/minizip/iowin32.c
|
||||
@@ -24,7 +24,12 @@
|
||||
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
+#ifdef _WIN32_WINNT
|
||||
+#undef _WIN32_WINNT
|
||||
+#define _WIN32_WINNT 0x601
|
||||
+#endif
|
||||
|
||||
+#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
|
||||
/* see Include/shared/winapifamily.h in the Windows Kit */
|
||||
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
|
||||
|
||||
@@ -37,6 +42,7 @@
|
||||
#define IOWIN32_USING_WINRT_API 1
|
||||
#endif
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
Vendored
-38
@@ -1,41 +1,3 @@
|
||||
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c
|
||||
index 782d32469ae5d..a38881dca90a2 100644
|
||||
--- a/contrib/minizip/ioapi.c
|
||||
+++ b/contrib/minizip/ioapi.c
|
||||
@@ -14,7 +14,7 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
-#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || (defined(__ANDROID_API__) && __ANDROID_API__ < 24)
|
||||
+#if defined(__APPLE__) || defined(__Fuchsia__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || (defined(__ANDROID_API__) && __ANDROID_API__ < 24)
|
||||
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
|
||||
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
|
||||
#define FTELLO_FUNC(stream) ftello(stream)
|
||||
diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c
|
||||
index 08536e94b8a28..bbd7773e67146 100644
|
||||
--- a/contrib/minizip/iowin32.c
|
||||
+++ b/contrib/minizip/iowin32.c
|
||||
@@ -24,7 +24,12 @@
|
||||
#define INVALID_SET_FILE_POINTER ((DWORD)-1)
|
||||
#endif
|
||||
|
||||
+#ifdef _WIN32_WINNT
|
||||
+#undef _WIN32_WINNT
|
||||
+#define _WIN32_WINNT 0x601
|
||||
+#endif
|
||||
|
||||
+#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
|
||||
/* see Include/shared/winapifamily.h in the Windows Kit */
|
||||
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
|
||||
|
||||
@@ -37,6 +42,7 @@
|
||||
#define IOWIN32_USING_WINRT_API 1
|
||||
#endif
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
diff --git a/gzread.c b/gzread.c
|
||||
index 956b91ea7d9e..832d3ef98c59 100644
|
||||
--- a/gzread.c
|
||||
|
||||
@@ -18,7 +18,7 @@ diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib
|
||||
index 82275d6c1775d..c8a01b23efd42 100644
|
||||
--- a/third_party/zlib/contrib/minizip/unzip.c
|
||||
+++ b/third_party/zlib/contrib/minizip/unzip.c
|
||||
@@ -1502,6 +1498,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
|
||||
@@ -1499,6 +1501,7 @@ extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method,
|
||||
zdecode(s->keys,s->pcrc_32_tab,source[i]);
|
||||
|
||||
s->pfile_in_zip_read->pos_in_zipfile+=12;
|
||||
@@ -45,7 +45,7 @@ diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib
|
||||
index 0264f7ac570f7..4eb0de302cfdf 100644
|
||||
--- a/third_party/zlib/contrib/minizip/unzip.c
|
||||
+++ b/third_party/zlib/contrib/minizip/unzip.c
|
||||
@@ -1439,6 +1439,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar
|
||||
@@ -1284,6 +1284,8 @@ local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar
|
||||
*/
|
||||
if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
|
||||
err=UNZ_ERRNO;
|
||||
|
||||
@@ -91,7 +91,7 @@ Date: Mon Apr 27 13:24:27 2026 +0200
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7797172
|
||||
|
||||
diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
|
||||
index 56f1468cd8d22..0264f7ac570f7 100644
|
||||
index fb5eb0bf0f852..c15f4484f75f7 100644
|
||||
--- a/third_party/zlib/contrib/minizip/unzip.c
|
||||
+++ b/third_party/zlib/contrib/minizip/unzip.c
|
||||
@@ -63,6 +63,7 @@
|
||||
@@ -129,7 +129,7 @@ index 56f1468cd8d22..0264f7ac570f7 100644
|
||||
local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def,
|
||||
voidpf filestream,
|
||||
uLong *pX) {
|
||||
@@ -836,6 +857,10 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
@@ -780,6 +801,10 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
uLong uMagic;
|
||||
long lSeek=0;
|
||||
uLong uL;
|
||||
@@ -140,7 +140,7 @@ index 56f1468cd8d22..0264f7ac570f7 100644
|
||||
|
||||
if (file==NULL)
|
||||
return UNZ_PARAMERROR;
|
||||
@@ -907,21 +932,34 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
@@ -851,21 +876,34 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
file_info_internal.offset_curfile = uL;
|
||||
|
||||
lSeek+=file_info.size_filename;
|
||||
@@ -186,7 +186,7 @@ index 56f1468cd8d22..0264f7ac570f7 100644
|
||||
}
|
||||
|
||||
/* Read extrafield */
|
||||
@@ -1007,6 +1045,62 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
@@ -951,6 +989,62 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
|
||||
}
|
||||
|
||||
}
|
||||
@@ -249,7 +249,7 @@ index 56f1468cd8d22..0264f7ac570f7 100644
|
||||
else
|
||||
{
|
||||
if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0)
|
||||
@@ -1106,6 +1200,9 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
|
||||
@@ -1050,6 +1144,9 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
|
||||
pfile_info->compressed_size = (uLong)file_info64.compressed_size;
|
||||
pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size;
|
||||
|
||||
|
||||
+2
-2
@@ -30,10 +30,10 @@ Date: Fri May 16 15:35:36 2025 +0200
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6554217
|
||||
|
||||
diff --git a/third_party/zlib/contrib/minizip/unzip.c b/third_party/zlib/contrib/minizip/unzip.c
|
||||
index a39e1752f6d2e..2c8a73e87e011 100644
|
||||
index c15f4484f75f7..2ec74e0ff2af8 100644
|
||||
--- a/third_party/zlib/contrib/minizip/unzip.c
|
||||
+++ b/third_party/zlib/contrib/minizip/unzip.c
|
||||
@@ -482,6 +482,44 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||
@@ -485,6 +485,46 @@ local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
|
||||
if (uL != 1)
|
||||
return CENTRALDIRINVALID;
|
||||
|
||||
|
||||
Vendored
+6
-3
@@ -37,6 +37,9 @@
|
||||
#ifdef USE_MMAP
|
||||
# include <sys/types.h>
|
||||
# include <sys/mman.h>
|
||||
# ifndef MAP_FAILED
|
||||
# define MAP_FAILED ((void *)-1)
|
||||
# endif
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
@@ -337,7 +340,7 @@ static int gz_compress_mmap(FILE *in, gzFile out) {
|
||||
int len;
|
||||
int err;
|
||||
int ifd = fileno(in);
|
||||
caddr_t buf; /* mmap'ed buffer for the entire input file */
|
||||
void *buf; /* mmap'ed buffer for the entire input file */
|
||||
off_t buf_len; /* length of the input file */
|
||||
struct stat sb;
|
||||
|
||||
@@ -347,8 +350,8 @@ static int gz_compress_mmap(FILE *in, gzFile out) {
|
||||
if (buf_len <= 0) return Z_ERRNO;
|
||||
|
||||
/* Now do the actual mmap: */
|
||||
buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
|
||||
if (buf == (caddr_t)(-1)) return Z_ERRNO;
|
||||
buf = mmap(NULL, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0);
|
||||
if (buf == MAP_FAILED) return Z_ERRNO;
|
||||
|
||||
/* Compress the whole file at once: */
|
||||
len = gzwrite(out, (char *)buf, (unsigned)buf_len);
|
||||
|
||||
Vendored
+1
-1
@@ -250,7 +250,7 @@ local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) {
|
||||
tree[n].Code = (ush)bi_reverse(next_code[len]++, len);
|
||||
|
||||
Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ",
|
||||
n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
|
||||
n, (isgraph(n & 0xff) ? n : ' '), len, tree[n].Code, next_code[len] - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -33,8 +33,8 @@ int ZEXPORT uncompress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
|
||||
const uInt max = (uInt)-1;
|
||||
z_size_t len, left;
|
||||
|
||||
if (sourceLen == NULL || (*sourceLen > 0 && source == NULL) ||
|
||||
destLen == NULL || (*destLen > 0 && dest == NULL))
|
||||
if (sourceLen == Z_NULL || (*sourceLen > 0 && source == Z_NULL) ||
|
||||
destLen == Z_NULL || (*destLen > 0 && dest == Z_NULL))
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
len = *sourceLen;
|
||||
|
||||
Vendored
+10
-1
@@ -514,6 +514,10 @@ typedef uLong FAR uLongf;
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && \
|
||||
!defined(UNDER_CE) && (defined(__MINGW32__) || !defined(__GNUC__))
|
||||
# define Z_LFS64 /* native Windows has 64-bit file offsets */
|
||||
# define Z_WINLFS
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
@@ -531,7 +535,7 @@ typedef uLong FAR uLongf;
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long long
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
@@ -546,6 +550,11 @@ typedef uLong FAR uLongf;
|
||||
# define z_off64_t z_off_t
|
||||
#endif
|
||||
|
||||
#if defined(Z_WINLFS) && defined(Z_WANT64) && !defined(Z_SOLO)
|
||||
# undef z_off_t
|
||||
# define z_off_t z_off64_t
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
|
||||
Vendored
+10
-1
@@ -499,6 +499,10 @@ typedef uLong FAR uLongf;
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && \
|
||||
!defined(UNDER_CE) && (defined(__MINGW32__) || !defined(__GNUC__))
|
||||
# define Z_LFS64 /* native Windows has 64-bit file offsets */
|
||||
# define Z_WINLFS
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
@@ -516,7 +520,7 @@ typedef uLong FAR uLongf;
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long long
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
@@ -531,6 +535,11 @@ typedef uLong FAR uLongf;
|
||||
# define z_off64_t z_off_t
|
||||
#endif
|
||||
|
||||
#if defined(Z_WINLFS) && defined(Z_WANT64) && !defined(Z_SOLO)
|
||||
# undef z_off_t
|
||||
# define z_off_t z_off64_t
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
.TH ZLIB 3 "xx Feb 2026"
|
||||
.TH ZLIB 3 "4 Nov 2026"
|
||||
.SH NAME
|
||||
zlib \- compression/decompression library
|
||||
.SH SYNOPSIS
|
||||
@@ -105,7 +105,7 @@ before asking for help.
|
||||
Send questions and/or comments to zlib@gzip.org,
|
||||
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
|
||||
.SH AUTHORS AND LICENSE
|
||||
Version 1.3.2.1
|
||||
Version 1.4
|
||||
.LP
|
||||
Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler
|
||||
.LP
|
||||
|
||||
Vendored
+45
-34
@@ -1,5 +1,5 @@
|
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.3.2.1, February xxth, 2026
|
||||
version 1.4, November 4th, 2026
|
||||
|
||||
Copyright (C) 1995-2026 Jean-loup Gailly and Mark Adler
|
||||
|
||||
@@ -41,12 +41,12 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ZLIB_VERSION "1.3.2.1-motley"
|
||||
#define ZLIB_VERNUM 0x1321
|
||||
#define ZLIB_VERSION "1.4"
|
||||
#define ZLIB_VERNUM 0x1400
|
||||
#define ZLIB_VER_MAJOR 1
|
||||
#define ZLIB_VER_MINOR 3
|
||||
#define ZLIB_VER_REVISION 2
|
||||
#define ZLIB_VER_SUBREVISION 1
|
||||
#define ZLIB_VER_MINOR 4
|
||||
#define ZLIB_VER_REVISION 0
|
||||
#define ZLIB_VER_SUBREVISION 0
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
@@ -695,7 +695,9 @@ ZEXTERN int ZEXPORT deflateCopy(z_streamp dest,
|
||||
deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
|
||||
(such as zalloc being Z_NULL). msg is left unchanged in both source and
|
||||
destination.
|
||||
destination. If deflateCopy fails and dest is not Z_NULL, then dest->state
|
||||
is set to Z_NULL with dest otherwise unchanged, so that deflateEnd(dest) can
|
||||
be called safely, though dest is not a usable stream.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateReset(z_streamp strm);
|
||||
@@ -768,17 +770,17 @@ ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen);
|
||||
ZEXTERN z_size_t ZEXPORT deflateBound_z(z_streamp strm, z_size_t sourceLen);
|
||||
/*
|
||||
deflateBound() returns an upper bound on the compressed size after
|
||||
deflation of sourceLen bytes. It must be called after deflateInit() or
|
||||
deflateInit2(), and after deflateSetHeader(), if used. This would be used
|
||||
to allocate an output buffer for deflation in a single pass, and so would be
|
||||
called before deflate(). If that first deflate() call is provided the
|
||||
sourceLen input bytes, an output buffer allocated to the size returned by
|
||||
deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
|
||||
to return Z_STREAM_END. Note that it is possible for the compressed size to
|
||||
be larger than the value returned by deflateBound() if flush options other
|
||||
than Z_FINISH or Z_NO_FLUSH are used.
|
||||
deflation of sourceLen bytes. It must be called after deflateInit() or
|
||||
deflateInit2(), and after deflateSetHeader() or deflateSetDictionary(), if
|
||||
used. This would be used to allocate an output buffer for deflation in a
|
||||
single pass, and so would be called before deflate(). If that first
|
||||
deflate() call is provided the sourceLen input bytes, an output buffer
|
||||
allocated to the size returned by deflateBound(), and the flush value
|
||||
Z_FINISH, then deflate() is guaranteed to return Z_STREAM_END. Note that it
|
||||
is possible for the compressed size to be larger than the value returned by
|
||||
deflateBound() if flush options other than Z_FINISH or Z_NO_FLUSH are used.
|
||||
|
||||
delfateBound_z() is the same, but takes and returns a size_t length. Note
|
||||
deflateBound_z() is the same, but takes and returns a size_t length. Note
|
||||
that a long is 32 bits on Windows.
|
||||
*/
|
||||
|
||||
@@ -788,7 +790,7 @@ ZEXTERN int ZEXPORT deflatePending(z_streamp strm,
|
||||
/*
|
||||
deflatePending() returns the number of bytes and bits of output that have
|
||||
been generated, but not yet provided in the available output. The bytes not
|
||||
provided would be due to the available output space having being consumed.
|
||||
provided would be due to the available output space having been consumed.
|
||||
The number of bits of output not provided are between 0 and 7, where they
|
||||
await more bits to join them in order to fill out a full byte. If pending
|
||||
or bits are Z_NULL, then those values are not set.
|
||||
@@ -868,8 +870,7 @@ ZEXTERN int ZEXPORT inflateInit2(z_streamp strm,
|
||||
instead. windowBits must be greater than or equal to the windowBits value
|
||||
provided to deflateInit2() while compressing, or it must be equal to 15 if
|
||||
deflateInit2() was not used. If a compressed stream with a larger window
|
||||
size is given as input, inflate() will return with the error code
|
||||
Z_DATA_ERROR instead of trying to allocate a larger window.
|
||||
size is given as input, inflate() may return with a Z_DATA_ERROR.
|
||||
|
||||
windowBits can also be zero to request that inflate use the window size in
|
||||
the zlib header of the compressed stream.
|
||||
@@ -979,7 +980,9 @@ ZEXTERN int ZEXPORT inflateCopy(z_streamp dest,
|
||||
inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||
enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
|
||||
(such as zalloc being Z_NULL). msg is left unchanged in both source and
|
||||
destination.
|
||||
destination. If inflateCopy fails and dest is not Z_NULL, then dest->state
|
||||
is set to Z_NULL with dest otherwise unchanged, so that inflateEnd(dest) can
|
||||
be called safely, though dest is not a usable stream.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateReset(z_streamp strm);
|
||||
@@ -1094,9 +1097,10 @@ ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm,
|
||||
a terminating zero. If any of extra, name, or comment are not present in
|
||||
the header, then that field's pointer is set to Z_NULL. This allows the use
|
||||
of deflateSetHeader() with the returned structure to duplicate the header.
|
||||
Note that if those fields initially pointed to allocated memory, then the
|
||||
application will need to save them elsewhere so that they can be eventually
|
||||
freed.
|
||||
Though take care that none of the fields were truncated before so using it,
|
||||
lest havoc ensue. Note that if those fields initially pointed to allocated
|
||||
memory, then the application will need to save them elsewhere so that they
|
||||
can be eventually freed.
|
||||
|
||||
If inflateGetHeader is not used, then the header information is simply
|
||||
discarded. The header is always checked for validity, including the header
|
||||
@@ -1393,8 +1397,8 @@ ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode);
|
||||
errno can be checked to determine if the reason gzopen failed was that the
|
||||
file could not be opened. Note that if 'N' is in mode for non-blocking, the
|
||||
open() itself can fail in order to not block. In that case gzopen() will
|
||||
return NULL and errno will be EAGAIN or ENONBLOCK. The call to gzopen() can
|
||||
then be re-tried. If the application would like to block on opening the
|
||||
return NULL and errno will be EAGAIN or EWOULDBLOCK. The call to gzopen()
|
||||
can then be re-tried. If the application would like to block on opening the
|
||||
file, then it can use open() without O_NONBLOCK, and then gzdopen() with the
|
||||
resulting file descriptor and 'N' in the mode, which will set it to non-
|
||||
blocking.
|
||||
@@ -1500,9 +1504,12 @@ ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
|
||||
gzfread() returns the number of full items read of size size, or zero if
|
||||
the end of the file was reached and a full item could not be read, or if
|
||||
there was an error. gzerror() must be consulted if zero is returned in
|
||||
order to determine if there was an error. If the multiplication of size and
|
||||
nitems overflows, i.e. the product does not fit in a z_size_t, then nothing
|
||||
is read, zero is returned, and the error state is set to Z_STREAM_ERROR.
|
||||
order to determine if there was an error. If some data was read before an
|
||||
error, then that data is returned until exhausted, after which the next call
|
||||
will return zero and gzerror() will report the error. If the multiplication
|
||||
of size and nitems overflows, i.e. the product does not fit in a z_size_t,
|
||||
then nothing is read, zero is returned, and the error state is set to
|
||||
Z_STREAM_ERROR.
|
||||
|
||||
In the event that the end of file is reached and only a partial item is
|
||||
available at the end, i.e. the remaining uncompressed data length is not a
|
||||
@@ -1568,7 +1575,7 @@ ZEXTERN int ZEXPORTVA gzprintf();
|
||||
these possibilities can be determined using zlibCompileFlags().
|
||||
|
||||
If a Z_BUF_ERROR is returned, then nothing was written due to a stall on
|
||||
the non-blocking write destination.
|
||||
the non-blocking write destination. The operation can be retried.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s);
|
||||
@@ -1676,7 +1683,9 @@ ZEXTERN z_off_t ZEXPORT gzseek(gzFile file,
|
||||
gzseek returns the resulting offset location as measured in bytes from
|
||||
the beginning of the uncompressed stream, or -1 in case of error, in
|
||||
particular if the file is opened for writing and the new starting position
|
||||
would be before the current position.
|
||||
would be before the current position, or if the resulting position would
|
||||
not be representable in the offset type. If gzseek returns -1, the stream
|
||||
position is unchanged.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzrewind(gzFile file);
|
||||
@@ -1777,7 +1786,8 @@ ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum);
|
||||
If errnum is not NULL, *errnum is set to zlib error number. If an error
|
||||
occurred in the file system and not in the compression library, *errnum is
|
||||
set to Z_ERRNO and the application may consult errno to get the exact error
|
||||
code.
|
||||
code. The error is reported by gzerror() as soon as it is detected, which
|
||||
may be before all of the data read prior to the error has been returned.
|
||||
|
||||
The application must not modify the returned string. Future calls to
|
||||
this function may invalidate the previously returned string. If file is
|
||||
@@ -1976,7 +1986,8 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */
|
||||
* change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
|
||||
* both are true, the application gets the *64 functions, and the regular
|
||||
* functions are changed to 64 bits) -- in case these are set on systems
|
||||
* without large file support, _LFS64_LARGEFILE must also be true
|
||||
* without large file support, _LFS64_LARGEFILE must also be true, except on
|
||||
* native Windows, where 64-bit offsets are always available
|
||||
*/
|
||||
#ifdef Z_LARGE64
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
@@ -2058,7 +2069,7 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */
|
||||
|
||||
#endif /* !Z_SOLO */
|
||||
|
||||
/* undocumented functions */
|
||||
/* undocumented functions (not part of the zlib API) */
|
||||
ZEXTERN const char * ZEXPORT zError(int);
|
||||
ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp);
|
||||
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void);
|
||||
|
||||
Vendored
+4
-4
@@ -1,8 +1,8 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=@CMAKE_INSTALL_PREFIX@
|
||||
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
sharedlibdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${exec_prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
exec_prefix=${prefix}
|
||||
libdir=@pc_libdir@
|
||||
sharedlibdir=${libdir}
|
||||
includedir=@pc_includedir@
|
||||
|
||||
Name: zlib
|
||||
Description: zlib compression library
|
||||
|
||||
Vendored
+26
-4
@@ -1,5 +1,3 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set(_ZLIB_supported_components "shared" "static")
|
||||
|
||||
if(ZLIB_FIND_COMPONENTS)
|
||||
@@ -9,10 +7,34 @@ if(ZLIB_FIND_COMPONENTS)
|
||||
set(ZLIB_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
|
||||
endif(NOT _comp IN_LIST _ZLIB_supported_components)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_comp}.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_comp}.cmake"
|
||||
OPTIONAL
|
||||
RESULT_VARIABLE _comp_loaded)
|
||||
|
||||
if(NOT _comp_loaded)
|
||||
set(ZLIB_FOUND False)
|
||||
set(ZLIB_NOT_FOUND_MESSAGE "Component ${_comp} not found.")
|
||||
else(NOT _comp_loaded)
|
||||
set(ZLIB_${_comp}_FOUND TRUE)
|
||||
endif(NOT _comp_loaded)
|
||||
endforeach(_comp ${ZLIB_FIND_COMPONENTS})
|
||||
else(ZLIB_FIND_COMPONENTS)
|
||||
foreach(_component_config IN LISTS _ZLIB_supported_components)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_component_config}.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/ZLIB-${_component_config}.cmake"
|
||||
OPTIONAL)
|
||||
endforeach(_component_config IN LISTS _ZLIB_supported_components)
|
||||
|
||||
if(NOT TARGET ZLIB::ZLIB)
|
||||
set(ZLIB_FOUND False)
|
||||
set(ZLIB_NOT_FOUND_MESSAGE "Target ZLIB::ZLIB not created\n")
|
||||
string(APPEND ZLIB_NOT_FOUND_MESSAGE "build zlib with support for shared libs or\n")
|
||||
string(APPEND ZLIB_NOT_FOUND_MESSAGE "specify COMPONENTS static in your find_package call")
|
||||
endif(NOT TARGET ZLIB::ZLIB)
|
||||
|
||||
if(NOT TARGET ZLIB::ZLIBSTATIC)
|
||||
set(ZLIB_FOUND False)
|
||||
set(ZLIB_NOT_FOUND_MESSAGE "Target ZLIB::ZLIBSTATIC not created\n")
|
||||
string(APPEND ZLIB_NOT_FOUND_MESSAGE "build zlib with support for static libs or\n")
|
||||
string(APPEND ZLIB_NOT_FOUND_MESSAGE "specify COMPONENTS shared in your find_package call")
|
||||
endif(NOT TARGET ZLIB::ZLIBSTATIC)
|
||||
endif(ZLIB_FIND_COMPONENTS)
|
||||
Vendored
+5
-1
@@ -227,7 +227,11 @@ voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) {
|
||||
} else {
|
||||
buf = farmalloc(bsize + 16L);
|
||||
}
|
||||
if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
|
||||
if (buf == NULL) return NULL;
|
||||
if (next_ptr >= MAX_PTR) {
|
||||
farfree(buf);
|
||||
return NULL;
|
||||
}
|
||||
table[next_ptr].org_ptr = buf;
|
||||
|
||||
/* Normalize the pointer to seg:0 */
|
||||
|
||||
+1
-1
@@ -2,5 +2,5 @@
|
||||
// Refer to tools/dep_updaters/update-zlib.sh
|
||||
#ifndef SRC_ZLIB_VERSION_H_
|
||||
#define SRC_ZLIB_VERSION_H_
|
||||
#define ZLIB_VERSION "1.3.2.1-motley-9f9f52c"
|
||||
#define ZLIB_VERSION "1.4-ec453dc"
|
||||
#endif // SRC_ZLIB_VERSION_H_
|
||||
Reference in new issue
Block a user