Imported Upstream version 1.6.0 upstream/1.6.0
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 23 Nov 2020 06:58:14 +0000 (15:58 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 23 Nov 2020 06:58:14 +0000 (15:58 +0900)
335 files changed:
.github/ISSUE_TEMPLATE/bug-report.md [new file with mode: 0644]
.github/ISSUE_TEMPLATE/compile-error.md [new file with mode: 0644]
.github/ISSUE_TEMPLATE/feature-request.md [new file with mode: 0644]
CMakeLists.txt
INSTALL.md
LICENSE
NEWS.md
README.md
THANKS
android/do.sh [new file with mode: 0755]
android/docker/Dockerfile [new file with mode: 0644]
android/readme.txt [new file with mode: 0644]
appveyor.yml
cmake-config.h.in
examples/in-memory.c
examples/windows-open.c
lib/CMakeLists.txt
lib/compat.h
lib/mkstemp.c [deleted file]
lib/zip.h
lib/zip_add.c
lib/zip_add_dir.c
lib/zip_add_entry.c
lib/zip_algorithm_bzip2.c
lib/zip_algorithm_deflate.c
lib/zip_algorithm_xz.c [new file with mode: 0644]
lib/zip_buffer.c
lib/zip_close.c
lib/zip_crypto.h
lib/zip_crypto_commoncrypto.c
lib/zip_crypto_gnutls.c
lib/zip_crypto_gnutls.h
lib/zip_crypto_mbedtls.c
lib/zip_crypto_mbedtls.h
lib/zip_crypto_openssl.c
lib/zip_crypto_openssl.h
lib/zip_crypto_win.c
lib/zip_crypto_win.h
lib/zip_delete.c
lib/zip_dir_add.c
lib/zip_dirent.c
lib/zip_discard.c
lib/zip_entry.c
lib/zip_err_str.c
lib/zip_error.c
lib/zip_error_clear.c
lib/zip_error_get.c
lib/zip_error_get_sys_type.c
lib/zip_error_strerror.c
lib/zip_error_to_str.c
lib/zip_extra_field.c
lib/zip_extra_field_api.c
lib/zip_fclose.c
lib/zip_fdopen.c
lib/zip_file_add.c
lib/zip_file_error_clear.c
lib/zip_file_error_get.c
lib/zip_file_get_comment.c
lib/zip_file_get_external_attributes.c
lib/zip_file_get_offset.c
lib/zip_file_rename.c
lib/zip_file_replace.c
lib/zip_file_set_comment.c
lib/zip_file_set_encryption.c
lib/zip_file_set_external_attributes.c
lib/zip_file_set_mtime.c
lib/zip_file_strerror.c
lib/zip_filerange_crc.c
lib/zip_fopen.c
lib/zip_fopen_encrypted.c
lib/zip_fopen_index.c
lib/zip_fopen_index_encrypted.c
lib/zip_fread.c
lib/zip_fseek.c
lib/zip_ftell.c
lib/zip_get_archive_comment.c
lib/zip_get_archive_flag.c
lib/zip_get_encryption_implementation.c
lib/zip_get_file_comment.c
lib/zip_get_name.c
lib/zip_get_num_entries.c
lib/zip_get_num_files.c
lib/zip_hash.c
lib/zip_io_util.c
lib/zip_libzip_version.c
lib/zip_memdup.c
lib/zip_mkstempm.c [new file with mode: 0644]
lib/zip_name_locate.c
lib/zip_new.c
lib/zip_open.c
lib/zip_progress.c
lib/zip_random_unix.c
lib/zip_random_uwp.c
lib/zip_random_win32.c
lib/zip_rename.c
lib/zip_replace.c
lib/zip_set_archive_comment.c
lib/zip_set_archive_flag.c
lib/zip_set_default_password.c
lib/zip_set_file_comment.c
lib/zip_set_file_compression.c
lib/zip_set_name.c
lib/zip_source_accept_empty.c [new file with mode: 0644]
lib/zip_source_begin_write.c
lib/zip_source_begin_write_cloning.c
lib/zip_source_buffer.c
lib/zip_source_call.c
lib/zip_source_close.c
lib/zip_source_commit_write.c
lib/zip_source_compress.c
lib/zip_source_crc.c
lib/zip_source_error.c
lib/zip_source_file.c
lib/zip_source_filep.c
lib/zip_source_free.c
lib/zip_source_function.c
lib/zip_source_get_compression_flags.c
lib/zip_source_is_deleted.c
lib/zip_source_layered.c
lib/zip_source_open.c
lib/zip_source_pkware.c
lib/zip_source_read.c
lib/zip_source_remove.c
lib/zip_source_rollback_write.c
lib/zip_source_seek.c
lib/zip_source_seek_write.c
lib/zip_source_stat.c
lib/zip_source_supports.c
lib/zip_source_tell.c
lib/zip_source_tell_write.c
lib/zip_source_win32a.c
lib/zip_source_win32handle.c
lib/zip_source_win32utf8.c
lib/zip_source_win32w.c
lib/zip_source_window.c
lib/zip_source_winzip_aes_decode.c
lib/zip_source_winzip_aes_encode.c
lib/zip_source_write.c
lib/zip_source_zip.c
lib/zip_source_zip_new.c
lib/zip_stat.c
lib/zip_stat_index.c
lib/zip_stat_init.c
lib/zip_strerror.c
lib/zip_string.c
lib/zip_unchange.c
lib/zip_unchange_all.c
lib/zip_unchange_archive.c
lib/zip_unchange_data.c
lib/zip_utf-8.c
lib/zip_winzip_aes.c
lib/zipint.h
lib/zipwin32.h
man/ZIP_SOURCE_GET_ARGS.html
man/libzip.html
man/libzip.man
man/libzip.mdoc
man/links
man/zip_add.html
man/zip_add_dir.html
man/zip_close.html
man/zip_close.man
man/zip_close.mdoc
man/zip_delete.html
man/zip_dir_add.html
man/zip_dir_add.man
man/zip_dir_add.mdoc
man/zip_discard.html
man/zip_error_clear.html
man/zip_error_clear.man
man/zip_error_clear.mdoc
man/zip_error_code_system.html
man/zip_error_code_zip.html
man/zip_error_fini.html
man/zip_error_get.html
man/zip_error_get_sys_type.html
man/zip_error_init.html
man/zip_error_set.html
man/zip_error_strerror.html
man/zip_error_system_type.html
man/zip_error_to_data.html
man/zip_error_to_str.html
man/zip_errors.html
man/zip_errors.man
man/zip_errors.mdoc
man/zip_fclose.html
man/zip_fdopen.html
man/zip_fdopen.man
man/zip_fdopen.mdoc
man/zip_file_add.html
man/zip_file_add.man
man/zip_file_add.mdoc
man/zip_file_extra_field_delete.html
man/zip_file_extra_field_get.html
man/zip_file_extra_field_set.html
man/zip_file_extra_fields_count.html
man/zip_file_get_comment.html
man/zip_file_get_error.html
man/zip_file_get_external_attributes.html
man/zip_file_rename.html
man/zip_file_rename.man
man/zip_file_rename.mdoc
man/zip_file_set_comment.html
man/zip_file_set_encryption.html
man/zip_file_set_external_attributes.html
man/zip_file_set_mtime.html
man/zip_file_set_mtime.man
man/zip_file_set_mtime.mdoc
man/zip_file_strerror.html
man/zip_file_strerror.man
man/zip_file_strerror.mdoc
man/zip_fopen.html
man/zip_fopen_encrypted.html
man/zip_fread.html
man/zip_fseek.html
man/zip_ftell.html
man/zip_get_archive_comment.html
man/zip_get_archive_flag.html
man/zip_get_error.html
man/zip_get_file_comment.html
man/zip_get_name.html
man/zip_get_num_entries.html
man/zip_get_num_files.html
man/zip_libzip_version.html
man/zip_name_locate.html
man/zip_open.html
man/zip_open.man
man/zip_open.mdoc
man/zip_register_progress_callback.html
man/zip_register_progress_callback_with_state.html
man/zip_rename.html
man/zip_set_archive_comment.html
man/zip_set_archive_comment.man
man/zip_set_archive_comment.mdoc
man/zip_set_archive_flag.html
man/zip_set_default_password.html
man/zip_set_file_comment.html
man/zip_set_file_compression.html
man/zip_source.html
man/zip_source.man
man/zip_source.mdoc
man/zip_source_begin_write.html
man/zip_source_buffer.html
man/zip_source_buffer.man
man/zip_source_buffer.mdoc
man/zip_source_buffer_fragment.html
man/zip_source_buffer_fragment.man
man/zip_source_buffer_fragment.mdoc
man/zip_source_close.html
man/zip_source_commit_write.html
man/zip_source_error.html
man/zip_source_file.html
man/zip_source_file.man
man/zip_source_file.mdoc
man/zip_source_filep.html
man/zip_source_filep.man
man/zip_source_filep.mdoc
man/zip_source_free.html
man/zip_source_function.html
man/zip_source_function.man
man/zip_source_function.mdoc
man/zip_source_is_deleted.html
man/zip_source_keep.html
man/zip_source_make_command_bitmap.html
man/zip_source_open.html
man/zip_source_read.html
man/zip_source_rollback_write.html
man/zip_source_seek.html
man/zip_source_seek_compute_offset.html
man/zip_source_seek_write.html
man/zip_source_stat.html
man/zip_source_stat.man
man/zip_source_stat.mdoc
man/zip_source_tell.html
man/zip_source_tell_write.html
man/zip_source_win32a.html
man/zip_source_win32a.man
man/zip_source_win32a.mdoc
man/zip_source_win32handle.html
man/zip_source_win32handle.man
man/zip_source_win32handle.mdoc
man/zip_source_win32w.html
man/zip_source_win32w.man
man/zip_source_win32w.mdoc
man/zip_source_write.html
man/zip_source_zip.html
man/zip_source_zip.man
man/zip_source_zip.mdoc
man/zip_stat.html
man/zip_stat_init.html
man/zip_unchange.html
man/zip_unchange_all.html
man/zip_unchange_archive.html
man/zipcmp.html
man/zipcmp.man
man/zipcmp.mdoc
man/zipmerge.html
man/zipmerge.man
man/zipmerge.mdoc
man/ziptool.html
regress/CMakeLists.txt
regress/NiHTest.pm
regress/add_from_filep.c
regress/can_clone_file.c
regress/cancel_45.test [new file with mode: 0644]
regress/cancel_90.test [new file with mode: 0644]
regress/fopen_unchanged.c
regress/fread.c
regress/fseek.c
regress/fuzz_main.c [new file with mode: 0644]
regress/hole.c
regress/malloc.c
regress/nonrandomopen.c
regress/nonrandomopentest.c
regress/open_empty_2.test
regress/open_file_count.test
regress/open_incons.test
regress/ossfuzz.sh [new file with mode: 0755]
regress/set_compression_store_to_xz.test [new file with mode: 0644]
regress/set_compression_xz_to_store.test [new file with mode: 0644]
regress/set_file_dostime.test [new file with mode: 0644]
regress/source_hole.c
regress/testfile-lzma.zip [new file with mode: 0644]
regress/testfile-stored-dos.zip [new file with mode: 0644]
regress/testfile-xz.zip [new file with mode: 0644]
regress/testfile0.zip [new file with mode: 0644]
regress/tryopen.c
regress/zip_read_fuzzer.cc [new file with mode: 0644]
regress/zip_read_fuzzer.dict [new file with mode: 0644]
regress/ziptool_regress.c
src/CMakeLists.txt
src/getopt.h
src/zipcmp.c
src/zipmerge.c
src/ziptool.c

diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md
new file mode 100644 (file)
index 0000000..86c1078
--- /dev/null
@@ -0,0 +1,32 @@
+---
+name: Bug Report
+about: Report where libzip didn't behave like you expected.
+title: ''
+labels: bug
+assignees: ''
+
+---
+
+**Describe the Bug**
+A clear and concise description of what the bug is.
+
+**Expected Behavior**
+A clear and concise description of what you expected to happen.
+
+**Observed Behavior**
+A clear and concise description of what actually happened.
+
+**To Reproduce**
+Short program or code snippet that reproduces the problem.
+
+**libzip Version**
+Version of libzip or revision repository used.
+
+**Operating System**
+Operating system and version, used compiler.
+
+**Test Files**
+If applicable, attach and describe zip archives that trigger the problem.
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/compile-error.md b/.github/ISSUE_TEMPLATE/compile-error.md
new file mode 100644 (file)
index 0000000..45c8a7a
--- /dev/null
@@ -0,0 +1,25 @@
+---
+name: Compile Error
+about: Report when libzip does not compile.
+title: ''
+labels: compile
+assignees: ''
+
+---
+
+**Compiler Error**
+Output from the compiler, including exact and complete error message, file name and line number.
+
+**libzip Version**
+Version of libzip or revision repository used.
+
+**Operating System and Compiler**
+The operating system and compiler used, including version number.
+
+Also, any flags passed to `cmake`.
+
+**Autodetected Configuration**
+Attach `CmakeCache.txt` from your build directory. This list everything `cmake` detected on your system.
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md
new file mode 100644 (file)
index 0000000..98bead5
--- /dev/null
@@ -0,0 +1,22 @@
+---
+name: Feature Request
+about: Suggest an idea for this project.
+title: ''
+labels: enhancement
+assignees: ''
+
+---
+
+**Description**
+A clear and concise description of what you want to achieve, why the current features are insufficient, and why you think it is generally useful.
+
+Also, have you checked wether the feature is already mentioned in TODO.md? If so, only submit a new issue if you expand on it. 
+
+**Solution**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context about the feature request here.
index 8008995..7af850c 100644 (file)
@@ -14,6 +14,7 @@ OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
 OPTION(ENABLE_WINDOWS_CRYPTO "Enable use of Windows cryptography libraries" ON)
 
 OPTION(ENABLE_BZIP2 "Enable use of BZip2" ON)
+OPTION(ENABLE_LZMA "Enable use of LZMA" ON)
 
 OPTION(BUILD_TOOLS "Build tools in the src directory (zipcmp, zipmerge, ziptool)" ON)
 OPTION(BUILD_REGRESS "Build regression tests" ON)
@@ -22,6 +23,7 @@ OPTION(BUILD_DOC "Build documentation" ON)
 
 INCLUDE(CheckFunctionExists)
 INCLUDE(CheckIncludeFiles)
+INCLUDE(CheckLibraryExists)
 INCLUDE(CheckSymbolExists)
 INCLUDE(CheckTypeSize)
 INCLUDE(CheckCSourceRuns)
@@ -42,7 +44,7 @@ ELSE()
 ENDIF()
 IF(ENABLE_MBEDTLS)
   FIND_PATH(MBEDTLS_INCLUDE_DIR mbedtls/aes.h)
-  FIND_LIBRARY(MBEDTLS_LIBRARIES NAMES mbedtls)
+  FIND_LIBRARY(MBEDTLS_LIBRARIES NAMES mbedcrypto)
 ELSE()
   SET(MBEDTLS_LIBRARIES FALSE)
 ENDIF()
@@ -79,8 +81,8 @@ ENDIF()
 SET(PACKAGE "libzip")
 SET(PACKAGE_NAME ${PACKAGE})
 SET(PACKAGE_VERSION_MAJOR "1")
-SET(PACKAGE_VERSION_MINOR "5")
-SET(PACKAGE_VERSION_MICRO "2")
+SET(PACKAGE_VERSION_MINOR "6")
+SET(PACKAGE_VERSION_MICRO "0")
 #SET(VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
 SET(VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_MICRO}")
 SET(PACKAGE_VERSION ${VERSION})
@@ -91,6 +93,7 @@ SET(LIBZIP_VERSION_MICRO ${PACKAGE_VERSION_MICRO})
 SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
 
 SET(ARCHIVE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION})
+IF(NOT TARGET dist)
 ADD_CUSTOM_TARGET(dist
   COMMAND git config tar.tar.xz.command "xz -c"
   COMMAND git archive --prefix=${ARCHIVE_NAME}/ -o ${ARCHIVE_NAME}.tar.gz HEAD
@@ -117,6 +120,7 @@ ADD_CUSTOM_TARGET(distcheck
   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
   )
 ADD_DEPENDENCIES(distcheck dist)
+ENDIF(NOT TARGET dist)
 
 IF(BUILD_SHARED_LIBS)
   SET(HAVE_SHARED TRUE)
@@ -138,8 +142,8 @@ CHECK_FUNCTION_EXISTS(_strdup HAVE__STRDUP)
 CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP)
 CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
 CHECK_FUNCTION_EXISTS(_strtoui64 HAVE__STRTOUI64)
-CHECK_FUNCTION_EXISTS(_umask HAVE__UMASK)
 CHECK_FUNCTION_EXISTS(_unlink HAVE__UNLINK)
+CHECK_FUNCTION_EXISTS(arc4random HAVE_ARC4RANDOM)
 CHECK_FUNCTION_EXISTS(clonefile HAVE_CLONEFILE)
 CHECK_FUNCTION_EXISTS(explicit_bzero HAVE_EXPLICIT_BZERO)
 CHECK_FUNCTION_EXISTS(explicit_memset HAVE_EXPLICIT_MEMSET)
@@ -147,8 +151,8 @@ CHECK_FUNCTION_EXISTS(fileno HAVE_FILENO)
 CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO)
 CHECK_FUNCTION_EXISTS(ftello HAVE_FTELLO)
 CHECK_FUNCTION_EXISTS(getprogname HAVE_GETPROGNAME)
+CHECK_FUNCTION_EXISTS(localtime_r HAVE_LOCALTIME_R)
 CHECK_FUNCTION_EXISTS(open HAVE_OPEN)
-CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
 CHECK_FUNCTION_EXISTS(setmode HAVE_SETMODE)
 CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
 CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP)
@@ -158,6 +162,24 @@ CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
 CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL)
 
 CHECK_INCLUDE_FILES("sys/types.h;sys/stat.h;fts.h" HAVE_FTS_H)
+# fts functions may be in external library
+IF(HAVE_FTS_H)
+  CHECK_FUNCTION_EXISTS(fts_open HAVE_FTS_OPEN)
+  IF(NOT HAVE_FTS_OPEN)
+    CHECK_LIBRARY_EXISTS(fts fts_open "" HAVE_LIB_FTS)
+  ELSE(NOT HAVE_FTS_OPEN)
+    SET(HAVE_LIB_FTS "" CACHE INTERNAL "")
+  ENDIF(NOT HAVE_FTS_OPEN)
+ELSE(HAVE_FTS_H)
+  SET(HAVE_LIB_FTS "" CACHE INTERNAL "")
+ENDIF(HAVE_FTS_H)
+
+IF(HAVE_LIB_FTS)
+  SET(FTS_LIB fts CACHE INTERNAL "")
+ELSE()
+  SET(FTS_LIB "" CACHE INTERNAL "")
+ENDIF()
+
 CHECK_INCLUDE_FILES(stdbool.h HAVE_STDBOOL_H)
 CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
 CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H)
@@ -200,12 +222,9 @@ int main(int argc, char *argv[]) { }" HAVE_NULLABLE)
 
 TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
 
-FIND_PACKAGE(ZLIB REQUIRED)
+FIND_PACKAGE(ZLIB 1.1.2 REQUIRED)
 INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
 SET(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR})
-IF(ZLIB_VERSION_STRING VERSION_LESS "1.1.2")
-  MESSAGE(FATAL_ERROR "-- ZLIB version too old, please install at least v1.1.2")
-ENDIF(ZLIB_VERSION_STRING VERSION_LESS "1.1.2")
 
 IF(ENABLE_BZIP2)
   FIND_PACKAGE(BZip2)
@@ -213,12 +232,25 @@ IF(ENABLE_BZIP2)
     SET (HAVE_LIBBZ2 1)
 
     INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
-    SET (OPTIONAL_LIBRARY ${BZIP2_LIBRARY})
+    SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} ${BZIP2_LIBRARIES})
   ELSE()
     MESSAGE(WARNING "-- bzip2 library not found; bzip2 support disabled")
   ENDIF(BZIP2_FOUND)
 ENDIF(ENABLE_BZIP2)
 
+IF(ENABLE_LZMA)
+  FIND_PACKAGE(LibLZMA)
+  IF(LIBLZMA_FOUND)
+    SET (HAVE_LIBLZMA 1)
+
+    INCLUDE_DIRECTORIES(${LIBLZMA_INCLUDE_DIR})
+    SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} ${LIBLZMA_LIBRARY})
+  ELSE()
+    MESSAGE(WARNING "-- lzma library not found; lzma support disabled")
+  ENDIF(LIBLZMA_FOUND)
+ENDIF(ENABLE_LZMA)
+
+
 IF (COMMONCRYPTO_FOUND)
   SET (HAVE_CRYPTO 1)
   SET (HAVE_COMMONCRYPTO 1)
@@ -253,12 +285,12 @@ ENDIF(MSVC)
 
 if(WIN32)
   if(HAVE_WINDOWS_CRYPTO)
-    SET (OPTIONAL_LIBRARY "${OPTIONAL_LIBRARY}" bcrypt)
+    SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} bcrypt)
   endif()
   if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
     ADD_DEFINITIONS(-DMS_UWP)
   else(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
-    SET (OPTIONAL_LIBRARY "${OPTIONAL_LIBRARY}" advapi32)
+    SET (OPTIONAL_LIBRARY ${OPTIONAL_LIBRARY} advapi32)
   endif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
 endif(WIN32)
 
@@ -299,22 +331,27 @@ SET(exec_prefix \${prefix})
 SET(bindir \${exec_prefix}/${CMAKE_INSTALL_BINDIR})
 SET(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
 SET(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
-IF(BZIP2_FOUND)
-  SET(LIBS "${LIBS} -lbz2")
-ENDIF()
-SET(LIBS "${LIBS} -lz")
 IF(CMAKE_SYSTEM_NAME MATCHES BSD)
   SET(PKG_CONFIG_RPATH "-Wl,-R\${libdir}")
 ENDIF(CMAKE_SYSTEM_NAME MATCHES BSD)
+get_target_property(LIBS_PRIVATE zip LINK_LIBRARIES)
+foreach(LIB ${LIBS_PRIVATE})
+  if(LIB MATCHES "^/")
+    get_filename_component(LIB ${LIB} NAME_WE)
+    string(REGEX REPLACE "^lib" "" LIB ${LIB})
+  endif()
+  set(LIBS "${LIBS} -l${LIB}")
+endforeach()
 CONFIGURE_FILE(libzip.pc.in libzip.pc @ONLY)
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzip.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 
 # fixed size integral types
 
-IF(HAVE_STDINT_H_LIBZIP)
+IF(HAVE_INTTYPES_H_LIBZIP)
+  SET(LIBZIP_TYPES_INCLUDE "#define __STDC_FORMAT_MACROS 1
+#include <inttypes.h>")
+ELSEIF(HAVE_STDINT_H_LIBZIP)
   SET(LIBZIP_TYPES_INCLUDE "#include <stdint.h>")
-ELSEIF(HAVE_INTTYPES_H_LIBZIP)
-  SET(LIBZIP_TYPES_INCLUDE "#include <inttypes.h>")
 ELSEIF(HAVE_SYS_TYPES_H_LIBZIP)
   SET(LIBZIP_TYPES_INCLUDE "#include <sys/types.h>")
 ENDIF()
@@ -406,11 +443,11 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake-zipconf.h.in ${CMAKE_CURRENT_BI
 
 SET(srcdir ${CMAKE_CURRENT_SOURCE_DIR}/regress)
 SET(abs_srcdir ${CMAKE_CURRENT_SOURCE_DIR}/regress)
-SET(top_builddir ${CMAKE_BINARY_DIR})
+SET(top_builddir ${CMAKE_CURRENT_BINARY_DIR}) # used to find config.h
 
-CONFIGURE_FILE(regress/runtest.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/runtest @ONLY)
-FILE(COPY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/runtest
-  DESTINATION ${CMAKE_BINARY_DIR}/regress
+CONFIGURE_FILE(regress/runtest.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/runtest @ONLY)
+FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/runtest
+  DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/regress
   FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
 )
 
index eef900e..14e4469 100644 (file)
@@ -8,6 +8,9 @@ comes with most operating systems.
 For supporting bzip2-compressed zip archives, you need
 [bzip2](http://bzip.org/).
 
+For supporting xz-compressed zip archives, you need
+[liblzma](https://tukaani.org/xz/) which is part of xz.
+
 For AES (encryption) support, you need one of these cryptographic libraries,
 listed in order of preference:
 
@@ -49,6 +52,11 @@ CFLAGS=-DMY_CUSTOM_FLAG cmake ..
 If you are compiling on a system with a small stack size, add
 `-DZIP_ALLOCATE_BUFFER` to `CFLAGS`.
 
+If you are building on a 32-bit Linux system it might be necessary
+to define `_FILE_OFFSET_BITS` to `64`. Your distro will need to provide
+a `fts.h` file that is new enough to support this, or the build
+will break in `zipcmp`.
+
 You can get verbose build output with by passing `VERBOSE=1` to
 `make`.
 
diff --git a/LICENSE b/LICENSE
index e93454e..e9fef2a 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner
+Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
 The authors can be contacted at <libzip@nih.at>
 
diff --git a/NEWS.md b/NEWS.md
index 9d8d2a3..723f993 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,13 @@
+1.6.0 [2020-01-24]
+==================
+
+* Avoid using umask() since it's not thread-safe.
+* Set close-on-exec flag when opening files.
+* Do not accept empty files as valid zip archives any longer.
+* Add support for XZ compressed files (using liblzma).
+* Add support for cancelling while closing zip archives.
+* Add support for setting the time in the on-disk format.
+
 1.5.2 [2019-03-12]
 ==================
 * Fix bug in AES encryption affecting certain file sizes
index 60f94f8..c42f4b6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
-This is libzip, a C library for reading, creating, and modifying zip
-archives. Files can be added from data buffers, files, or compressed
-data copied directly from other zip archives. Changes made without
-closing the archive can be reverted. Decryption and encryption of
-Winzip AES and decryption of legacy PKware encrypted files is
-supported. The API is documented by man pages.
+This is libzip, a C library for reading, creating, and modifying
+zip and zip64 archives. Files can be added from data buffers, files,
+or compressed data copied directly from other zip archives. Changes
+made without closing the archive can be reverted. Decryption and
+encryption of Winzip AES and decryption of legacy PKware encrypted
+files is supported. The API is documented by man pages.
 
 libzip is fully documented via man pages. HTML versions of the man
 pages are on [libzip.org](https://libzip.org/documentation/) and
diff --git a/THANKS b/THANKS
index e8f3b3d..fea6428 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -6,21 +6,25 @@ Thanks to these people for suggestions, testing, and bug reports:
 Agostino Sarubbo
 Alexander Galanin <al@galanin.nnov.ru>
 Alexandr Shadchin <alexandr.shadchin@gmail.com>
+Alexey Bykov <gnfalex@rambler.ru>
 Andreas Falkenhahn <andreas@falkenhahn.com>
 Andrew Brampton <brampton@gmail.com>
 Andrew Molyneux <andrew@molyneuxfamily.co.uk>
 Ankur Kothari <ankz.kothari@gmail.com>
 BALATON Zoltan <balaton@eik.bme.hu>
 Benjamin Gilbert <bgilbert@backtick.net>
+Beuc <beuc@beuc.net>
 Boaz Stolk <bstolk@aweta.nl>
 Bogdan <bogiebog@gmail.com>
 Brian 'geeknik' Carpenter <geeknik@protonmail.ch>
 Carl Mastrangelo <notcarl@google.com>
 Cédric Tabin
+celan69
 Chris Nehren <cnehren+libzip@pobox.com>
 Coverity <info@coverity.com>
 Dane Springmeyer <dane.springmeyer@gmail.com>
 David Demelier <demelier.david@gmail.com>
+Declan Moran
 Del Merritt <del@alum.mit.edu>
 Dmytro Rybachenko <atmoliton@gmail.com>
 Elvis Angelaccio
@@ -37,17 +41,19 @@ Ilya Voronin
 Info-ZIP group
 Jan Weiß <jan@geheimwerk.de>
 Jay Freeman (saurik) <saurik@saurik.com>
+Joachim Reichel <joachim.reichel@gmx.de>
 João Custódio <joao_custodio@symantec.com>
 Joel Ebrahimi <joel.ebrahimi@gmail.com>
 Jono Spiro <jono.spiro@gmail.com>
 Julien Schueller <schueller@phimeca.com>
+kensington <kensington@gentoo.org>
 Keith Jones <keith@keithjjones.com>
 Kohei Yoshida <kohei.yoshida@gmail.com>
 Leith Bade <leith@mapbox.com>
 Lubomir I. Ivanov <neolit123@gmail.com>
 Maël Nison
 Martin Buchholz <martinrb@google.com>
-Martin Herkt
+Martin Herkt <lachs0r@srsfckn.biz>
 Martin Szulecki <m.szulecki@libimobiledevice.org>
 Michael Balzer
 Michael Beck <mm.beck@gmx.net>
@@ -55,8 +61,10 @@ MichaÅ‚ Janiszewski
 Michal Vyskocil <mvyskocil@suse.cz>
 Mikhail Gusarov <dottedmag@dottedmag.net>.
 Miklos Vajna
+Morris Hafner
 Oliver Kaiser <under.northern.sky@googlemail.com>
 Oliver Kuckertz <oliver.kuckertz@mologie.de>
+OSS-Fuzz Team
 Pascal Terjan <pterjan@gmail.com>
 Patrick Spendrin <ps_ml@gmx.de>
 Paul Harris <harris.pc@gmail.com>
@@ -64,12 +72,16 @@ Paul Sheppard <shepsoft@googlemail.com>
 Pavel Raiskup <praiskup@redhat.com>
 Pierre Joye <pierre.php@gmail.com>
 Pierre-Louis Cabelguen <plcabelguen@googlemail.com>
+Randy <randy408@protonmail.com>
 Remi Collet <remi@fedoraproject.org>
 Richard Schütz
 Rick Carback <carback1@umbc.edu>
 Robert Norris <rw_norris@hotmail.com>
 Roberto Tirabassi <rtirabassi@3di.it>
 Roland Ortloff <Ortloff.R@gmx.de>
+Rosen Penev <rosenp@gmail.com>
+Sebastian Kemper <sebastian_ml@gmx.net>
+Sebastian Schmitt <sebastian.schmitt@auvesy.de>
 Sergei Ozerov <ru.programmist@gmail.com>
 Simon Talbot <simont@nse.co.uk>
 Stephen Bryant <steve@bawue.de>
@@ -79,7 +91,7 @@ Tim Lunn <Tim@feathertop.org>
 Timo Warns <warns@pre-sense.de>
 Tom Callaway <tcallawa@redhat.com>
 Tomas Hoger <thoger@redhat.com>
-Tomáš Malý
+Tomáš Malý <malytomas@ucpu.cz>
 Torsten Paul <Torsten.Paul@gmx.de>
 Vassili Courzakis <vcoxvco@googlemail.com>
 William Lee
diff --git a/android/do.sh b/android/do.sh
new file mode 100755 (executable)
index 0000000..c4641c9
--- /dev/null
@@ -0,0 +1,63 @@
+
+# Author: Declan Moran
+# www.silverglint.com 
+# Thanks to damaex (https://github.com/damaex), for significant contributions
+
+ANDROID_NDK_ROOT=/home/android/android-ndk-r19c
+
+INSTALL_DIR=install
+BUILD_DIR=build
+START_DIR=$(pwd)
+
+rm -rf $INSTALL_DIR
+rm -rf $BUILD_DIR
+mkdir -p $BUILD_DIR #"${ANDROID_TARGET_PLATFORM}"
+
+#--------------------------------------------------------------------
+build_it()
+{
+    # builds either a static or shared lib depending on parm passed (ON or OFF)
+    want_shared=$1
+
+       cmake -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake \
+               -DCMAKE_INSTALL_PREFIX:PATH=../../${INSTALL_DIR}/${ANDROID_TARGET_PLATFORM} \
+               -DANDROID_ABI=${ANDROID_TARGET_PLATFORM} \
+               -DENABLE_OPENSSL:BOOL=OFF \
+               -DENABLE_COMMONCRYPTO:BOOL=OFF \
+               -DENABLE_GNUTLS:BOOL=OFF \
+               -DENABLE_MBEDTLS:BOOL=OFF \
+               -DENABLE_OPENSSL:BOOL=OFF \
+               -DENABLE_WINDOWS_CRYPTO:BOOL=OFF \
+               -DBUILD_TOOLS:BOOL=OFF \
+               -DBUILD_REGRESS:BOOL=OFF \
+               -DBUILD_EXAMPLES:BOOL=OFF \
+               -DBUILD_SHARED_LIBS:BOOL=$want_shared \
+               -DBUILD_DOC:BOOL=OFF \
+               -DANDROID_TOOLCHAIN=clang  cmake -H.. -B$BUILD_DIR/${ANDROID_TARGET_PLATFORM}
+                       
+        #run make with all system threads and install
+        cd $BUILD_DIR/${ANDROID_TARGET_PLATFORM}
+        make install -j$(nproc --all)
+        cd $START_DIR
+    }
+
+#--------------------------------------------------------------------
+for ANDROID_TARGET_PLATFORM in armeabi-v7a arm64-v8a x86 x86_64
+do
+       echo "Building libzip for ${ANDROID_TARGET_PLATFORM}" 
+       
+       build_it ON
+       build_it OFF
+       
+       if [ $? -ne 0 ]; then
+               echo "Error executing: cmake"
+               exit 1
+       fi
+
+       
+       if [ $? -ne 0 ]; then
+               echo "Error executing make install for platform: ${ANDROID_TARGET_PLATFORM}"
+               exit 1
+    fi
+    
+done    
diff --git a/android/docker/Dockerfile b/android/docker/Dockerfile
new file mode 100644 (file)
index 0000000..2e726e4
--- /dev/null
@@ -0,0 +1,122 @@
+# Version: 1.0
+
+# Dockerfile for building libzip for android
+# https://github.com/dec1/libzip.git
+# creates docker container with all tools, libraries and sources required to build libzip for android.
+
+# Author: Declan Moran
+# www.silverglint.com
+
+
+# Usage: 
+#---------
+# download the libzip repository
+# > git clone https://github.com/dec1/libzip.git
+# > cd libzip
+#
+# build docker image "my_img_zip" from the dockerfile in "docker" dir
+# > docker build -t my_img_zip ./android/docker
+#
+# run docker container "my_ctr_zip" from this image, mounting the current dir. (Need to pass absolute host paths to mount volume- hence "pwd")
+# > docker run  -v $(pwd):/home/docker-share/libzip -it --entrypoint=/bin/bash --name my_ctr_zip my_img_zip
+#
+# Now inside docker container
+# $ cd /home/docker-share/libzip/android
+#
+# Modify ./do.sh (on host), to match the boost and android ndk versions/paths in the "Configure here" section below
+# Build from running docker container. 
+# $./do.sh
+#
+# "./build" dir contains required build, but owned by root. chown to your username/group
+# > sudo chown -R <userid>:<groupid> ./build
+# > sudo chown -R <userid>:<groupid> ./install
+#
+# Exit container, when build is finsihed.
+# $ exit
+# 
+
+
+
+
+FROM ubuntu:18.04
+## --------------------------------------------------------------------
+##              Configure here
+# ---------------------------------------------------------------------
+# ---------------------------------------------------------------------
+# Here you can speciofy exactly what android ndk (and sdk) version you want to use.
+
+
+
+# (2) Android SDK
+# https://developer.android.com/studio#downloads
+ARG SDK_URL_BASE=https://dl.google.com/android/repository
+ARG SDK_FILE=sdk-tools-linux-4333796.zip
+
+# the sdk plaform to use 
+# https://developer.android.com/guide/topics/manifest/uses-sdk-element
+ARG ANDROID_SDK_PLATFORM_VERS="platforms;android-28"
+
+
+
+# (3) Android NDK
+# https://developer.android.com/ndk/downloads
+ARG NDK_URL_BASE=https://dl.google.com/android/repository
+ARG NDK_FILE=android-ndk-r19c-linux-x86_64.zip
+# ---------------------------------------------------------------------
+## --------------------------------------------------------------------
+
+RUN apt-get update
+RUN apt-get -y dist-upgrade
+
+
+# for downloading archives
+RUN apt-get -y install wget
+
+# for unzipping downloaded android archives
+RUN apt-get -y install zip 
+RUN apt-get -y install cmake
+
+RUN apt-get -y install lib32z1
+
+
+# need this this to install some (32 bit) prerequisites for android builds 
+RUN dpkg --add-architecture i386
+RUN apt-get update
+RUN apt-get -y dist-upgrade
+RUN apt-get install -y  libc6:i386 libncurses5:i386 libstdc++6:i386 libbz2-1.0:i386
+
+
+# need c compiler to set up create boost build system (before building boost with it and android toolchain)
+RUN apt-get -y install build-essential 
+RUN apt-get -y install libc6-dev-i386
+RUN apt-get -y install clang
+
+RUN apt-get -y install openjdk-8-jdk
+#--------------------------------------
+
+ARG ANDROID_HOME=/home/android
+WORKDIR ${ANDROID_HOME}
+
+
+# SDK
+# ----
+# download android sdk command line tools
+RUN wget ${SDK_URL_BASE}/$SDK_FILE
+RUN unzip $SDK_FILE 
+
+ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools
+
+
+RUN yes | sdkmanager --licenses
+
+RUN sdkmanager "platform-tools" $ANDROID_SDK_PLATFORM_VERS
+#RUN sdkmanager "platform-tools" "platforms;android-28" 
+
+
+# NDK
+# ----
+RUN wget ${NDK_URL_BASE}/$NDK_FILE
+RUN unzip $NDK_FILE 
+
diff --git a/android/readme.txt b/android/readme.txt
new file mode 100644 (file)
index 0000000..aa69fbd
--- /dev/null
@@ -0,0 +1,10 @@
+
+Cross compile libzip for android.
+--------------------------------
+Modify "do.sh" as appropriate if you need to specify a different ndk dir or wish to specify different build parameters
+
+Prerequisites for the development machine - see docker/Dockerfile
+
+You can either set you host machine up with these prerequisites or simply use docker (in which case you need not install anything on your host machine except docker itself).
+
+See "Usage" in docker/Dockerfile for detailed instructions.
index 2061365..9954edf 100644 (file)
@@ -1,31 +1,49 @@
 os:
 - Visual Studio 2017
+
 environment:
   matrix:
     - GENERATOR: "Visual Studio 15 2017 Win64"
       TRIPLET: x64-windows
       CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
+      CMAKE_CONFIG: Release
+    - GENERATOR: "Visual Studio 15 2017 Win64"
+      TRIPLET: x64-windows
+      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
+      CMAKE_CONFIG: Debug
+    - GENERATOR: "Visual Studio 15 2017 Win64"
+      TRIPLET: x64-uwp
+      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0"
+      CMAKE_CONFIG: Release
+    - GENERATOR: "Visual Studio 15 2017"
+      TRIPLET: x86-windows
+      CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
+      CMAKE_CONFIG: Release
     - GENERATOR: "Visual Studio 15 2017"
       TRIPLET: x86-windows
       CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off"
+      CMAKE_CONFIG: Debug
+    - GENERATOR: "Visual Studio 15 2017"
+      TRIPLET: x86-uwp
+      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0"
+      CMAKE_CONFIG: Release
     - GENERATOR: "Visual Studio 15 2017 ARM"
       TRIPLET: arm-windows
       CMAKE_OPTS: "-DENABLE_OPENSSL=off"
-    - GENERATOR: "Visual Studio 15 2017"
-      TRIPLET: x86-uwp
-      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore"
-    - GENERATOR: "Visual Studio 15 2017 Win64"
-      TRIPLET: x64-uwp
-      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore"
+      CMAKE_CONFIG: Release
     - GENERATOR: "Visual Studio 15 2017 ARM"
       TRIPLET: arm-uwp
-      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DENABLE_OPENSSL=off"
+      CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off"
+      CMAKE_CONFIG: Release
     - GENERATOR: "Visual Studio 15 2017"
       TRIPLET: arm64-windows
       CMAKE_OPTS: "-AARM64 -DENABLE_OPENSSL=off"
+      CMAKE_CONFIG: Release
     - GENERATOR: "Visual Studio 15 2017"
       TRIPLET: arm64-uwp
-      CMAKE_OPTS: "-AARM64 -DCMAKE_SYSTEM_NAME=WindowsStore -DENABLE_OPENSSL=off"
+      CMAKE_OPTS: "-AARM64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off"
+      CMAKE_CONFIG: Release
+
 before_build:
   cmd: >-
     git clone https://github.com/Microsoft/vcpkg
@@ -52,6 +70,12 @@ before_build:
 
 build_script:
   cmd: >-
-    cmake --build . --config Release --target INSTALL
+    cmake --build . --config %CMAKE_CONFIG% --target INSTALL
+
+    cmake --build . --config %CMAKE_CONFIG%
+
+test_script:
+  cmd: >-
+    set VERBOSE=yes
 
-    cmake --build . --config Debug --target INSTALL
+    ctest -C %CMAKE_CONFIG% --output-on-failure
index 51efe61..7d5bdab 100644 (file)
@@ -19,6 +19,7 @@
 #cmakedefine HAVE__STRTOUI64
 #cmakedefine HAVE__UMASK
 #cmakedefine HAVE__UNLINK
+#cmakedefine HAVE_ARC4RANDOM
 #cmakedefine HAVE_CLONEFILE
 #cmakedefine HAVE_COMMONCRYPTO
 #cmakedefine HAVE_CRYPTO
@@ -29,6 +30,8 @@
 #cmakedefine HAVE_GETPROGNAME
 #cmakedefine HAVE_GNUTLS
 #cmakedefine HAVE_LIBBZ2
+#cmakedefine HAVE_LIBLZMA
+#cmakedefine HAVE_LOCALTIME_R
 #cmakedefine HAVE_MBEDTLS
 #cmakedefine HAVE_MKSTEMP
 #cmakedefine HAVE_NULLABLE
index 625e280..e7705dd 100644 (file)
@@ -1,6 +1,6 @@
 /*
   in-memory.c -- modify zip file in memory
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 5108af5..bc8660d 100644 (file)
@@ -1,6 +1,6 @@
 /*
   windows-open.c -- open zip archive using Windows UTF-16/Unicode file name
-  Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 8be48a0..d5bf580 100644 (file)
@@ -10,9 +10,9 @@ MACRO(GET_TARGET_PROPERTY_WITH_DEFAULT _variable _target _property _default_valu
   IF(${_variable} STREQUAL NOTFOUND)
     SET(${_variable} ${_default_value})
   ENDIF()
-  
+
 ENDMACRO()
-  
+
 MACRO(CREATE_LIBTOOL_FILE _target _install_DIR)
   GET_TARGET_PROPERTY(_target_location ${_target} LOCATION)
   GET_TARGET_PROPERTY_WITH_DEFAULT(_target_static_lib ${_target} STATIC_LIB "")
@@ -51,7 +51,7 @@ MACRO(CREATE_LIBTOOL_FILE _target _install_DIR)
   FILE(APPEND ${_laname} "libdir='${CMAKE_INSTALL_PREFIX}/${_install_DIR}'\n")
   INSTALL( FILES ${_laname} ${_soname} DESTINATION ${CMAKE_INSTALL_PREFIX}${_install_DIR})
 ENDMACRO()
+
 SET(LIBZIP_SOURCES
   zip_add.c
   zip_add_dir.c
@@ -119,6 +119,7 @@ SET(LIBZIP_SOURCES
   zip_set_file_comment.c
   zip_set_file_compression.c
   zip_set_name.c
+  zip_source_accept_empty.c
   zip_source_begin_write.c
   zip_source_begin_write_cloning.c
   zip_source_buffer.c
@@ -175,7 +176,9 @@ IF(WIN32)
   ENDIF()
 ELSE(WIN32)
   SET(LIBZIP_OPSYS_FILES
+    zip_mkstempm.c
     zip_source_file.c
+    zip_random_unix.c
   )
 ENDIF(WIN32)
 
@@ -185,17 +188,17 @@ ADD_CUSTOM_TARGET(update_zip_err_str
   COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/make_zip_err_str.sh ${CMAKE_CURRENT_SOURCE_DIR}/zip.h ${CMAKE_CURRENT_SOURCE_DIR}/zip_err_str.c
   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/zip.h ${CMAKE_CURRENT_SOURCE_DIR}/make_zip_err_str.sh
 )
-CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
-IF(NOT HAVE_MKSTEMP)
-  SET(LIBZIP_EXTRA_FILES mkstemp.c)
-ENDIF(NOT HAVE_MKSTEMP)
 IF(HAVE_LIBBZ2)
   SET(LIBZIP_OPTIONAL_FILES zip_algorithm_bzip2.c)
 ENDIF()
 
+IF(HAVE_LIBLZMA)
+  SET(LIBZIP_OPTIONAL_FILES ${LIBZIP_OPTIONAL_FILES} zip_algorithm_xz.c)
+ENDIF()
+
 IF(HAVE_COMMONCRYPTO)
   SET(LIBZIP_OPTIONAL_FILES ${LIBZIP_OPTIONAL_FILES} zip_crypto_commoncrypto.c
-)  
+)
 ELSEIF(HAVE_WINDOWS_CRYPTO)
   SET(LIBZIP_OPTIONAL_FILES ${LIBZIP_OPTIONAL_FILES} zip_crypto_win.c
 )
@@ -218,11 +221,11 @@ ENDIF()
 ADD_LIBRARY(zip ${LIBZIP_SOURCES} ${LIBZIP_EXTRA_FILES} ${LIBZIP_OPTIONAL_FILES} ${LIBZIP_OPSYS_FILES})
 
 IF(SHARED_LIB_VERSIONNING)
-SET_TARGET_PROPERTIES(zip PROPERTIES VERSION 5.0 SOVERSION 5)
+SET_TARGET_PROPERTIES(zip PROPERTIES VERSION 5.1 SOVERSION 5)
 ENDIF()
 
 
-TARGET_LINK_LIBRARIES(zip ${ZLIB_LIBRARY} ${OPTIONAL_LIBRARY})
+TARGET_LINK_LIBRARIES(zip PRIVATE ${ZLIB_LIBRARIES} ${OPTIONAL_LIBRARY})
 INSTALL(TARGETS zip
   RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
   ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
index 79f94db..2f05bf0 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
   compat.h -- compatibility defines.
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -77,6 +77,11 @@ typedef char bool;
 #define EOVERFLOW EFBIG
 #endif
 
+/* not supported on at least Windows */
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
 #ifdef _WIN32
 #if defined(HAVE__CHMOD)
 #define chmod _chmod
@@ -116,9 +121,6 @@ typedef char bool;
 #if !defined(HAVE_STRTOULL) && defined(HAVE__STRTOUI64)
 #define strtoull _strtoui64
 #endif
-#if defined(HAVE__UMASK)
-#define umask _umask
-#endif
 #if defined(HAVE__UNLINK)
 #define unlink _unlink
 #endif
@@ -132,11 +134,6 @@ typedef char bool;
 #define ftello(s) ((long)ftell((s)))
 #endif
 
-#ifndef HAVE_MKSTEMP
-int _zip_mkstemp(char *);
-#define mkstemp _zip_mkstemp
-#endif
-
 #if !defined(HAVE_STRCASECMP)
 #if defined(HAVE__STRICMP)
 #define strcasecmp _stricmp
@@ -199,4 +196,8 @@ int _zip_mkstemp(char *);
 #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
 #endif
 
+#ifndef S_ISREG
+#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG)
+#endif
+
 #endif /* compat.h */
diff --git a/lib/mkstemp.c b/lib/mkstemp.c
deleted file mode 100644 (file)
index f18f10b..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/* Adapted from NetBSB libc by Dieter Baron */
-
-/*     NetBSD: gettemp.c,v 1.13 2003/12/05 00:57:36 uebayasi Exp       */
-
-/*
- * Copyright (c) 1987, 1993
- *     The Regents of the University of California.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#ifdef _WIN32
-#include <io.h>
-#include <process.h>
-#else
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-
-int
-_zip_mkstemp(char *path) {
-#ifdef _WIN32
-    int ret;
-    ret = _creat(_mktemp(path), _S_IREAD | _S_IWRITE);
-    if (ret == -1) {
-       return 0;
-    }
-    else {
-       return ret;
-    }
-#else
-    int fd;
-    char *start, *trv;
-    struct stat sbuf;
-    pid_t pid;
-
-    /* To guarantee multiple calls generate unique names even if
-       the file is not created. 676 different possibilities with 7
-       or more X's, 26 with 6 or less. */
-    static char xtra[2] = "aa";
-    int xcnt = 0;
-
-    pid = getpid();
-
-    /* Move to end of path and count trailing X's. */
-    for (trv = path; *trv; ++trv)
-       if (*trv == 'X')
-           xcnt++;
-       else
-           xcnt = 0;
-
-    /* Use at least one from xtra.  Use 2 if more than 6 X's. */
-    if (*(trv - 1) == 'X')
-       *--trv = xtra[0];
-    if (xcnt > 6 && *(trv - 1) == 'X')
-       *--trv = xtra[1];
-
-    /* Set remaining X's to pid digits with 0's to the left. */
-    while (*--trv == 'X') {
-       *trv = (pid % 10) + '0';
-       pid /= 10;
-    }
-
-    /* update xtra for next call. */
-    if (xtra[0] != 'z')
-       xtra[0]++;
-    else {
-       xtra[0] = 'a';
-       if (xtra[1] != 'z')
-           xtra[1]++;
-       else
-           xtra[1] = 'a';
-    }
-
-    /*
-     * check the target directory; if you have six X's and it
-     * doesn't exist this runs for a *very* long time.
-     */
-    for (start = trv + 1;; --trv) {
-       if (trv <= path)
-           break;
-       if (*trv == '/') {
-           *trv = '\0';
-           if (stat(path, &sbuf))
-               return (0);
-           if (!S_ISDIR(sbuf.st_mode)) {
-               errno = ENOTDIR;
-               return (0);
-           }
-           *trv = '/';
-           break;
-       }
-    }
-
-    for (;;) {
-       if ((fd = open(path, O_CREAT | O_EXCL | O_RDWR | O_BINARY, 0600)) >= 0)
-           return (fd);
-       if (errno != EEXIST)
-           return (0);
-
-       /* tricky little algorithm for backward compatibility */
-       for (trv = start;;) {
-           if (!*trv)
-               return (0);
-           if (*trv == 'z')
-               *trv++ = 'a';
-           else {
-               if (isdigit((unsigned char)*trv))
-                   *trv = 'a';
-               else
-                   ++*trv;
-               break;
-           }
-       }
-    }
-    /*NOTREACHED*/
-#endif
-}
index 42c3e14..b0d1493 100644 (file)
--- a/lib/zip.h
+++ b/lib/zip.h
@@ -3,7 +3,7 @@
 
 /*
   zip.h -- exported declarations.
-  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -134,6 +134,7 @@ extern "C" {
 #define ZIP_ER_INUSE 29           /* N Resource still in use */
 #define ZIP_ER_TELL 30            /* S Tell error */
 #define ZIP_ER_COMPRESSED_DATA 31 /* N Compressed data invalid */
+#define ZIP_ER_CANCELLED 32       /* N Operation cancelled */
 
 /* type of system error value */
 
@@ -162,6 +163,7 @@ extern "C" {
 /* 15-17 - Reserved by PKWARE */
 #define ZIP_CM_TERSE 18   /* compressed using IBM TERSE (new) */
 #define ZIP_CM_LZ77 19    /* IBM LZ77 z Architecture (PFS) */
+#define ZIP_CM_LZMA2 33
 #define ZIP_CM_XZ 95      /* XZ compressed data */
 #define ZIP_CM_JPEG 96    /* Compressed Jpeg data */
 #define ZIP_CM_WAVPACK 97 /* WavPack compressed data */
@@ -229,7 +231,8 @@ enum zip_source_cmd {
     ZIP_SOURCE_SUPPORTS,              /* check whether source supports command */
     ZIP_SOURCE_REMOVE,                /* remove file */
     ZIP_SOURCE_GET_COMPRESSION_FLAGS, /* get compression flags, internal only */
-    ZIP_SOURCE_BEGIN_WRITE_CLONING    /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */
+    ZIP_SOURCE_BEGIN_WRITE_CLONING,   /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */
+    ZIP_SOURCE_ACCEPT_EMPTY           /* whether empty files are valid archives */
 };
 typedef enum zip_source_cmd zip_source_cmd_t;
 
@@ -321,6 +324,7 @@ typedef zip_uint32_t zip_flags_t;
 
 typedef zip_int64_t (*zip_source_callback)(void * _Nullable, void * _Nullable, zip_uint64_t, zip_source_cmd_t);
 typedef void (*zip_progress_callback)(zip_t * _Nonnull, double, void * _Nullable);
+typedef int (*zip_cancel_callback)(zip_t * _Nonnull, void * _Nullable);
 
 #ifndef ZIP_DISABLE_DEPRECATED
 typedef void (*zip_progress_callback_t)(double);
@@ -373,6 +377,7 @@ ZIP_EXTERN int zip_file_get_external_attributes(zip_t * _Nonnull, zip_uint64_t,
 ZIP_EXTERN int zip_file_rename(zip_t * _Nonnull, zip_uint64_t, const char * _Nonnull, zip_flags_t);
 ZIP_EXTERN int zip_file_replace(zip_t * _Nonnull, zip_uint64_t, zip_source_t * _Nonnull, zip_flags_t);
 ZIP_EXTERN int zip_file_set_comment(zip_t * _Nonnull, zip_uint64_t, const char * _Nullable, zip_uint16_t, zip_flags_t);
+ZIP_EXTERN int zip_file_set_dostime(zip_t * _Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t);
 ZIP_EXTERN int zip_file_set_encryption(zip_t * _Nonnull, zip_uint64_t, zip_uint16_t, const char * _Nullable);
 ZIP_EXTERN int zip_file_set_external_attributes(zip_t * _Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t);
 ZIP_EXTERN int zip_file_set_mtime(zip_t * _Nonnull, zip_uint64_t, time_t, zip_flags_t);
@@ -393,6 +398,7 @@ ZIP_EXTERN zip_int64_t zip_name_locate(zip_t * _Nonnull, const char * _Nonnull,
 ZIP_EXTERN zip_t * _Nullable zip_open(const char * _Nonnull, int, int * _Nullable);
 ZIP_EXTERN zip_t * _Nullable zip_open_from_source(zip_source_t * _Nonnull, int, zip_error_t * _Nullable);
 ZIP_EXTERN int zip_register_progress_callback_with_state(zip_t * _Nonnull, double, zip_progress_callback _Nullable, void (* _Nullable)(void * _Nullable), void * _Nullable);
+ZIP_EXTERN int zip_register_cancel_callback_with_state(zip_t * _Nonnull, zip_cancel_callback _Nullable, void (* _Nullable)(void * _Nullable), void * _Nullable);
 ZIP_EXTERN int zip_set_archive_comment(zip_t * _Nonnull, const char * _Nullable, zip_uint16_t);
 ZIP_EXTERN int zip_set_archive_flag(zip_t * _Nonnull, zip_flags_t, int);
 ZIP_EXTERN int zip_set_default_password(zip_t * _Nonnull, const char * _Nullable);
@@ -402,7 +408,7 @@ ZIP_EXTERN int zip_source_begin_write_cloning(zip_source_t * _Nonnull, zip_uint6
 ZIP_EXTERN zip_source_t * _Nullable zip_source_buffer(zip_t * _Nonnull, const void * _Nullable, zip_uint64_t, int);
 ZIP_EXTERN zip_source_t * _Nullable zip_source_buffer_create(const void * _Nullable, zip_uint64_t, int, zip_error_t * _Nullable);
 ZIP_EXTERN zip_source_t * _Nullable zip_source_buffer_fragment(zip_t * _Nonnull, const zip_buffer_fragment_t * _Nonnull, zip_uint64_t, int);
-ZIP_EXTERN zip_source_t * _Nullable zip_source_buffer_fragment_create(const zip_buffer_fragment_t * _Nonnull, zip_uint64_t, int, zip_error_t * _Nullable);
+ZIP_EXTERN zip_source_t * _Nullable zip_source_buffer_fragment_create(const zip_buffer_fragment_t * _Nullable, zip_uint64_t, int, zip_error_t * _Nullable);
 ZIP_EXTERN int zip_source_close(zip_source_t * _Nonnull);
 ZIP_EXTERN int zip_source_commit_write(zip_source_t * _Nonnull);
 ZIP_EXTERN zip_error_t * _Nonnull zip_source_error(zip_source_t * _Nonnull);
index f09c9ff..1954235 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_add.c -- add file via callback function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 6beb929..88fcf53 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_add_dir.c -- add directory
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 45def7a..f52e0b5 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_add_entry.c -- create and init struct zip_entry
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 72fbad1..df4aeb6 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_algorithm_bzip2.c -- bzip2 (de)compression routines
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index ba5ad43..30e072a 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_algorithm_deflate.c -- deflate (de)compression routines
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -51,6 +51,7 @@ allocate(bool compress, int compression_flags, zip_error_t *error) {
     struct ctx *ctx;
 
     if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) {
+       zip_error_set(error, ZIP_ET_SYS, errno);
        return NULL;
     }
 
diff --git a/lib/zip_algorithm_xz.c b/lib/zip_algorithm_xz.c
new file mode 100644 (file)
index 0000000..6dd14ce
--- /dev/null
@@ -0,0 +1,240 @@
+/*
+  zip_algorithm_xz.c      -- XZ (de)compression routines
+  Bazed on zip_algorithm_deflate.c -- deflate (de)compression routines
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
+
+  This file is part of libzip, a library to manipulate ZIP archives.
+  The authors can be contacted at <libzip@nih.at>
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+  3. The names of the authors may not be used to endorse or promote
+     products derived from this software without specific prior
+     written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "zipint.h"
+
+#include <limits.h>
+#include <stdlib.h>
+#include <lzma.h>
+
+struct ctx {
+    zip_error_t *error;
+    bool compress;
+    int compression_flags;
+    bool end_of_input;
+    lzma_stream zstr;
+    zip_uint16_t method;
+};
+
+
+static void *
+allocate(bool compress, int compression_flags, zip_error_t *error, zip_uint16_t method) {
+    struct ctx *ctx;
+
+    if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) {
+       zip_error_set(error, ZIP_ET_SYS, errno);
+       return NULL;
+    }
+
+    ctx->error = error;
+    ctx->compress = compress;
+    ctx->compression_flags = compression_flags;
+    ctx->compression_flags |= LZMA_PRESET_EXTREME;
+    ctx->end_of_input = false;
+    memset(&ctx->zstr, 0, sizeof(ctx->zstr));
+    ctx->method = method;
+    return ctx;
+}
+
+
+static void *
+compress_allocate(zip_uint16_t method, int compression_flags, zip_error_t *error) {
+    return allocate(true, compression_flags, error, method);
+}
+
+
+static void *
+decompress_allocate(zip_uint16_t method, int compression_flags, zip_error_t *error) {
+    return allocate(false, compression_flags, error, method);
+}
+
+
+static void
+deallocate(void *ud) {
+    struct ctx *ctx = (struct ctx *)ud;
+    free(ctx);
+}
+
+
+static int
+compression_flags(void *ud) {
+    /* struct ctx *ctx = (struct ctx *)ud; */
+    return 0;
+}
+
+static int
+map_error(lzma_ret ret) {
+    switch (ret) {
+      case LZMA_UNSUPPORTED_CHECK:
+        return ZIP_ER_COMPRESSED_DATA;
+
+      case LZMA_MEM_ERROR:
+        return ZIP_ER_MEMORY;
+
+      case LZMA_OPTIONS_ERROR:
+        return ZIP_ER_INVAL;
+
+      default:
+        return ZIP_ER_INTERNAL;
+    }
+}
+
+
+static bool
+start(void *ud) {
+    struct ctx *ctx = (struct ctx *)ud;
+    lzma_ret ret;
+
+    lzma_options_lzma opt_lzma;
+    lzma_lzma_preset(&opt_lzma, ctx->compression_flags);
+    lzma_filter filters[] = {
+      { .id = (ctx->method == ZIP_CM_LZMA ? LZMA_FILTER_LZMA1 : LZMA_FILTER_LZMA2), .options = &opt_lzma},
+      { .id = LZMA_VLI_UNKNOWN, .options = NULL },
+    };
+
+    ctx->zstr.avail_in = 0;
+    ctx->zstr.next_in = NULL;
+    ctx->zstr.avail_out = 0;
+    ctx->zstr.next_out = NULL;
+
+    if (ctx->compress) {
+      if (ctx->method == ZIP_CM_LZMA)
+        ret = lzma_alone_encoder(&ctx->zstr, filters[0].options);
+      else
+        ret = lzma_stream_encoder(&ctx->zstr, filters, LZMA_CHECK_CRC64);
+    } else {
+     if (ctx->method == ZIP_CM_LZMA)
+       ret = lzma_alone_decoder(&ctx->zstr, UINT64_MAX);
+     else
+      ret = lzma_stream_decoder(&ctx->zstr, UINT64_MAX, LZMA_CONCATENATED);
+    }
+
+    if (ret != LZMA_OK) {
+      zip_error_set(ctx->error, map_error(ret), 0);
+      return false;
+    }
+
+    return true;
+}
+
+
+static bool
+end(void *ud) {
+    struct ctx *ctx = (struct ctx *)ud;
+
+    lzma_end(&ctx->zstr);
+    return true;
+}
+
+
+static bool
+input(void *ud, zip_uint8_t *data, zip_uint64_t length) {
+    struct ctx *ctx = (struct ctx *)ud;
+
+    if (length > UINT_MAX || ctx->zstr.avail_in > 0) {
+      zip_error_set(ctx->error, ZIP_ER_INVAL, 0);
+      return false;
+    }
+
+    ctx->zstr.avail_in = (uInt)length;
+    ctx->zstr.next_in = (Bytef *)data;
+
+    return true;
+}
+
+
+static void
+end_of_input(void *ud) {
+    struct ctx *ctx = (struct ctx *)ud;
+
+    ctx->end_of_input = true;
+}
+
+
+static zip_compression_status_t
+process(void *ud, zip_uint8_t *data, zip_uint64_t *length) {
+    struct ctx *ctx = (struct ctx *)ud;
+    lzma_ret ret;
+
+    ctx->zstr.avail_out = (uInt)ZIP_MIN(UINT_MAX, *length);
+    ctx->zstr.next_out = (Bytef *)data;
+
+    ret = lzma_code(&ctx->zstr, ctx->end_of_input ? LZMA_FINISH : LZMA_RUN);
+    *length = *length - ctx->zstr.avail_out;
+
+    switch (ret) {
+    case LZMA_OK:
+        return ZIP_COMPRESSION_OK;
+
+    case LZMA_STREAM_END:
+        return ZIP_COMPRESSION_END;
+
+    case LZMA_BUF_ERROR:
+       if (ctx->zstr.avail_in == 0) {
+           return ZIP_COMPRESSION_NEED_DATA;
+       }
+
+       /* fallthrough */
+    default:
+       zip_error_set(ctx->error, map_error(ret), 0);
+       return ZIP_COMPRESSION_ERROR;
+    }
+}
+
+// clang-format off
+
+zip_compression_algorithm_t zip_algorithm_xz_compress = {
+    compress_allocate,
+    deallocate,
+    compression_flags,
+    start,
+    end,
+    input,
+    end_of_input,
+    process
+};
+
+
+zip_compression_algorithm_t zip_algorithm_xz_decompress = {
+    decompress_allocate,
+    deallocate,
+    compression_flags,
+    start,
+    end,
+    input,
+    end_of_input,
+    process
+};
+
+// clang-format on
index 37977f0..8c24b27 100644 (file)
@@ -1,6 +1,6 @@
 /*
  zip_buffer.c -- bounds checked access to memory buffer
- Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
index 2657226..2a9fed2 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_close.c -- close zip archive and update changes
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -73,8 +73,10 @@ zip_close(zip_t *za) {
     if (survivors == 0) {
        if ((za->open_flags & ZIP_TRUNCATE) || changed) {
            if (zip_source_remove(za->src) < 0) {
-               _zip_error_set_from_source(&za->error, za->src);
-               return -1;
+               if (!((zip_error_code_zip(zip_source_error(za->src)) == ZIP_ER_REMOVE) && (zip_error_code_system(zip_source_error(za->src)) == ENOENT))) {
+                   _zip_error_set_from_source(&za->error, za->src);
+                   return -1;
+               }
            }
        }
        zip_discard(za);
@@ -158,14 +160,23 @@ zip_close(zip_t *za) {
        }
     }
 
-    _zip_progress_start(za->progress);
+    if (_zip_progress_start(za->progress) != 0) {
+       zip_error_set(&za->error, ZIP_ER_CANCELLED, 0);
+       zip_source_rollback_write(za->src);
+       free(filelist);
+       return -1;
+    }
     error = 0;
     for (j = 0; j < survivors; j++) {
        int new_data;
        zip_entry_t *entry;
        zip_dirent_t *de;
 
-       _zip_progress_subrange(za->progress, (double)j / (double)survivors, (double)(j + 1) / (double)survivors);
+       if (_zip_progress_subrange(za->progress, (double)j / (double)survivors, (double)(j + 1) / (double)survivors) != 0) {
+           zip_error_set(&za->error, ZIP_ER_CANCELLED, 0);
+           error = 1;
+           break;
+       }
 
        i = filelist[j].idx;
        entry = za->entry + i;
@@ -256,10 +267,9 @@ zip_close(zip_t *za) {
            _zip_error_set_from_source(&za->error, za->src);
            error = 1;
        }
+       _zip_progress_end(za->progress);
     }
 
-    _zip_progress_end(za->progress);
-
     if (error) {
        zip_source_rollback_write(za->src);
        return -1;
@@ -543,7 +553,10 @@ copy_data(zip_t *za, zip_uint64_t len) {
 
        len -= n;
 
-       _zip_progress_update(za->progress, (total - (double)len) / total);
+       if (_zip_progress_update(za->progress, (total - (double)len) / total) != 0) {
+           zip_error_set(&za->error, ZIP_ER_CANCELLED, 0);
+           return -1;
+       }
     }
 
     byte_array_fini(buf);
@@ -576,7 +589,11 @@ copy_source(zip_t *za, zip_source_t *src, zip_int64_t data_length) {
        }
        if (n == BUFSIZE && za->progress && data_length > 0) {
            current += n;
-           _zip_progress_update(za->progress, (double)current / (double)data_length);
+           if (_zip_progress_update(za->progress, (double)current / (double)data_length) != 0) {
+               zip_error_set(&za->error, ZIP_ER_CANCELLED, 0);
+               ret = -1;
+               break;
+           }
        }
     }
 
index 585de21..f46c7d8 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto.h -- crypto definitions
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 10f7700..2d57bd4 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_commoncrypto.c -- CommonCrypto wrapper.
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -108,21 +108,3 @@ _zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_
 
     return hmac;
 }
-
-
-ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
-    int fd;
-
-    if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
-       return false;
-    }
-
-    if (read(fd, buffer, length) != length) {
-       close(fd);
-       return false;
-    }
-
-    close(fd);
-    return true;
-}
index 9184867..9f9e991 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_gnutls.c -- GnuTLS wrapper.
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -130,6 +130,6 @@ _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac) {
 
 
 ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     return gnutls_rnd(GNUTLS_RND_KEY, buffer, length) == 0;
 }
index 40d34a5..484ddbb 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_gnutls.h -- definitions for GnuTLS wrapper.
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
 #ifndef HAD_ZIP_CRYPTO_GNUTLS_H
 #define HAD_ZIP_CRYPTO_GNUTLS_H
 
+#define HAVE_SECURE_RANDOM
+
 #include <nettle/aes.h>
 #include <nettle/pbkdf2.h>
 
-#include <gnutls/crypto.h>
 #include <gnutls/gnutls.h>
+#include <gnutls/crypto.h>
 
 typedef struct {
     union {
index 8e74fbc..f0049ea 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_mbedtls.c -- mbed TLS wrapper
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -136,7 +136,7 @@ typedef struct {
 } zip_random_context_t;
 
 ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     static zip_random_context_t *ctx = NULL;
     const unsigned char *pers = "zip_crypto_mbedtls";
 
index af22d5b..7381951 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_mbedtls.h -- definitions for mbedtls wrapper
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -34,6 +34,8 @@
 #ifndef HAD_ZIP_CRYPTO_MBEDTLS_H
 #define HAD_ZIP_CRYPTO_MBEDTLS_H
 
+#define HAVE_SECURE_RANDOM
+
 #include <mbedtls/aes.h>
 #include <mbedtls/md.h>
 
index a1766bf..1cb0047 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_openssl.c -- OpenSSL wrapper.
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -131,6 +131,6 @@ _zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data) {
 
 
 ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     return RAND_bytes(buffer, length) == 1;
 }
index 906890e..51bd4ed 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_openssl.h -- definitions for OpenSSL wrapper.
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -34,6 +34,8 @@
 #ifndef HAD_ZIP_CRYPTO_OPENSSL_H
 #define HAD_ZIP_CRYPTO_OPENSSL_H
 
+#define HAVE_SECURE_RANDOM
+
 #include <openssl/aes.h>
 #include <openssl/hmac.h>
 
index a596540..97727ad 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_win.c -- Windows Crypto API wrapper.
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -39,7 +39,7 @@
 #define WIN32_LEAN_AND_MEAN
 #define NOCRYPT
 
-#include <Windows.h>
+#include <windows.h>
 #include <bcrypt.h>
 
 #pragma comment(lib, "bcrypt.lib")
@@ -159,6 +159,9 @@ hmacInit(PRF_CTX *pContext, PUCHAR pbPassword, DWORD cbPassword) {
     if (cbPassword > BLOCK_SIZE) {
        BCRYPT_HASH_HANDLE hHash = NULL;
        PUCHAR pbHashObject = malloc(pContext->cbHashObject);
+       if (pbHashObject == NULL) {
+           goto hmacInit_end;
+       }
 
        bStatus = BCRYPT_SUCCESS(BCryptCreateHash(pContext->hAlgorithm, &hHash, pbHashObject, pContext->cbHashObject, NULL, 0, 0)) && BCRYPT_SUCCESS(BCryptHashData(hHash, pbPassword, cbPassword, 0)) && BCRYPT_SUCCESS(BCryptGetProperty(hHash, BCRYPT_HASH_LENGTH, (PUCHAR)&cbPassword, sizeof(cbPassword), &cbResult, 0)) && BCRYPT_SUCCESS(BCryptFinishHash(hHash, key, cbPassword, 0));
 
@@ -189,6 +192,10 @@ hmacCalculateInternal(BCRYPT_HASH_HANDLE hHashTemplate, PUCHAR pbData, DWORD cbD
     BCRYPT_HASH_HANDLE hHash = NULL;
     PUCHAR pbHashObject = malloc(cbHashObject);
 
+    if (pbHashObject == NULL) {
+       return FALSE;
+    }
+
     if (BCRYPT_SUCCESS(BCryptDuplicateHash(hHashTemplate, &hHash, pbHashObject, cbHashObject, 0))) {
        success = BCRYPT_SUCCESS(BCryptHashData(hHash, pbData, cbData, 0)) && BCRYPT_SUCCESS(BCryptFinishHash(hHash, pbOutput, cbOutput, 0));
 
@@ -208,13 +215,14 @@ hmacCalculate(PRF_CTX *pContext, PUCHAR pbData, DWORD cbData, PUCHAR pbDigest) {
     return BCRYPT_SUCCESS(BCryptGetProperty(pContext->hAlgorithm, BCRYPT_OBJECT_LENGTH, (PUCHAR)&cbHashObject, sizeof(cbHashObject), &cbResult, 0)) && hmacCalculateInternal(pContext->hInnerHash, pbData, cbData, pbDigest, DIGEST_SIZE, cbHashObject) && hmacCalculateInternal(pContext->hOuterHash, pbDigest, DIGEST_SIZE, pbDigest, DIGEST_SIZE, cbHashObject);
 }
 
-static void xor
-    (LPBYTE ptr1, LPBYTE ptr2, DWORD dwLen) {
-       while (dwLen--)
-           *ptr1++ ^= *ptr2++;
-    }
+static void
+xor(LPBYTE ptr1, LPBYTE ptr2, DWORD dwLen) {
+    while (dwLen--)
+       *ptr1++ ^= *ptr2++;
+}
 
-    BOOL pbkdf2(PUCHAR pbPassword, ULONG cbPassword, PUCHAR pbSalt, ULONG cbSalt, DWORD cIterations, PUCHAR pbDerivedKey, ULONG cbDerivedKey) {
+BOOL
+pbkdf2(PUCHAR pbPassword, ULONG cbPassword, PUCHAR pbSalt, ULONG cbSalt, DWORD cIterations, PUCHAR pbDerivedKey, ULONG cbDerivedKey) {
     BOOL bStatus = FALSE;
     DWORD l, r, dwULen, i, j;
     BYTE Ti[DIGEST_SIZE];
@@ -222,6 +230,10 @@ static void xor
     LPBYTE U = malloc(max((cbSalt + 4), DIGEST_SIZE));
     PRF_CTX prfCtx = {0};
 
+    if (U == NULL) {
+       return FALSE;
+    }
+
     if (pbPassword == NULL || cbPassword == 0 || pbSalt == NULL || cbSalt == 0 || cIterations == 0 || pbDerivedKey == NULL || cbDerivedKey == 0) {
        free(U);
        return FALSE;
@@ -319,6 +331,11 @@ _zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *
     }
 
     aes->pbKeyObject = malloc(aes->cbKeyObject);
+    if (aes->pbKeyObject == NULL) {
+       _zip_crypto_aes_free(aes);
+       zip_error_set(error, ZIP_ER_MEMORY, 0);
+       return NULL;
+    }
 
     if (!BCRYPT_SUCCESS(BCryptGenerateSymmetricKey(aes->hAlgorithm, &aes->hKey, aes->pbKeyObject, aes->cbKeyObject, (PUCHAR)key, key_length, 0))) {
        _zip_crypto_aes_free(aes);
@@ -398,6 +415,11 @@ _zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_
     }
 
     hmac->pbHashObject = malloc(hmac->cbHashObject);
+    if (hmac->pbHashObject == NULL) {
+       _zip_crypto_hmac_free(hmac);
+       zip_error_set(error, ZIP_ER_MEMORY, 0);
+       return NULL;
+    }
 
     status = BCryptGetProperty(hmac->hAlgorithm, BCRYPT_HASH_LENGTH, (PUCHAR)&hmac->cbHash, sizeof(hmac->cbHash), &cbResult, 0);
     if (!BCRYPT_SUCCESS(status)) {
@@ -406,6 +428,11 @@ _zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_
     }
 
     hmac->pbHash = malloc(hmac->cbHash);
+    if (hmac->pbHash == NULL) {
+       _zip_crypto_hmac_free(hmac);
+       zip_error_set(error, ZIP_ER_MEMORY, 0);
+       return NULL;
+    }
 
     status = BCryptCreateHash(hmac->hAlgorithm, &hmac->hHash, hmac->pbHashObject, hmac->cbHashObject, (PUCHAR)secret, (ULONG)secret_length, 0);
     if (!BCRYPT_SUCCESS(status)) {
@@ -460,6 +487,6 @@ _zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data) {
 }
 
 ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     return BCRYPT_SUCCESS(BCryptGenRandom(NULL, buffer, length, BCRYPT_USE_SYSTEM_PREFERRED_RNG));
 }
index 9a239af..d5c22a9 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_crypto_win.h -- Windows Crypto API wrapper.
-  Copyright (C) 2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2018-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -34,6 +34,8 @@
 #ifndef HAD_ZIP_CRYPTO_WIN_H
 #define HAD_ZIP_CRYPTO_WIN_H
 
+#define HAVE_SECURE_RANDOM
+
 typedef struct _zip_crypto_aes_s _zip_crypto_aes_t;
 typedef struct _zip_crypto_hmac_s _zip_crypto_hmac_t;
 
index 458a1b8..97701a0 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_delete.c -- delete file from zip archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 46c76cf..c40b1cb 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_dir_add.c -- add directory
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 4dcb339..2bbb63d 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_dirent.c -- read directory entry (local or central), clean dirent
-  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -41,7 +41,6 @@
 
 #include "zipint.h"
 
-static time_t _zip_d2u_time(zip_uint16_t, zip_uint16_t);
 static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str);
 static zip_extra_field_t *_zip_ef_utf8(zip_uint16_t, zip_string_t *, zip_error_t *);
 static bool _zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error);
@@ -978,7 +977,7 @@ _zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags) {
 }
 
 
-static time_t
+time_t
 _zip_d2u_time(zip_uint16_t dtime, zip_uint16_t ddate) {
     struct tm tm;
 
@@ -1066,21 +1065,26 @@ _zip_get_dirent(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *err
 
 void
 _zip_u2d_time(time_t intime, zip_uint16_t *dtime, zip_uint16_t *ddate) {
-    struct tm *tm;
+    struct tm *tpm;
 
-    tm = localtime(&intime);
-    if (tm == NULL) {
+#ifdef HAVE_LOCALTIME_R
+    struct tm tm;
+    tpm = localtime_r(&intime, &tm);
+#else
+    tpm = localtime(&intime);
+#endif
+    if (tpm == NULL) {
         /* if localtime() fails, return an arbitrary date (1980-01-01 00:00:00) */
        *ddate = (1 << 5) + 1;
        *dtime = 0;
        return;
     }
-    if (tm->tm_year < 80) {
-       tm->tm_year = 80;
+    if (tpm->tm_year < 80) {
+       tpm->tm_year = 80;
     }
 
-    *ddate = (zip_uint16_t)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday);
-    *dtime = (zip_uint16_t)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1));
+    *ddate = (zip_uint16_t)(((tpm->tm_year + 1900 - 1980) << 9) + ((tpm->tm_mon + 1) << 5) + tpm->tm_mday);
+    *dtime = (zip_uint16_t)(((tpm->tm_hour) << 11) + ((tpm->tm_min) << 5) + ((tpm->tm_sec) >> 1));
 
     return;
 }
index 94972cf..12f0636 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_discard.c -- discard and free struct zip
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 55f6458..52ecaef 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_entry.c -- struct zip_entry helper functions
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 3d9ee54..e0a04a9 100644 (file)
@@ -5,16 +5,80 @@
 
 #include "zipint.h"
 
-const char *const _zip_err_str[] = {
-    "No error", "Multi-disk zip archives not supported", "Renaming temporary file failed", "Closing zip archive failed", "Seek error", "Read error", "Write error", "CRC error", "Containing zip archive was closed", "No such file", "File already exists", "Can't open file", "Failure to create temporary file", "Zlib error", "Malloc failure", "Entry has been changed", "Compression method not supported", "Premature end of file", "Invalid argument", "Not a zip archive", "Internal error", "Zip archive inconsistent", "Can't remove file", "Entry has been deleted", "Encryption method not supported", "Read-only archive", "No password provided", "Wrong password provided", "Operation not supported", "Resource still in use", "Tell error", "Compressed data invalid",
+const char * const _zip_err_str[] = {
+    "No error",
+    "Multi-disk zip archives not supported",
+    "Renaming temporary file failed",
+    "Closing zip archive failed",
+    "Seek error",
+    "Read error",
+    "Write error",
+    "CRC error",
+    "Containing zip archive was closed",
+    "No such file",
+    "File already exists",
+    "Can't open file",
+    "Failure to create temporary file",
+    "Zlib error",
+    "Malloc failure",
+    "Entry has been changed",
+    "Compression method not supported",
+    "Premature end of file",
+    "Invalid argument",
+    "Not a zip archive",
+    "Internal error",
+    "Zip archive inconsistent",
+    "Can't remove file",
+    "Entry has been deleted",
+    "Encryption method not supported",
+    "Read-only archive",
+    "No password provided",
+    "Wrong password provided",
+    "Operation not supported",
+    "Resource still in use",
+    "Tell error",
+    "Compressed data invalid",
+    "Operation cancelled",
 };
 
-const int _zip_nerr_str = sizeof(_zip_err_str) / sizeof(_zip_err_str[0]);
+const int _zip_nerr_str = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
 
 #define N ZIP_ET_NONE
 #define S ZIP_ET_SYS
 #define Z ZIP_ET_ZLIB
 
 const int _zip_err_type[] = {
-    N, N, S, S, S, S, S, N, N, N, N, S, S, Z, N, N, N, N, N, N, N, N, S, N, N, N, N, N, N, N, S, N,
+    N,
+    N,
+    S,
+    S,
+    S,
+    S,
+    S,
+    N,
+    N,
+    N,
+    N,
+    S,
+    S,
+    Z,
+    N,
+    N,
+    N,
+    N,
+    N,
+    N,
+    N,
+    N,
+    S,
+    N,
+    N,
+    N,
+    N,
+    N,
+    N,
+    N,
+    S,
+    N,
+    N,
 };
index e05ae50..a0f74f0 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_error.c -- zip_error_t helper functions
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 6b3a8da..eec1568 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_error_clear.c -- clear zip error
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 12341d1..9588b4c 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_error_get.c -- get zip error
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 80bfc0c..3dfe5c2 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_error_get_sys_type.c -- return type of system error code
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 0f650b5..6358577 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_error_sterror.c -- get string representation of struct zip_error
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index bf51569..13faf96 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_error_to_str.c -- get string representation of zip error code
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index a17e491..7114a25 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_extra_field.c -- manipulate extra fields
-  Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 31808de..605f95d 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_extra_field_api.c -- public extra fields API functions
-  Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 1c69a96..6eb9dc9 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fclose.c -- close file in zip archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 3270935..5a732cd 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fdopen.c -- open read-only archive from file descriptor
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index c2c13d6..c019d8d 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_add.c -- add file via callback function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 2e7dcea..47e5da6 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_error_clear.c -- clear zip file error
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 1d13807..1ed68df 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_error_get.c -- get zip file error
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index ad944aa..8f68141 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_get_comment.c -- get file comment
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index e2e5535..ebc2058 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_get_external_attributes.c -- get opsys/external attributes
-  Copyright (C) 2013-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2013-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 858a78a..9ea8909 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_get_offset.c -- get offset of file data in archive.
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index cc42dfc..7ca428c 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_rename.c -- rename file in zip archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 70b379a..87401f4 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_replace.c -- replace file via callback function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index ae6b602..c309db8 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_set_comment.c -- set comment for file in archive
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 7e7a9b1..a66a1b5 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_set_encryption.c -- set encryption for file in archive
-  Copyright (C) 2016-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2016-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index c412f27..bb2ea61 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_set_external_attributes.c -- set external attributes for entry
-  Copyright (C) 2013-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2013-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index f8d6c20..838548e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  zip_file_set_mtime.c -- set modification time of entry.
- Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
 #include "zipint.h"
 
 ZIP_EXTERN int
+zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
+    time_t mtime;
+    mtime = _zip_d2u_time(dtime, ddate);
+    return zip_file_set_mtime(za, idx, mtime, flags);
+}
+
+ZIP_EXTERN int
 zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) {
     zip_entry_t *e;
-    int changed;
 
     if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
        return -1;
@@ -48,27 +54,15 @@ zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags)
 
     e = za->entry + idx;
 
-    changed = e->orig == NULL || mtime != e->orig->last_mod;
-
-    if (changed) {
-       if (e->changes == NULL) {
-           if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
-               zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
-               return -1;
-           }
-       }
-       e->changes->last_mod = mtime;
-       e->changes->changed |= ZIP_DIRENT_LAST_MOD;
-    }
-    else {
-       if (e->changes) {
-           e->changes->changed &= ~ZIP_DIRENT_LAST_MOD;
-           if (e->changes->changed == 0) {
-               _zip_dirent_free(e->changes);
-               e->changes = NULL;
-           }
+    if (e->changes == NULL) {
+       if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) {
+           zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
+           return -1;
        }
     }
 
+    e->changes->last_mod = mtime;
+    e->changes->changed |= ZIP_DIRENT_LAST_MOD;
+
     return 0;
 }
index 189c556..1fa7fff 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_file_sterror.c -- get string representation of zip file error
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 33bf5d8..b887363 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_filerange_crc.c -- compute CRC32 for a range of a file
-  Copyright (C) 2008-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2008-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 4ef76ba..4f1a051 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fopen.c -- open file in zip archive for reading
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 47cd377..9e9b13e 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fopen_encrypted.c -- open file for reading with password
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 5f0dc2a..ffca281 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fopen_index.c -- open file in zip archive for reading by index
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 4d4aee3..6712c32 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fopen_index_encrypted.c -- open file for reading by index w/ password
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 3020a16..646d712 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fread.c -- read from file
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 3557401..86d3865 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_fseek.c -- seek in file
-  Copyright (C) 2016-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2016-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index f4e4550..9502dd6 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_ftell.c -- tell position in file
-  Copyright (C) 2016-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2016-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index c51148d..953c6f4 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_archive_comment.c -- get archive comment
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 1aaca72..fa4dd50 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_archive_flag.c -- get archive global flag
-  Copyright (C) 2008-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2008-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 07e4316..c9d52ad 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_encryption_implementation.c -- get encryption implementation
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 6e85a58..f800686 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_file_comment.c -- get file comment
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 2ac005a..4344209 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_name.c -- get filename for a file in zip file
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 99dfc7a..410d26e 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_num_entries.c -- get number of entries in archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index b6e910e..4895eaa 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_num_files.c -- get number of files in archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 7288453..3206dbf 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_hash.c -- hash table string -> uint64
-  Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 53f4437..dd07cbb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  zip_io_util.c -- I/O helper functions
- Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
index c6787a9..fadbc69 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_libzip_version.c -- return run-time version of library
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index d604408..05fcb7b 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_memdup.c -- internal zip function, "strdup" with len
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
diff --git a/lib/zip_mkstempm.c b/lib/zip_mkstempm.c
new file mode 100644 (file)
index 0000000..a38ba61
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+  zip_mkstempm.c -- mkstemp replacement that accepts a mode argument
+  Copyright (C) 2019 Dieter Baron and Thomas Klausner
+
+  This file is part of libzip, a library to manipulate ZIP archives.
+  The authors can be contacted at <libzip@nih.at>
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+  3. The names of the authors may not be used to endorse or promote
+     products derived from this software without specific prior
+     written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include <sys/stat.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "zipint.h"
+
+/*
+ * create temporary file with same permissions as previous one;
+ * or default permissions if there is no previous file
+ */
+int
+_zip_mkstempm(char *path, int mode) {
+    int fd;
+    char *start, *end, *xs;
+
+    int xcnt = 0;
+
+    end = path + strlen(path);
+    start = end - 1;
+    while (start >= path && *start == 'X') {
+       xcnt++;
+       start--;
+    }
+
+    if (xcnt == 0) {
+       errno = EINVAL;
+       return -1;
+    }
+
+    start++;
+
+    for (;;) {
+        zip_uint32_t value = zip_random_uint32();
+
+       xs = start;
+
+       while (xs < end) {
+            char digit = value % 36;
+            if (digit < 10) {
+                *(xs++) = digit + '0';
+            }
+            else {
+                *(xs++) = digit - 10 + 'a';
+            }
+           value /= 36;
+       }
+
+       if ((fd = open(path, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, mode == -1 ? 0666 : (mode_t)mode)) >= 0) {
+           if (mode != -1) {
+               /* open() honors umask(), which we don't want in this case */
+               (void)chmod(path, (mode_t)mode);
+           }
+           return fd;
+       }
+       if (errno != EEXIST) {
+           return -1;
+       }
+    }
+}
index 37b1ffe..f7318ec 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_name_locate.c -- get index by name
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 1cd614d..4f58ecc 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_new.c -- create and init struct zip
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 593bfde..4e29c5b 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_open.c -- open zip archive by name
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -43,8 +43,7 @@
 typedef enum {
     EXISTS_ERROR = -1,
     EXISTS_NOT = 0,
-    EXISTS_EMPTY,
-    EXISTS_NONEMPTY,
+    EXISTS_OK
 } exists_t;
 static zip_t *_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error);
 static zip_int64_t _zip_checkcons(zip_t *za, zip_cdir_t *cdir, zip_error_t *error);
@@ -174,19 +173,16 @@ _zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error) {
     }
     len = st.size;
 
-    /* treat empty files as empty archives */
-    if (len == 0) {
-       if ((za = _zip_allocate_new(src, flags, error)) == NULL) {
-           return NULL;
-       }
-
-       return za;
-    }
 
     if ((za = _zip_allocate_new(src, flags, error)) == NULL) {
        return NULL;
     }
 
+    /* treat empty files as empty archives */
+    if (len == 0 && zip_source_accept_empty(src)) {
+       return za;
+    }
+
     if ((cdir = _zip_find_central_dir(za, len)) == NULL) {
        _zip_error_copy(error, &za->error);
        /* keep src so discard does not get rid of it */
@@ -540,7 +536,7 @@ _zip_file_exists(zip_source_t *src, zip_error_t *error) {
        return EXISTS_ERROR;
     }
 
-    return (st.valid & ZIP_STAT_SIZE) && st.size == 0 ? EXISTS_EMPTY : EXISTS_NONEMPTY;
+    return EXISTS_OK;
 }
 
 
@@ -725,16 +721,19 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse
     eocd_disk = _zip_buffer_get_16(buffer);
     eocd_offset = _zip_buffer_get_64(buffer);
 
-    if (eocd_offset > ZIP_INT64_MAX || eocd_offset + EOCD64LEN < eocd_offset) {
+    /* valid seek value for start of EOCD */
+    if (eocd_offset > ZIP_INT64_MAX) {
        zip_error_set(error, ZIP_ER_SEEK, EFBIG);
        return NULL;
     }
 
+    /* does EOCD fit before EOCD locator? */
     if (eocd_offset + EOCD64LEN > eocdloc_offset + buf_offset) {
        zip_error_set(error, ZIP_ER_INCONS, 0);
        return NULL;
     }
 
+    /* make sure current position of buffer is beginning of EOCD */
     if (eocd_offset >= buf_offset && eocd_offset + EOCD64LEN <= buf_offset + _zip_buffer_size(buffer)) {
        _zip_buffer_set_offset(buffer, eocd_offset - buf_offset);
        free_buffer = false;
@@ -758,8 +757,10 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse
        return NULL;
     }
 
+    /* size of EOCD */
     size = _zip_buffer_get_64(buffer);
 
+    /* is there a hole between EOCD and EOCD locator, or do they overlap? */
     if ((flags & ZIP_CHECKCONS) && size + eocd_offset + 12 != buf_offset + eocdloc_offset) {
        zip_error_set(error, ZIP_ER_INCONS, 0);
        if (free_buffer) {
@@ -811,6 +812,7 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse
     size = _zip_buffer_get_64(buffer);
     offset = _zip_buffer_get_64(buffer);
 
+    /* did we read past the end of the buffer? */
     if (!_zip_buffer_ok(buffer)) {
        zip_error_set(error, ZIP_ER_INTERNAL, 0);
        if (free_buffer) {
@@ -837,6 +839,11 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse
        return NULL;
     }
 
+    if (nentry > size / CDENTRYSIZE) {
+       zip_error_set(error, ZIP_ER_INCONS, 0);
+       return NULL;
+    }
+
     if ((cd = _zip_cdir_new(nentry, error)) == NULL)
        return NULL;
 
index 9b11694..d48ae56 100644 (file)
@@ -1,6 +1,6 @@
 /*
  zip_progress.c -- progress reporting
- Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2020 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
 
 struct zip_progress {
     zip_t *za;
-    zip_progress_callback callback;
-    void (*ud_free)(void *);
 
-    void *ud;
+    zip_progress_callback callback_progress;
+    void (*ud_progress_free)(void *);
+    void *ud_progress;
+
+    zip_cancel_callback callback_cancel;
+    void (*ud_cancel_free)(void *);
+    void *ud_cancel;
 
     double precision;
 
@@ -54,6 +58,11 @@ struct zip_progress {
     double end;   /* end of sub-progress section */
 };
 
+static void _zip_progress_free_cancel_callback(zip_progress_t *progress);
+static void _zip_progress_free_progress_callback(zip_progress_t *progress);
+static zip_progress_t *_zip_progress_new(zip_t *za);
+static void _zip_progress_set_cancel_callback(zip_progress_t *progress, zip_cancel_callback callback, void (*ud_free)(void *), void *ud);
+static void _zip_progress_set_progress_callback(zip_progress_t *progress, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud);
 
 void
 _zip_progress_end(zip_progress_t *progress) {
@@ -67,16 +76,15 @@ _zip_progress_free(zip_progress_t *progress) {
        return;
     }
 
-    if (progress->ud_free) {
-       progress->ud_free(progress->ud);
-    }
+    _zip_progress_free_progress_callback(progress);
+    _zip_progress_free_cancel_callback(progress);
 
     free(progress);
 }
 
 
-zip_progress_t *
-_zip_progress_new(zip_t *za, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud) {
+static zip_progress_t *
+_zip_progress_new(zip_t *za) {
     zip_progress_t *progress = (zip_progress_t *)malloc(sizeof(*progress));
 
     if (progress == NULL) {
@@ -85,52 +93,117 @@ _zip_progress_new(zip_t *za, double precision, zip_progress_callback callback, v
     }
 
     progress->za = za;
-    progress->callback = callback;
-    progress->ud_free = ud_free;
-    progress->ud = ud;
-    progress->precision = precision;
+
+    progress->callback_progress = NULL;
+    progress->ud_progress_free = NULL;
+    progress->ud_progress = NULL;
+    progress->precision = 0.0;
+
+    progress->callback_cancel = NULL;
+    progress->ud_cancel_free = NULL;
+    progress->ud_cancel = NULL;
 
     return progress;
 }
 
+static void
+_zip_progress_free_progress_callback(zip_progress_t *progress) {
+    if (progress->ud_progress_free) {
+       progress->ud_progress_free(progress->ud_progress);
+    }
+
+    progress->callback_progress = NULL;
+    progress->ud_progress = NULL;
+    progress->ud_progress_free = NULL;
+}
+
+static void
+_zip_progress_free_cancel_callback(zip_progress_t *progress) {
+    if (progress->ud_cancel_free) {
+       progress->ud_cancel_free(progress->ud_cancel);
+    }
+
+    progress->callback_cancel = NULL;
+    progress->ud_cancel = NULL;
+    progress->ud_cancel_free = NULL;
+}
+
+static void
+_zip_progress_set_progress_callback(zip_progress_t *progress, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud) {
+    _zip_progress_free_progress_callback(progress);
+
+    progress->callback_progress = callback;
+    progress->ud_progress_free = ud_free;
+    progress->ud_progress = ud;
+    progress->precision = precision;
+}
 
 void
+_zip_progress_set_cancel_callback(zip_progress_t *progress, zip_cancel_callback callback, void (*ud_free)(void *), void *ud) {
+    _zip_progress_free_cancel_callback(progress);
+
+    progress->callback_cancel = callback;
+    progress->ud_cancel_free = ud_free;
+    progress->ud_cancel = ud;
+}
+
+int
 _zip_progress_start(zip_progress_t *progress) {
     if (progress == NULL) {
-       return;
+       return 0;
+    }
+
+    if (progress->callback_progress != NULL) {
+       progress->last_update = 0.0;
+       progress->callback_progress(progress->za, 0.0, progress->ud_progress);
+    }
+
+    if (progress->callback_cancel != NULL) {
+       if (progress->callback_cancel(progress->za, progress->ud_cancel)) {
+           return -1;
+       }
     }
 
-    progress->last_update = 0.0;
-    progress->callback(progress->za, 0.0, progress->ud);
+    return 0;
 }
 
 
-void
+int
 _zip_progress_subrange(zip_progress_t *progress, double start, double end) {
     if (progress == NULL) {
-       return;
+       return 0;
     }
 
     progress->start = start;
     progress->end = end;
 
-    _zip_progress_update(progress, 0.0);
+    return _zip_progress_update(progress, 0.0);
 }
 
-void
+int
 _zip_progress_update(zip_progress_t *progress, double sub_current) {
     double current;
 
     if (progress == NULL) {
-       return;
+       return 0;
     }
 
-    current = ZIP_MIN(ZIP_MAX(sub_current, 0.0), 1.0) * (progress->end - progress->start) + progress->start;
+    if (progress->callback_progress != NULL) {
+       current = ZIP_MIN(ZIP_MAX(sub_current, 0.0), 1.0) * (progress->end - progress->start) + progress->start;
 
-    if (current - progress->last_update > progress->precision) {
-       progress->callback(progress->za, current, progress->ud);
-       progress->last_update = current;
+       if (current - progress->last_update > progress->precision) {
+           progress->callback_progress(progress->za, current, progress->ud_progress);
+           progress->last_update = current;
+       }
     }
+
+    if (progress->callback_cancel != NULL) {
+       if (progress->callback_cancel(progress->za, progress->ud_cancel)) {
+           return -1;
+       }
+    }
+
+    return 0;
 }
 
 
@@ -139,13 +212,54 @@ zip_register_progress_callback_with_state(zip_t *za, double precision, zip_progr
     zip_progress_t *progress = NULL;
 
     if (callback != NULL) {
-       if ((progress = _zip_progress_new(za, precision, callback, ud_free, ud)) == NULL) {
-           return -1;
+        if (za->progress == NULL) {
+           if ((za->progress = _zip_progress_new(za)) == NULL) {
+               return -1;
+           }
        }
+
+       _zip_progress_set_progress_callback(za->progress, precision, callback, ud_free, ud);
     }
+    else {
+       if (za->progress != NULL) {
+           if (za->progress->callback_cancel == NULL) {
+               _zip_progress_free(za->progress);
+               za->progress = NULL;
+           }
+           else {
+               _zip_progress_free_progress_callback(za->progress);
+           }
+       }
+    }
+
+    return 0;
+}
+
+
+ZIP_EXTERN int
+zip_register_cancel_callback_with_state(zip_t *za, zip_cancel_callback callback, void (*ud_free)(void *), void *ud) {
+    zip_progress_t *progress = NULL;
+
+    if (callback != NULL) {
+        if (za->progress == NULL) {
+           if ((za->progress = _zip_progress_new(za)) == NULL) {
+               return -1;
+           }
+       }
 
-    _zip_progress_free(za->progress);
-    za->progress = progress;
+       _zip_progress_set_cancel_callback(za->progress, callback, ud_free, ud);
+    }
+    else {
+       if (za->progress != NULL) {
+           if (za->progress->callback_progress == NULL) {
+               _zip_progress_free(za->progress);
+               za->progress = NULL;
+           }
+           else {
+               _zip_progress_free_cancel_callback(za->progress);
+           }
+       }
+    }
 
     return 0;
 }
index 8e289df..24c7c1f 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_random_unix.c -- fill the user's buffer with random stuff (Unix version)
-  Copyright (C) 2016-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2016-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
 
 #include "zipint.h"
 
+#ifdef HAVE_CRYPTO
+#include "zip_crypto.h"
+#endif
+
+
+#ifdef HAVE_ARC4RANDOM
+
+#include <stdlib.h>
+
+#ifndef HAVE_SECURE_RANDOM
+ZIP_EXTERN bool
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
+    arc4random_buf(buffer, length);
+    return true;
+}
+#endif
+
+#ifndef HAVE_RANDOM_UINT32
+zip_uint32_t
+zip_random_uint32(void) {
+    return arc4random();
+}
+#endif
+
+#else /* HAVE_ARC4RANDOM */
+
+#ifndef HAVE_SECURE_RANDOM
 #include <fcntl.h>
 #include <unistd.h>
 
 ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     int fd;
 
     if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
@@ -52,3 +79,27 @@ zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
     close(fd);
     return true;
 }
+#endif
+
+#ifndef HAVE_RANDOM_UINT32
+#include <stdlib.h>
+
+zip_uint32_t
+zip_random_uint32(void) {
+    static bool seeded = false;
+    
+    zip_uint32_t value;
+    
+    if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) {
+        return value;
+    }
+    
+    if (!seeded) {
+        srandom((unsigned int)time(NULL));
+    }
+    
+    return (zip_uint32_t)random();
+}
+#endif
+
+#endif /* HAVE_ARC4RANDOM */
index 42b96a0..ce7d6b8 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_random_uwp.c -- fill the user's buffer with random stuff (UWP version)
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#include "zipint.h"
+
+#ifdef HAVE_CRYPTO
+#include "zip_crypto.h"
+#endif
+
+#ifndef HAVE_SECURE_RANDOM
+
 #include <bcrypt.h>
 #include <ntstatus.h>
 #include <windows.h>
 
-#include "zipint.h"
 #include "zipwin32.h"
 
 ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     BCRYPT_ALG_HANDLE hAlg = NULL;
     NTSTATUS hr = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_RNG_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0);
     if (hr != STATUS_SUCCESS || hAlg == NULL) {
@@ -52,3 +59,26 @@ zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
     }
     return true;
 }
+
+#endif
+
+#ifndef HAVE_RANDOM_UINT32
+#include <stdlib.h>
+
+zip_uint32_t
+zip_random_uint32(void) {
+    static bool seeded = false;
+    
+    zip_uint32_t value;
+    
+    if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) {
+        return value;
+    }
+    
+    if (!seeded) {
+        srandom((unsigned int)time(NULL));
+    }
+    
+    return (zip_uint32_t)random();
+}
+#endif
index 3b92978..16d0f64 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_random_win32.c -- fill the user's buffer with random stuff (Windows version)
-  Copyright (C) 2016-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2016-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
 #include "zipint.h"
 #include "zipwin32.h"
 
+#ifdef HAVE_CRYPTO
+#include "zip_crypto.h"
+#endif
+
+#ifndef HAVE_SECURE_RANDOM
+
 #include <wincrypt.h>
 
 ZIP_EXTERN bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     HCRYPTPROV hprov;
     if (!CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
        return false;
@@ -50,3 +56,25 @@ zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
     }
     return true;
 }
+#endif
+
+#ifndef HAVE_RANDOM_UINT32
+#include <stdlib.h>
+
+zip_uint32_t
+zip_random_uint32(void) {
+    static bool seeded = false;
+    
+    zip_uint32_t value;
+    
+    if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) {
+        return value;
+    }
+    
+    if (!seeded) {
+        srandom((unsigned int)time(NULL));
+    }
+    
+    return (zip_uint32_t)random();
+}
+#endif
index 4fdf636..e5f1682 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_rename.c -- rename file in zip archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 2e982af..30a2eb1 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_replace.c -- replace file via callback function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 166a2c0..3f050b3 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_set_archive_comment.c -- set archive comment
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index facf614..e0d5502 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_get_archive_flag.c -- set archive global flag
-  Copyright (C) 2008-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2008-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 8081657..41c7c51 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_set_default_password.c -- set default password for decryption
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index e4e0331..1fa01ae 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_set_file_comment.c -- set comment for file in archive
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 054dd1f..927fbb7 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_set_file_compression.c -- set compression for file in archive
-  Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index aa1dd8e..43c772e 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_set_name.c -- rename helper function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
diff --git a/lib/zip_source_accept_empty.c b/lib/zip_source_accept_empty.c
new file mode 100644 (file)
index 0000000..e6d5151
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+  zip_source_accept_empty.c -- if empty source is a valid archive
+  Copyright (C) 2019 Dieter Baron and Thomas Klausner
+
+  This file is part of libzip, a library to manipulate ZIP archives.
+  The authors can be contacted at <libzip@nih.at>
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in
+     the documentation and/or other materials provided with the
+     distribution.
+  3. The names of the authors may not be used to endorse or promote
+     products derived from this software without specific prior
+     written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+  OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#include "zipint.h"
+
+
+bool
+zip_source_accept_empty(zip_source_t *src) {
+    int ret;
+
+    if ((zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY)) == 0) {
+       if (ZIP_SOURCE_IS_LAYERED(src)) {
+           return zip_source_accept_empty(src->src);
+       }
+       return true;
+    }
+
+    ret = (int)_zip_source_call(src, NULL, 0, ZIP_SOURCE_ACCEPT_EMPTY);
+
+    return ret != 0;
+}
index a8b90b5..432c2c1 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_begin_write.c -- start a new file for writing
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index b38de04..41b4c73 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_begin_write_cloning.c -- clone part of file for writing
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 119bc02..0685fb3 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_buffer.c -- create zip data source from buffer
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -93,9 +93,13 @@ ZIP_EXTERN zip_source_t *
 zip_source_buffer_create(const void *data, zip_uint64_t len, int freep, zip_error_t *error) {
     zip_buffer_fragment_t fragment;
 
-    if (data == NULL && len > 0) {
-       zip_error_set(error, ZIP_ER_INVAL, 0);
-       return NULL;
+    if (data == NULL) {
+        if (len > 0) {
+            zip_error_set(error, ZIP_ER_INVAL, 0);
+            return NULL;
+        }
+
+        return zip_source_buffer_fragment_create(NULL, 0, freep, error);
     }
 
     fragment.data = (zip_uint8_t *)data;
@@ -457,7 +461,7 @@ buffer_new(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int
        }
        buffer->nfragments = j;
        buffer->first_owned_fragment = free_data ? 0 : buffer->nfragments;
-       buffer->fragment_offsets[nfragments] = offset;
+       buffer->fragment_offsets[buffer->nfragments] = offset;
        buffer->size = offset;
     }
 
index 3f374fc..e7c2954 100644 (file)
@@ -1,6 +1,6 @@
 /*
  zip_source_call.c -- invoke callback command on zip_source
- Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
index 7916550..ab7898c 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_close.c -- close zip_source (stop reading)
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 67881f0..d1254bf 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_commit_write.c -- commit changes to file
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index d2ae220..59b1212 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_compress.c -- (de)compression routines
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -67,6 +67,16 @@ static struct implementation implementations[] = {
 #if defined(HAVE_LIBBZ2)
     {ZIP_CM_BZIP2, &zip_algorithm_bzip2_compress, &zip_algorithm_bzip2_decompress},
 #endif
+#if defined(HAVE_LIBLZMA)
+/*  Disabled - because 7z isn't able to unpack ZIP+LZMA ZIP+LZMA2
+    archives made this way - and vice versa.
+
+    {ZIP_CM_LZMA, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress},
+    {ZIP_CM_LZMA2, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress},
+*/
+    {ZIP_CM_XZ, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress},
+#endif
+
 };
 
 static size_t implementations_size = sizeof(implementations) / sizeof(implementations[0]);
index e16f929..56572c0 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_crc.c -- pass-through source that calculates CRC32 and size
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 1e0e0d4..2257f71 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_error.c -- get last error from zip_source
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 8714785..3fff4e3 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_file.c -- create data source from file
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index cb3d151..30e5991 100644 (file)
@@ -31,6 +31,7 @@
   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #define CAN_CLONE
 #endif
 
-#ifdef _WIN32
-/* WIN32 needs <fcntl.h> for _O_BINARY */
-#include <fcntl.h>
-#endif
-
-/* Windows sys/types.h does not provide these */
-#ifndef S_ISREG
-#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
-#endif
-#if defined(S_IXUSR) && defined(S_IRWXG) && defined(S_IRWXO)
-#define _SAFE_MASK (S_IXUSR | S_IRWXG | S_IRWXO)
-#elif defined(_S_IWRITE)
-#define _SAFE_MASK (_S_IWRITE)
-#else
-#error do not know safe values for umask, please report this
-#endif
-
-#ifdef _MSC_VER
-/* MSVC doesn't have mode_t */
-typedef int mode_t;
-#endif
-
 struct read_file {
     zip_error_t error; /* last error information */
     zip_int64_t supports;
@@ -99,6 +78,7 @@ static int create_temp_output(struct read_file *ctx);
 #ifdef CAN_CLONE
 static zip_int64_t create_temp_output_cloning(struct read_file *ctx, zip_uint64_t offset);
 #endif
+static FILE *_zip_fopen(const char *name, bool writeable);
 static int _zip_fseek_u(FILE *f, zip_uint64_t offset, int whence, zip_error_t *error);
 static int _zip_fseek(FILE *f, zip_int64_t offset, int whence, zip_error_t *error);
 
@@ -225,6 +205,7 @@ _zip_source_file_or_p(const char *fname, FILE *file, zip_uint64_t start, zip_int
        }
     }
 
+    ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY);
 #ifdef CAN_CLONE
     if (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE)) {
        ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE_CLONING);
@@ -245,23 +226,29 @@ static int
 create_temp_output(struct read_file *ctx) {
     char *temp;
     int tfd;
-    mode_t mask;
+    int mode;
     FILE *tfp;
+    struct stat st;
 
     if ((temp = (char *)malloc(strlen(ctx->fname) + 8)) == NULL) {
        zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0);
        return -1;
     }
+
+    if (stat(ctx->fname, &st) == 0) {
+       mode = st.st_mode;
+    }
+    else {
+       mode = -1;
+    }
+
     sprintf(temp, "%s.XXXXXX", ctx->fname);
 
-    mask = umask(_SAFE_MASK);
-    if ((tfd = mkstemp(temp)) == -1) {
+    if ((tfd = _zip_mkstempm(temp, mode)) == -1) {
        zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
-       umask(mask);
        free(temp);
        return -1;
     }
-    umask(mask);
 
     if ((tfp = fdopen(tfd, "r+b")) == NULL) {
        zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
@@ -271,14 +258,6 @@ create_temp_output(struct read_file *ctx) {
        return -1;
     }
 
-#ifdef _WIN32
-    /*
-     According to Pierre Joye, Windows in some environments per
-     default creates text files, so force binary mode.
-     */
-    _setmode(_fileno(tfp), _O_BINARY);
-#endif
-
     ctx->fout = tfp;
     ctx->tmpname = temp;
 
@@ -316,7 +295,7 @@ zip_int64_t static create_temp_output_cloning(struct read_file *ctx, zip_uint64_
        free(temp);
        return -1;
     }
-    if ((tfp = fopen(temp, "r+b")) == NULL) {
+    if ((tfp = _zip_fopen(temp, true)) == NULL) {
        zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
        (void)remove(temp);
        free(temp);
@@ -396,12 +375,19 @@ read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) {
     buf = (char *)data;
 
     switch (cmd) {
+    case ZIP_SOURCE_ACCEPT_EMPTY:
+       return 0;
+
     case ZIP_SOURCE_BEGIN_WRITE:
+#ifdef _WIN32
+       return -1;
+#else
        if (ctx->fname == NULL) {
            zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0);
            return -1;
        }
        return create_temp_output(ctx);
+#endif
 
 #ifdef CAN_CLONE
     case ZIP_SOURCE_BEGIN_WRITE_CLONING:
@@ -412,40 +398,28 @@ read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) {
        return create_temp_output_cloning(ctx, len);
 #endif
 
-    case ZIP_SOURCE_COMMIT_WRITE: {
-       mode_t mode;
-       struct stat st;
+    case ZIP_SOURCE_CLOSE:
+       if (ctx->fname) {
+           fclose(ctx->f);
+           ctx->f = NULL;
+       }
+       return 0;
 
+    case ZIP_SOURCE_COMMIT_WRITE: {
        if (fclose(ctx->fout) < 0) {
            ctx->fout = NULL;
            zip_error_set(&ctx->error, ZIP_ER_WRITE, errno);
        }
        ctx->fout = NULL;
-       if (stat(ctx->fname, &st) == 0) {
-           mode = st.st_mode;
-       } else {
-           mode_t mask = umask(022);
-           umask(mask);
-           mode = 0666 & ~mask;
-       }
        if (rename(ctx->tmpname, ctx->fname) < 0) {
            zip_error_set(&ctx->error, ZIP_ER_RENAME, errno);
            return -1;
        }
-       /* not much we can do if chmod fails except make the whole commit fail */
-       (void)chmod(ctx->fname, mode);
        free(ctx->tmpname);
        ctx->tmpname = NULL;
        return 0;
     }
 
-    case ZIP_SOURCE_CLOSE:
-       if (ctx->fname) {
-           fclose(ctx->f);
-           ctx->f = NULL;
-       }
-       return 0;
-
     case ZIP_SOURCE_ERROR:
        return zip_error_to_data(&ctx->error, data, len);
 
@@ -459,7 +433,7 @@ read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) {
 
     case ZIP_SOURCE_OPEN:
        if (ctx->fname) {
-           if ((ctx->f = fopen(ctx->fname, "rb")) == NULL) {
+           if ((ctx->f = _zip_fopen(ctx->fname, false)) == NULL) {
                zip_error_set(&ctx->error, ZIP_ER_OPEN, errno);
                return -1;
            }
@@ -656,3 +630,34 @@ _zip_fseek(FILE *f, zip_int64_t offset, int whence, zip_error_t *error) {
     }
     return 0;
 }
+
+
+/*
+ * fopen replacement that sets the close-on-exec flag
+ * some implementations support an fopen 'e' flag for that,
+ * but e.g. macOS doesn't.
+ */
+static FILE *
+_zip_fopen(const char *name, bool writeable)
+{
+    int fd;
+    int flags;
+    FILE *fp;
+
+    flags = O_CLOEXEC;
+    if (writeable) {
+       flags |= O_RDWR;
+    }
+    else {
+       flags |= O_RDONLY;
+    }
+
+    /* mode argument needed on Windows */
+    if ((fd = open(name, flags, 0666)) < 0) {
+       return NULL;
+    }
+    if ((fp = fdopen(fd, writeable ? "r+b" : "rb")) == NULL) {
+       return NULL;
+    }
+    return fp;
+}
index dd3c6df..2f10ef8 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_free.c -- free zip data source
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index c9730c9..d5c1b5b 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_function.c -- create zip data source from callback function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index a9442aa..7e04bed 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_get_compression_flags.c -- get compression flags for entry
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 090a67b..edd10ca 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_is_deleted.c -- was archive was removed?
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 580bff0..d02bc85 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_layered.c -- create layered source
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index d10a3c5..414c677 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_open.c -- open zip_source (prepare for reading)
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index cc510ea..1b59d7a 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_pkware.c -- Traditional PKWARE de/encryption routines
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 816fb3d..33088cb 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_read.c -- read data from zip_source
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 6841b74..14eddb8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  zip_source_remove.c -- remove empty archive
- Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
index 04aa938..e8259bf 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_rollback_write.c -- discard changes
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index c7bd8e6..163daf1 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_seek.c -- seek to offset
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index a20dc82..6b0aa78 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_seek_write.c -- seek to offset for writing
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index f3af3be..3421d2c 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_stat.c -- get meta information from zip_source
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 394f06e..8471559 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_supports.c -- check for supported functions
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index da13cf5..772e252 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_tell.c -- report current offset
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index d20139f..96ad7e2 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_tell_write.c -- report current offset for writing
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 79bb2e8..68c007f 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_win32a.c -- create data source from Windows file (ANSI)
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -107,8 +107,18 @@ _win32_create_temp_a(_zip_source_win32_read_file_t *ctx, void **temp, zip_uint32
 
 static int
 _win32_rename_temp_a(_zip_source_win32_read_file_t *ctx) {
+    DWORD attributes = GetFileAttributesA(ctx->tmpname);
+    if (INVALID_FILE_ATTRIBUTES == attributes)
+       return -1;
+
+    if (FILE_ATTRIBUTE_TEMPORARY & attributes) {
+       if (!SetFileAttributesA(ctx->tmpname, attributes & ~FILE_ATTRIBUTE_TEMPORARY))
+           return -1;
+    }
+
     if (!MoveFileExA(ctx->tmpname, ctx->fname, MOVEFILE_REPLACE_EXISTING))
        return -1;
+
     return 0;
 }
 
index 3a2f52e..8746cdd 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_win32file.c -- create data source from HANDLE (Win32)
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -127,6 +127,8 @@ _zip_source_win32_handle_or_name(const void *fname, HANDLE h, zip_uint64_t start
        ctx->supports = ZIP_SOURCE_SUPPORTS_SEEKABLE;
     }
 
+    ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY);
+
     if ((zs = zip_source_function_create(_win32_read_file, ctx, error)) == NULL) {
        free(ctx->fname);
        free(ctx);
@@ -148,6 +150,9 @@ _win32_read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd
     buf = (char *)data;
 
     switch (cmd) {
+    case ZIP_SOURCE_ACCEPT_EMPTY:
+       return 0;
+
     case ZIP_SOURCE_BEGIN_WRITE:
        if (ctx->fname == NULL) {
            zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0);
@@ -261,7 +266,7 @@ _win32_read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd
 
        switch (args->whence) {
        case SEEK_SET:
-           new_current = args->offset;
+           new_current = args->offset + ctx->start;
            break;
 
        case SEEK_END:
index 4ad2bf0..3d2ce39 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_win32utf8.c -- create data source from Windows file (UTF-8)
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 6a433fb..75afdcb 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_win32w.c -- create data source from Windows file (UTF-16)
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -131,8 +131,18 @@ _win32_create_temp_w(_zip_source_win32_read_file_t *ctx, void **temp, zip_uint32
 
 static int
 _win32_rename_temp_w(_zip_source_win32_read_file_t *ctx) {
+    DWORD attributes = GetFileAttributesW(ctx->tmpname);
+    if (INVALID_FILE_ATTRIBUTES == attributes)
+       return -1;
+
+    if (FILE_ATTRIBUTE_TEMPORARY & attributes) {
+       if (!SetFileAttributesW(ctx->tmpname, attributes & ~FILE_ATTRIBUTE_TEMPORARY))
+           return -1;
+    }
+
     if (!MoveFileExW(ctx->tmpname, ctx->fname, MOVEFILE_REPLACE_EXISTING))
        return -1;
+
     return 0;
 }
 
index d9e90bf..1276485 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_window.c -- return part of lower source
-  Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index f1a05a8..2ee626a 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_winzip_aes_decode.c -- Winzip AES decryption routines
-  Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index c428c9a..7df5faf 100644 (file)
@@ -83,7 +83,7 @@ zip_source_winzip_aes_encode(zip_t *za, zip_source_t *src, zip_uint16_t encrypti
 static int
 encrypt_header(zip_source_t *src, struct winzip_aes *ctx) {
     zip_uint16_t salt_length = SALT_LENGTH(ctx->encryption_method);
-    if (!zip_random(ctx->data, salt_length)) {
+    if (!zip_secure_random(ctx->data, salt_length)) {
        zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0);
        return -1;
     }
@@ -163,7 +163,7 @@ winzip_aes_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length,
                /* TODO: return partial read? */
                return -1;
            }
-           buffer_n += _zip_buffer_read(ctx->buffer, data + ret, length - (zip_uint64_t)ret);
+           buffer_n += _zip_buffer_read(ctx->buffer, (zip_uint8_t *)data + ret, length - (zip_uint64_t)ret);
        }
 
        return (zip_int64_t)(buffer_n + (zip_uint64_t)ret);
index 9f494e0..73fc3a3 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_write.c -- start a new file for writing
-  Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 3fd90ab..1f77aaa 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_zip.c -- create data source from zip file
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index ab78561..f36609b 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_source_zip_new.c -- prepare data structures for zip_fopen/zip_source_zip
-  Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 237d985..341c6f7 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_stat.c -- get information about file by name
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index d19e76a..71f8049 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_stat_index.c -- get information about file by index
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -48,10 +48,17 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
 
 
     if ((flags & ZIP_FL_UNCHANGED) == 0 && ZIP_ENTRY_DATA_CHANGED(za->entry + index)) {
-       if (zip_source_stat(za->entry[index].source, st) < 0) {
+       zip_entry_t *entry = za->entry+index;
+
+       if (zip_source_stat(entry->source, st) < 0) {
            zip_error_set(&za->error, ZIP_ER_CHANGED, 0);
            return -1;
        }
+
+       if (entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
+           st->mtime = de->last_mod;
+           st->valid |= ZIP_STAT_MTIME;
+       }
     }
     else {
        zip_stat_init(st);
index 46fa404..6d0903d 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_stat_init.c -- initialize struct zip_stat.
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index eb94198..906c7f7 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_sterror.c -- get string representation of zip error
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 7e16a72..a6edbc5 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_string.c -- string handling (with encoding)
-  Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 8285707..1a78e2c 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_unchange.c -- undo changes to file in zip archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 6a43358..5e7df80 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_unchange.c -- undo changes to all files in zip archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 404f1ed..bd223ef 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_unchange_archive.c -- undo global changes to ZIP archive
-  Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index f1df2bd..74a429c 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_unchange_data.c -- undo helper function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 684eba5..099db9b 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_utf-8.c -- UTF-8 support functions for libzip
-  Copyright (C) 2011-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2011-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 03159d7..188b4bb 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zip_winzip_aes.c -- Winzip AES de/encryption backend routines
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 093a1b2..721d36e 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
   zipint.h -- internal declarations.
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -150,6 +150,9 @@ extern zip_compression_algorithm_t zip_algorithm_bzip2_compress;
 extern zip_compression_algorithm_t zip_algorithm_bzip2_decompress;
 extern zip_compression_algorithm_t zip_algorithm_deflate_compress;
 extern zip_compression_algorithm_t zip_algorithm_deflate_decompress;
+extern zip_compression_algorithm_t zip_algorithm_xz_compress;
+extern zip_compression_algorithm_t zip_algorithm_xz_decompress;
+
 
 bool zip_compression_method_supported(zip_int32_t method, bool compress);
 
@@ -468,6 +471,7 @@ void _zip_cdir_free(zip_cdir_t *);
 bool _zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error);
 zip_cdir_t *_zip_cdir_new(zip_uint64_t, zip_error_t *);
 zip_int64_t _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors);
+time_t _zip_d2u_time(zip_uint16_t, zip_uint16_t);
 void _zip_deregister_source(zip_t *za, zip_source_t *src);
 
 zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *);
@@ -523,16 +527,19 @@ zip_hash_t *_zip_hash_new(zip_error_t *error);
 bool _zip_hash_reserve_capacity(zip_hash_t *hash, zip_uint64_t capacity, zip_error_t *error);
 bool _zip_hash_revert(zip_hash_t *hash, zip_error_t *error);
 
+int _zip_mkstempm(char *path, int mode);
+
 zip_t *_zip_open(zip_source_t *, unsigned int, zip_error_t *);
 
 void _zip_progress_end(zip_progress_t *progress);
 void _zip_progress_free(zip_progress_t *progress);
-zip_progress_t *_zip_progress_new(zip_t *za, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud);
-void _zip_progress_start(zip_progress_t *progress);
-void _zip_progress_subrange(zip_progress_t *progress, double start, double end);
-void _zip_progress_update(zip_progress_t *progress, double value);
+int _zip_progress_start(zip_progress_t *progress);
+int _zip_progress_subrange(zip_progress_t *progress, double start, double end);
+int _zip_progress_update(zip_progress_t *progress, double value);
 
-ZIP_EXTERN bool zip_random(zip_uint8_t *buffer, zip_uint16_t length);
+/* this symbol is extern so it can be overridden for regression testing */
+ZIP_EXTERN bool zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length);
+zip_uint32_t zip_random_uint32(void);
 
 int _zip_read(zip_source_t *src, zip_uint8_t *data, zip_uint64_t length, zip_error_t *error);
 int _zip_read_at_offset(zip_source_t *src, zip_uint64_t offset, unsigned char *b, size_t length, zip_error_t *error);
@@ -543,6 +550,7 @@ int _zip_register_source(zip_t *za, zip_source_t *src);
 
 void _zip_set_open_error(int *zep, const zip_error_t *err, int ze);
 
+bool zip_source_accept_empty(zip_source_t *src);
 zip_int64_t _zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command);
 bool _zip_source_eof(zip_source_t *);
 zip_source_t *_zip_source_file_or_p(const char *, FILE *, zip_uint64_t, zip_int64_t, const zip_stat_t *, zip_error_t *error);
index 7d3ac76..870f1d5 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
   zipwin32.h -- internal declarations for Windows.
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 66af70e..3f89dcf 100644 (file)
@@ -107,7 +107,7 @@ On success, <code class="Fn">ZIP_SOURCE_GET_ARGS</code>() returns
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 58f5d9b..3851288 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    libzip.mdoc -- general overview of available functions
-   Copyright (C) 2005-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2005-2020 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -149,6 +149,7 @@ libzip (-lzip)
   <li><a class="Xr" href="zip_file_add.html">zip_file_add(3)</a></li>
   <li><a class="Xr" href="zip_file_replace.html">zip_file_replace(3)</a></li>
   <li><a class="Xr" href="zip_file_set_comment.html">zip_file_set_comment(3)</a></li>
+  <li><a class="Xr" href="zip_file_set_dostime.html">zip_file_set_dostime(3)</a></li>
   <li><a class="Xr" href="zip_file_set_external_attributes.html">zip_file_set_external_attributes(3)</a></li>
   <li><a class="Xr" href="zip_file_set_encryption.html">zip_file_set_encryption(3)</a></li>
   <li><a class="Xr" href="zip_file_set_mtime.html">zip_file_set_mtime(3)</a></li>
@@ -240,8 +241,8 @@ libzip (-lzip)
 </div>
 <table class="foot">
   <tr>
-    <td class="foot-date">September 29, 2018</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-date">January 7, 2020</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 19a5ca6..aac756e 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" libzip.mdoc -- general overview of available functions
-.\" Copyright (C) 2005-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2005-2020 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -30,7 +30,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.TH "LIBZIP" "3" "September 29, 2018" "NiH" "Library Functions Manual"
+.TH "LIBZIP" "3" "January 7, 2020" "NiH" "Library Functions Manual"
 .nh
 .if n .ad l
 .SH "NAME"
@@ -161,6 +161,9 @@ zip_file_replace(3)
 zip_file_set_comment(3)
 .TP 4n
 \fB\(bu\fR
+zip_file_set_dostime(3)
+.TP 4n
+\fB\(bu\fR
 zip_file_set_external_attributes(3)
 .TP 4n
 \fB\(bu\fR
index 8f16564..72f18db 100644 (file)
@@ -1,5 +1,5 @@
 .\" libzip.mdoc -- general overview of available functions
-.\" Copyright (C) 2005-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2005-2020 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd September 29, 2018
+.Dd January 7, 2020
 .Dt LIBZIP 3
 .Os
 .Sh NAME
@@ -137,6 +137,8 @@ from zip archives and one for how to create/modify them.
 .It
 .Xr zip_file_set_comment 3
 .It
+.Xr zip_file_set_dostime 3
+.It
 .Xr zip_file_set_external_attributes 3
 .It
 .Xr zip_file_set_encryption 3
index 7364474..807dd49 100644 (file)
--- a/man/links
+++ b/man/links
@@ -6,6 +6,7 @@ zip_file_add zip_file_replace
 zip_file_extra_field_delete zip_file_extra_field_delete_by_id
 zip_file_extra_field_get zip_file_extra_field_get_by_id
 zip_file_extra_fields_count zip_file_extra_fields_count_by_id
+zip_file_set_mtime zip_file_set_dostime
 zip_file_strerror zip_strerror
 zip_fopen zip_fopen_index
 zip_fopen_encrypted zip_fopen_index_encrypted
index c911ef3..7796753 100644 (file)
@@ -114,7 +114,7 @@ The function <code class="Fn">zip_add</code>() is the obsolete version of
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index f6d0086..dd9a14e 100644 (file)
@@ -95,7 +95,7 @@ The function <code class="Fn">zip_add_dir</code>() is the obsolete version of
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 20d41b6..834a0de 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_close.mdoc -- close zip archive
-   Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -68,8 +68,7 @@ libzip (-lzip)
 The <code class="Fn">zip_close</code>() function writes any changes made to
   <var class="Ar">archive</var> to disk. If <var class="Ar">archive</var>
   contains no files, the file is completely removed (no empty archive is
-  written). If successful, <var class="Ar">archive</var> is freed. If writing
-  fails, <code class="Fn">zip_close</code>() fails;
+  written). If successful, <var class="Ar">archive</var> is freed. Otherwise
   <var class="Ar">archive</var> is left unchanged and must still be freed.
 <p class="Pp">To close and free a zip archive without saving changes, use
     <a class="Xr" href="zip_discard.html">zip_discard(3)</a>.</p>
@@ -138,8 +137,8 @@ Additionally, any errors returned by the callback function for added or replaced
 </div>
 <table class="foot">
   <tr>
-    <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-date">September 17, 2019</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 69552b0..a5264eb 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_close.mdoc -- close zip archive
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -30,7 +30,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.TH "ZIP_CLOSE" "3" "December 18, 2017" "NiH" "Library Functions Manual"
+.TH "ZIP_CLOSE" "3" "September 17, 2019" "NiH" "Library Functions Manual"
 .nh
 .if n .ad l
 .SH "NAME"
@@ -60,9 +60,7 @@ written).
 If successful,
 \fIarchive\fR
 is freed.
-If writing fails,
-\fBzip_close\fR()
-fails;
+Otherwise
 \fIarchive\fR
 is left unchanged and must still be freed.
 .PP
index d9327cb..b5bfd21 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_close.mdoc -- close zip archive
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 18, 2017
+.Dd September 17, 2019
 .Dt ZIP_CLOSE 3
 .Os
 .Sh NAME
@@ -54,9 +54,7 @@ written).
 If successful,
 .Ar archive
 is freed.
-If writing fails,
-.Fn zip_close
-fails;
+Otherwise
 .Ar archive
 is left unchanged and must still be freed.
 .Pp
index d9f5cc3..46c71aa 100644 (file)
@@ -107,7 +107,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 961c9df..f055865 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_dir_add.mdoc -- add directory to zip archive
-   Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -128,7 +128,7 @@ Upon successful completion, the index of the new entry in the archive is
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 59e63a0..28d3fa4 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_dir_add.mdoc -- add directory to zip archive
-.\" Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index c075f83..4d60f8f 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_dir_add.mdoc -- add directory to zip archive
-.\" Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 078dd77..21a3661 100644 (file)
@@ -90,7 +90,7 @@ The <code class="Fn">zip_discard</code>() function closes
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 20ae860..b0e3c60 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_error_clear.mdoc -- clear error state for archive or file
-   Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -97,7 +97,7 @@ The <code class="Fn">zip_error_clear</code>() function clears the error state
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index fe92515..5ccda3f 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_error_clear.mdoc -- clear error state for archive or file
-.\" Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index edac2c3..ebb157a 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_error_clear.mdoc -- clear error state for archive or file
-.\" Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 0d622e3..3bd1cc0 100644 (file)
@@ -92,7 +92,7 @@ The <code class="Fn">zip_error_code_system</code>() function returns the system
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 7f7f852..9496cb9 100644 (file)
@@ -89,7 +89,7 @@ The <code class="Fn">zip_error_code_zip</code>() function returns the libzip
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index c752141..a0f9e10 100644 (file)
@@ -90,7 +90,7 @@ The <code class="Fn">zip_error_fini</code>() function cleans up and frees
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 91f15ce..1e276af 100644 (file)
@@ -143,7 +143,7 @@ se = zip_error_code_system(error);
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index e85152c..8a4094e 100644 (file)
@@ -109,7 +109,7 @@ int i = zip_error_system_type(&amp;error);
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 24b671e..84c7d2f 100644 (file)
@@ -101,7 +101,7 @@ The <code class="Fn">zip_error_init</code>() function initializes the zip_error
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index eba09b6..80dfeb5 100644 (file)
@@ -94,7 +94,7 @@ The <code class="Fn">zip_error_set</code>() function sets the zip_error pointed
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index cba19f8..c3b9de6 100644 (file)
@@ -94,7 +94,7 @@ The <code class="Fn">zip_error_strerror</code>() function returns an error
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 0a6308e..78dbbe4 100644 (file)
@@ -100,7 +100,7 @@ The <code class="Fn">zip_error_system_type</code>() function returns the type of
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 9f3ab16..06bcd0d 100644 (file)
@@ -101,7 +101,7 @@ libzip (-lzip)
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 1319139..2008072 100644 (file)
@@ -117,7 +117,7 @@ zip_error_fini(&amp;error);
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index f9eef5f..904760d 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_errors.mdoc -- list of all libzip error codes
-   Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -143,7 +143,7 @@ The following error codes are used by libzip:
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 63c3947..ba9ae9b 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_errors.mdoc -- list of all libzip error codes
-.\" Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 9f6357f..a35890c 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_errors.mdoc -- list of all libzip error codes
-.\" Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index c19b2ca..3ca888a 100644 (file)
@@ -96,7 +96,7 @@ Upon successful completion 0 is returned. Otherwise, the error code is returned.
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index d34f1e6..46505e6 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_fdopen.mdoc -- open zip archive using existing file descriptor
-   Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -147,7 +147,7 @@ The file specified by <var class="Ar">fd</var> is prepared for use by
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index e07f926..359e5ce 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_fdopen.mdoc -- open zip archive using existing file descriptor
-.\" Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 44b5055..8921125 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_fdopen.mdoc -- open zip archive using existing file descriptor
-.\" Copyright (C) 2009-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2009-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 99274c9..4f6e730 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_file_add.mdoc -- add files to zip archive
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -170,7 +170,7 @@ if ((s=zip_source_buffer(archive, buf, sizeof(buf), 0)) == NULL ||
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 10c0050..4a59589 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_file_add.mdoc -- add files to zip archive
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 9939ddd..4a3e3b0 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_file_add.mdoc -- add files to zip archive
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 7457e16..7dcb1c3 100644 (file)
@@ -152,7 +152,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 2f1a942..1e7e734 100644 (file)
@@ -169,7 +169,7 @@ Please note that the extra field IDs 0x0001 (ZIP64 extension), 0x6375 (Infozip
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 8f78da5..5bd7530 100644 (file)
@@ -141,7 +141,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index ad968da..2e6d35d 100644 (file)
@@ -142,7 +142,7 @@ Upon successful completion, the requested number of extra fields is returned.
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 3471489..e485baf 100644 (file)
@@ -135,7 +135,7 @@ Upon successful completion, a pointer to the comment is returned, or
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 0f89e39..fbd7df1 100644 (file)
@@ -88,7 +88,7 @@ libzip (-lzip)
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 937b0d0..52198ad 100644 (file)
@@ -169,7 +169,7 @@ _zip_dos_attr2mode(zip_uint32_t attr)
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index b15e352..1ddc0b3 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_file_rename.mdoc -- rename file in zip archive
-   Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -124,7 +124,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 45cee19..92a3771 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_file_rename.mdoc -- rename file in zip archive
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 017e26e..d1a23d1 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_file_rename.mdoc -- rename file in zip archive
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index e567e3b..09428fc 100644 (file)
@@ -129,7 +129,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index ea5c280..075f7de 100644 (file)
@@ -137,7 +137,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 5892f0a..3a7b636 100644 (file)
@@ -118,7 +118,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index e56948f..23cd023 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_file_set_mtime.mdoc -- set mtime for file in zip
-   Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+   Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP files.
    The authors can be contacted at <libzip@nih.at>
@@ -48,7 +48,8 @@
 <div class="manual-text">
 <section class="Sh">
 <h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
-<code class="Nm">zip_file_set_mtime</code> &#x2014;
+<code class="Nm">zip_file_set_dostime</code>,
+  <code class="Nm">zip_file_set_mtime</code> &#x2014;
 <div class="Nd">set last modification time (mtime) for file in zip</div>
 </section>
 <section class="Sh">
@@ -60,6 +61,14 @@ libzip (-lzip)
 <code class="In">#include &lt;<a class="In">zip.h</a>&gt;</code>
 <p class="Pp"><var class="Ft">int</var>
   <br/>
+  <code class="Fn">zip_file_set_dostime</code>(<var class="Fa" style="white-space: nowrap;">zip_t
+    *archive</var>, <var class="Fa" style="white-space: nowrap;">zip_uint64_t
+    index</var>, <var class="Fa" style="white-space: nowrap;">zip_uint16_t
+    dostime</var>, <var class="Fa" style="white-space: nowrap;">zip_uint16_t
+    dosdate</var>, <var class="Fa" style="white-space: nowrap;">zip_flags_t
+    flags</var>);</p>
+<p class="Pp"><var class="Ft">int</var>
+  <br/>
   <code class="Fn">zip_file_set_mtime</code>(<var class="Fa" style="white-space: nowrap;">zip_t
     *archive</var>, <var class="Fa" style="white-space: nowrap;">zip_uint64_t
     index</var>, <var class="Fa" style="white-space: nowrap;">time_t
@@ -72,6 +81,31 @@ The <code class="Fn">zip_file_set_mtime</code>() function sets the last
   modification time (mtime) for the file at position <var class="Ar">index</var>
   in the zip archive to <var class="Ar">mtime</var>. Currently, no support for
   any <var class="Ar">flags</var> is implemented.
+<p class="Pp">In the zip archive, the time and date are saved as two 16-bit
+    integers. To set the values directly, call the
+    <code class="Fn">zip_file_set_dostime</code>() function. The values of the
+    time bytes are defined as follows:</p>
+<div class="Bd-indent">
+<dl class="Bl-tag">
+  <dt>0-4</dt>
+  <dd>day of the month (1-31)</dd>
+  <dt>5-8</dt>
+  <dd>month (January = 1, February = 2, ...)</dd>
+  <dt>9-15</dt>
+  <dd>year offset from 1980 (1980 = 0, 1981 = 1, ...)</dd>
+</dl>
+</div>
+<p class="Pp">The values of the date bytes are defined as follows:</p>
+<div class="Bd-indent">
+<dl class="Bl-tag">
+  <dt>0-4</dt>
+  <dd>seconds divided by two (1-2 = 1, 3-4 = 2, ...)</dd>
+  <dt>5-10</dt>
+  <dd>minute (0-59)</dd>
+  <dt>11-15</dt>
+  <dd>hour (0-23)</dd>
+</dl>
+</div>
 </section>
 <section class="Sh">
 <h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
@@ -82,7 +116,8 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 </section>
 <section class="Sh">
 <h1 class="Sh" id="ERRORS"><a class="permalink" href="#ERRORS">ERRORS</a></h1>
-<code class="Fn">zip_file_set_mtime</code>() fails if:
+<code class="Fn">zip_file_set_dostime</code>() and
+  <code class="Fn">zip_file_set_mtime</code>() fail if:
 <dl class="Bl-tag">
   <dt>[<a class="permalink" href="#ZIP_ER_INVAL"><code class="Er" id="ZIP_ER_INVAL">ZIP_ER_INVAL</code></a>]</dt>
   <dd><var class="Ar">index</var> is not a valid file index in
@@ -102,6 +137,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <section class="Sh">
 <h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
 <code class="Fn">zip_file_set_mtime</code>() was added in libzip 1.0.
+  <code class="Fn">zip_file_set_dostime</code>() was added in libzip 1.6.
 </section>
 <section class="Sh">
 <h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
@@ -110,11 +146,18 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
   <span class="An">Thomas Klausner</span>
   &lt;<a class="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>&gt;
 </section>
+<section class="Sh">
+<h1 class="Sh" id="CAVEATS"><a class="permalink" href="#CAVEATS">CAVEATS</a></h1>
+Following historical practice, the <code class="Fn">zip_file_set_mtime</code>()
+  function translates the time from the zip archive into the local time zone. If
+  you want to avoid this, use the <code class="Fn">zip_file_set_dostime</code>()
+  function instead.
+</section>
 </div>
 <table class="foot">
   <tr>
-    <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-date">January 7, 2020</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index aa2e52f..48dc132 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_file_set_mtime.mdoc -- set mtime for file in zip
-.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP files.
 .\" The authors can be contacted at <libzip@nih.at>
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.TH "ZIP_FILE_SET_MTIME" "3" "December 18, 2017" "NiH" "Library Functions Manual"
+.TH "ZIP_FILE_SET_MTIME" "3" "January 7, 2020" "NiH" "Library Functions Manual"
 .nh
 .if n .ad l
 .SH "NAME"
+\fBzip_file_set_dostime\fR,
 \fBzip_file_set_mtime\fR
 \- set last modification time (mtime) for file in zip
 .SH "LIBRARY"
@@ -45,6 +46,13 @@ libzip (-lzip)
 .br
 .PD 0
 .HP 4n
+\fBzip_file_set_dostime\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ dostime\fR, \fIzip_uint16_t\ dosdate\fR, \fIzip_flags_t\ flags\fR);
+.PD
+.PP
+\fIint\fR
+.br
+.PD 0
+.HP 4n
 \fBzip_file_set_mtime\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fItime_t\ mtime\fR, \fIzip_flags_t\ flags\fR);
 .PD
 .SH "DESCRIPTION"
@@ -58,14 +66,46 @@ in the zip archive to
 Currently, no support for any
 \fIflags\fR
 is implemented.
+.PP
+In the zip archive, the time and date are saved as two 16-bit integers.
+To set the values directly, call the
+\fBzip_file_set_dostime\fR()
+function.
+The values of the time bytes are defined as follows:
+.RS 6n
+.TP 7n
+0-4
+day of the month (1-31)
+.TP 7n
+5-8
+month (January = 1, February = 2, ...)
+.TP 7n
+9-15
+year offset from 1980 (1980 = 0, 1981 = 1, ...)
+.RE
+.PP
+The values of the date bytes are defined as follows:
+.RS 6n
+.TP 7n
+0-4
+seconds divided by two (1-2 = 1, 3-4 = 2, ...)
+.TP 7n
+5-10
+minute (0-59)
+.TP 7n
+11-15
+hour (0-23)
+.RE
 .SH "RETURN VALUES"
 Upon successful completion 0 is returned.
 Otherwise, \-1 is returned and the error information in
 \fIarchive\fR
 is set to indicate the error.
 .SH "ERRORS"
+\fBzip_file_set_dostime\fR()
+and
 \fBzip_file_set_mtime\fR()
-fails if:
+fail if:
 .TP 19n
 [\fRZIP_ER_INVAL\fR]
 \fIindex\fR
@@ -85,7 +125,17 @@ zip_stat(3)
 .SH "HISTORY"
 \fBzip_file_set_mtime\fR()
 was added in libzip 1.0.
+\fBzip_file_set_dostime\fR()
+was added in libzip 1.6.
 .SH "AUTHORS"
 Dieter Baron <\fIdillo@nih.at\fR>
 and
 Thomas Klausner <\fItk@giga.or.at\fR>
+.SH "CAVEATS"
+Following historical practice, the
+\fBzip_file_set_mtime\fR()
+function translates the time from the zip archive into the local time
+zone.
+If you want to avoid this, use the
+\fBzip_file_set_dostime\fR()
+function instead.
index 32057b5..e024e24 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_file_set_mtime.mdoc -- set mtime for file in zip
-.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2014-2020 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP files.
 .\" The authors can be contacted at <libzip@nih.at>
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 18, 2017
+.Dd January 7, 2020
 .Dt ZIP_FILE_SET_MTIME 3
 .Os
 .Sh NAME
+.Nm zip_file_set_dostime ,
 .Nm zip_file_set_mtime
 .Nd set last modification time (mtime) for file in zip
 .Sh LIBRARY
@@ -40,6 +41,8 @@ libzip (-lzip)
 .Sh SYNOPSIS
 .In zip.h
 .Ft int
+.Fn zip_file_set_dostime "zip_t *archive" "zip_uint64_t index" "zip_uint16_t dostime" "zip_uint16_t dosdate" "zip_flags_t flags"
+.Ft int
 .Fn zip_file_set_mtime "zip_t *archive" "zip_uint64_t index" "time_t mtime" "zip_flags_t flags"
 .Sh DESCRIPTION
 The
@@ -52,14 +55,40 @@ in the zip archive to
 Currently, no support for any
 .Ar flags
 is implemented.
+.Pp
+In the zip archive, the time and date are saved as two 16-bit integers.
+To set the values directly, call the
+.Fn zip_file_set_dostime
+function.
+The values of the time bytes are defined as follows:
+.Bl -tag -width 5n -offset indent
+.It 0-4
+day of the month (1-31)
+.It 5-8
+month (January = 1, February = 2, ...)
+.It 9-15
+year offset from 1980 (1980 = 0, 1981 = 1, ...)
+.El
+.Pp
+The values of the date bytes are defined as follows:
+.Bl -tag -width 5n -offset indent
+.It 0-4
+seconds divided by two (1-2 = 1, 3-4 = 2, ...)
+.It 5-10
+minute (0-59)
+.It 11-15
+hour (0-23)
+.El
 .Sh RETURN VALUES
 Upon successful completion 0 is returned.
 Otherwise, \-1 is returned and the error information in
 .Ar archive
 is set to indicate the error.
 .Sh ERRORS
+.Fn zip_file_set_dostime
+and
 .Fn zip_file_set_mtime
-fails if:
+fail if:
 .Bl -tag -width Er
 .It Bq Er ZIP_ER_INVAL
 .Ar index
@@ -78,8 +107,18 @@ was opened in read-only mode.
 .Sh HISTORY
 .Fn zip_file_set_mtime
 was added in libzip 1.0.
+.Fn zip_file_set_dostime
+was added in libzip 1.6.
 .Sh AUTHORS
 .An -nosplit
 .An Dieter Baron Aq Mt dillo@nih.at
 and
 .An Thomas Klausner Aq Mt tk@giga.or.at
+.Sh CAVEATS
+Following historical practice, the
+.Fn zip_file_set_mtime
+function translates the time from the zip archive into the local time
+zone.
+If you want to avoid this, use the
+.Fn zip_file_set_dostime
+function instead.
index 8e19642..efcd37e 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_file_strerror.mdoc -- get string representation for a zip error
-   Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -108,7 +108,7 @@ The <code class="Fn">zip_strerror</code>() function returns a string describing
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index a8cee3a..db2b16d 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_file_strerror.mdoc -- get string representation for a zip error
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 1f16b9b..7ce929d 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_file_strerror.mdoc -- get string representation for a zip error
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 5367fae..d5e9b5c 100644 (file)
@@ -164,7 +164,7 @@ Upon successful completion, a <var class="Ft">struct zip_file</var> pointer is
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 51af5a9..3ef91e2 100644 (file)
@@ -137,7 +137,7 @@ Upon successful completion, a <var class="Ft">struct zip_file</var> pointer is
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index d6f5b16..c24d5a8 100644 (file)
@@ -103,7 +103,7 @@ If successful, the number of bytes actually read is returned. Otherwise, -1 is
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 7fb7f20..eceacfe 100644 (file)
@@ -103,7 +103,7 @@ If successful, <code class="Nm">zip_fseek</code> returns 0. Otherwise, -1 is
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index d38061a..5668f89 100644 (file)
@@ -100,7 +100,7 @@ If successful, <code class="Nm">zip_ftell</code> returns the current file
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index e2b8e32..5e68a85 100644 (file)
@@ -123,7 +123,7 @@ Upon successful completion, a pointer to the comment is returned, or
 <table class="foot">
   <tr>
     <td class="foot-date">July 22, 2018</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 1299aca..5c1eb8d 100644 (file)
@@ -111,7 +111,7 @@ The <code class="Fn">zip_get_archive_flag</code>() function returns if the flag
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index f7f50e1..0e2e8b8 100644 (file)
@@ -90,7 +90,7 @@ The <code class="Fn">zip_get_error</code>() function returns the zip error for
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 7242ee4..edfc61b 100644 (file)
@@ -98,7 +98,7 @@ The <code class="Fn">zip_get_file_comment</code>() function is the obsolete
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index e68dbbc..a2dc835 100644 (file)
@@ -139,7 +139,7 @@ Upon successful completion, a pointer to the name is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index a81a1ab..c2d00ff 100644 (file)
@@ -104,7 +104,7 @@ The <code class="Fn">zip_get_num_entries</code>() function returns the number of
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 82b8a85..a3b7f3e 100644 (file)
@@ -103,7 +103,7 @@ libzip (-lzip)
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index ed1b794..be00065 100644 (file)
   </tr>
 </table>
 <div class="manual-text">
-<h1 class="Sh" title="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
-<code class="Nm" title="Nm">zip_libzip_version</code> &#x2014;
-<div class="Nd" title="Nd">return run-time version of library</div>
-<h1 class="Sh" title="Sh" id="LIBRARY"><a class="permalink" href="#LIBRARY">LIBRARY</a></h1>
+<section class="Sh">
+<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
+<code class="Nm">zip_libzip_version</code> &#x2014;
+<div class="Nd">return run-time version of library</div>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="LIBRARY"><a class="permalink" href="#LIBRARY">LIBRARY</a></h1>
 libzip (-lzip)
-<h1 class="Sh" title="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
-<code class="In" title="In">#include
-  &lt;<a class="In" title="In">zip.h</a>&gt;</code>
-<div class="Pp"></div>
-<var class="Ft" title="Ft">const char *</var>
-<br/>
-<code class="Fn" title="Fn">zip_libzip_version</code>(<var class="Fa" title="Fa" style="white-space: nowrap;">void</var>);
-<h1 class="Sh" title="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
-<code class="Nm" title="Nm">zip_libzip_version</code> returns the version number
-  of the library as string in the format
-  &#x201C;$MAJOR.$MINOR.$MICRO$SUFFIX&#x201D; where
-  <var class="Ar" title="Ar">$MAJOR</var> is the major version,
-  <var class="Ar" title="Ar">$MINOR</var> the minor,
-  <var class="Ar" title="Ar">$MICRO</var> the micro, and
-  <var class="Ar" title="Ar">$SUFFIX</var> a suffix that's only set for
+</section>
+<section class="Sh">
+<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
+<code class="In">#include &lt;<a class="In">zip.h</a>&gt;</code>
+<p class="Pp"><var class="Ft">const char *</var>
+  <br/>
+  <code class="Fn">zip_libzip_version</code>(<var class="Fa" style="white-space: nowrap;">void</var>);</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
+<code class="Nm">zip_libzip_version</code> returns the version number of the
+  library as string in the format &#x201C;$MAJOR.$MINOR.$MICRO$SUFFIX&#x201D;
+  where <var class="Ar">$MAJOR</var> is the major version,
+  <var class="Ar">$MINOR</var> the minor, <var class="Ar">$MICRO</var> the
+  micro, and <var class="Ar">$SUFFIX</var> a suffix that's only set for
   development versions.
-<h1 class="Sh" title="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
+</section>
+<section class="Sh">
+<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
   ALSO</a></h1>
-<a class="Xr" title="Xr" href="libzip.html">libzip(3)</a>
-<h1 class="Sh" title="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
-<code class="Fn" title="Fn">zip_libzip_version</code>() was added in libzip
-  1.3.1.
-<h1 class="Sh" title="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
-<span class="An" title="An">Dieter Baron</span>
-  &lt;<a class="Mt" title="Mt" href="mailto:dillo@nih.at">dillo@nih.at</a>&gt;
-  and <span class="An" title="An">Thomas Klausner</span>
-  &lt;<a class="Mt" title="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>&gt;</div>
+<a class="Xr" href="libzip.html">libzip(3)</a>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
+<code class="Fn">zip_libzip_version</code>() was added in libzip 1.3.1.
+</section>
+<section class="Sh">
+<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
+<span class="An">Dieter Baron</span>
+  &lt;<a class="Mt" href="mailto:dillo@nih.at">dillo@nih.at</a>&gt; and
+  <span class="An">Thomas Klausner</span>
+  &lt;<a class="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>&gt;
+</section>
+</div>
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.27</td>
+    <td class="foot-os">NetBSD 8.99.35</td>
   </tr>
 </table>
 </body>
index 6648724..aefe44a 100644 (file)
@@ -141,7 +141,7 @@ The <code class="Fn">zip_name_locate</code>() function returns the index of the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 6be3f05..d6f69fb 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_open.mdoc -- open zip archive
-   Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -169,7 +169,7 @@ The archive specified by <var class="Ar">path</var> is opened unless:
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index c822395..5bf7cb3 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_open.mdoc -- open zip archive
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 49d036c..586af78 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_open.mdoc -- open zip archive
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 59ce4a2..d80b86b 100644 (file)
@@ -104,7 +104,7 @@ The function <code class="Fn">zip_register_progress_callback</code>() is the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index f6a0932..2da4275 100644 (file)
   </tr>
 </table>
 <div class="manual-text">
-<h1 class="Sh" title="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
-<code class="Nm" title="Nm">zip_register_progress_callback_with_state</code>
-  &#x2014;
-<div class="Nd" title="Nd">provide updates during zip_close</div>
-<h1 class="Sh" title="Sh" id="LIBRARY"><a class="permalink" href="#LIBRARY">LIBRARY</a></h1>
+<section class="Sh">
+<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
+<code class="Nm">zip_register_progress_callback_with_state</code> &#x2014;
+<div class="Nd">provide updates during zip_close</div>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="LIBRARY"><a class="permalink" href="#LIBRARY">LIBRARY</a></h1>
 libzip (-lzip)
-<h1 class="Sh" title="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
-<code class="In" title="In">#include
-  &lt;<a class="In" title="In">zip.h</a>&gt;</code>
-<div class="Pp"></div>
-<var class="Vt" title="Vt">typedef void (*zip_progress_callback)(zip_t *,
-  double, void *);</var>
-<div class="Pp"></div>
-<var class="Ft" title="Ft">void</var>
-<br/>
-<code class="Fn" title="Fn">zip_register_progress_callback_with_state</code>(<var class="Fa" title="Fa" style="white-space: nowrap;">zip_t
-  *archive</var>, <var class="Fa" title="Fa" style="white-space: nowrap;">double
-  precision</var>,
-  <var class="Fa" title="Fa" style="white-space: nowrap;">zip_progress_callback
-  callback</var>, <var class="Fa" title="Fa" style="white-space: nowrap;">void
-  (*ud_free)(void *)</var>,
-  <var class="Fa" title="Fa" style="white-space: nowrap;">void *ud</var>);
-<h1 class="Sh" title="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
-The
-  <code class="Fn" title="Fn">zip_register_progress_callback_with_state</code>()
-  function registers a callback function
-  <var class="Ar" title="Ar">callback</var> for the zip archive
-  <var class="Ar" title="Ar">archive</var>. The
-  <var class="Ar" title="Ar">precision</var> argument is a double in the range
-  from 0.00 to 1.0 that defines the smallest change for which the callback
-  should be called (to avoid too frequent calls). The
-  <var class="Ar" title="Ar">ud_free</var> function is called during cleanup for
-  deleting the userdata supplied in <var class="Ar" title="Ar">ud</var>.
-<div class="Pp"></div>
-The callback function is called during
-  <a class="Xr" title="Xr" href="zip_close.html">zip_close(3)</a> in regular
-  intervals (after every zip archive entry that's completely written to disk,
-  and while writing data for entries) with zip archive
-  <var class="Ar" title="Ar">archive</var>, the current progression state as a
-  <var class="Vt" title="Vt">double</var>, and the user-provided user-data
-  <var class="Ar" title="Ar">ud</var> as arguments. The progression state is a
-  <var class="Vt" title="Vt">double</var> in the range from 0.0 to 1.0. This can
-  be used to provide progress indicators for user interfaces.
-<h1 class="Sh" title="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
+</section>
+<section class="Sh">
+<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
+<code class="In">#include &lt;<a class="In">zip.h</a>&gt;</code>
+<p class="Pp"><var class="Vt">typedef void (*zip_progress_callback)(zip_t *,
+    double, void *);</var></p>
+<p class="Pp"><var class="Ft">void</var>
+  <br/>
+  <code class="Fn">zip_register_progress_callback_with_state</code>(<var class="Fa" style="white-space: nowrap;">zip_t
+    *archive</var>, <var class="Fa" style="white-space: nowrap;">double
+    precision</var>,
+    <var class="Fa" style="white-space: nowrap;">zip_progress_callback
+    callback</var>, <var class="Fa" style="white-space: nowrap;">void
+    (*ud_free)(void *)</var>, <var class="Fa" style="white-space: nowrap;">void
+    *ud</var>);</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
+The <code class="Fn">zip_register_progress_callback_with_state</code>() function
+  registers a callback function <var class="Ar">callback</var> for the zip
+  archive <var class="Ar">archive</var>. The <var class="Ar">precision</var>
+  argument is a double in the range from 0.00 to 1.0 that defines the smallest
+  change for which the callback should be called (to avoid too frequent calls).
+  The <var class="Ar">ud_free</var> function is called during cleanup for
+  deleting the userdata supplied in <var class="Ar">ud</var>.
+<p class="Pp">The callback function is called during
+    <a class="Xr" href="zip_close.html">zip_close(3)</a> in regular intervals
+    (after every zip archive entry that's completely written to disk, and while
+    writing data for entries) with zip archive <var class="Ar">archive</var>,
+    the current progression state as a <var class="Vt">double</var>, and the
+    user-provided user-data <var class="Ar">ud</var> as arguments. The
+    progression state is a <var class="Vt">double</var> in the range from 0.0 to
+    1.0. This can be used to provide progress indicators for user
+  interfaces.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
   ALSO</a></h1>
-<a class="Xr" title="Xr" href="libzip.html">libzip(3)</a>,
-  <a class="Xr" title="Xr" href="zip_close.html">zip_close(3)</a>
-<h1 class="Sh" title="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
-<code class="Fn" title="Fn">zip_register_progress_callback_with_state</code>()
-  was added in libzip 1.3.0.
-<h1 class="Sh" title="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
-<span class="An" title="An">Dieter Baron</span>
-  &lt;<a class="Mt" title="Mt" href="mailto:dillo@nih.at">dillo@nih.at</a>&gt;
-  and <span class="An" title="An">Thomas Klausner</span>
-  &lt;<a class="Mt" title="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>&gt;</div>
+<a class="Xr" href="libzip.html">libzip(3)</a>,
+  <a class="Xr" href="zip_close.html">zip_close(3)</a>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
+<code class="Fn">zip_register_progress_callback_with_state</code>() was added in
+  libzip 1.3.0.
+</section>
+<section class="Sh">
+<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
+<span class="An">Dieter Baron</span>
+  &lt;<a class="Mt" href="mailto:dillo@nih.at">dillo@nih.at</a>&gt; and
+  <span class="An">Thomas Klausner</span>
+  &lt;<a class="Mt" href="mailto:tk@giga.or.at">tk@giga.or.at</a>&gt;
+</section>
+</div>
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.27</td>
+    <td class="foot-os">NetBSD 8.99.35</td>
   </tr>
 </table>
 </body>
index 6d4d2f6..f137ea6 100644 (file)
@@ -97,7 +97,7 @@ libzip (-lzip)
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 13c92cf..f5ee9b3 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_set_archive_comment.mdoc -- set zip archive comment
-   Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -117,7 +117,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index d50ec71..2b5d9d2 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_set_archive_comment.mdoc -- set zip archive comment
-.\" Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 3d90b0b..f4bfad0 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_set_archive_comment.mdoc -- set zip archive comment
-.\" Copyright (C) 2006-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2006-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 0de64b6..9c72def 100644 (file)
@@ -100,7 +100,7 @@ Upon successful completion 0 is returned, and -1 if an error occurred.
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index ff4135a..5c38766 100644 (file)
@@ -112,7 +112,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index ee7591a..dc98e88 100644 (file)
@@ -102,7 +102,7 @@ The <code class="Fn">zip_set_file_comment</code>() function is the obsolete
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 07d8e03..a63dfcf 100644 (file)
@@ -141,7 +141,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 762d892..997ebd3 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source.mdoc -- description of zip data source
-   Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+   Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -110,7 +110,7 @@ A <var class="Vt">struct zip_source</var> is a data source used by
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 856401e..6b3098d 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source.mdoc -- description of zip data source
-.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 0795bd8..9f3398c 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source.mdoc -- description of zip data source
-.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index a5d1d9c..4fc8cb8 100644 (file)
@@ -116,7 +116,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 4e8a3a6..0d3d2a8 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_buffer.mdoc -- create zip data source from buffer
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -128,7 +128,7 @@ Upon successful completion, the created source is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 5e29096..2d6909c 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_buffer.mdoc -- create zip data source from buffer
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index a08927e..b8f0b19 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_buffer.mdoc -- create zip data source from buffer
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 0c3a670..612dd89 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_buffer_fragment.mdoc -- create zip data source from multiple buffers
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -143,7 +143,7 @@ Upon successful completion, the created source is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 7c8ebbc..772df19 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_buffer_fragment.mdoc -- create zip data source from multiple buffers
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index e39eba0..6ac35e0 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_buffer_fragment.mdoc -- create zip data source from multiple buffers
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index c3bf7bf..70e6ab5 100644 (file)
@@ -98,7 +98,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 2c3ebb1..430fd5d 100644 (file)
@@ -102,7 +102,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 16b982a..3447446 100644 (file)
@@ -90,7 +90,7 @@ The <code class="Fn">zip_source_error</code>() function returns the zip error
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 11ec0da..641ce17 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_file.mdoc -- create data source from a file
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -134,7 +134,7 @@ Upon successful completion, the created source is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index ab719a1..307c2a7 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_file.mdoc -- create data source from a file
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 90304dd..9f2ed4b 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_file.mdoc -- create data source from a file
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 423ac21..3e68493 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_filep.mdoc -- create data source from a file stream
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -130,7 +130,7 @@ Upon successful completion, the created source is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 8037262..c9d1853 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_filep.mdoc -- create data source from a file stream
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 848ba76..fc3f085 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_filep.mdoc -- create data source from a file stream
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 8c75385..f5ecad3 100644 (file)
@@ -97,7 +97,7 @@ The function <code class="Fn">zip_source_free</code>() decrements the reference
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index cc24448..b6bf91e 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_function.mdoc -- create data source from function
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -118,6 +118,12 @@ The functions <code class="Fn">zip_source_function</code>() and
       <code class="Dv">ZIP_SOURCE_REMOVE</code>.</dd>
 </dl>
 <section class="Ss">
+<h2 class="Ss"><code class="Dv">ZIP_SOURCE_ACCEPT_EMPTY</code></h2>
+Return 1 if an empty source should be accepted as a valid zip archive. This is
+  the default if this command is not supported by a source. File system backed
+  sources should return 0.
+</section>
+<section class="Ss">
 <h2 class="Ss"><code class="Dv">ZIP_SOURCE_BEGIN_WRITE</code></h2>
 Prepare the source for writing. Use this to create any temporary file(s).
 </section>
@@ -325,8 +331,8 @@ Upon successful completion, the created source is returned. Otherwise,
 </div>
 <table class="foot">
   <tr>
-    <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-date">September 17, 2019</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 073f56c..4901694 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_function.mdoc -- create data source from function
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -30,7 +30,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.TH "ZIP_SOURCE_FUNCTION" "3" "December 18, 2017" "NiH" "Library Functions Manual"
+.TH "ZIP_SOURCE_FUNCTION" "3" "September 17, 2019" "NiH" "Library Functions Manual"
 .nh
 .if n .ad l
 .SH "NAME"
@@ -120,6 +120,10 @@ Must additionally support
 \fRZIP_SOURCE_TELL_WRITE\fR,
 and
 \fRZIP_SOURCE_REMOVE\fR.
+.SS "\fRZIP_SOURCE_ACCEPT_EMPTY\fR"
+Return 1 if an empty source should be accepted as a valid zip archive.
+This is the default if this command is not supported by a source.
+File system backed sources should return 0.
 .SS "\fRZIP_SOURCE_BEGIN_WRITE\fR"
 Prepare the source for writing.
 Use this to create any temporary file(s).
index a433b37..9a9cc4b 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_function.mdoc -- create data source from function
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -29,7 +29,7 @@
 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 18, 2017
+.Dd September 17, 2019
 .Dt ZIP_SOURCE_FUNCTION 3
 .Os
 .Sh NAME
@@ -110,6 +110,10 @@ Must additionally support
 and
 .Dv ZIP_SOURCE_REMOVE .
 .El
+.Ss Dv ZIP_SOURCE_ACCEPT_EMPTY
+Return 1 if an empty source should be accepted as a valid zip archive.
+This is the default if this command is not supported by a source.
+File system backed sources should return 0.
 .Ss Dv ZIP_SOURCE_BEGIN_WRITE
 Prepare the source for writing.
 Use this to create any temporary file(s).
index 54e3602..95a8f04 100644 (file)
@@ -96,7 +96,7 @@ The function <code class="Fn">zip_source_is_deleted</code>() returns whether the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 392b82a..34b1267 100644 (file)
@@ -90,7 +90,7 @@ The function <code class="Fn">zip_source_keep</code>() increments the reference
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index a836bad..c2f5cb7 100644 (file)
@@ -92,7 +92,7 @@ The <code class="Fn">zip_source_make_command_bitmap</code>() function returns a
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 01fecc6..963489d 100644 (file)
@@ -101,7 +101,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 9a898ba..5208933 100644 (file)
@@ -105,7 +105,7 @@ Upon successful completion the number of bytes read is returned. Upon reading
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index b655ba0..1885c36 100644 (file)
@@ -103,7 +103,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 4063eb8..a6e8ab5 100644 (file)
@@ -113,7 +113,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index c6dfa95..eeca105 100644 (file)
@@ -112,7 +112,7 @@ On success, it returns the new offset, on error it returns -1 and sets
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index baedea3..01de4c0 100644 (file)
@@ -116,7 +116,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 8b911d2..1c26a78 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_stat.mdoc -- get information about zip source
-   Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+   Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -95,23 +95,23 @@ The structure pointed to by <var class="Ar">sb</var> must be initialized with
     defines are in <var class="Ar">valid</var> before accessing the fields:</p>
 <div class="Bd-indent">
 <dl class="Bl-tag Bl-compact">
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_NAME"><code class="Dv" id="ZIP_SOURCE_STAT_NAME">ZIP_SOURCE_STAT_NAME</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_NAME"><code class="Dv" id="ZIP_STAT_NAME">ZIP_STAT_NAME</code></a></dt>
   <dd><var class="Ar">name</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_INDEX"><code class="Dv" id="ZIP_SOURCE_STAT_INDEX">ZIP_SOURCE_STAT_INDEX</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_INDEX"><code class="Dv" id="ZIP_STAT_INDEX">ZIP_STAT_INDEX</code></a></dt>
   <dd><var class="Ar">index</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_SIZE"><code class="Dv" id="ZIP_SOURCE_STAT_SIZE">ZIP_SOURCE_STAT_SIZE</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_SIZE"><code class="Dv" id="ZIP_STAT_SIZE">ZIP_STAT_SIZE</code></a></dt>
   <dd><var class="Ar">size</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_COMP_SIZE"><code class="Dv" id="ZIP_SOURCE_STAT_COMP_SIZE">ZIP_SOURCE_STAT_COMP_SIZE</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_COMP_SIZE"><code class="Dv" id="ZIP_STAT_COMP_SIZE">ZIP_STAT_COMP_SIZE</code></a></dt>
   <dd><var class="Ar">comp_size</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_MTIME"><code class="Dv" id="ZIP_SOURCE_STAT_MTIME">ZIP_SOURCE_STAT_MTIME</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_MTIME"><code class="Dv" id="ZIP_STAT_MTIME">ZIP_STAT_MTIME</code></a></dt>
   <dd><var class="Ar">mtime</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_CRC"><code class="Dv" id="ZIP_SOURCE_STAT_CRC">ZIP_SOURCE_STAT_CRC</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_CRC"><code class="Dv" id="ZIP_STAT_CRC">ZIP_STAT_CRC</code></a></dt>
   <dd><var class="Ar">crc</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_COMP_METHOD"><code class="Dv" id="ZIP_SOURCE_STAT_COMP_METHOD">ZIP_SOURCE_STAT_COMP_METHOD</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_COMP_METHOD"><code class="Dv" id="ZIP_STAT_COMP_METHOD">ZIP_STAT_COMP_METHOD</code></a></dt>
   <dd><var class="Ar">comp_method</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_ENCRYPTION_METHOD"><code class="Dv" id="ZIP_SOURCE_STAT_ENCRYPTION_METHOD">ZIP_SOURCE_STAT_ENCRYPTION_METHOD</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_ENCRYPTION_METHOD"><code class="Dv" id="ZIP_STAT_ENCRYPTION_METHOD">ZIP_STAT_ENCRYPTION_METHOD</code></a></dt>
   <dd><var class="Ar">encryption_method</var></dd>
-  <dt><a class="permalink" href="#ZIP_SOURCE_STAT_FLAGS"><code class="Dv" id="ZIP_SOURCE_STAT_FLAGS">ZIP_SOURCE_STAT_FLAGS</code></a></dt>
+  <dt><a class="permalink" href="#ZIP_STAT_FLAGS"><code class="Dv" id="ZIP_STAT_FLAGS">ZIP_STAT_FLAGS</code></a></dt>
   <dd><var class="Ar">flags</var></dd>
 </dl>
 </div>
@@ -147,7 +147,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index cbc12ff..cb8443b 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_stat.mdoc -- get information about zip source
-.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -90,32 +90,32 @@ Check if the flag defined by the following defines are in
 before accessing the fields:
 .RS 6n
 .PD 0
-.TP 37n
-\fRZIP_SOURCE_STAT_NAME\fR
+.TP 30n
+\fRZIP_STAT_NAME\fR
 \fIname\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_INDEX\fR
+.TP 30n
+\fRZIP_STAT_INDEX\fR
 \fIindex\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_SIZE\fR
+.TP 30n
+\fRZIP_STAT_SIZE\fR
 \fIsize\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_COMP_SIZE\fR
+.TP 30n
+\fRZIP_STAT_COMP_SIZE\fR
 \fIcomp_size\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_MTIME\fR
+.TP 30n
+\fRZIP_STAT_MTIME\fR
 \fImtime\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_CRC\fR
+.TP 30n
+\fRZIP_STAT_CRC\fR
 \fIcrc\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_COMP_METHOD\fR
+.TP 30n
+\fRZIP_STAT_COMP_METHOD\fR
 \fIcomp_method\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_ENCRYPTION_METHOD\fR
+.TP 30n
+\fRZIP_STAT_ENCRYPTION_METHOD\fR
 \fIencryption_method\fR
-.TP 37n
-\fRZIP_SOURCE_STAT_FLAGS\fR
+.TP 30n
+\fRZIP_STAT_FLAGS\fR
 \fIflags\fR
 .RE
 .PD
index 69f4516..c501daa 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_stat.mdoc -- get information about zip source
-.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
@@ -79,24 +79,24 @@ field of the structure specifies which other fields are valid.
 Check if the flag defined by the following defines are in
 .Ar valid
 before accessing the fields:
-.Bl -tag -width ZIP_SOURCE_STAT_ENCRYPTION_METHODXX -compact -offset indent
-.It Dv ZIP_SOURCE_STAT_NAME
+.Bl -tag -width ZIP_STAT_ENCRYPTION_METHODXX -compact -offset indent
+.It Dv ZIP_STAT_NAME
 .Ar name
-.It Dv ZIP_SOURCE_STAT_INDEX
+.It Dv ZIP_STAT_INDEX
 .Ar index
-.It Dv ZIP_SOURCE_STAT_SIZE
+.It Dv ZIP_STAT_SIZE
 .Ar size
-.It Dv ZIP_SOURCE_STAT_COMP_SIZE
+.It Dv ZIP_STAT_COMP_SIZE
 .Ar comp_size
-.It Dv ZIP_SOURCE_STAT_MTIME
+.It Dv ZIP_STAT_MTIME
 .Ar mtime
-.It Dv ZIP_SOURCE_STAT_CRC
+.It Dv ZIP_STAT_CRC
 .Ar crc
-.It Dv ZIP_SOURCE_STAT_COMP_METHOD
+.It Dv ZIP_STAT_COMP_METHOD
 .Ar comp_method
-.It Dv ZIP_SOURCE_STAT_ENCRYPTION_METHOD
+.It Dv ZIP_STAT_ENCRYPTION_METHOD
 .Ar encryption_method
-.It Dv ZIP_SOURCE_STAT_FLAGS
+.It Dv ZIP_STAT_FLAGS
 .Ar flags
 .El
 .Pp
index 6fda2b4..bef6328 100644 (file)
@@ -101,7 +101,7 @@ Upon successful completion the current read offset is returned. Otherwise, -1 is
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 778896d..b2b9a01 100644 (file)
@@ -105,7 +105,7 @@ Upon successful completion the current write offset is returned. Otherwise, -1
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index a528c94..f6f2acb 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_win32a.mdoc -- create data source using a win32 ANSI name
-   Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -136,7 +136,7 @@ Upon successful completion, the created source is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 1001b5d..a6f279c 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_win32a.mdoc -- create data source using a win32 ANSI name
-.\" Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 9b6d762..5761caf 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_win32a.mdoc -- create data source using a win32 ANSI name
-.\" Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index f186f68..ecad454 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_handle.mdoc -- create data source from a Windows file handle
-   Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -136,7 +136,7 @@ Upon successful completion, the created source is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index f06a1e8..e7462cd 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_handle.mdoc -- create data source from a Windows file handle
-.\" Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 920fcb5..a1bf934 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_handle.mdoc -- create data source from a Windows file handle
-.\" Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 5958984..907fce7 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_win32w.mdoc -- create data source using a win32 Unicode name
-   Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -135,7 +135,7 @@ Upon successful completion, the created source is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">June 22, 2018</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 6e18d59..557a628 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_win32w.mdoc -- create data source using a win32 Unicode name
-.\" Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 75d30f4..aa1265d 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_win32w.mdoc -- create data source using a win32 Unicode name
-.\" Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 70e5c87..5b5d2b1 100644 (file)
@@ -108,7 +108,7 @@ Upon successful completion the number of bytes written is returned. Otherwise,
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index cb79b08..74dd28b 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zip_source_zip.mdoc -- create data source from zip file
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
@@ -136,7 +136,7 @@ Additionally, it can return all error codes from
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index efbcf0a..9719115 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zip_source_zip.mdoc -- create data source from zip file
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 4da7da4..943ceef 100644 (file)
@@ -1,5 +1,5 @@
 .\" zip_source_zip.mdoc -- create data source from zip file
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 246adb7..fc3c98d 100644 (file)
@@ -183,7 +183,7 @@ The function <code class="Fn">zip_stat</code>() can fail for any of the errors
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index d274b74..bc06322 100644 (file)
@@ -102,7 +102,7 @@ If <var class="Ar">sb</var> is valid, the function is always successful.
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 20ea1fd..d107a3f 100644 (file)
@@ -109,7 +109,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 27f5690..405fc83 100644 (file)
@@ -96,7 +96,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 770709c..e830f66 100644 (file)
@@ -96,7 +96,7 @@ Upon successful completion 0 is returned. Otherwise, -1 is returned and the
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 0cfdeee..a2245ab 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zipcmp.mdoc -- compare zip archives
-   Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 58cf205..fe84821 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zipcmp.mdoc -- compare zip archives
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index a3bc508..5311abf 100644 (file)
@@ -1,5 +1,5 @@
 .\" zipcmp.mdoc -- compare zip archives
-.\" Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index ce2d819..dfe7770 100644 (file)
@@ -2,7 +2,7 @@
 <html>
 <!-- This is an automatically generated file.  Do not edit.
    zipmerge.mdoc -- merge zip archives
-   Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+   Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
   
    This file is part of libzip, a library to manipulate ZIP archives.
    The authors can be contacted at <libzip@nih.at>
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 5ea5ef6..088b346 100644 (file)
@@ -1,6 +1,6 @@
 .\" Automatically generated from an mdoc input file.  Do not edit.
 .\" zipmerge.mdoc -- merge zip archives
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index 9c99514..bf0b869 100644 (file)
@@ -1,5 +1,5 @@
 .\" zipmerge.mdoc -- merge zip archives
-.\" Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+.\" Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 .\"
 .\" This file is part of libzip, a library to manipulate ZIP archives.
 .\" The authors can be contacted at <libzip@nih.at>
index ea9f406..6917345 100644 (file)
@@ -308,7 +308,7 @@ ziptool testfile.zip delete 0
 <table class="foot">
   <tr>
     <td class="foot-date">December 18, 2017</td>
-    <td class="foot-os">NetBSD 8.99.35</td>
+    <td class="foot-os">NetBSD 9.99.41</td>
   </tr>
 </table>
 </body>
index 6337e16..47c25d8 100644 (file)
@@ -83,12 +83,14 @@ SET(EXTRA_TESTS
        add_stored_in_memory.test
        buffer-fragment-read.test
        buffer-fragment-write.test
-        clone-buffer-add.test
-        clone-buffer-delete.test
-        clone-buffer-replace.test
-        clone-fs-add.test
-        clone-fs-delete.test
-        clone-fs-replace.test
+       cancel_45.test
+       cancel_90.test
+       clone-buffer-add.test
+       clone-buffer-delete.test
+       clone-buffer-replace.test
+       clone-fs-add.test
+       clone-fs-delete.test
+       clone-fs-replace.test
        cm-default.test
        count_entries.test
        decrypt-correct-password-aes128.test
@@ -178,7 +180,10 @@ SET(EXTRA_TESTS
        set_compression_store_to_bzip2.test
        set_compression_store_to_deflate.test
        set_compression_store_to_store.test
+       set_compression_store_to_xz.test
        set_compression_unknown.test
+       set_compression_xz_to_store.test
+       set_file_dostime.test
        stat_index_cp437_guess.test
        stat_index_cp437_raw.test
        stat_index_cp437_strict.test
@@ -196,11 +201,22 @@ SET(EXTRA_TESTS
        zip64_stored_creation.test
 )
 
+
+set(path "$<TARGET_FILE_DIR:zip>;$ENV{PATH}")
+if (TARGET zlib)
+  set(path "$<TARGET_FILE_DIR:zlib>;${path}")
+endif()
+string(REPLACE ";" "\\;" path "${path}")
+
 FOREACH(CASE ${EXTRA_TESTS})
-  ADD_TEST(${CASE} perl ${CMAKE_BINARY_DIR}/regress/runtest ${CMAKE_CURRENT_SOURCE_DIR}/${CASE})
+  ADD_TEST(NAME ${CASE} COMMAND perl ${CMAKE_CURRENT_BINARY_DIR}/runtest --bin-sub-directory $<CONFIG> ${CMAKE_CURRENT_SOURCE_DIR}/${CASE})
   SET_TESTS_PROPERTIES(${CASE} PROPERTIES SKIP_RETURN_CODE 77)
+  SET_TESTS_PROPERTIES(${CASE} PROPERTIES ENVIRONMENT "PATH=${path}")
 ENDFOREACH()
 
 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/../lib ${CMAKE_CURRENT_SOURCE_DIR}/../src ${CMAKE_CURRENT_BINARY_DIR}/..)
 
 ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
+
+ADD_EXECUTABLE(fuzz_main fuzz_main.c)
+TARGET_LINK_LIBRARIES(fuzz_main zip)
index 736ebae..66c2f0c 100644 (file)
@@ -8,6 +8,7 @@ use File::Copy;
 use File::Path qw(mkpath remove_tree);
 use Getopt::Long qw(:config posix_default bundling no_ignore_case);
 use IPC::Open3;
+#use IPC::Cmd qw(run);
 use Storable qw(dclone);
 use Symbol 'gensym';
 use UNIVERSAL;
@@ -419,6 +420,7 @@ sub setup {
        @ARGV = @argv;
        my $ok = GetOptions(
                'help|h' => \my $help,
+               'bin-sub-directory=s' => \$self->{bin_sub_directory},
                'keep-broken|k' => \$self->{keep_broken},
                'no-cleanup' => \$self->{no_cleanup},
                # 'run-gdb' => \$self->{run_gdb},
@@ -429,7 +431,7 @@ sub setup {
        @ARGV = @save_argv;
 
        if (!$ok || scalar(@argv) != 1 || $help) {
-               print STDERR "Usage: $0 [-hv] [--keep-broken] [--no-cleanup] [--setup-only] testcase\n";
+               print STDERR "Usage: $0 [-hv] [--bin-sub-directory DIR] [--keep-broken] [--no-cleanup] [--setup-only] testcase\n";
                exit(1);
        }
 
@@ -450,6 +452,7 @@ sub setup {
        $self->run_precheck() if ($self->{test}->{precheck});
 
        $self->end_test('SKIP') if ($self->{test}->{preload} && $^O eq 'darwin');
+       $self->end_test('SKIP') if (($self->{test}->{pipein} || $self->{test}->{pipefile}) && $^O eq 'MSWin32');
 }
 
 
@@ -508,7 +511,8 @@ sub check_features_requirement() {
 sub comparator_zip {
        my ($self, $got, $expected) = @_;
 
-       my @args = ($self->{zipcmp}, $self->{verbose} ? '-v' : '-q');
+       my $zipcmp = (-f $self->{zipcmp}) ? $self->{zipcmp} : $self->find_program('zipcmp');
+       my @args = ($zipcmp, $self->{verbose} ? '-v' : '-q');
        push @args, $self->{zipcmp_flags} if ($self->{zipcmp_flags});
        push @args, ($expected, $got);
 
@@ -598,7 +602,7 @@ sub list_files {
 
        while (scalar(@dirs) > 0) {
                my $dir = shift @dirs;
-               
+
                opendir($ls, $dir);
                unless ($ls) {
                        # TODO: handle error
@@ -608,7 +612,7 @@ sub list_files {
                        if ($dir eq '.') {
                                $file = $entry;
                        }
-                       
+
                        if (-f $file) {
                                push @files, "$file";
                        }
@@ -739,7 +743,7 @@ sub find_file() {
 
        for my $dir (('', "$self->{srcdir}/")) {
                my $f = "$dir$fname";
-               $f = "../$f" if ($self->{in_sandbox} && $dir !~ m,^/,);
+               $f = "../$f" if ($self->{in_sandbox} && $dir !~ m,^(\w:)?/,);
 
                return $f if (-f $f);
        }
@@ -899,7 +903,7 @@ sub parse_case() {
        my %test = ();
 
        while (my $line = <TST>) {
-               chomp $line;
+               $line =~ s/(\n|\r)//g;
 
                next if ($line =~ m/^\#/);
 
@@ -1090,9 +1094,9 @@ sub run_hook {
 
        return $ok;
 }
-sub args_decode {
 
 
+sub args_decode {
        my ($str, $srcdir) = @_;
 
        if ($str =~ m/\\/) {
@@ -1134,13 +1138,36 @@ sub run_precheck {
 }
 
 
+sub find_program() {
+        my ($self, $pname) = @_;
+
+       my @directories = (".");
+       if ($self->{bin_sub_directory}) {
+               push @directories, $self->{bin_sub_directory};
+       }
+
+       for my $up (('.', '..', '../..', '../../..')) {
+               for my $sub (('.', 'src')) {
+                       for my $dir (@directories) {
+                               for my $ext (('', '.exe')) {
+                                       my $f = "$up/$sub/$dir/$pname$ext";
+                                       return $f if (-f $f);
+                               }
+                       }
+               }
+       }
+
+       return undef;
+}
+
+
 sub run_program {
        my ($self) = @_;
-       goto &pipein_win32 if $^O eq 'MSWin32' && $self->{test}->{pipein};
+       goto &pipein_win32 if (($^O eq 'MSWin32') or ($^O eq 'msys')) && $self->{test}->{pipein};
        my ($stdin, $stdout, $stderr);
        $stderr = gensym;
 
-       my @cmd = ('../' . $self->{test}->{program}, map ({ args_decode($_, $self->{srcdir}); } @{$self->{test}->{args}}));
+       my @cmd = ($self->find_program($self->{test}->{program}), map ({ args_decode($_, $self->{srcdir}); } @{$self->{test}->{args}}));
 
        ### TODO: catch errors?
 
@@ -1170,25 +1197,14 @@ sub run_program {
         }
 
        while (my $line = <$stdout>) {
-               if ($^O eq 'MSWin32') {
-                       $line =~ s/[\r\n]+$//;
-               }
-               else {
-                       chomp $line;
-               }
+               $line =~ s/(\n|\r)//g;
                push @{$self->{stdout}}, $line;
        }
        my $prg = $self->{test}->{program};
        $prg =~ s,.*/,,;
        while (my $line = <$stderr>) {
-               if ($^O eq 'MSWin32') {
-                       $line =~ s/[\r\n]+$//;
-               }
-               else {
-                       chomp $line;
-               }
-
-               $line =~ s/^[^: ]*$prg: //;
+               $line =~ s/(\n|\r)//g;
+               $line =~ s/^[^: ]*$prg(\.exe)?: //;
                if (defined($self->{test}->{'stderr-replace'})) {
                        $line = $self->stderr_rewrite($self->{test}->{'stderr-replace'}, $line);
                }
@@ -1203,7 +1219,9 @@ sub run_program {
 sub pipein_win32() {
        my ($self) = @_;
 
-       my $cmd = "$self->{test}->{pipein}| ..\\$self->{test}->{program} " . join(' ', map ({ args_decode($_, $self->{srcdir}); } @{$self->{test}->{args}}));
+       # TODO this is currently broken, IPC::Cmd::run fails to load
+       my $program = $self->find_program($self->{test}->{program});
+       my $cmd = "$self->{test}->{pipein} | $program " . join(' ', map ({ args_decode($_, $self->{srcdir}); } @{$self->{test}->{args}}));
        my ($success, $error_message, $full_buf, $stdout_buf, $stderr_buf) = IPC::Cmd::run(command => $cmd);
        if (!$success) {
                ### TODO: catch errors?
@@ -1218,7 +1236,7 @@ sub pipein_win32() {
        foreach my $line (@$stderr_buf) {
                $line =~ s/[\r\n]+$//;
 
-               $line =~ s/^[^: ]*$prg: //;
+               $line =~ s/^[^: ]*$prg(\.exe)?: //;
                if (defined($self->{test}->{'stderr-replace'})) {
                        $line = $self->stderr_rewrite($self->{test}->{'stderr-replace'}, $line);
                }
@@ -1275,10 +1293,9 @@ sub sandbox_leave {
 sub sandbox_remove {
        my ($self) = @_;
 
-       my $ok = 1;
        remove_tree($self->{sandbox_dir});
 
-       return $ok;
+       return 1;
 }
 
 
index d477580..cb6fe92 100644 (file)
@@ -1,6 +1,6 @@
 /*
   add_from_filep.c -- test case for adding file to archive
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index 401e576..1f03b47 100644 (file)
@@ -1,6 +1,6 @@
 /*
  can_clone_file.c -- does the current filesystem support cloning
- Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
diff --git a/regress/cancel_45.test b/regress/cancel_45.test
new file mode 100644 (file)
index 0000000..ad273d3
--- /dev/null
@@ -0,0 +1,8 @@
+# test default compression stores if smaller; test cancel after 45%
+return 1
+args -n test.zip  cancel 45  add compressable aaaaaaaaaaaaaa  add uncompressable uncompressable  add_nul large-compressable 8200  add_file large-uncompressable large-uncompressable 0 -1
+file large-uncompressable large-uncompressable large-uncompressable
+stdout 0.0% done
+stdout 25.0% done
+stdout 50.0% done
+stderr can't close zip archive 'test.zip': Operation cancelled
diff --git a/regress/cancel_90.test b/regress/cancel_90.test
new file mode 100644 (file)
index 0000000..f4cf028
--- /dev/null
@@ -0,0 +1,10 @@
+# test default compression stores if smaller; test cancel after 90%
+return 1
+args -n test.zip  cancel 90  add compressable aaaaaaaaaaaaaa  add uncompressable uncompressable  add_nul large-compressable 8200  add_file large-uncompressable large-uncompressable 0 -1
+file large-uncompressable large-uncompressable large-uncompressable
+stdout 0.0% done
+stdout 25.0% done
+stdout 50.0% done
+stdout 75.0% done
+stdout 100.0% done
+stderr can't close zip archive 'test.zip': Operation cancelled
index 497d810..9c937b3 100644 (file)
@@ -1,6 +1,6 @@
 /*
   fopen_unchanged.c -- test case for adding file and reading from unchanged
-  Copyright (C) 2012-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index e27351c..e28b8c3 100644 (file)
@@ -1,6 +1,6 @@
 /*
   fread.c -- test cases for reading from zip archives
-  Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -104,7 +104,9 @@ main(int argc, char *argv[]) {
     fail += do_read(z, "storedcrcerror", 0, WHEN_READ, ZIP_ER_CRC, 0);
     fail += do_read(z, "deflatecrcerror", 0, WHEN_READ, ZIP_ER_CRC, 0);
     fail += do_read(z, "deflatezliberror", 0, WHEN_READ, ZIP_ER_ZLIB, -3);
+#ifndef __clang_analyzer__ /* This test intentionally violates nullability. */
     fail += do_read(z, NULL, 0, WHEN_OPEN, ZIP_ER_INVAL, 0);
+#endif
     fail += do_read(z, "nosuchfile", 0, WHEN_OPEN, ZIP_ER_NOENT, 0);
     fail += do_read(z, "deflatezliberror", ZIP_FL_COMPRESSED, WHEN_NEVER, 0, 0);
     fail += do_read(z, "deflatecrcerror", ZIP_FL_COMPRESSED, WHEN_NEVER, 0, 0);
index 19f3c40..cba1033 100644 (file)
@@ -1,6 +1,6 @@
 /*
   fseek.c -- test tool for seeking in zip archives
-  Copyright (C) 2016-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2016-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -77,6 +77,7 @@ main(int argc, char *argv[]) {
 
     if (zip_fseek(zf, offset, SEEK_SET) < 0) {
        fprintf(stderr, "%s: zip_fseek failed: %s\n", progname, zip_error_strerror(zip_file_get_error(zf)));
+       zip_fclose(zf);
        zip_close(z);
        return 1;
     }
@@ -86,10 +87,16 @@ main(int argc, char *argv[]) {
     }
     if (n < 0) {
        fprintf(stderr, "%s: zip_fread failed: %s\n", progname, zip_error_strerror(zip_file_get_error(zf)));
+       zip_fclose(zf);
        zip_close(z);
        return 1;
     }
 
+    if (zip_fclose(zf) == -1) {
+       fprintf(stderr, "%s: can't close zip archive entry %" PRIu64 " in '%s': %s\n", progname, index, archive, zip_strerror(z));
+       return 1;
+    }
+
     if (zip_close(z) == -1) {
        fprintf(stderr, "%s: can't close zip archive '%s': %s\n", progname, archive, zip_strerror(z));
        return 1;
diff --git a/regress/fuzz_main.c b/regress/fuzz_main.c
new file mode 100644 (file)
index 0000000..a0859e0
--- /dev/null
@@ -0,0 +1,50 @@
+#include "zip_read_fuzzer.cc"
+#include <stdio.h>
+#include <stdlib.h>
+
+/* fuzz target entry point, works without libFuzzer */
+
+int main(int argc, char **argv)
+{
+    FILE *f;
+    char *buf = NULL;
+    long siz_buf;
+
+    if (argc < 2) {
+        fprintf(stderr, "no input file\n");
+        goto err;
+    }
+
+    f = fopen(argv[1], "rb");
+    if (f == NULL) {
+        fprintf(stderr, "error opening input file %s\n", argv[1]);
+        goto err;
+    }
+
+    fseek(f, 0, SEEK_END);
+
+    siz_buf = ftell(f);
+    rewind(f);
+
+    if (siz_buf < 1) {
+       goto err;
+    }
+
+    buf = (char*)malloc(siz_buf);
+    if (buf == NULL) {
+        fprintf(stderr, "malloc() failed\n");
+        goto err;
+    }
+
+    if (fread(buf, siz_buf, 1, f) != 1) {
+        fprintf(stderr, "fread() failed\n");
+        goto err;
+    }
+
+    (void)LLVMFuzzerTestOneInput((uint8_t*)buf, siz_buf);
+
+err:
+    free(buf);
+
+    return 0;
+}
index 5f24966..542fc3a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  hole.c -- convert huge files with mostly NULs to/from source_hole
- Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
index ba5a105..0032c71 100644 (file)
@@ -1,6 +1,6 @@
 /*
   malloc.c -- override *alloc() to allow testing special cases
-  Copyright (C) 2015-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2015-2019 Dieter Baron and Thomas Klausner
 
   This file is part of ckmame, a program to check rom sets for MAME.
   The authors can be contacted at <ckmame@nih.at>
index c9833e0..5e3c629 100644 (file)
@@ -1,7 +1,7 @@
 /*
-  nonrandomopen.c -- override zip_random
+  nonrandomopen.c -- override zip_secure_random
 
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of ckmame, a program to check rom sets for MAME.
   The authors can be contacted at <ckmame@nih.at>
@@ -43,7 +43,7 @@
 #include "zipint.h"
 
 bool
-zip_random(zip_uint8_t *buffer, zip_uint16_t length) {
+zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) {
     memset(buffer, 0, length);
 
     return true;
index 1ed6249..be585ee 100644 (file)
@@ -1,6 +1,6 @@
 /*
   nonrandomopentest.c -- test nonrandomopen.so
-  Copyright (C) 2017-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2017-2019 Dieter Baron and Thomas Klausner
 
   This file is part of ckmame, a program to check rom sets for MAME.
   The authors can be contacted at <ckmame@nih.at>
@@ -42,8 +42,8 @@ main(int argc, const char *argv[]) {
     int i;
 
 #ifdef HAVE_CRYPTO
-    if (!zip_random(buf, sizeof(buf))) {
-       fprintf(stderr, "zip_random returned false\n");
+    if (!zip_secure_random(buf, sizeof(buf))) {
+       fprintf(stderr, "zip_secure_random returned false\n");
        exit(1);
     }
     for (i = 0; i < sizeof(buf); i++) {
index 07a5358..bb35bc6 100644 (file)
@@ -2,5 +2,6 @@
 program tryopen
 file testfile.txt testfile.txt testfile.txt
 args testfile.txt
-return 0
-stdout opening 'testfile.txt' succeeded, 0 entries
+return 1
+stdout opening 'testfile.txt' returned error 19
+stderr 1 errors
index 56f0447..5078978 100644 (file)
@@ -8,5 +8,5 @@ args incons-file-count-high.zzip incons-file-count-low.zzip incons-file-count-ov
 return 1
 stdout opening 'incons-file-count-high.zzip' returned error 21
 stdout opening 'incons-file-count-low.zzip' returned error 21
-stdout opening 'incons-file-count-overflow.zzip' returned error 14
+stdout opening 'incons-file-count-overflow.zzip' returned error 21
 stderr 3 errors
index 0843816..cda6afb 100644 (file)
@@ -60,7 +60,7 @@ stdout opening 'incons-ef-local-size.zzip' returned error 21
 stdout opening 'incons-eocd-magic-bad.zzip' returned error 19
 stdout opening 'incons-file-count-high.zzip' returned error 21
 stdout opening 'incons-file-count-low.zzip' returned error 21
-stdout opening 'incons-file-count-overflow.zzip' returned error 14
+stdout opening 'incons-file-count-overflow.zzip' returned error 21
 stdout opening 'incons-local-compression-method.zzip' returned error 21
 stdout opening 'incons-local-compsize-larger.zzip' returned error 21
 stdout opening 'incons-local-compsize-smaller.zzip' returned error 21
diff --git a/regress/ossfuzz.sh b/regress/ossfuzz.sh
new file mode 100755 (executable)
index 0000000..01e4170
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash -eu
+# Copyright 2019 Google Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+################################################################################
+
+# This script is meant to be run by
+# https://github.com/google/oss-fuzz/blob/master/projects/libzip/Dockerfile
+
+mkdir build
+cd build
+cmake -DBUILD_SHARED_LIBS=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=OFF -DBUILD_TOOLS=OFF -DENABLE_LZMA=OFF ..
+make -j$(nproc)
+
+$CXX $CXXFLAGS -std=c++11 -I. -I../lib \
+    $SRC/libzip/regress/zip_read_fuzzer.cc \
+    -o $OUT/zip_read_fuzzer \
+    $LIB_FUZZING_ENGINE $SRC/libzip/build/lib/libzip.a -lz
+
+find $SRC/libzip/regress -name "*.zip" | \
+     xargs zip $OUT/zip_read_fuzzer_seed_corpus.zip
+
+cp $SRC/libzip/regress/zip_read_fuzzer.dict $OUT/
+
diff --git a/regress/set_compression_store_to_xz.test b/regress/set_compression_store_to_xz.test
new file mode 100644 (file)
index 0000000..fe6d8db
--- /dev/null
@@ -0,0 +1,5 @@
+# change method from stored to xz-compressed
+features LIBLZMA
+return 0
+args test.zip  set_file_compression 0 xz 0
+file test.zip testfile-stored-dos.zip testfile-xz.zip
diff --git a/regress/set_compression_xz_to_store.test b/regress/set_compression_xz_to_store.test
new file mode 100644 (file)
index 0000000..6294ba2
--- /dev/null
@@ -0,0 +1,5 @@
+# change method from xz-compressed to stored
+features LIBLZMA
+return 0
+args test.zip  set_file_compression 0 store 0
+file test.zip testfile-xz.zip testfile-stored-dos.zip
diff --git a/regress/set_file_dostime.test b/regress/set_file_dostime.test
new file mode 100644 (file)
index 0000000..bd1af87
--- /dev/null
@@ -0,0 +1,4 @@
+# change dostime in a zip archive (use torrentzip default time)
+return 0
+args testfile set_file_dostime 0 48128 8600
+file testfile testfile.zip testfile0.zip
index dc3eec3..5791670 100644 (file)
@@ -1,6 +1,6 @@
 /*
  source_hole.c -- source for handling huge files that are mostly NULs
- Copyright (C) 2014-2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2019 Dieter Baron and Thomas Klausner
 
  This file is part of libzip, a library to manipulate ZIP archives.
  The authors can be contacted at <libzip@nih.at>
diff --git a/regress/testfile-lzma.zip b/regress/testfile-lzma.zip
new file mode 100644 (file)
index 0000000..59abb07
Binary files /dev/null and b/regress/testfile-lzma.zip differ
diff --git a/regress/testfile-stored-dos.zip b/regress/testfile-stored-dos.zip
new file mode 100644 (file)
index 0000000..beb6bdf
Binary files /dev/null and b/regress/testfile-stored-dos.zip differ
diff --git a/regress/testfile-xz.zip b/regress/testfile-xz.zip
new file mode 100644 (file)
index 0000000..6be8f9c
Binary files /dev/null and b/regress/testfile-xz.zip differ
diff --git a/regress/testfile0.zip b/regress/testfile0.zip
new file mode 100644 (file)
index 0000000..5e565d1
Binary files /dev/null and b/regress/testfile0.zip differ
index 32c96c8..ee379b8 100644 (file)
@@ -1,6 +1,6 @@
 /*
   tryopen.c -- tool for tests that try opening zip archives
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
 
 #include "compat.h"
 #include "zip.h"
-
-const char *usage = "usage: %s [-cent] file\n\n"
-                   "\t-c\tcheck consistency\n"
-                   "\t-e\texclusively open archive\n"
-                   "\t-n\tcreate new file\n"
-                   "\t-t\ttruncate file to size 0\n";
+#define TRYOPEN_USAGE "usage: %s [-cent] file\n\n" \
+                     "\t-c\tcheck consistency\n" \
+                     "\t-e\texclusively open archive\n" \
+                     "\t-n\tcreate new file\n" \
+                     "\t-t\ttruncate file to size 0\n"
 
 
 int
@@ -80,7 +79,7 @@ main(int argc, char *argv[]) {
            break;
 
        default:
-           fprintf(stderr, usage, argv[0]);
+           fprintf(stderr, TRYOPEN_USAGE, argv[0]);
            return 1;
        }
     }
diff --git a/regress/zip_read_fuzzer.cc b/regress/zip_read_fuzzer.cc
new file mode 100644 (file)
index 0000000..6813807
--- /dev/null
@@ -0,0 +1,48 @@
+#include <zip.h>
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
+{
+    zip_source_t *src;
+    zip_t *za;
+    zip_error_t error;
+    char buf[32768];
+    zip_int64_t i, n;
+    zip_file_t *f;
+
+    zip_error_init(&error);
+
+    if ((src = zip_source_buffer_create(data, size, 0, &error)) == NULL) {
+       zip_error_fini(&error);
+       return 0;
+    }
+
+    if ((za = zip_open_from_source(src, 0, &error)) == NULL) {
+       zip_source_free(src);
+       zip_error_fini(&error);
+       return 0;
+    }
+
+    zip_error_fini(&error);
+
+    n = zip_get_num_entries(za, 0);
+
+    for (i = 0; i < n; i++) {
+       f = zip_fopen_index(za, i, 0);
+       if (f == NULL) {
+           continue;
+       }
+
+       while (zip_fread(f, buf, sizeof(buf)) > 0) {
+           ;
+       }
+
+       zip_fclose(f);
+    }
+
+    zip_close(za);
+
+    return 0;
+}
diff --git a/regress/zip_read_fuzzer.dict b/regress/zip_read_fuzzer.dict
new file mode 100644 (file)
index 0000000..b54ac52
--- /dev/null
@@ -0,0 +1,3 @@
+header_lfh="\x50\x4b\x03\x04"
+header_cd="\x50\x4b\x01\x02"
+header_eocd="\x50\x4b\x05\x06"
index daf3d62..0b60fd0 100644 (file)
@@ -10,6 +10,7 @@ source_type_t source_type = SOURCE_TYPE_NONE;
 zip_uint64_t fragment_size = 0;
 
 static int add_nul(int argc, char *argv[]);
+static int cancel(int argc, char *argv[]);
 static int unchange_all(int argc, char *argv[]);
 static int zin_close(int argc, char *argv[]);
 
@@ -29,7 +30,10 @@ static int zin_close(int argc, char *argv[]);
        break;
 
 #define DISPATCH_REGRESS \
-    {"add_nul", 2, "name length", "add NUL bytes", add_nul}, {"unchange_all", 0, "", "revert all changes", unchange_all}, { "zin_close", 1, "index", "close input zip_source (for internal tests)", zin_close }
+    {"add_nul", 2, "name length", "add NUL bytes", add_nul}, \
+    {"cancel", 1, "limit", "cancel writing archive when limit% have been written (calls print_progress)", cancel}, \
+    {"unchange_all", 0, "", "revert all changes", unchange_all}, \
+    { "zin_close", 1, "index", "close input zip_source (for internal tests)", zin_close }
 
 
 zip_t *ziptool_open(const char *archive, int flags, zip_error_t *error, zip_uint64_t offset, zip_uint64_t len);
@@ -74,6 +78,31 @@ unchange_all(int argc, char *argv[]) {
 }
 
 static int
+cancel_callback(zip_t *archive, void *ud) {
+    if (progress_userdata.percentage >= progress_userdata.limit) {
+       return -1;
+    }
+    return 0;
+}
+
+static int
+cancel(int argc, char *argv[]) {
+    zip_int64_t percent;
+    percent = strtoll(argv[0], NULL, 10);
+    if (percent > 100 || percent < 0) {
+       fprintf(stderr, "invalid percentage '%" PRId64 "' for cancel (valid: 0 <= x <= 100)\n", percent);
+       return -1;
+    }
+    progress_userdata.limit = ((double)percent)/100;
+
+    zip_register_cancel_callback_with_state(za, cancel_callback, NULL, NULL);
+
+    /* needs the percentage updates from print_progress */
+    print_progress(argc, argv);
+    return 0;
+}
+
+static int
 zin_close(int argc, char *argv[]) {
     zip_uint64_t idx;
 
index ad1f38c..59db62a 100644 (file)
@@ -6,7 +6,7 @@ IF(NOT HAVE_GETOPT)
 ENDIF(NOT HAVE_GETOPT)
 
 ADD_EXECUTABLE(zipcmp zipcmp.c ${SRC_EXTRA_FILES})
-TARGET_LINK_LIBRARIES(zipcmp zip)
+TARGET_LINK_LIBRARIES(zipcmp zip ${FTS_LIB} ${ZLIB_LIBRARIES})
 INSTALL(TARGETS zipcmp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
 
 ADD_EXECUTABLE(zipmerge zipmerge.c ${SRC_EXTRA_FILES})
index 01dcd93..05669aa 100644 (file)
@@ -3,7 +3,7 @@
 
 /*
   getopt.h -- header for getopt() replacement function
-  Copyright (C) 1999-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 1999-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
index c452684..f08ea0b 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zipcmp.c -- compare zip files
-  Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -106,7 +106,7 @@ char help[] = "\n\
 Report bugs to <libzip@nih.at>.\n";
 
 char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\
-Copyright (C) 2003-2018 Dieter Baron and Thomas Klausner\n\
+Copyright (C) 2003-2019 Dieter Baron and Thomas Klausner\n\
 " PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n";
 
 #define OPTIONS "hVipqtv"
@@ -233,16 +233,25 @@ compare_zip(char *const zn[]) {
     if (paranoid) {
        if (comment_compare(a[0].comment, a[0].comment_length, a[1].comment, a[1].comment_length) != 0) {
            if (verbose) {
-               printf("--- archive comment (%ld)\n", a[0].comment_length);
-               printf("+++ archive comment (%ld)\n", a[1].comment_length);
+               printf("--- archive comment (%zd)\n", a[0].comment_length);
+               printf("+++ archive comment (%zd)\n", a[1].comment_length);
            }
            res = 1;
        }
     }
 
-    for (i = 0; i < 2; i++)
-       if (a[i].za)
+    for (i = 0; i < 2; i++) {
+       zip_uint64_t j;
+
+       if (a[i].za) {
            zip_close(a[i].za);
+       }
+       for (j = 0; j < a[i].nentry; j++) {
+           free(a[i].entry[j].name);
+           free(a[i].entry[j].extra_fields);
+       }
+       free(a[i].entry);
+    }
 
     switch (res) {
     case 0:
index 3b26c95..685bfdf 100644 (file)
@@ -1,6 +1,6 @@
 /*
   zipmerge.c -- merge zip archives
-  Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner
+  Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -71,7 +71,7 @@ char help[] = "\n\
 Report bugs to <libzip@nih.at>.\n";
 
 char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\
-Copyright (C) 2004-2018 Dieter Baron and Thomas Klausner\n\
+Copyright (C) 2004-2019 Dieter Baron and Thomas Klausner\n\
 " PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n";
 
 #define OPTIONS "hVDiIsS"
index e33b9b5..be30ab1 100644 (file)
@@ -1,6 +1,6 @@
 /*
   ziptool.c -- tool for modifying zip archive in multiple ways
-  Copyright (C) 2012-2019 Dieter Baron and Thomas Klausner
+  Copyright (C) 2012-2020 Dieter Baron and Thomas Klausner
 
   This file is part of libzip, a library to manipulate ZIP archives.
   The authors can be contacted at <libzip@nih.at>
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <time.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -386,9 +387,17 @@ name_locate(int argc, char *argv[]) {
     return 0;
 }
 
+struct progress_userdata_s {
+  double percentage;
+  double limit;
+};
+
+struct progress_userdata_s progress_userdata;
+
 static void
 progress_callback(zip_t *archive, double percentage, void *ud) {
     printf("%.1lf%% done\n", percentage * 100);
+    progress_userdata.percentage = percentage;
 }
 
 static int
@@ -496,6 +505,22 @@ set_file_encryption(int argc, char *argv[]) {
 }
 
 static int
+set_file_dostime(int argc, char *argv[]) {
+    /* set file last modification time (mtime) directly */
+    time_t mtime;
+    zip_uint16_t dostime, dosdate;
+    zip_uint64_t idx;
+    idx = strtoull(argv[0], NULL, 10);
+    dostime = (time_t)strtoull(argv[1], NULL, 10);
+    dosdate = (time_t)strtoull(argv[2], NULL, 10);
+    if (zip_file_set_dostime(za, idx, dostime, dosdate, 0) < 0) {
+       fprintf(stderr, "can't set file dostime at index '%" PRIu64 "' to '%d'/'%d': %s\n", idx, (int)dostime, (int)dosdate, zip_strerror(za));
+       return -1;
+    }
+    return 0;
+}
+
+static int
 set_file_mtime(int argc, char *argv[]) {
     /* set file last modification time (mtime) */
     time_t mtime;
@@ -503,7 +528,7 @@ set_file_mtime(int argc, char *argv[]) {
     idx = strtoull(argv[0], NULL, 10);
     mtime = (time_t)strtoull(argv[1], NULL, 10);
     if (zip_file_set_mtime(za, idx, mtime, 0) < 0) {
-       fprintf(stderr, "can't set file mtime at index '%" PRIu64 "' to '%ld': %s\n", idx, mtime, zip_strerror(za));
+       fprintf(stderr, "can't set file mtime at index '%" PRIu64 "' to '%lld': %s\n", idx, (long long)mtime, zip_strerror(za));
        return -1;
     }
     return 0;
@@ -523,7 +548,7 @@ set_file_mtime_all(int argc, char *argv[]) {
     }
     for (idx = 0; idx < (zip_uint64_t)num_entries; idx++) {
        if (zip_file_set_mtime(za, idx, mtime, 0) < 0) {
-           fprintf(stderr, "can't set file mtime at index '%" PRIu64 "' to '%ld': %s\n", idx, mtime, zip_strerror(za));
+           fprintf(stderr, "can't set file mtime at index '%" PRIu64 "' to '%lld': %s\n", idx, (long long)mtime, zip_strerror(za));
            return -1;
        }
     }
@@ -562,7 +587,12 @@ zstat(int argc, char *argv[]) {
        printf("compressed size: '%" PRIu64 "'\n", sb.comp_size);
     if (sb.valid & ZIP_STAT_MTIME) {
        struct tm *tpm;
+#ifdef HAVE_LOCALTIME_R
+       struct tm tm;
+       tpm = localtime_r(&sb.mtime, &tm);
+#else
        tpm = localtime(&sb.mtime);
+#endif
        if (tpm == NULL) {
            printf("mtime: <not valid>\n");
        } else {
@@ -611,6 +641,19 @@ get_compression_method(const char *arg) {
     else if (strcmp(arg, "bzip2") == 0)
        return ZIP_CM_BZIP2;
 #endif
+#if defined(HAVE_LIBLZMA)
+/*  Disabled - because 7z isn't able to unpack ZIP+LZMA ZIP+LZMA2
+    archives made this way - and vice versa.
+
+    else if (strcmp(arg, "lzma") == 0)
+      return ZIP_CM_LZMA;
+    else if (strcmp(arg, "lzma2") == 0)
+      return ZIP_CM_LZMA2;
+*/
+    else if (strcmp(arg, "xz") == 0)
+      return ZIP_CM_XZ;
+
+#endif
     else if (strcmp(arg, "unknown") == 0)
        return 100;
     return 0; /* TODO: error handling */
@@ -702,6 +745,7 @@ dispatch_table_t dispatch_table[] = {{"add", 2, "name content", "add file called
                                     {"set_extra", 5, "index extra_id extra_index flags value", "set extra field", set_extra},
                                     {"set_file_comment", 2, "index comment", "set file comment", set_file_comment},
                                     {"set_file_compression", 3, "index method compression_flags", "set file compression method", set_file_compression},
+                                    {"set_file_dostime", 3, "index time date", "set file modification time and date (DOS format)", set_file_dostime},
                                     {"set_file_encryption", 3, "index method password", "set file encryption method", set_file_encryption},
                                     {"set_file_mtime", 2, "index timestamp", "set file modification time", set_file_mtime},
                                     {"set_file_mtime_all", 1, "timestamp", "set file modification time for all files", set_file_mtime_all},