Imported Upstream version 3.2.2 88/134788/1 upstream/3.2.2
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 20 Jun 2017 05:06:13 +0000 (14:06 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 20 Jun 2017 05:06:18 +0000 (14:06 +0900)
Change-Id: Id505d6a62d71781731fdf0a4d9139d31c3e3190c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
170 files changed:
CMakeLists.txt
Makefile.am
Makefile.in
NEWS
README [deleted file]
aclocal.m4
build/autoconf/config.guess
build/autoconf/config.sub
build/cmake/CheckStructMember.cmake [deleted file]
build/cmake/config.h.in
build/version
cat/test/CMakeLists.txt
cat/test/main.c
cat/test/test.h
cat/test/test_version.c
config.h.in
configure
configure.ac
cpio/cmdline.c
cpio/cpio.c
cpio/test/CMakeLists.txt
cpio/test/main.c
cpio/test/test.h
cpio/test/test_option_version.c
doc/html/archive_entry.3.html
doc/html/archive_entry_acl.3.html
doc/html/archive_entry_linkify.3.html
doc/html/archive_entry_paths.3.html
doc/html/archive_entry_perms.3.html
doc/html/archive_entry_stat.3.html
doc/html/archive_entry_time.3.html
doc/html/archive_read.3.html
doc/html/archive_read_add_passphrase.3.html
doc/html/archive_read_data.3.html
doc/html/archive_read_disk.3.html
doc/html/archive_read_extract.3.html
doc/html/archive_read_filter.3.html
doc/html/archive_read_format.3.html
doc/html/archive_read_free.3.html
doc/html/archive_read_header.3.html
doc/html/archive_read_new.3.html
doc/html/archive_read_open.3.html
doc/html/archive_read_set_options.3.html
doc/html/archive_util.3.html
doc/html/archive_write.3.html
doc/html/archive_write_blocksize.3.html
doc/html/archive_write_data.3.html
doc/html/archive_write_disk.3.html
doc/html/archive_write_filter.3.html
doc/html/archive_write_finish_entry.3.html
doc/html/archive_write_format.3.html
doc/html/archive_write_free.3.html
doc/html/archive_write_header.3.html
doc/html/archive_write_new.3.html
doc/html/archive_write_open.3.html
doc/html/archive_write_set_options.3.html
doc/html/archive_write_set_passphrase.3.html
doc/html/bsdcpio.1.html
doc/html/bsdtar.1.html
doc/html/cpio.5.html
doc/html/libarchive-formats.5.html
doc/html/libarchive.3.html
doc/html/libarchive_changes.3.html
doc/html/libarchive_internals.3.html
doc/html/mtree.5.html
doc/html/tar.5.html
doc/pdf/archive_entry.3.pdf
doc/pdf/archive_entry_acl.3.pdf
doc/pdf/archive_entry_linkify.3.pdf
doc/pdf/archive_entry_paths.3.pdf
doc/pdf/archive_entry_perms.3.pdf
doc/pdf/archive_entry_stat.3.pdf
doc/pdf/archive_entry_time.3.pdf
doc/pdf/archive_read.3.pdf
doc/pdf/archive_read_add_passphrase.3.pdf
doc/pdf/archive_read_data.3.pdf
doc/pdf/archive_read_disk.3.pdf
doc/pdf/archive_read_extract.3.pdf
doc/pdf/archive_read_filter.3.pdf
doc/pdf/archive_read_format.3.pdf
doc/pdf/archive_read_free.3.pdf
doc/pdf/archive_read_header.3.pdf
doc/pdf/archive_read_new.3.pdf
doc/pdf/archive_read_open.3.pdf
doc/pdf/archive_read_set_options.3.pdf
doc/pdf/archive_util.3.pdf
doc/pdf/archive_write.3.pdf
doc/pdf/archive_write_blocksize.3.pdf
doc/pdf/archive_write_data.3.pdf
doc/pdf/archive_write_disk.3.pdf
doc/pdf/archive_write_filter.3.pdf
doc/pdf/archive_write_finish_entry.3.pdf
doc/pdf/archive_write_format.3.pdf
doc/pdf/archive_write_free.3.pdf
doc/pdf/archive_write_header.3.pdf
doc/pdf/archive_write_new.3.pdf
doc/pdf/archive_write_open.3.pdf
doc/pdf/archive_write_set_options.3.pdf
doc/pdf/archive_write_set_passphrase.3.pdf
doc/pdf/bsdcpio.1.pdf
doc/pdf/bsdtar.1.pdf
doc/pdf/cpio.5.pdf
doc/pdf/libarchive-formats.5.pdf
doc/pdf/libarchive.3.pdf
doc/pdf/libarchive_changes.3.pdf
doc/pdf/libarchive_internals.3.pdf
doc/pdf/mtree.5.pdf
doc/pdf/tar.5.pdf
examples/minitar/minitar.c
libarchive/archive.h
libarchive/archive_acl.c
libarchive/archive_entry.h
libarchive/archive_match.c
libarchive/archive_platform.h
libarchive/archive_ppmd7_private.h
libarchive/archive_read_add_passphrase.c
libarchive/archive_read_disk_entry_from_file.c
libarchive/archive_read_disk_posix.c
libarchive/archive_read_disk_set_standard_lookup.c
libarchive/archive_read_disk_windows.c
libarchive/archive_read_private.h
libarchive/archive_read_support_filter_lz4.c
libarchive/archive_read_support_format_7zip.c
libarchive/archive_read_support_format_lha.c
libarchive/archive_read_support_format_mtree.c
libarchive/archive_read_support_format_tar.c
libarchive/archive_read_support_format_warc.c
libarchive/archive_read_support_format_zip.c
libarchive/archive_string.c
libarchive/archive_util.c
libarchive/archive_write_disk_acl.c
libarchive/archive_write_disk_posix.c
libarchive/archive_write_set_format_iso9660.c
libarchive/archive_write_set_format_ustar.c
libarchive/config_freebsd.h
libarchive/test/CMakeLists.txt
libarchive/test/list.h
libarchive/test/main.c
libarchive/test/test.h
libarchive/test/test_acl_freebsd_nfs4.c
libarchive/test/test_acl_freebsd_posix1e.c
libarchive/test/test_archive_string_conversion.c
libarchive/test/test_fuzz.c
libarchive/test/test_read_format_mtree_crash747.c [new file with mode: 0644]
libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu [new file with mode: 0644]
libarchive/test/test_read_format_rar.c
libarchive/test/test_read_format_zip_high_compression.c [new file with mode: 0644]
libarchive/test/test_read_format_zip_high_compression.zip.uu [new file with mode: 0644]
libarchive/test/test_read_set_format.c
libarchive/test/test_write_disk_secure744.c [new file with mode: 0644]
libarchive/test/test_write_disk_secure745.c [new file with mode: 0644]
libarchive/test/test_write_disk_secure746.c [new file with mode: 0644]
libarchive/test/test_write_format_gnutar_filenames.c
libarchive/test/test_write_format_iso9660.c
libarchive_fe/passphrase.c
tar/cmdline.c
tar/subst.c
tar/test/CMakeLists.txt
tar/test/main.c
tar/test/test.h
tar/test/test_missing_file.c
tar/test/test_option_H_upper.c
tar/test/test_option_L_upper.c
tar/test/test_option_U_upper.c
tar/test/test_option_b.c
tar/test/test_option_n.c
tar/test/test_symlink_dir.c
tar/test/test_version.c
tar/util.c
tar/write.c

index 68e94a6..a376fce 100644 (file)
@@ -274,7 +274,7 @@ INCLUDE(CheckHeaderDirent)
 INCLUDE(CheckIncludeFile)
 INCLUDE(CheckIncludeFiles)
 INCLUDE(CheckLibraryExists)
-INCLUDE(CheckStructMember)
+INCLUDE(CheckStructHasMember)
 INCLUDE(CheckSymbolExists)
 INCLUDE(CheckTypeExists)
 INCLUDE(CheckTypeSize)
@@ -1274,6 +1274,14 @@ CHECK_FUNCTION_EXISTS(wmemmove HAVE_WMEMMOVE)
 
 CMAKE_POP_CHECK_STATE()        # Restore the state of the variables
 
+CHECK_C_SOURCE_COMPILES(
+  "#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct vfsconf v; return sizeof(v);}"
+  HAVE_STRUCT_VFSCONF)
+
+CHECK_C_SOURCE_COMPILES(
+  "#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct xvfsconf v; return sizeof(v);}"
+  HAVE_STRUCT_XVFSCONF)
+
 # Make sure we have the POSIX version of readdir_r, not the
 # older 2-argument version.
 CHECK_C_SOURCE_COMPILES(
@@ -1299,6 +1307,10 @@ CHECK_C_SOURCE_COMPILES(
   "#include <sys/sysmacros.h>\nint main() { return major(256); }"
   MAJOR_IN_SYSMACROS)
 
+CHECK_C_SOURCE_COMPILES(
+  "#include <lzma.h>\n#if LZMA_VERSION < 50020000\n#error unsupported\n#endif\nint main(void){lzma_stream_encoder_mt(0, 0); return 0;}"
+  HAVE_LZMA_STREAM_ENCODER_MT)
+
 IF(HAVE_STRERROR_R)
   SET(HAVE_DECL_STRERROR_R 1)
 ENDIF(HAVE_STRERROR_R)
@@ -1332,47 +1344,47 @@ CHECK_SYMBOL_EXISTS(SSIZE_MAX        "limits.h"   HAVE_DECL_SSIZE_MAX)
 # Check struct members
 #
 # Check for tm_gmtoff in struct tm
-CHECK_STRUCT_MEMBER("struct tm" tm_gmtoff
+CHECK_STRUCT_HAS_MEMBER("struct tm" tm_gmtoff
     "time.h" HAVE_STRUCT_TM_TM_GMTOFF)
-CHECK_STRUCT_MEMBER("struct tm" __tm_gmtoff
+CHECK_STRUCT_HAS_MEMBER("struct tm" __tm_gmtoff
     "time.h" HAVE_STRUCT_TM___TM_GMTOFF)
 
 # Check for f_namemax in struct statfs
-CHECK_STRUCT_MEMBER("struct statfs" f_namemax
+CHECK_STRUCT_HAS_MEMBER("struct statfs" f_namemax
     "sys/param.h;sys/mount.h" HAVE_STRUCT_STATFS_F_NAMEMAX)
 
 # Check for birthtime in struct stat
-CHECK_STRUCT_MEMBER("struct stat" st_birthtime
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtime
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIME)
 
 # Check for high-resolution timestamps in struct stat
-CHECK_STRUCT_MEMBER("struct stat" st_birthtimespec.tv_nsec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtimespec.tv_nsec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC)
-CHECK_STRUCT_MEMBER("struct stat" st_mtimespec.tv_nsec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC)
-CHECK_STRUCT_MEMBER("struct stat" st_mtim.tv_nsec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
-CHECK_STRUCT_MEMBER("struct stat" st_mtime_n
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_n
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_N)
-CHECK_STRUCT_MEMBER("struct stat" st_umtime
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_umtime
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_UMTIME)
-CHECK_STRUCT_MEMBER("struct stat" st_mtime_usec
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_usec
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_MTIME_USEC)
 # Check for block size support in struct stat
-CHECK_STRUCT_MEMBER("struct stat" st_blksize
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_blksize
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_BLKSIZE)
 # Check for st_flags in struct stat (BSD fflags)
-CHECK_STRUCT_MEMBER("struct stat" st_flags
+CHECK_STRUCT_HAS_MEMBER("struct stat" st_flags
     "sys/types.h;sys/stat.h" HAVE_STRUCT_STAT_ST_FLAGS)
 
 IF(HAVE_SYS_STATVFS_H)
-  CHECK_STRUCT_MEMBER("struct statvfs" f_iosize
+  CHECK_STRUCT_HAS_MEMBER("struct statvfs" f_iosize
     "sys/types.h;sys/statvfs.h" HAVE_STRUCT_STATVFS_F_IOSIZE)
 ENDIF()
 
 #
 #
-CHECK_STRUCT_MEMBER("struct tm" tm_sec
+CHECK_STRUCT_HAS_MEMBER("struct tm" tm_sec
     "sys/types.h;sys/time.h;time.h" TIME_WITH_SYS_TIME)
 
 #
@@ -1592,6 +1604,7 @@ IF(ENABLE_ACL)
   # test for specific permissions in a permset.)  Linux uses the obvious
   # name, FreeBSD adds _np to mark it as "non-Posix extension."
   # Test for both as a double-check that we really have POSIX-style ACL support.
+  CHECK_FUNCTION_EXISTS(acl_get_fd_np HAVE_ACL_GET_FD_NP)
   CHECK_FUNCTION_EXISTS(acl_get_perm HAVE_ACL_GET_PERM)
   CHECK_FUNCTION_EXISTS(acl_get_perm_np HAVE_ACL_GET_PERM_NP)
   CHECK_FUNCTION_EXISTS(acl_get_link HAVE_ACL_GET_LINK)
index b02797f..5fe2d49 100644 (file)
@@ -449,6 +449,7 @@ libarchive_test_SOURCES= \
        libarchive/test/test_read_format_lha_bugfix_0.c \
        libarchive/test/test_read_format_lha_filename.c \
        libarchive/test/test_read_format_mtree.c \
+       libarchive/test/test_read_format_mtree_crash747.c \
        libarchive/test/test_read_format_pax_bz2.c \
        libarchive/test/test_read_format_rar.c \
        libarchive/test/test_read_format_rar_encryption_data.c \
@@ -475,6 +476,7 @@ libarchive_test_SOURCES= \
        libarchive/test/test_read_format_zip_encryption_partially.c \
        libarchive/test/test_read_format_zip_encryption_header.c \
        libarchive/test/test_read_format_zip_filename.c \
+       libarchive/test/test_read_format_zip_high_compression.c \
        libarchive/test/test_read_format_zip_mac_metadata.c \
        libarchive/test/test_read_format_zip_malformed.c \
        libarchive/test/test_read_format_zip_msdos.c \
@@ -509,6 +511,9 @@ libarchive_test_SOURCES= \
        libarchive/test/test_write_disk_no_hfs_compression.c \
        libarchive/test/test_write_disk_perms.c \
        libarchive/test/test_write_disk_secure.c \
+       libarchive/test/test_write_disk_secure744.c \
+       libarchive/test/test_write_disk_secure745.c \
+       libarchive/test/test_write_disk_secure746.c \
        libarchive/test/test_write_disk_sparse.c \
        libarchive/test/test_write_disk_symlink.c \
        libarchive/test/test_write_disk_times.c \
@@ -657,6 +662,7 @@ libarchive_test_EXTRA_DIST=\
        libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
        libarchive/test/test_read_filter_lzop.tar.lzo.uu \
        libarchive/test/test_read_filter_lzop_multiple_parts.tar.lzo.uu \
+       libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu \
        libarchive/test/test_read_format_7zip_bcj2_bzip2.7z.uu \
        libarchive/test/test_read_format_7zip_bcj2_copy_1.7z.uu \
        libarchive/test/test_read_format_7zip_bcj2_copy_2.7z.uu \
@@ -782,6 +788,7 @@ libarchive_test_EXTRA_DIST=\
        libarchive/test/test_read_format_zip_filename_utf8_jp.zip.uu \
        libarchive/test/test_read_format_zip_filename_utf8_ru.zip.uu \
        libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \
+       libarchive/test/test_read_format_zip_high_compression.zip.uu \
        libarchive/test/test_read_format_zip_length_at_end.zip.uu \
        libarchive/test/test_read_format_zip_mac_metadata.zip.uu \
        libarchive/test/test_read_format_zip_malformed1.zip.uu \
index 0d860d3..46b6976 100644 (file)
@@ -857,6 +857,7 @@ am__libarchive_test_SOURCES_DIST = libarchive/archive_acl.c \
        libarchive/test/test_read_format_lha_bugfix_0.c \
        libarchive/test/test_read_format_lha_filename.c \
        libarchive/test/test_read_format_mtree.c \
+       libarchive/test/test_read_format_mtree_crash747.c \
        libarchive/test/test_read_format_pax_bz2.c \
        libarchive/test/test_read_format_rar.c \
        libarchive/test/test_read_format_rar_encryption_data.c \
@@ -883,6 +884,7 @@ am__libarchive_test_SOURCES_DIST = libarchive/archive_acl.c \
        libarchive/test/test_read_format_zip_encryption_partially.c \
        libarchive/test/test_read_format_zip_encryption_header.c \
        libarchive/test/test_read_format_zip_filename.c \
+       libarchive/test/test_read_format_zip_high_compression.c \
        libarchive/test/test_read_format_zip_mac_metadata.c \
        libarchive/test/test_read_format_zip_malformed.c \
        libarchive/test/test_read_format_zip_msdos.c \
@@ -917,6 +919,9 @@ am__libarchive_test_SOURCES_DIST = libarchive/archive_acl.c \
        libarchive/test/test_write_disk_no_hfs_compression.c \
        libarchive/test/test_write_disk_perms.c \
        libarchive/test/test_write_disk_secure.c \
+       libarchive/test/test_write_disk_secure744.c \
+       libarchive/test/test_write_disk_secure745.c \
+       libarchive/test/test_write_disk_secure746.c \
        libarchive/test/test_write_disk_sparse.c \
        libarchive/test/test_write_disk_symlink.c \
        libarchive/test/test_write_disk_times.c \
@@ -1230,6 +1235,7 @@ am_libarchive_test_OBJECTS = $(am__objects_9) $(am__objects_10) \
        libarchive/test/libarchive_test-test_read_format_lha_bugfix_0.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_lha_filename.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_mtree.$(OBJEXT) \
+       libarchive/test/libarchive_test-test_read_format_mtree_crash747.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_pax_bz2.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_rar.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_rar_encryption_data.$(OBJEXT) \
@@ -1256,6 +1262,7 @@ am_libarchive_test_OBJECTS = $(am__objects_9) $(am__objects_10) \
        libarchive/test/libarchive_test-test_read_format_zip_encryption_partially.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_zip_encryption_header.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_zip_filename.$(OBJEXT) \
+       libarchive/test/libarchive_test-test_read_format_zip_high_compression.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_zip_mac_metadata.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_zip_malformed.$(OBJEXT) \
        libarchive/test/libarchive_test-test_read_format_zip_msdos.$(OBJEXT) \
@@ -1290,6 +1297,9 @@ am_libarchive_test_OBJECTS = $(am__objects_9) $(am__objects_10) \
        libarchive/test/libarchive_test-test_write_disk_no_hfs_compression.$(OBJEXT) \
        libarchive/test/libarchive_test-test_write_disk_perms.$(OBJEXT) \
        libarchive/test/libarchive_test-test_write_disk_secure.$(OBJEXT) \
+       libarchive/test/libarchive_test-test_write_disk_secure744.$(OBJEXT) \
+       libarchive/test/libarchive_test-test_write_disk_secure745.$(OBJEXT) \
+       libarchive/test/libarchive_test-test_write_disk_secure746.$(OBJEXT) \
        libarchive/test/libarchive_test-test_write_disk_sparse.$(OBJEXT) \
        libarchive/test/libarchive_test-test_write_disk_symlink.$(OBJEXT) \
        libarchive/test/libarchive_test-test_write_disk_times.$(OBJEXT) \
@@ -1618,7 +1628,7 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \
        $(top_srcdir)/build/autoconf/missing \
        $(top_srcdir)/build/autoconf/test-driver \
        $(top_srcdir)/build/pkgconfig/libarchive.pc.in COPYING INSTALL \
-       NEWS README build/autoconf/compile build/autoconf/config.guess \
+       NEWS build/autoconf/compile build/autoconf/config.guess \
        build/autoconf/config.rpath build/autoconf/config.sub \
        build/autoconf/depcomp build/autoconf/install-sh \
        build/autoconf/ltmain.sh build/autoconf/missing
@@ -1689,6 +1699,7 @@ LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBICONV = @LTLIBICONV@
 LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -2159,6 +2170,7 @@ libarchive_test_SOURCES = \
        libarchive/test/test_read_format_lha_bugfix_0.c \
        libarchive/test/test_read_format_lha_filename.c \
        libarchive/test/test_read_format_mtree.c \
+       libarchive/test/test_read_format_mtree_crash747.c \
        libarchive/test/test_read_format_pax_bz2.c \
        libarchive/test/test_read_format_rar.c \
        libarchive/test/test_read_format_rar_encryption_data.c \
@@ -2185,6 +2197,7 @@ libarchive_test_SOURCES = \
        libarchive/test/test_read_format_zip_encryption_partially.c \
        libarchive/test/test_read_format_zip_encryption_header.c \
        libarchive/test/test_read_format_zip_filename.c \
+       libarchive/test/test_read_format_zip_high_compression.c \
        libarchive/test/test_read_format_zip_mac_metadata.c \
        libarchive/test/test_read_format_zip_malformed.c \
        libarchive/test/test_read_format_zip_msdos.c \
@@ -2219,6 +2232,9 @@ libarchive_test_SOURCES = \
        libarchive/test/test_write_disk_no_hfs_compression.c \
        libarchive/test/test_write_disk_perms.c \
        libarchive/test/test_write_disk_secure.c \
+       libarchive/test/test_write_disk_secure744.c \
+       libarchive/test/test_write_disk_secure745.c \
+       libarchive/test/test_write_disk_secure746.c \
        libarchive/test/test_write_disk_sparse.c \
        libarchive/test/test_write_disk_symlink.c \
        libarchive/test/test_write_disk_times.c \
@@ -2358,6 +2374,7 @@ libarchive_test_EXTRA_DIST = \
        libarchive/test/test_read_filter_lrzip.tar.lrz.uu \
        libarchive/test/test_read_filter_lzop.tar.lzo.uu \
        libarchive/test/test_read_filter_lzop_multiple_parts.tar.lzo.uu \
+       libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu \
        libarchive/test/test_read_format_7zip_bcj2_bzip2.7z.uu \
        libarchive/test/test_read_format_7zip_bcj2_copy_1.7z.uu \
        libarchive/test/test_read_format_7zip_bcj2_copy_2.7z.uu \
@@ -2483,6 +2500,7 @@ libarchive_test_EXTRA_DIST = \
        libarchive/test/test_read_format_zip_filename_utf8_jp.zip.uu \
        libarchive/test/test_read_format_zip_filename_utf8_ru.zip.uu \
        libarchive/test/test_read_format_zip_filename_utf8_ru2.zip.uu \
+       libarchive/test/test_read_format_zip_high_compression.zip.uu \
        libarchive/test/test_read_format_zip_length_at_end.zip.uu \
        libarchive/test/test_read_format_zip_mac_metadata.zip.uu \
        libarchive/test/test_read_format_zip_malformed1.zip.uu \
@@ -2866,7 +2884,7 @@ all: $(BUILT_SOURCES) config.h
 .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
 am--refresh: Makefile
        @:
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
        @for dep in $?; do \
          case '$(am__configure_deps)' in \
            *$$dep*) \
@@ -2892,9 +2910,9 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
        $(SHELL) ./config.status --recheck
 
-$(top_srcdir)/configure:  $(am__configure_deps)
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
        $(am__cd) $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
        $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
 $(am__aclocal_m4_deps):
 
@@ -2905,7 +2923,7 @@ config.h: stamp-h1
 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
        @rm -f stamp-h1
        cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in:  $(am__configure_deps) 
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
        ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
        rm -f stamp-h1
        touch $@
@@ -4442,6 +4460,9 @@ libarchive/test/libarchive_test-test_read_format_lha_filename.$(OBJEXT):  \
 libarchive/test/libarchive_test-test_read_format_mtree.$(OBJEXT):  \
        libarchive/test/$(am__dirstamp) \
        libarchive/test/$(DEPDIR)/$(am__dirstamp)
+libarchive/test/libarchive_test-test_read_format_mtree_crash747.$(OBJEXT):  \
+       libarchive/test/$(am__dirstamp) \
+       libarchive/test/$(DEPDIR)/$(am__dirstamp)
 libarchive/test/libarchive_test-test_read_format_pax_bz2.$(OBJEXT):  \
        libarchive/test/$(am__dirstamp) \
        libarchive/test/$(DEPDIR)/$(am__dirstamp)
@@ -4520,6 +4541,9 @@ libarchive/test/libarchive_test-test_read_format_zip_encryption_header.$(OBJEXT)
 libarchive/test/libarchive_test-test_read_format_zip_filename.$(OBJEXT):  \
        libarchive/test/$(am__dirstamp) \
        libarchive/test/$(DEPDIR)/$(am__dirstamp)
+libarchive/test/libarchive_test-test_read_format_zip_high_compression.$(OBJEXT):  \
+       libarchive/test/$(am__dirstamp) \
+       libarchive/test/$(DEPDIR)/$(am__dirstamp)
 libarchive/test/libarchive_test-test_read_format_zip_mac_metadata.$(OBJEXT):  \
        libarchive/test/$(am__dirstamp) \
        libarchive/test/$(DEPDIR)/$(am__dirstamp)
@@ -4622,6 +4646,15 @@ libarchive/test/libarchive_test-test_write_disk_perms.$(OBJEXT):  \
 libarchive/test/libarchive_test-test_write_disk_secure.$(OBJEXT):  \
        libarchive/test/$(am__dirstamp) \
        libarchive/test/$(DEPDIR)/$(am__dirstamp)
+libarchive/test/libarchive_test-test_write_disk_secure744.$(OBJEXT):  \
+       libarchive/test/$(am__dirstamp) \
+       libarchive/test/$(DEPDIR)/$(am__dirstamp)
+libarchive/test/libarchive_test-test_write_disk_secure745.$(OBJEXT):  \
+       libarchive/test/$(am__dirstamp) \
+       libarchive/test/$(DEPDIR)/$(am__dirstamp)
+libarchive/test/libarchive_test-test_write_disk_secure746.$(OBJEXT):  \
+       libarchive/test/$(am__dirstamp) \
+       libarchive/test/$(DEPDIR)/$(am__dirstamp)
 libarchive/test/libarchive_test-test_write_disk_sparse.$(OBJEXT):  \
        libarchive/test/$(am__dirstamp) \
        libarchive/test/$(DEPDIR)/$(am__dirstamp)
@@ -5267,6 +5300,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_lha_bugfix_0.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_lha_filename.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree_crash747.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_pax_bz2.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_rar.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_rar_encryption_data.Po@am__quote@
@@ -5293,6 +5327,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_encryption_header.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_encryption_partially.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_filename.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_high_compression.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_mac_metadata.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_malformed.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_msdos.Po@am__quote@
@@ -5327,6 +5362,9 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_no_hfs_compression.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_perms.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure744.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure745.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure746.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_sparse.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_symlink.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_times.Po@am__quote@
@@ -10940,6 +10978,20 @@ libarchive/test/libarchive_test-test_read_format_mtree.obj: libarchive/test/test
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_read_format_mtree.obj `if test -f 'libarchive/test/test_read_format_mtree.c'; then $(CYGPATH_W) 'libarchive/test/test_read_format_mtree.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_read_format_mtree.c'; fi`
 
+libarchive/test/libarchive_test-test_read_format_mtree_crash747.o: libarchive/test/test_read_format_mtree_crash747.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_read_format_mtree_crash747.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree_crash747.Tpo -c -o libarchive/test/libarchive_test-test_read_format_mtree_crash747.o `test -f 'libarchive/test/test_read_format_mtree_crash747.c' || echo '$(srcdir)/'`libarchive/test/test_read_format_mtree_crash747.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree_crash747.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree_crash747.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_read_format_mtree_crash747.c' object='libarchive/test/libarchive_test-test_read_format_mtree_crash747.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_read_format_mtree_crash747.o `test -f 'libarchive/test/test_read_format_mtree_crash747.c' || echo '$(srcdir)/'`libarchive/test/test_read_format_mtree_crash747.c
+
+libarchive/test/libarchive_test-test_read_format_mtree_crash747.obj: libarchive/test/test_read_format_mtree_crash747.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_read_format_mtree_crash747.obj -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree_crash747.Tpo -c -o libarchive/test/libarchive_test-test_read_format_mtree_crash747.obj `if test -f 'libarchive/test/test_read_format_mtree_crash747.c'; then $(CYGPATH_W) 'libarchive/test/test_read_format_mtree_crash747.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_read_format_mtree_crash747.c'; fi`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree_crash747.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_mtree_crash747.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_read_format_mtree_crash747.c' object='libarchive/test/libarchive_test-test_read_format_mtree_crash747.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_read_format_mtree_crash747.obj `if test -f 'libarchive/test/test_read_format_mtree_crash747.c'; then $(CYGPATH_W) 'libarchive/test/test_read_format_mtree_crash747.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_read_format_mtree_crash747.c'; fi`
+
 libarchive/test/libarchive_test-test_read_format_pax_bz2.o: libarchive/test/test_read_format_pax_bz2.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_read_format_pax_bz2.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_pax_bz2.Tpo -c -o libarchive/test/libarchive_test-test_read_format_pax_bz2.o `test -f 'libarchive/test/test_read_format_pax_bz2.c' || echo '$(srcdir)/'`libarchive/test/test_read_format_pax_bz2.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_pax_bz2.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_pax_bz2.Po
@@ -11304,6 +11356,20 @@ libarchive/test/libarchive_test-test_read_format_zip_filename.obj: libarchive/te
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_read_format_zip_filename.obj `if test -f 'libarchive/test/test_read_format_zip_filename.c'; then $(CYGPATH_W) 'libarchive/test/test_read_format_zip_filename.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_read_format_zip_filename.c'; fi`
 
+libarchive/test/libarchive_test-test_read_format_zip_high_compression.o: libarchive/test/test_read_format_zip_high_compression.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_read_format_zip_high_compression.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_high_compression.Tpo -c -o libarchive/test/libarchive_test-test_read_format_zip_high_compression.o `test -f 'libarchive/test/test_read_format_zip_high_compression.c' || echo '$(srcdir)/'`libarchive/test/test_read_format_zip_high_compression.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_high_compression.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_high_compression.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_read_format_zip_high_compression.c' object='libarchive/test/libarchive_test-test_read_format_zip_high_compression.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_read_format_zip_high_compression.o `test -f 'libarchive/test/test_read_format_zip_high_compression.c' || echo '$(srcdir)/'`libarchive/test/test_read_format_zip_high_compression.c
+
+libarchive/test/libarchive_test-test_read_format_zip_high_compression.obj: libarchive/test/test_read_format_zip_high_compression.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_read_format_zip_high_compression.obj -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_high_compression.Tpo -c -o libarchive/test/libarchive_test-test_read_format_zip_high_compression.obj `if test -f 'libarchive/test/test_read_format_zip_high_compression.c'; then $(CYGPATH_W) 'libarchive/test/test_read_format_zip_high_compression.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_read_format_zip_high_compression.c'; fi`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_high_compression.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_high_compression.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_read_format_zip_high_compression.c' object='libarchive/test/libarchive_test-test_read_format_zip_high_compression.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_read_format_zip_high_compression.obj `if test -f 'libarchive/test/test_read_format_zip_high_compression.c'; then $(CYGPATH_W) 'libarchive/test/test_read_format_zip_high_compression.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_read_format_zip_high_compression.c'; fi`
+
 libarchive/test/libarchive_test-test_read_format_zip_mac_metadata.o: libarchive/test/test_read_format_zip_mac_metadata.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_read_format_zip_mac_metadata.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_mac_metadata.Tpo -c -o libarchive/test/libarchive_test-test_read_format_zip_mac_metadata.o `test -f 'libarchive/test/test_read_format_zip_mac_metadata.c' || echo '$(srcdir)/'`libarchive/test/test_read_format_zip_mac_metadata.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_mac_metadata.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_read_format_zip_mac_metadata.Po
@@ -11780,6 +11846,48 @@ libarchive/test/libarchive_test-test_write_disk_secure.obj: libarchive/test/test
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_write_disk_secure.obj `if test -f 'libarchive/test/test_write_disk_secure.c'; then $(CYGPATH_W) 'libarchive/test/test_write_disk_secure.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_write_disk_secure.c'; fi`
 
+libarchive/test/libarchive_test-test_write_disk_secure744.o: libarchive/test/test_write_disk_secure744.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_write_disk_secure744.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure744.Tpo -c -o libarchive/test/libarchive_test-test_write_disk_secure744.o `test -f 'libarchive/test/test_write_disk_secure744.c' || echo '$(srcdir)/'`libarchive/test/test_write_disk_secure744.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure744.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure744.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_write_disk_secure744.c' object='libarchive/test/libarchive_test-test_write_disk_secure744.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_write_disk_secure744.o `test -f 'libarchive/test/test_write_disk_secure744.c' || echo '$(srcdir)/'`libarchive/test/test_write_disk_secure744.c
+
+libarchive/test/libarchive_test-test_write_disk_secure744.obj: libarchive/test/test_write_disk_secure744.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_write_disk_secure744.obj -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure744.Tpo -c -o libarchive/test/libarchive_test-test_write_disk_secure744.obj `if test -f 'libarchive/test/test_write_disk_secure744.c'; then $(CYGPATH_W) 'libarchive/test/test_write_disk_secure744.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_write_disk_secure744.c'; fi`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure744.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure744.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_write_disk_secure744.c' object='libarchive/test/libarchive_test-test_write_disk_secure744.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_write_disk_secure744.obj `if test -f 'libarchive/test/test_write_disk_secure744.c'; then $(CYGPATH_W) 'libarchive/test/test_write_disk_secure744.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_write_disk_secure744.c'; fi`
+
+libarchive/test/libarchive_test-test_write_disk_secure745.o: libarchive/test/test_write_disk_secure745.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_write_disk_secure745.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure745.Tpo -c -o libarchive/test/libarchive_test-test_write_disk_secure745.o `test -f 'libarchive/test/test_write_disk_secure745.c' || echo '$(srcdir)/'`libarchive/test/test_write_disk_secure745.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure745.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure745.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_write_disk_secure745.c' object='libarchive/test/libarchive_test-test_write_disk_secure745.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_write_disk_secure745.o `test -f 'libarchive/test/test_write_disk_secure745.c' || echo '$(srcdir)/'`libarchive/test/test_write_disk_secure745.c
+
+libarchive/test/libarchive_test-test_write_disk_secure745.obj: libarchive/test/test_write_disk_secure745.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_write_disk_secure745.obj -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure745.Tpo -c -o libarchive/test/libarchive_test-test_write_disk_secure745.obj `if test -f 'libarchive/test/test_write_disk_secure745.c'; then $(CYGPATH_W) 'libarchive/test/test_write_disk_secure745.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_write_disk_secure745.c'; fi`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure745.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure745.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_write_disk_secure745.c' object='libarchive/test/libarchive_test-test_write_disk_secure745.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_write_disk_secure745.obj `if test -f 'libarchive/test/test_write_disk_secure745.c'; then $(CYGPATH_W) 'libarchive/test/test_write_disk_secure745.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_write_disk_secure745.c'; fi`
+
+libarchive/test/libarchive_test-test_write_disk_secure746.o: libarchive/test/test_write_disk_secure746.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_write_disk_secure746.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure746.Tpo -c -o libarchive/test/libarchive_test-test_write_disk_secure746.o `test -f 'libarchive/test/test_write_disk_secure746.c' || echo '$(srcdir)/'`libarchive/test/test_write_disk_secure746.c
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure746.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure746.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_write_disk_secure746.c' object='libarchive/test/libarchive_test-test_write_disk_secure746.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_write_disk_secure746.o `test -f 'libarchive/test/test_write_disk_secure746.c' || echo '$(srcdir)/'`libarchive/test/test_write_disk_secure746.c
+
+libarchive/test/libarchive_test-test_write_disk_secure746.obj: libarchive/test/test_write_disk_secure746.c
+@am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_write_disk_secure746.obj -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure746.Tpo -c -o libarchive/test/libarchive_test-test_write_disk_secure746.obj `if test -f 'libarchive/test/test_write_disk_secure746.c'; then $(CYGPATH_W) 'libarchive/test/test_write_disk_secure746.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_write_disk_secure746.c'; fi`
+@am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure746.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_secure746.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='libarchive/test/test_write_disk_secure746.c' object='libarchive/test/libarchive_test-test_write_disk_secure746.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libarchive/test/libarchive_test-test_write_disk_secure746.obj `if test -f 'libarchive/test/test_write_disk_secure746.c'; then $(CYGPATH_W) 'libarchive/test/test_write_disk_secure746.c'; else $(CYGPATH_W) '$(srcdir)/libarchive/test/test_write_disk_secure746.c'; fi`
+
 libarchive/test/libarchive_test-test_write_disk_sparse.o: libarchive/test/test_write_disk_sparse.c
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libarchive_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libarchive/test/libarchive_test-test_write_disk_sparse.o -MD -MP -MF libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_sparse.Tpo -c -o libarchive/test/libarchive_test-test_write_disk_sparse.o `test -f 'libarchive/test/test_write_disk_sparse.c' || echo '$(srcdir)/'`libarchive/test/test_write_disk_sparse.c
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_sparse.Tpo libarchive/test/$(DEPDIR)/libarchive_test-test_write_disk_sparse.Po
diff --git a/NEWS b/NEWS
index f672d3d..dd4cfd5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+Oct 23, 2016: libarchive 3.2.2 released
+    Security release
+
 Jun 20, 2016: libarchive 3.2.1 released
     This fixes a handful of security and other critical issues with 3.2.0
 
diff --git a/README b/README
deleted file mode 100644 (file)
index 180d284..0000000
--- a/README
+++ /dev/null
@@ -1,163 +0,0 @@
-README for libarchive bundle.
-
-Questions?  Issues?
-   * http://www.libarchive.org is the home for ongoing
-     libarchive development, including documentation, and
-     links to the libarchive mailing lists.
-   * To report an issue, use the issue tracker at
-     https://github.com/libarchive/libarchive/issues
-   * To submit an enhancement to libarchive, please submit
-     a pull request via GitHub.
-     https://github.com/libarchive/libarchive/pulls
-
-This distribution bundle includes the following components:
-   * libarchive: a library for reading and writing streaming archives
-   * tar: the 'bsdtar' program is a full-featured 'tar'
-          implementation built on libarchive
-   * cpio: the 'bsdcpio' program is a different interface to
-          essentially the same functionality
-   * cat: the 'bsdcat' program is a simple replacement tool for
-          zcat, bzcat, xzcat, and such
-   * examples: Some small example programs that you may find useful.
-   * examples/minitar: a compact sample demonstrating use of libarchive.
-   * contrib:  Various items sent to me by third parties;
-          please contact the authors with any questions.
-
-The top-level directory contains the following information files:
-   * NEWS - highlights of recent changes
-   * COPYING - what you can do with this
-   * INSTALL - installation instructions
-   * README - this file
-   * configure - configuration script, see INSTALL for details.
-   * CMakeLists.txt - input for "cmake" build tool, see INSTALL
-
-The following files in the top-level directory are used by the
-'configure' script:
-   * Makefile.am, aclocal.m4, configure.ac
-       - used to build this distribution, only needed by maintainers
-   * Makefile.in, config.h.in
-       - templates used by configure script
-
-Guide to Documentation installed by this system:
- * bsdtar.1 explains the use of the bsdtar program
- * bsdcpio.1 explains the use of the bsdcpio program
- * bsdcat.1 explains the use of the bsdcat program
- * libarchive.3 gives an overview of the library as a whole
- * archive_read.3, archive_write.3, archive_write_disk.3, and
-   archive_read_disk.3 provide detailed calling sequences for the read
-   and write APIs
- * archive_entry.3 details the "struct archive_entry" utility class
- * archive_internals.3 provides some insight into libarchive's
-   internal structure and operation.
- * libarchive-formats.5 documents the file formats supported by the library
- * cpio.5, mtree.5, and tar.5 provide detailed information about these
-   popular archive formats, including hard-to-find details about
-   modern cpio and tar variants.
-The manual pages above are provided in the 'doc' directory in
-a number of different formats.
-
-You should also read the copious comments in "archive.h" and the
-source code for the sample programs for more details.  Please let us
-know about any errors or omissions you find.
-
-Currently, the library automatically detects and reads the following fomats:
-  * GNU tar format (including GNU long filenames, long link names, and sparse files)
-  * Solaris 9 extended tar format (including ACLs)
-  * Old V7 tar archives
-  * POSIX ustar
-  * POSIX pax interchange format
-  * POSIX octet-oriented cpio
-  * SVR4 ASCII cpio
-  * POSIX octet-oriented cpio
-  * Binary cpio (big-endian or little-endian)
-  * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
-  * ZIP archives (with uncompressed or "deflate" compressed entries)
-  * GNU and BSD 'ar' archives
-  * 'mtree' format
-  * 7-Zip archives
-  * Microsoft CAB format
-  * LHA and LZH archives
-  * RAR archives
-  * XAR archives
-
-The library also detects and handles any of the following before evaluating the archive:
-  * uuencoded files
-  * files with RPM wrapper
-  * gzip compression
-  * bzip2 compression
-  * compress/LZW compression
-  * lzma, lzip, and xz compression
-  * lz4 compression
-  * lzop compression
-
-The library can create archives in any of the following formats:
-  * POSIX ustar
-  * POSIX pax interchange format
-  * "restricted" pax format, which will create ustar archives except for
-    entries that require pax extensions (for long filenames, ACLs, etc).
-  * Old GNU tar format
-  * Old V7 tar format
-  * POSIX octet-oriented cpio
-  * SVR4 "newc" cpio
-  * shar archives
-  * ZIP archives (with uncompressed or "deflate" compressed entries)
-  * GNU and BSD 'ar' archives
-  * 'mtree' format
-  * ISO9660 format
-  * 7-Zip archives
-  * XAR archives
-
-When creating archives, the result can be filtered with any of the following:
-  * uuencode
-  * gzip compression
-  * bzip2 compression
-  * compress/LZW compression
-  * lzma, lzip, and xz compression
-  * lz4 compression
-  * lzop compression
-
-Notes about the library architecture:
-
- * This is a heavily stream-oriented system.  There is no direct
-   support for in-place modification or random access.
-
- * The library is designed to be extended with new compression and
-   archive formats.  The only requirement is that the format be
-   readable or writable as a stream and that each archive entry be
-   independent.  There are articles on the libarchive Wiki explaining
-   how to extend libarchive.
-
- * On read, compression and format are always detected automatically.
-
- * I've attempted to minimize static link pollution.  If you don't
-   explicitly invoke a particular feature (such as support for a
-   particular compression or format), it won't get pulled in to
-   statically-linked programs.  In particular, if you don't explicitly
-   enable a particular compression or decompression support, you won't
-   need to link against the corresponding compression or decompression
-   libraries.  This also reduces the size of statically-linked
-   binaries in environments where that matters.
-
- * On read, the library accepts whatever blocks you hand it.
-   Your read callback is free to pass the library a byte at a time
-   or mmap the entire archive and give it to the library at once.
-   On write, the library always produces correctly-blocked output.
-
- * The object-style approach allows you to have multiple archive streams
-   open at once.  bsdtar uses this in its "@archive" extension.
-
- * The archive itself is read/written using callback functions.
-   You can read an archive directly from an in-memory buffer or
-   write it to a socket, if you wish.  There are some utility
-   functions to provide easy-to-use "open file," etc, capabilities.
-
- * The read/write APIs are designed to allow individual entries
-   to be read or written to any data source:  You can create
-   a block of data in memory and add it to a tar archive without
-   first writing a temporary file.  You can also read an entry from
-   an archive and write the data directly to a socket.  If you want
-   to read/write entries to disk, there are convenience functions to
-   make this especially easy.
-
- * Note: "pax interchange format" is really an extended tar format,
-   despite what the name says.
index acfb5d7..8a75261 100644 (file)
@@ -9462,6 +9462,42 @@ fi
 rmdir .tst 2>/dev/null
 AC_SUBST([am__leading_dot])])
 
+# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
+# From Jim Meyering
+
+# Copyright (C) 1996-2014 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAINTAINER_MODE([DEFAULT-MODE])
+# ----------------------------------
+# Control maintainer-specific portions of Makefiles.
+# Default is to disable them, unless 'enable' is passed literally.
+# For symmetry, 'disable' may be passed as well.  Anyway, the user
+# can override the default with the --enable/--disable switch.
+AC_DEFUN([AM_MAINTAINER_MODE],
+[m4_case(m4_default([$1], [disable]),
+       [enable], [m4_define([am_maintainer_other], [disable])],
+       [disable], [m4_define([am_maintainer_other], [enable])],
+       [m4_define([am_maintainer_other], [enable])
+        m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])
+AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+  dnl maintainer-mode's default is 'disable' unless 'enable' is passed
+  AC_ARG_ENABLE([maintainer-mode],
+    [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],
+      am_maintainer_other[ make rules and dependencies not useful
+      (and sometimes confusing) to the casual installer])],
+    [USE_MAINTAINER_MODE=$enableval],
+    [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
+  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+  AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
+  MAINT=$MAINTAINER_MODE_TRUE
+  AC_SUBST([MAINT])dnl
+]
+)
+
 # Check to see how 'make' treats includes.                 -*- Autoconf -*-
 
 # Copyright (C) 2001-2014 Free Software Foundation, Inc.
index c4bd827..2e9ad7f 100755 (executable)
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-05-15'
+timestamp='2016-10-02'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -1000,6 +1000,9 @@ EOF
        eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
        test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
        ;;
+    mips64el:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
     openrisc*:Linux:*:*)
        echo or1k-unknown-linux-${LIBC}
        exit ;;
@@ -1032,6 +1035,9 @@ EOF
     ppcle:Linux:*:*)
        echo powerpcle-unknown-linux-${LIBC}
        exit ;;
+    riscv32:Linux:*:* | riscv64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
        echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
        exit ;;
index 9feb73b..cc69b06 100755 (executable)
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2016 Free Software Foundation, Inc.
 
-timestamp='2016-06-20'
+timestamp='2016-09-05'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -117,7 +117,7 @@ case $maybe_os in
   nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
   linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
   knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
-  kopensolaris*-gnu* | \
+  kopensolaris*-gnu* | cloudabi*-eabi* | \
   storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
@@ -1030,7 +1030,7 @@ case $basic_machine in
        ppc-* | ppcbe-*)
                basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
                ;;
-       ppcle | powerpclittle | ppc-le | powerpc-little)
+       ppcle | powerpclittle)
                basic_machine=powerpcle-unknown
                ;;
        ppcle-* | powerpclittle-*)
@@ -1040,7 +1040,7 @@ case $basic_machine in
                ;;
        ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
                ;;
-       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+       ppc64le | powerpc64little)
                basic_machine=powerpc64le-unknown
                ;;
        ppc64le-* | powerpc64little-*)
diff --git a/build/cmake/CheckStructMember.cmake b/build/cmake/CheckStructMember.cmake
deleted file mode 100644 (file)
index 05ddb3a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-# - Check if the given struct or class has the specified member variable
-# CHECK_STRUCT_MEMBER (STRUCT MEMBER HEADER VARIABLE)
-#
-#  STRUCT - the name of the struct or class you are interested in
-#  MEMBER - the member which existence you want to check
-#  HEADER - the header(s) where the prototype should be declared
-#  VARIABLE - variable to store the result
-#
-# The following variables may be set before calling this macro to
-# modify the way the check is run:
-#
-#  CMAKE_REQUIRED_FLAGS = string of compile command line flags
-#  CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
-#  CMAKE_REQUIRED_INCLUDES = list of include directories
-
-# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-
-INCLUDE(CheckCSourceCompiles)
-
-MACRO (CHECK_STRUCT_MEMBER _STRUCT _MEMBER _HEADER _RESULT)
-   SET(_INCLUDE_FILES)
-   FOREACH (it ${_HEADER})
-      SET(_INCLUDE_FILES "${_INCLUDE_FILES}#include <${it}>\n")
-   ENDFOREACH (it)
-
-   SET(_CHECK_STRUCT_MEMBER_SOURCE_CODE "
-${_INCLUDE_FILES}
-int main()
-{
-   static ${_STRUCT} tmp;
-   if (sizeof(tmp.${_MEMBER}))
-      return 0;
-  return 0;
-}
-")
-   CHECK_C_SOURCE_COMPILES("${_CHECK_STRUCT_MEMBER_SOURCE_CODE}" ${_RESULT})
-
-ENDMACRO (CHECK_STRUCT_MEMBER)
-
index 64f4d4d..053d205 100644 (file)
@@ -293,6 +293,9 @@ typedef uint64_t uintmax_t;
 /* Define to 1 if you have the `acl_create_entry' function. */
 #cmakedefine HAVE_ACL_CREATE_ENTRY 1
 
+/* Define to 1 if you have the `acl_get_fd_np' function. */
+#cmakedefine HAVE_ACL_GET_FD_NP 1
+
 /* Define to 1 if you have the `acl_get_link' function. */
 #cmakedefine HAVE_ACL_GET_LINK 1
 
@@ -721,6 +724,9 @@ typedef uint64_t uintmax_t;
 /* Define to 1 if you have the <lzma.h> header file. */
 #cmakedefine HAVE_LZMA_H 1
 
+/* Define to 1 if you have a working `lzma_stream_encoder_mt' function. */
+#cmakedefine HAVE_LZMA_STREAM_ENCODER_MT 1
+
 /* Define to 1 if you have the <lzo/lzo1x.h> header file. */
 #cmakedefine HAVE_LZO_LZO1X_H 1
 
@@ -923,6 +929,12 @@ typedef uint64_t uintmax_t;
 /* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */
 #cmakedefine HAVE_STRUCT_TM___TM_GMTOFF 1
 
+/* Define to 1 if you have `struct vfsconf'. */
+#cmakedefine HAVE_STRUCT_VFSCONF 1
+
+/* Define to 1 if you have `struct xvfsconf'. */
+#cmakedefine HAVE_STRUCT_XVFSCONF 1
+
 /* Define to 1 if you have the `symlink' function. */
 #cmakedefine HAVE_SYMLINK 1
 
index f293156..f54ddaa 100644 (file)
@@ -1 +1 @@
-3002001
+3002002
index 0990bcf..c4642ae 100644 (file)
@@ -58,7 +58,8 @@ IF(ENABLE_CAT AND ENABLE_TEST)
   # Experimental new test handling
   ADD_CUSTOM_TARGET(run_bsdcat_test
        COMMAND bsdcat_test -p $<TARGET_FILE:bsdcat>
-                           -r ${CMAKE_CURRENT_SOURCE_DIR})
+                           -r ${CMAKE_CURRENT_SOURCE_DIR}
+                           -vv)
   ADD_DEPENDENCIES(run_bsdcat_test bsdcat)
   ADD_DEPENDENCIES(run_all_tests run_bsdcat_test)
 
index 0aa1deb..a579842 100644 (file)
 # include <crtdbg.h>
 #endif
 
+mode_t umasked(mode_t expected_mode)
+{
+       mode_t mode = umask(0);
+       umask(mode);
+       return expected_mode & ~mode;
+}
+
 /* Path to working directory for current test */
 const char *testworkdir;
 #ifdef PROGRAM
@@ -1156,6 +1163,35 @@ assertion_file_contains_lines_any_order(const char *file, int line,
        return (0);
 }
 
+/* Verify that a text file does not contains the specified strings */
+int
+assertion_file_contains_no_invalid_strings(const char *file, int line,
+    const char *pathname, const char *strings[])
+{
+       char *buff;
+       int i;
+
+       buff = slurpfile(NULL, "%s", pathname);
+       if (buff == NULL) {
+               failure_start(file, line, "Can't read file: %s", pathname);
+               failure_finish(NULL);
+               return (0);
+       }
+
+       for (i = 0; strings[i] != NULL; ++i) {
+               if (strstr(buff, strings[i]) != NULL) {
+                       failure_start(file, line, "Invalid string in %s: %s", pathname,
+                           strings[i]);
+                       failure_finish(NULL);
+                       free(buff);
+                       return(0);
+               }
+       }
+
+       free(buff);
+       return (0);
+}
+
 /* Test that two paths point to the same file. */
 /* As a side-effect, asserts that both files exist. */
 static int
@@ -1293,6 +1329,11 @@ assertion_file_time(const char *file, int line,
        switch (type) {
        case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
        case 'b': filet = st.st_birthtime;
+               /* FreeBSD filesystems that don't support birthtime
+                * (e.g., UFS1) always return -1 here. */
+               if (filet == -1) {
+                       return (1);
+               }
                filet_nsec = st.st_birthtimespec.tv_nsec; break;
        case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
        default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
@@ -1360,6 +1401,33 @@ assertion_file_birthtime_recent(const char *file, int line,
        return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
 }
 
+/* Verify mode of 'pathname'. */
+int
+assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
+{
+       int mode;
+       int r;
+
+       assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       failure_start(file, line, "assertFileMode not yet implemented for Windows");
+       (void)mode; /* UNUSED */
+       (void)r; /* UNUSED */
+#else
+       {
+               struct stat st;
+               r = lstat(pathname, &st);
+               mode = (int)(st.st_mode & 0777);
+       }
+       if (r == 0 && mode == expected_mode)
+                       return (1);
+       failure_start(file, line, "File %s has mode %o, expected %o",
+           pathname, mode, expected_mode);
+#endif
+       failure_finish(NULL);
+       return (0);
+}
+
 /* Verify mtime of 'pathname'. */
 int
 assertion_file_mtime(const char *file, int line,
@@ -1399,7 +1467,7 @@ assertion_file_nlinks(const char *file, int line,
        assertion_count(file, line);
        r = lstat(pathname, &st);
        if (r == 0 && (int)st.st_nlink == nlinks)
-                       return (1);
+               return (1);
        failure_start(file, line, "File %s has %d links, expected %d",
            pathname, st.st_nlink, nlinks);
        failure_finish(NULL);
@@ -1578,8 +1646,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
        if (0 == _mkdir(dirname))
                return (1);
 #else
-       if (0 == mkdir(dirname, mode))
-               return (1);
+       if (0 == mkdir(dirname, mode)) {
+               if (0 == chmod(dirname, mode)) {
+                       assertion_file_mode(file, line, dirname, mode);
+                       return (1);
+               }
+       }
 #endif
        failure_start(file, line, "Could not create directory %s", dirname);
        failure_finish(NULL);
@@ -1628,6 +1700,12 @@ assertion_make_file(const char *file, int line,
                failure_finish(NULL);
                return (0);
        }
+       if (0 != chmod(path, mode)) {
+               failure_start(file, line, "Could not chmod %s", path);
+               failure_finish(NULL);
+               close(fd);
+               return (0);
+       }
        if (contents != NULL) {
                ssize_t wsize;
 
@@ -1640,10 +1718,12 @@ assertion_make_file(const char *file, int line,
                        failure_start(file, line,
                            "Could not write to %s", path);
                        failure_finish(NULL);
+                       close(fd);
                        return (0);
                }
        }
        close(fd);
+       assertion_file_mode(file, line, path, mode);
        return (1);
 #endif
 }
index 704a137..3a23a05 100644 (file)
 /* Assert that file contents match a string. */
 #define assertFileContents(data, data_size, pathname) \
   assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
+/* Verify that a file does not contain invalid strings */
+#define assertFileContainsNoInvalidStrings(pathname, strings) \
+  assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
 #define assertFileMtime(pathname, sec, nsec)   \
   assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileMtimeRecent(pathname) \
   assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
 #define assertFileSize(pathname, size)  \
   assertion_file_size(__FILE__, __LINE__, pathname, size)
+#define assertFileMode(pathname, mode)  \
+  assertion_file_mode(__FILE__, __LINE__, pathname, mode)
 #define assertTextFileContents(text, pathname) \
   assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
 #define assertFileContainsLinesAnyOrder(pathname, lines)       \
@@ -239,8 +244,10 @@ int assertion_file_atime_recent(const char *, int, const char *);
 int assertion_file_birthtime(const char *, int, const char *, long, long);
 int assertion_file_birthtime_recent(const char *, int, const char *);
 int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
+int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
 int assertion_file_contents(const char *, int, const void *, int, const char *);
 int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mode(const char *, int, const char *, int);
 int assertion_file_mtime(const char *, int, const char *, long, long);
 int assertion_file_mtime_recent(const char *, int, const char *);
 int assertion_file_nlinks(const char *, int, const char *, int);
@@ -326,6 +333,9 @@ void copy_reference_file(const char *);
  */
 void extract_reference_files(const char **);
 
+/* Subtract umask from mode */
+mode_t umasked(mode_t expected_mode);
+
 /* Path to working directory for current test */
 extern const char *testworkdir;
 
index e7c9363..e587b34 100644 (file)
@@ -83,7 +83,7 @@ DEFINE_TEST(test_version)
        if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
                ++q;
        /* Skip arbitrary third-party version numbers. */
-       while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
+       while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
                ++q;
                --s;
        }
index f5bc56f..c117579 100644 (file)
 /* Define to 1 if you have the `acl_create_entry' function. */
 #undef HAVE_ACL_CREATE_ENTRY
 
+/* Define to 1 if you have the `acl_get_fd_np' function. */
+#undef HAVE_ACL_GET_FD_NP
+
 /* Define to 1 if you have the `acl_get_link' function. */
 #undef HAVE_ACL_GET_LINK
 
 /* Define to 1 if `__tm_gmtoff' is a member of `struct tm'. */
 #undef HAVE_STRUCT_TM___TM_GMTOFF
 
+/* Define to 1 if the system has the type `struct vfsconf'. */
+#undef HAVE_STRUCT_VFSCONF
+
+/* Define to 1 if the system has the type `struct xvfsconf'. */
+#undef HAVE_STRUCT_XVFSCONF
+
 /* Define to 1 if you have the `symlink' function. */
 #undef HAVE_SYMLINK
 
index 892401d..a2b18f0 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libarchive 3.2.1.
+# Generated by GNU Autoconf 2.69 for libarchive 3.2.2.
 #
 # Report bugs to <libarchive-discuss@googlegroups.com>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libarchive'
 PACKAGE_TARNAME='libarchive'
-PACKAGE_VERSION='3.2.1'
-PACKAGE_STRING='libarchive 3.2.1'
+PACKAGE_VERSION='3.2.2'
+PACKAGE_STRING='libarchive 3.2.2'
 PACKAGE_BUGREPORT='libarchive-discuss@googlegroups.com'
 PACKAGE_URL=''
 
@@ -714,6 +714,9 @@ BSDCAT_VERSION_STRING
 BSDTAR_VERSION_STRING
 BSDCPIO_VERSION_STRING
 ARCHIVE_LIBTOOL_VERSION
+MAINT
+MAINTAINER_MODE_FALSE
+MAINTAINER_MODE_TRUE
 AM_BACKSLASH
 AM_DEFAULT_VERBOSITY
 AM_DEFAULT_V
@@ -783,6 +786,7 @@ ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 enable_silent_rules
+enable_maintainer_mode
 enable_dependency_tracking
 enable_shared
 enable_static
@@ -1366,7 +1370,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libarchive 3.2.1 to adapt to many kinds of systems.
+\`configure' configures libarchive 3.2.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1436,7 +1440,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libarchive 3.2.1:";;
+     short | recursive ) echo "Configuration of libarchive 3.2.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1446,6 +1450,9 @@ Optional Features:
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --enable-silent-rules   less verbose build output (undo: "make V=1")
   --disable-silent-rules  verbose build output (undo: "make V=0")
+  --disable-maintainer-mode
+                          disable make rules and dependencies not useful (and
+                          sometimes confusing) to the casual installer
   --enable-dependency-tracking
                           do not reject slow dependency extractors
   --disable-dependency-tracking
@@ -1592,7 +1599,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libarchive configure 3.2.1
+libarchive configure 3.2.2
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2431,7 +2438,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libarchive $as_me 3.2.1, which was
+It was created by libarchive $as_me 3.2.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3300,7 +3307,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='libarchive'
- VERSION='3.2.1'
+ VERSION='3.2.2'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3393,6 +3400,29 @@ END
   fi
 fi
 
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
+$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
+    # Check whether --enable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then :
+  enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
+else
+  USE_MAINTAINER_MODE=yes
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
+$as_echo "$USE_MAINTAINER_MODE" >&6; }
+   if test $USE_MAINTAINER_MODE = yes; then
+  MAINTAINER_MODE_TRUE=
+  MAINTAINER_MODE_FALSE='#'
+else
+  MAINTAINER_MODE_TRUE='#'
+  MAINTAINER_MODE_FALSE=
+fi
+
+  MAINT=$MAINTAINER_MODE_TRUE
+
+
 # Check whether --enable-silent-rules was given.
 if test "${enable_silent_rules+set}" = set; then :
   enableval=$enable_silent_rules;
@@ -3437,7 +3467,7 @@ AM_BACKSLASH='\'
 
 # Libtool interface version bumps on any API change, so increments
 # whenever libarchive minor version does.
-ARCHIVE_MINOR=$(( (3002001 / 1000) % 1000 ))
+ARCHIVE_MINOR=$(( (3002002 / 1000) % 1000 ))
 # Libarchive 2.7 == libtool interface 9 = 2 + 7
 # Libarchive 2.8 == libtool interface 10 = 2 + 8
 # Libarchive 2.9 == libtool interface 11 = 2 + 8
@@ -3445,37 +3475,37 @@ ARCHIVE_MINOR=$(( (3002001 / 1000) % 1000 ))
 # Libarchive 3.1 == libtool interface 13
 ARCHIVE_INTERFACE=`echo $((13 + ${ARCHIVE_MINOR}))`
 # Libarchive revision is bumped on any source change === libtool revision
-ARCHIVE_REVISION=$(( 3002001 % 1000 ))
+ARCHIVE_REVISION=$(( 3002002 % 1000 ))
 # Libarchive minor is bumped on any interface addition === libtool age
 ARCHIVE_LIBTOOL_VERSION=$ARCHIVE_INTERFACE:$ARCHIVE_REVISION:$ARCHIVE_MINOR
 
 # Stick the version numbers into config.h
 
-$as_echo "#define LIBARCHIVE_VERSION_STRING \"3.2.1\"" >>confdefs.h
+$as_echo "#define LIBARCHIVE_VERSION_STRING \"3.2.2\"" >>confdefs.h
 
 
 cat >>confdefs.h <<_ACEOF
-#define LIBARCHIVE_VERSION_NUMBER "3002001"
+#define LIBARCHIVE_VERSION_NUMBER "3002002"
 _ACEOF
 
 
-$as_echo "#define BSDCPIO_VERSION_STRING \"3.2.1\"" >>confdefs.h
+$as_echo "#define BSDCPIO_VERSION_STRING \"3.2.2\"" >>confdefs.h
 
 
-$as_echo "#define BSDTAR_VERSION_STRING \"3.2.1\"" >>confdefs.h
+$as_echo "#define BSDTAR_VERSION_STRING \"3.2.2\"" >>confdefs.h
 
 
-$as_echo "#define BSDCAT_VERSION_STRING \"3.2.1\"" >>confdefs.h
+$as_echo "#define BSDCAT_VERSION_STRING \"3.2.2\"" >>confdefs.h
 
 
 # The shell variables here must be the same as the AC_SUBST() variables
 # below, but the shell variable names apparently cannot be the same as
 # the m4 macro names above.  Why?  Ask autoconf.
-BSDCPIO_VERSION_STRING=3.2.1
-BSDTAR_VERSION_STRING=3.2.1
-BSDCAT_VERSION_STRING=3.2.1
-LIBARCHIVE_VERSION_STRING=3.2.1
-LIBARCHIVE_VERSION_NUMBER=3002001
+BSDCPIO_VERSION_STRING=3.2.2
+BSDTAR_VERSION_STRING=3.2.2
+BSDCAT_VERSION_STRING=3.2.2
+LIBARCHIVE_VERSION_STRING=3.2.2
+LIBARCHIVE_VERSION_NUMBER=3002002
 
 # Substitute the above version numbers into the various files below.
 # Yes, I believe this is the fourth time we define what are essentially
@@ -14733,6 +14763,9 @@ else
 /* end confdefs.h.  */
 
       #include <lzma.h>
+                       #if LZMA_VERSION < 50020000
+                       #error unsupported
+                       #endif
 int
 main ()
 {
@@ -14741,12 +14774,13 @@ lzma_stream_encoder_mt(0, 0);
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_c_try_link "$LINENO"; then :
   ac_cv_lzma_has_mt=yes
 else
   ac_cv_lzma_has_mt=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lzma_has_mt" >&5
 $as_echo "$ac_cv_lzma_has_mt" >&6; }
 done
 
 
+# DragonFly uses vfsconf, FreeBSD xvfsconf.
+ac_fn_c_check_type "$LINENO" "struct vfsconf" "ac_cv_type_struct_vfsconf" "#if HAVE_SYS_TYPES_H
+       #include <sys/types.h>
+       #endif
+       #include <sys/mount.h>
+
+"
+if test "x$ac_cv_type_struct_vfsconf" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_VFSCONF 1
+_ACEOF
+
+
+fi
+
+
+ac_fn_c_check_type "$LINENO" "struct xvfsconf" "ac_cv_type_struct_xvfsconf" "#if HAVE_SYS_TYPES_H
+       #include <sys/types.h>
+       #endif
+       #include <sys/mount.h>
+
+"
+if test "x$ac_cv_type_struct_xvfsconf" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_XVFSCONF 1
+_ACEOF
+
+
+fi
+
+
 # There are several variants of readdir_r around; we only
 # accept the POSIX-compliant version.
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -17555,7 +17622,19 @@ _ACEOF
 
 fi
 
-   for ac_func in acl_create_entry acl_init acl_set_fd acl_set_fd_np acl_set_file
+   for ac_func in acl_create_entry acl_get_fd_np
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+   for ac_func in acl_init acl_set_fd acl_set_fd_np acl_set_file
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
 done
 
     fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EVP_CIPHER_CTX_init in -lcrypto" >&5
+$as_echo_n "checking for EVP_CIPHER_CTX_init in -lcrypto... " >&6; }
+if ${ac_cv_lib_crypto_EVP_CIPHER_CTX_init+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char EVP_CIPHER_CTX_init ();
+int
+main ()
+{
+return EVP_CIPHER_CTX_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_crypto_EVP_CIPHER_CTX_init=yes
+else
+  ac_cv_lib_crypto_EVP_CIPHER_CTX_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_EVP_CIPHER_CTX_init" >&5
+$as_echo "$ac_cv_lib_crypto_EVP_CIPHER_CTX_init" >&6; }
+if test "x$ac_cv_lib_crypto_EVP_CIPHER_CTX_init" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBCRYPTO 1
+_ACEOF
+
+  LIBS="-lcrypto $LIBS"
+
+fi
+
 fi
 
 # Probe libmd AFTER OpenSSL/libcrypto.
@@ -20085,6 +20209,10 @@ else
   am__EXEEXT_FALSE=
 fi
 
+if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
+  as_fn_error $? "conditional \"MAINTAINER_MODE\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${INC_WINDOWS_FILES_TRUE}" && test -z "${INC_WINDOWS_FILES_FALSE}"; then
   as_fn_error $? "conditional \"INC_WINDOWS_FILES\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -20522,7 +20650,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libarchive $as_me 3.2.1, which was
+This file was extended by libarchive $as_me 3.2.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -20588,7 +20716,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libarchive config.status 3.2.1
+libarchive config.status 3.2.2
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index e15ceee..008b04d 100644 (file)
@@ -4,8 +4,8 @@ dnl First, define all of the version numbers up front.
 dnl In particular, this allows the version macro to be used in AC_INIT
 
 dnl These first two version numbers are updated automatically on each release.
-m4_define([LIBARCHIVE_VERSION_S],[3.2.1])
-m4_define([LIBARCHIVE_VERSION_N],[3002001])
+m4_define([LIBARCHIVE_VERSION_S],[3.2.2])
+m4_define([LIBARCHIVE_VERSION_N],[3002002])
 
 dnl bsdtar and bsdcpio versioning tracks libarchive
 m4_define([BSDTAR_VERSION_S],LIBARCHIVE_VERSION_S())
@@ -27,6 +27,7 @@ AC_CONFIG_AUX_DIR([build/autoconf])
 AC_CONFIG_MACRO_DIR([build/autoconf])
 # Must follow AC_CONFIG macros above...
 AM_INIT_AUTOMAKE()
+AM_MAINTAINER_MODE([enable])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 # Libtool's "interface version" can be computed from the libarchive version.
@@ -373,8 +374,11 @@ if test "x$with_lzma" != "xno"; then
   AC_CACHE_CHECK(
     [whether we have multithread support in lzma],
     ac_cv_lzma_has_mt,
-    [AC_COMPILE_IFELSE([
-      AC_LANG_PROGRAM([[#include <lzma.h>]],
+    [AC_LINK_IFELSE([
+      AC_LANG_PROGRAM([[#include <lzma.h>]
+                       [#if LZMA_VERSION < 50020000]
+                       [#error unsupported]
+                       [#endif]],
                       [[lzma_stream_encoder_mt(0, 0);]])],
       [ac_cv_lzma_has_mt=yes], [ac_cv_lzma_has_mt=no])])
   if test "x$ac_cv_lzma_has_mt" != xno; then
@@ -612,6 +616,21 @@ AC_CHECK_FUNCS([_get_timezone _localtime64_s _mkgmtime64])
 # detects cygwin-1.7, as opposed to older versions
 AC_CHECK_FUNCS([cygwin_conv_path])
 
+# DragonFly uses vfsconf, FreeBSD xvfsconf.
+AC_CHECK_TYPES(struct vfsconf,,,
+       [#if HAVE_SYS_TYPES_H
+       #include <sys/types.h>
+       #endif
+       #include <sys/mount.h>
+       ])
+
+AC_CHECK_TYPES(struct xvfsconf,,,
+       [#if HAVE_SYS_TYPES_H
+       #include <sys/types.h>
+       #endif
+       #include <sys/mount.h>
+       ])
+
 # There are several variants of readdir_r around; we only
 # accept the POSIX-compliant version.
 AC_COMPILE_IFELSE(
@@ -676,7 +695,8 @@ if test "x$enable_acl" != "xno"; then
    AC_CHECK_HEADERS([acl/libacl.h])
    AC_CHECK_HEADERS([sys/acl.h])
    AC_CHECK_LIB([acl],[acl_get_file])
-   AC_CHECK_FUNCS([acl_create_entry acl_init acl_set_fd acl_set_fd_np acl_set_file])
+   AC_CHECK_FUNCS([acl_create_entry acl_get_fd_np])
+   AC_CHECK_FUNCS([acl_init acl_set_fd acl_set_fd_np acl_set_file])
 
    AC_CHECK_TYPES(acl_permset_t,,,
        [#if HAVE_SYS_TYPES_H
@@ -845,6 +865,7 @@ if test "x$with_openssl" != "xno"; then
     else
       AC_CHECK_FUNCS([PKCS5_PBKDF2_HMAC_SHA1])
     fi
+    AC_CHECK_LIB(crypto,EVP_CIPHER_CTX_init)
 fi
 
 # Probe libmd AFTER OpenSSL/libcrypto.
index 7e59536..0c10b2c 100644 (file)
@@ -63,6 +63,7 @@ static const struct option {
 } cpio_longopts[] = {
        { "b64encode",                  0, OPTION_B64ENCODE },
        { "create",                     0, 'o' },
+       { "dereference",                0, 'L' },
        { "dot",                        0, 'V' },
        { "extract",                    0, 'i' },
        { "file",                       1, 'F' },
index 4b69893..c11ac16 100644 (file)
@@ -498,7 +498,7 @@ long_help(void)
 static void
 version(void)
 {
-       fprintf(stdout,"bsdcpio %s -- %s\n",
+       fprintf(stdout,"bsdcpio %s - %s\n",
            BSDCPIO_VERSION_STRING,
            archive_version_details());
        exit(0);
index e3063ee..8ffb542 100644 (file)
@@ -91,7 +91,8 @@ IF(ENABLE_CPIO AND ENABLE_TEST)
   # Experimental new test handling
   ADD_CUSTOM_TARGET(run_bsdcpio_test
        COMMAND bsdcpio_test -p $<TARGET_FILE:bsdcpio>
-                            -r ${CMAKE_CURRENT_SOURCE_DIR})
+                            -r ${CMAKE_CURRENT_SOURCE_DIR}
+                            -vv)
   ADD_DEPENDENCIES(run_bsdcpio_test bsdcpio)
   ADD_DEPENDENCIES(run_all_tests run_bsdcpio_test)
 ENDIF(ENABLE_CPIO AND ENABLE_TEST)
index 1c9ae6e..6e6b5ab 100644 (file)
@@ -130,6 +130,13 @@ __FBSDID("$FreeBSD: src/usr.bin/cpio/test/main.c,v 1.3 2008/08/24 04:58:22 kient
 # include <crtdbg.h>
 #endif
 
+mode_t umasked(mode_t expected_mode)
+{
+       mode_t mode = umask(0);
+       umask(mode);
+       return expected_mode & ~mode;
+}
+
 /* Path to working directory for current test */
 const char *testworkdir;
 #ifdef PROGRAM
@@ -1157,6 +1164,35 @@ assertion_file_contains_lines_any_order(const char *file, int line,
        return (0);
 }
 
+/* Verify that a text file does not contains the specified strings */
+int
+assertion_file_contains_no_invalid_strings(const char *file, int line,
+    const char *pathname, const char *strings[])
+{
+       char *buff;
+       int i;
+
+       buff = slurpfile(NULL, "%s", pathname);
+       if (buff == NULL) {
+               failure_start(file, line, "Can't read file: %s", pathname);
+               failure_finish(NULL);
+               return (0);
+       }
+
+       for (i = 0; strings[i] != NULL; ++i) {
+               if (strstr(buff, strings[i]) != NULL) {
+                       failure_start(file, line, "Invalid string in %s: %s", pathname,
+                           strings[i]);
+                       failure_finish(NULL);
+                       free(buff);
+                       return(0);
+               }
+       }
+
+       free(buff);
+       return (0);
+}
+
 /* Test that two paths point to the same file. */
 /* As a side-effect, asserts that both files exist. */
 static int
@@ -1294,6 +1330,11 @@ assertion_file_time(const char *file, int line,
        switch (type) {
        case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
        case 'b': filet = st.st_birthtime;
+               /* FreeBSD filesystems that don't support birthtime
+                * (e.g., UFS1) always return -1 here. */
+               if (filet == -1) {
+                       return (1);
+               }
                filet_nsec = st.st_birthtimespec.tv_nsec; break;
        case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
        default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
@@ -1361,6 +1402,33 @@ assertion_file_birthtime_recent(const char *file, int line,
        return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
 }
 
+/* Verify mode of 'pathname'. */
+int
+assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
+{
+       int mode;
+       int r;
+
+       assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       failure_start(file, line, "assertFileMode not yet implemented for Windows");
+       (void)mode; /* UNUSED */
+       (void)r; /* UNUSED */
+#else
+       {
+               struct stat st;
+               r = lstat(pathname, &st);
+               mode = (int)(st.st_mode & 0777);
+       }
+       if (r == 0 && mode == expected_mode)
+                       return (1);
+       failure_start(file, line, "File %s has mode %o, expected %o",
+           pathname, mode, expected_mode);
+#endif
+       failure_finish(NULL);
+       return (0);
+}
+
 /* Verify mtime of 'pathname'. */
 int
 assertion_file_mtime(const char *file, int line,
@@ -1400,7 +1468,7 @@ assertion_file_nlinks(const char *file, int line,
        assertion_count(file, line);
        r = lstat(pathname, &st);
        if (r == 0 && (int)st.st_nlink == nlinks)
-                       return (1);
+               return (1);
        failure_start(file, line, "File %s has %d links, expected %d",
            pathname, st.st_nlink, nlinks);
        failure_finish(NULL);
@@ -1579,8 +1647,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
        if (0 == _mkdir(dirname))
                return (1);
 #else
-       if (0 == mkdir(dirname, mode))
-               return (1);
+       if (0 == mkdir(dirname, mode)) {
+               if (0 == chmod(dirname, mode)) {
+                       assertion_file_mode(file, line, dirname, mode);
+                       return (1);
+               }
+       }
 #endif
        failure_start(file, line, "Could not create directory %s", dirname);
        failure_finish(NULL);
@@ -1629,6 +1701,12 @@ assertion_make_file(const char *file, int line,
                failure_finish(NULL);
                return (0);
        }
+       if (0 != chmod(path, mode)) {
+               failure_start(file, line, "Could not chmod %s", path);
+               failure_finish(NULL);
+               close(fd);
+               return (0);
+       }
        if (contents != NULL) {
                ssize_t wsize;
 
@@ -1641,10 +1719,12 @@ assertion_make_file(const char *file, int line,
                        failure_start(file, line,
                            "Could not write to %s", path);
                        failure_finish(NULL);
+                       close(fd);
                        return (0);
                }
        }
        close(fd);
+       assertion_file_mode(file, line, path, mode);
        return (1);
 #endif
 }
index 606b121..49fa32c 100644 (file)
 /* Assert that file contents match a string. */
 #define assertFileContents(data, data_size, pathname) \
   assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
+/* Verify that a file does not contain invalid strings */
+#define assertFileContainsNoInvalidStrings(pathname, strings) \
+  assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
 #define assertFileMtime(pathname, sec, nsec)   \
   assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileMtimeRecent(pathname) \
   assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
 #define assertFileSize(pathname, size)  \
   assertion_file_size(__FILE__, __LINE__, pathname, size)
+#define assertFileMode(pathname, mode)  \
+  assertion_file_mode(__FILE__, __LINE__, pathname, mode)
 #define assertTextFileContents(text, pathname) \
   assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
 #define assertFileContainsLinesAnyOrder(pathname, lines)       \
@@ -239,8 +244,10 @@ int assertion_file_atime_recent(const char *, int, const char *);
 int assertion_file_birthtime(const char *, int, const char *, long, long);
 int assertion_file_birthtime_recent(const char *, int, const char *);
 int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
+int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
 int assertion_file_contents(const char *, int, const void *, int, const char *);
 int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mode(const char *, int, const char *, int);
 int assertion_file_mtime(const char *, int, const char *, long, long);
 int assertion_file_mtime_recent(const char *, int, const char *);
 int assertion_file_nlinks(const char *, int, const char *, int);
@@ -326,6 +333,9 @@ void copy_reference_file(const char *);
  */
 void extract_reference_files(const char **);
 
+/* Subtract umask from mode */
+mode_t umasked(mode_t expected_mode);
+
 /* Path to working directory for current test */
 extern const char *testworkdir;
 
index 2f2c409..ac58cef 100644 (file)
@@ -59,8 +59,8 @@ verify(const char *p, size_t s)
        ++q; --s;
        /* Separator. */
        failure("Version: %s", p);
-       assertEqualMem(q, "-- ", 3);
-       q += 3; s -= 3;
+       assertEqualMem(q, "- ", 2);
+       q += 2; s -= 2;
        /* libarchive name and version number */
        assert(s > 11);
        failure("Version: %s", p);
@@ -75,7 +75,7 @@ verify(const char *p, size_t s)
        if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
                ++q;
        /* Skip arbitrary third-party version numbers. */
-       while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
+       while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
                ++q;
                --s;
        }
index 2c1de49..1642f29 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:05 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index f4068d3..be4b52a 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:05 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 2e7af8b..b5301c4 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 4e7d559..0ca2adf 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index a20c6c8..af085b5 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index be32b92..73c4675 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index a385f50..dc38f14 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 2f1a80e..7467b0f 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:25 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 7d32eea..e51d21c 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 4ca22ad..c7b89b8 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index c2a782a..401246a 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 5928645..c3d57fe 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:06 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 2e14347..e8dae11 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 548eed9..cfd7b8b 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 49a21ef..eefea70 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 7c16ef9..6540e09 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index d415322..ead6e27 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 41097e8..b1b265e 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 8e7f182..6d66c03 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:26 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index ab0c3f0..3e5ce1c 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 44c8e42..2ce047d 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 2ddd3a5..2f6d54f 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index a4542eb..c79a23b 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:07 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 0e976b4..836447f 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index c66133a..19d60d5 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index bf63015..9a6256a 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 09d6147..e96b3ab 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index b65a085..81c4abd 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 404075a..9c63f1c 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 1cd3e06..268c256 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 5c69284..1db700d 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:27 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 50e1731..f984e80 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 94e90b3..6f1a8d3 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 31c9378..4a7f247 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:10 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:29 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 92e798a..758409a 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:10 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:29 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index a532116..b8aeb2f 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:08 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 2298d6b..5d4ba28 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:09 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index a128625..c208b77 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:09 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 76b6232..c3b0225 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:09 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 4b9aa52..93f6d21 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:09 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index 5f37ee9..4b004c3 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:09 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:28 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index c30306d..2191caa 100644 (file)
@@ -1,5 +1,5 @@
 <!-- Creator     : groff version 1.22.3 -->
-<!-- CreationDate: Sun Jun 19 19:54:09 2016 -->
+<!-- CreationDate: Sun Oct 23 20:38:29 2016 -->
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
 <html>
index a347a71..8e99cdb 100644 (file)
Binary files a/doc/pdf/archive_entry.3.pdf and b/doc/pdf/archive_entry.3.pdf differ
index 39e81a7..5d28633 100644 (file)
Binary files a/doc/pdf/archive_entry_acl.3.pdf and b/doc/pdf/archive_entry_acl.3.pdf differ
index d950391..b57bb86 100644 (file)
Binary files a/doc/pdf/archive_entry_linkify.3.pdf and b/doc/pdf/archive_entry_linkify.3.pdf differ
index fcab5e7..f97a003 100644 (file)
Binary files a/doc/pdf/archive_entry_paths.3.pdf and b/doc/pdf/archive_entry_paths.3.pdf differ
index 2b10ae2..2b3832b 100644 (file)
Binary files a/doc/pdf/archive_entry_perms.3.pdf and b/doc/pdf/archive_entry_perms.3.pdf differ
index 6318911..b4c0a6a 100644 (file)
Binary files a/doc/pdf/archive_entry_stat.3.pdf and b/doc/pdf/archive_entry_stat.3.pdf differ
index 4c4fbfd..5ba8fef 100644 (file)
Binary files a/doc/pdf/archive_entry_time.3.pdf and b/doc/pdf/archive_entry_time.3.pdf differ
index 002f7a1..c677ac1 100644 (file)
Binary files a/doc/pdf/archive_read.3.pdf and b/doc/pdf/archive_read.3.pdf differ
index 7015dc0..7e1229d 100644 (file)
Binary files a/doc/pdf/archive_read_add_passphrase.3.pdf and b/doc/pdf/archive_read_add_passphrase.3.pdf differ
index 8c4343c..06d926c 100644 (file)
Binary files a/doc/pdf/archive_read_data.3.pdf and b/doc/pdf/archive_read_data.3.pdf differ
index d70ee33..590d5ce 100644 (file)
Binary files a/doc/pdf/archive_read_disk.3.pdf and b/doc/pdf/archive_read_disk.3.pdf differ
index 2e81c8b..234a30b 100644 (file)
Binary files a/doc/pdf/archive_read_extract.3.pdf and b/doc/pdf/archive_read_extract.3.pdf differ
index cfa1530..4c688d1 100644 (file)
Binary files a/doc/pdf/archive_read_filter.3.pdf and b/doc/pdf/archive_read_filter.3.pdf differ
index 0c9e148..b8ca8ac 100644 (file)
Binary files a/doc/pdf/archive_read_format.3.pdf and b/doc/pdf/archive_read_format.3.pdf differ
index cc9276e..decf21d 100644 (file)
Binary files a/doc/pdf/archive_read_free.3.pdf and b/doc/pdf/archive_read_free.3.pdf differ
index 4581a74..f61f24b 100644 (file)
Binary files a/doc/pdf/archive_read_header.3.pdf and b/doc/pdf/archive_read_header.3.pdf differ
index d94331d..c9b5f2f 100644 (file)
Binary files a/doc/pdf/archive_read_new.3.pdf and b/doc/pdf/archive_read_new.3.pdf differ
index 544d558..4c73225 100644 (file)
Binary files a/doc/pdf/archive_read_open.3.pdf and b/doc/pdf/archive_read_open.3.pdf differ
index f1da66a..262c21b 100644 (file)
Binary files a/doc/pdf/archive_read_set_options.3.pdf and b/doc/pdf/archive_read_set_options.3.pdf differ
index e7b0ce1..00780a0 100644 (file)
Binary files a/doc/pdf/archive_util.3.pdf and b/doc/pdf/archive_util.3.pdf differ
index 45fec5a..9c6e0b6 100644 (file)
Binary files a/doc/pdf/archive_write.3.pdf and b/doc/pdf/archive_write.3.pdf differ
index 377debe..46e2752 100644 (file)
Binary files a/doc/pdf/archive_write_blocksize.3.pdf and b/doc/pdf/archive_write_blocksize.3.pdf differ
index df28a12..1c9d772 100644 (file)
Binary files a/doc/pdf/archive_write_data.3.pdf and b/doc/pdf/archive_write_data.3.pdf differ
index edbbcf6..940ccd9 100644 (file)
Binary files a/doc/pdf/archive_write_disk.3.pdf and b/doc/pdf/archive_write_disk.3.pdf differ
index cfd8847..9680453 100644 (file)
Binary files a/doc/pdf/archive_write_filter.3.pdf and b/doc/pdf/archive_write_filter.3.pdf differ
index b14ae31..979606a 100644 (file)
Binary files a/doc/pdf/archive_write_finish_entry.3.pdf and b/doc/pdf/archive_write_finish_entry.3.pdf differ
index 541d41b..0f50566 100644 (file)
Binary files a/doc/pdf/archive_write_format.3.pdf and b/doc/pdf/archive_write_format.3.pdf differ
index 23ba1d2..d3c4b87 100644 (file)
Binary files a/doc/pdf/archive_write_free.3.pdf and b/doc/pdf/archive_write_free.3.pdf differ
index be13576..0fc7cf1 100644 (file)
Binary files a/doc/pdf/archive_write_header.3.pdf and b/doc/pdf/archive_write_header.3.pdf differ
index 282b900..befd373 100644 (file)
Binary files a/doc/pdf/archive_write_new.3.pdf and b/doc/pdf/archive_write_new.3.pdf differ
index 7e95664..56a9449 100644 (file)
Binary files a/doc/pdf/archive_write_open.3.pdf and b/doc/pdf/archive_write_open.3.pdf differ
index 8befb4b..7efcccc 100644 (file)
Binary files a/doc/pdf/archive_write_set_options.3.pdf and b/doc/pdf/archive_write_set_options.3.pdf differ
index 31a3881..a22dc66 100644 (file)
Binary files a/doc/pdf/archive_write_set_passphrase.3.pdf and b/doc/pdf/archive_write_set_passphrase.3.pdf differ
index a5ddd70..8054f8d 100644 (file)
Binary files a/doc/pdf/bsdcpio.1.pdf and b/doc/pdf/bsdcpio.1.pdf differ
index 42ab827..a65282c 100644 (file)
Binary files a/doc/pdf/bsdtar.1.pdf and b/doc/pdf/bsdtar.1.pdf differ
index e6f548e..534c349 100644 (file)
Binary files a/doc/pdf/cpio.5.pdf and b/doc/pdf/cpio.5.pdf differ
index d3609b2..4eab579 100644 (file)
Binary files a/doc/pdf/libarchive-formats.5.pdf and b/doc/pdf/libarchive-formats.5.pdf differ
index 5bc1464..756528a 100644 (file)
Binary files a/doc/pdf/libarchive.3.pdf and b/doc/pdf/libarchive.3.pdf differ
index 9fe90ec..5ac2e48 100644 (file)
Binary files a/doc/pdf/libarchive_changes.3.pdf and b/doc/pdf/libarchive_changes.3.pdf differ
index 0a2ab71..0504450 100644 (file)
Binary files a/doc/pdf/libarchive_internals.3.pdf and b/doc/pdf/libarchive_internals.3.pdf differ
index 4f2eb90..fb38329 100644 (file)
Binary files a/doc/pdf/mtree.5.pdf and b/doc/pdf/mtree.5.pdf differ
index 997af2a..e166241 100644 (file)
Binary files a/doc/pdf/tar.5.pdf and b/doc/pdf/tar.5.pdf differ
index 81e5e11..0b4b414 100644 (file)
@@ -222,7 +222,6 @@ static void
 create(const char *filename, int compress, const char **argv)
 {
        struct archive *a;
-       struct archive *disk;
        struct archive_entry *entry;
        ssize_t len;
        int fd;
@@ -253,12 +252,11 @@ create(const char *filename, int compress, const char **argv)
                filename = NULL;
        archive_write_open_filename(a, filename);
 
-       disk = archive_read_disk_new();
-#ifndef NO_LOOKUP
-       archive_read_disk_set_standard_lookup(disk);
-#endif
        while (*argv != NULL) {
                struct archive *disk = archive_read_disk_new();
+#ifndef NO_LOOKUP
+               archive_read_disk_set_standard_lookup(disk);
+#endif
                int r;
 
                r = archive_read_disk_open(disk, *argv);
index 1794dd3..ff401e9 100644 (file)
@@ -36,7 +36,7 @@
  * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
  */
 /* Note: Compiler will complain if this does not match archive_entry.h! */
-#define        ARCHIVE_VERSION_NUMBER 3002001
+#define        ARCHIVE_VERSION_NUMBER 3002002
 
 #include <sys/stat.h>
 #include <stddef.h>  /* for wchar_t */
@@ -155,7 +155,7 @@ __LA_DECL int               archive_version_number(void);
 /*
  * Textual name/version of the library, useful for version displays.
  */
-#define        ARCHIVE_VERSION_ONLY_STRING "3.2.1"
+#define        ARCHIVE_VERSION_ONLY_STRING "3.2.2"
 #define        ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
 __LA_DECL const char * archive_version_string(void);
 
index bf4b610..d128920 100644 (file)
@@ -707,10 +707,11 @@ archive_acl_text_l(struct archive_acl *acl, int flags,
                        if (r != 0)
                                return (-1);
                        *p++ = separator;
-                       if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
+                       if (name == NULL || (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)) {
                                id = ap->id;
-                       else
+                       } else {
                                id = -1;
+                       }
                        append_entry(&p, NULL, ap->tag, name,
                            ap->permset, id);
                        count++;
index dab2c9d..71b1e87 100644 (file)
@@ -29,7 +29,7 @@
 #define        ARCHIVE_ENTRY_H_INCLUDED
 
 /* Note: Compiler will complain if this does not match archive.h! */
-#define        ARCHIVE_VERSION_NUMBER 3002001
+#define        ARCHIVE_VERSION_NUMBER 3002002
 
 /*
  * Note: archive_entry.h is for use outside of libarchive; the
index 4c41bad..0719cbd 100644 (file)
@@ -655,7 +655,7 @@ add_pattern_from_file(struct archive_match *a, struct match_list *mlist,
                }
        }
 
-       /* If something error happend, report it immediately. */ 
+       /* If an error occurred, report it immediately. */
        if (r < ARCHIVE_OK) {
                archive_copy_error(&(a->archive), ar);
                archive_read_free(ar);
index b06c3cd..e44c932 100644 (file)
 #define        CAN_RESTORE_METADATA_FD
 #endif
 
+/*
+ * glibc 2.24 deprecates readdir_r
+ */
+#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24))
+#define        USE_READDIR_R   1
+#else
+#undef USE_READDIR_R
+#endif
+
 /* Set up defaults for internal error codes. */
 #ifndef ARCHIVE_ERRNO_FILE_FORMAT
 #if HAVE_EFTYPE
index 3a6b9eb..06c99e8 100644 (file)
@@ -19,7 +19,7 @@ If you need the compatibility with original PPMd var.H, you can use external Ran
 #define PPMD7_MAX_ORDER 64
 
 #define PPMD7_MIN_MEM_SIZE (1 << 11)
-#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
+#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFFu - 12 * 3)
 
 struct CPpmd7_Context_;
 
index f67f1eb..cf821b5 100644 (file)
@@ -125,7 +125,7 @@ void
 __archive_read_reset_passphrase(struct archive_read *a)
 {
 
-       a->passphrases.candiate = -1;
+       a->passphrases.candidate = -1;
 }
 
 /*
@@ -137,31 +137,31 @@ __archive_read_next_passphrase(struct archive_read *a)
        struct archive_read_passphrase *p;
        const char *passphrase;
 
-       if (a->passphrases.candiate < 0) {
+       if (a->passphrases.candidate < 0) {
                /* Count out how many passphrases we have. */
                int cnt = 0;
 
                for (p = a->passphrases.first; p != NULL; p = p->next)
                        cnt++;
-               a->passphrases.candiate = cnt;
+               a->passphrases.candidate = cnt;
                p = a->passphrases.first;
-       } else if (a->passphrases.candiate > 1) {
+       } else if (a->passphrases.candidate > 1) {
                /* Rotate a passphrase list. */
-               a->passphrases.candiate--;
+               a->passphrases.candidate--;
                p = remove_passphrases_from_head(a);
                add_passphrase_to_tail(a, p);
-               /* Pick a new passphrase candiate up. */
+               /* Pick a new passphrase candidate up. */
                p = a->passphrases.first;
-       } else if (a->passphrases.candiate == 1) {
-               /* This case is that all cadiates failed to decryption. */
-               a->passphrases.candiate = 0;
+       } else if (a->passphrases.candidate == 1) {
+               /* This case is that all candidates failed to decrypt. */
+               a->passphrases.candidate = 0;
                if (a->passphrases.first->next != NULL) {
                        /* Rotate a passphrase list. */
                        p = remove_passphrases_from_head(a);
                        add_passphrase_to_tail(a, p);
                }
                p = NULL;
-       } else  /* There is no passphrase candaite. */
+       } else  /* There is no passphrase candidate. */
                p = NULL;
 
        if (p != NULL)
@@ -177,7 +177,7 @@ __archive_read_next_passphrase(struct archive_read *a)
                        if (p == NULL)
                                return (NULL);
                        insert_passphrase_to_head(a, p);
-                       a->passphrases.candiate = 1;
+                       a->passphrases.candidate = 1;
                }
        } else
                passphrase = NULL;
index 74fe353..4c7f048 100644 (file)
@@ -411,20 +411,38 @@ setup_acls(struct archive_read_disk *a,
 {
        const char      *accpath;
        acl_t            acl;
-#if HAVE_ACL_IS_TRIVIAL_NP
        int             r;
-#endif
 
        accpath = archive_entry_sourcepath(entry);
        if (accpath == NULL)
                accpath = archive_entry_pathname(entry);
 
+       if (*fd < 0 && a->tree != NULL) {
+               if (a->follow_symlinks ||
+                   archive_entry_filetype(entry) != AE_IFLNK)
+                       *fd = a->open_on_current_dir(a->tree,
+                           accpath, O_RDONLY | O_NONBLOCK);
+               if (*fd < 0) {
+                       if (a->tree_enter_working_dir(a->tree) != 0) {
+                               archive_set_error(&a->archive, errno,
+                                   "Couldn't access %s", accpath);
+                               return (ARCHIVE_FAILED);
+                       }
+               }
+       }
+
        archive_entry_acl_clear(entry);
 
+       acl = NULL;
+
 #ifdef ACL_TYPE_NFS4
        /* Try NFS4 ACL first. */
        if (*fd >= 0)
+#if HAVE_ACL_GET_FD_NP
+               acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
+#else
                acl = acl_get_fd(*fd);
+#endif
 #if HAVE_ACL_GET_LINK_NP
        else if (!a->follow_symlinks)
                acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
@@ -437,20 +455,31 @@ setup_acls(struct archive_read_disk *a,
 #endif
        else
                acl = acl_get_file(accpath, ACL_TYPE_NFS4);
+
 #if HAVE_ACL_IS_TRIVIAL_NP
-       /* Ignore "trivial" ACLs that just mirror the file mode. */
-       acl_is_trivial_np(acl, &r);
-       if (r) {
-               acl_free(acl);
-               acl = NULL;
+       if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+               /* Ignore "trivial" ACLs that just mirror the file mode. */
+               if (r) {
+                       acl_free(acl);
+                       acl = NULL;
+                       /*
+                        * Simultaneous NFSv4 and POSIX.1e ACLs for the same
+                        * entry are not allowed, so we should return here
+                        */
+                       return (ARCHIVE_OK);
+               }
        }
 #endif
        if (acl != NULL) {
-               translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
+               r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
                acl_free(acl);
-               return (ARCHIVE_OK);
+               if (r != ARCHIVE_OK) {
+                       archive_set_error(&a->archive, errno,
+                           "Couldn't translate NFSv4 ACLs: %s", accpath);
+               }
+               return (r);
        }
-#endif
+#endif /* ACL_TYPE_NFS4 */
 
        /* Retrieve access ACL from file. */
        if (*fd >= 0)
@@ -467,19 +496,42 @@ setup_acls(struct archive_read_disk *a,
 #endif
        else
                acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
+
+#if HAVE_ACL_IS_TRIVIAL_NP
+       /* Ignore "trivial" ACLs that just mirror the file mode. */
+       if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
+               if (r) {
+                       acl_free(acl);
+                       acl = NULL;
+               }
+       }
+#endif
+
        if (acl != NULL) {
-               translate_acl(a, entry, acl,
+               r = translate_acl(a, entry, acl,
                    ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
                acl_free(acl);
+               acl = NULL;
+               if (r != ARCHIVE_OK) {
+                       archive_set_error(&a->archive, errno,
+                           "Couldn't translate access ACLs: %s", accpath);
+                       return (r);
+               }
        }
 
        /* Only directories can have default ACLs. */
        if (S_ISDIR(archive_entry_mode(entry))) {
                acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
                if (acl != NULL) {
-                       translate_acl(a, entry, acl,
+                       r = translate_acl(a, entry, acl,
                            ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
                        acl_free(acl);
+                       if (r != ARCHIVE_OK) {
+                               archive_set_error(&a->archive, errno,
+                                   "Couldn't translate default ACLs: %s",
+                                   accpath);
+                               return (r);
+                       }
                }
        }
        return (ARCHIVE_OK);
@@ -535,12 +587,12 @@ translate_acl(struct archive_read_disk *a,
 #ifdef ACL_TYPE_NFS4
        acl_entry_type_t acl_type;
        acl_flagset_t    acl_flagset;
-       int brand, r;
+       int brand;
 #endif
        acl_entry_t      acl_entry;
        acl_permset_t    acl_permset;
        int              i, entry_acl_type;
-       int              s, ae_id, ae_tag, ae_perm;
+       int              r, s, ae_id, ae_tag, ae_perm;
        const char      *ae_name;
 
 
@@ -548,7 +600,11 @@ translate_acl(struct archive_read_disk *a,
        // FreeBSD "brands" ACLs as POSIX.1e or NFSv4
        // Make sure the "brand" on this ACL is consistent
        // with the default_entry_acl_type bits provided.
-       acl_get_brand_np(acl, &brand);
+       if (acl_get_brand_np(acl, &brand) != 0) {
+               archive_set_error(&a->archive, errno,
+                   "Failed to read ACL brand");
+               return (ARCHIVE_WARN);
+       }
        switch (brand) {
        case ACL_BRAND_POSIX:
                switch (default_entry_acl_type) {
@@ -556,31 +612,42 @@ translate_acl(struct archive_read_disk *a,
                case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
                        break;
                default:
-                       // XXX set warning message?
-                       return ARCHIVE_FAILED;
+                       archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+                           "Invalid ACL entry type for POSIX.1e ACL");
+                       return (ARCHIVE_WARN);
                }
                break;
        case ACL_BRAND_NFS4:
                if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
-                       // XXX set warning message?
-                       return ARCHIVE_FAILED;
+                       archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+                           "Invalid ACL entry type for NFSv4 ACL");
+                       return (ARCHIVE_WARN);
                }
                break;
        default:
-               // XXX set warning message?
-               return ARCHIVE_FAILED;
-               break;
+               archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+                   "Unknown ACL brand");
+               return (ARCHIVE_WARN);
        }
 #endif
 
 
        s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
+       if (s == -1) {
+               archive_set_error(&a->archive, errno,
+                   "Failed to get first ACL entry");
+               return (ARCHIVE_WARN);
+       }
        while (s == 1) {
                ae_id = -1;
                ae_name = NULL;
                ae_perm = 0;
 
-               acl_get_tag_type(acl_entry, &acl_tag);
+               if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
+                       archive_set_error(&a->archive, errno,
+                           "Failed to get ACL tag type");
+                       return (ARCHIVE_WARN);
+               }
                switch (acl_tag) {
                case ACL_USER:
                        ae_id = (int)*(uid_t *)acl_get_qualifier(acl_entry);
@@ -615,13 +682,18 @@ translate_acl(struct archive_read_disk *a,
                        continue;
                }
 
-               // XXX acl type maps to allow/deny/audit/YYYY bits
-               // XXX acl_get_entry_type_np on FreeBSD returns EINVAL for
-               // non-NFSv4 ACLs
+               // XXX acl_type maps to allow/deny/audit/YYYY bits
                entry_acl_type = default_entry_acl_type;
 #ifdef ACL_TYPE_NFS4
-               r = acl_get_entry_type_np(acl_entry, &acl_type);
-               if (r == 0) {
+               if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
+                       /*
+                        * acl_get_entry_type_np() falis with non-NFSv4 ACLs
+                        */
+                       if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
+                               archive_set_error(&a->archive, errno, "Failed "
+                                   "to get ACL type from a NFSv4 ACL entry");
+                               return (ARCHIVE_WARN);
+                       }
                        switch (acl_type) {
                        case ACL_ENTRY_TYPE_ALLOW:
                                entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
@@ -635,29 +707,53 @@ translate_acl(struct archive_read_disk *a,
                        case ACL_ENTRY_TYPE_ALARM:
                                entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
                                break;
+                       default:
+                               archive_set_error(&a->archive, errno,
+                                   "Invalid NFSv4 ACL entry type");
+                               return (ARCHIVE_WARN);
                        }
-               }
 
-               /*
-                * Libarchive stores "flag" (NFSv4 inheritance bits)
-                * in the ae_perm bitmap.
-                */
-               acl_get_flagset_np(acl_entry, &acl_flagset);
-                for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
-                       if (acl_get_flag_np(acl_flagset,
-                                           acl_inherit_map[i].platform_inherit))
-                               ae_perm |= acl_inherit_map[i].archive_inherit;
-
-                }
+                       /*
+                        * Libarchive stores "flag" (NFSv4 inheritance bits)
+                        * in the ae_perm bitmap.
+                        *
+                        * acl_get_flagset_np() fails with non-NFSv4 ACLs
+                        */
+                       if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
+                               archive_set_error(&a->archive, errno,
+                                   "Failed to get flagset from a NFSv4 ACL entry");
+                               return (ARCHIVE_WARN);
+                       }
+                       for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
+                               r = acl_get_flag_np(acl_flagset,
+                                   acl_inherit_map[i].platform_inherit);
+                               if (r == -1) {
+                                       archive_set_error(&a->archive, errno,
+                                           "Failed to check flag in a NFSv4 "
+                                           "ACL flagset");
+                                       return (ARCHIVE_WARN);
+                               } else if (r)
+                                       ae_perm |= acl_inherit_map[i].archive_inherit;
+                       }
+               }
 #endif
 
-               acl_get_permset(acl_entry, &acl_permset);
+               if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+                       archive_set_error(&a->archive, errno,
+                           "Failed to get ACL permission set");
+                       return (ARCHIVE_WARN);
+               }
                for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
                        /*
                         * acl_get_perm() is spelled differently on different
                         * platforms; see above.
                         */
-                       if (ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm))
+                       r = ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm);
+                       if (r == -1) {
+                               archive_set_error(&a->archive, errno,
+                                   "Failed to check permission in an ACL permission set");
+                               return (ARCHIVE_WARN);
+                       } else if (r)
                                ae_perm |= acl_perm_map[i].archive_perm;
                }
 
@@ -666,6 +762,11 @@ translate_acl(struct archive_read_disk *a,
                                            ae_id, ae_name);
 
                s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+               if (s == -1) {
+                       archive_set_error(&a->archive, errno,
+                           "Failed to get next ACL entry");
+                       return (ARCHIVE_WARN);
+               }
        }
        return (ARCHIVE_OK);
 }
index 22a1f14..e856d98 100644 (file)
@@ -165,7 +165,7 @@ struct filesystem {
        int             synthetic;
        int             remote;
        int             noatime;
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        size_t          name_max;
 #endif
        long            incr_xfer_size;
@@ -200,7 +200,7 @@ struct tree {
        DIR                     *d;
 #define        INVALID_DIR_HANDLE NULL
        struct dirent           *de;
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        struct dirent           *dirent;
        size_t                   dirent_allocated;
 #endif
@@ -938,7 +938,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
                r = archive_match_path_excluded(a->matching, entry);
                if (r < 0) {
                        archive_set_error(&(a->archive), errno,
-                           "Faild : %s", archive_error_string(a->matching));
+                           "Failed : %s", archive_error_string(a->matching));
                        return (r);
                }
                if (r) {
@@ -1041,7 +1041,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
                r = archive_match_time_excluded(a->matching, entry);
                if (r < 0) {
                        archive_set_error(&(a->archive), errno,
-                           "Faild : %s", archive_error_string(a->matching));
+                           "Failed : %s", archive_error_string(a->matching));
                        return (r);
                }
                if (r) {
@@ -1067,7 +1067,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
                r = archive_match_owner_excluded(a->matching, entry);
                if (r < 0) {
                        archive_set_error(&(a->archive), errno,
-                           "Faild : %s", archive_error_string(a->matching));
+                           "Failed : %s", archive_error_string(a->matching));
                        return (r);
                }
                if (r) {
@@ -1504,7 +1504,20 @@ setup_current_filesystem(struct archive_read_disk *a)
        struct tree *t = a->tree;
        struct statfs sfs;
 #if defined(HAVE_GETVFSBYNAME) && defined(VFCF_SYNTHETIC)
+/* TODO: configure should set GETVFSBYNAME_ARG_TYPE to make
+ * this accurate; some platforms have both and we need the one that's
+ * used by getvfsbyname()
+ *
+ * Then the following would become:
+ *  #if defined(GETVFSBYNAME_ARG_TYPE)
+ *   GETVFSBYNAME_ARG_TYPE vfc;
+ *  #endif
+ */
+#  if defined(HAVE_STRUCT_XVFSCONF)
        struct xvfsconf vfc;
+#  else
+       struct vfsconf vfc;
+#  endif
 #endif
        int r, xr = 0;
 #if !defined(HAVE_STRUCT_STATFS_F_NAMEMAX)
@@ -1579,7 +1592,7 @@ setup_current_filesystem(struct archive_read_disk *a)
 #endif
                t->current_filesystem->noatime = 0;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
 #if defined(HAVE_STRUCT_STATFS_F_NAMEMAX)
        t->current_filesystem->name_max = sfs.f_namemax;
@@ -1602,7 +1615,7 @@ setup_current_filesystem(struct archive_read_disk *a)
        else
                t->current_filesystem->name_max = nm;
 #endif
-#endif /* HAVE_READDIR_R */
+#endif /* USE_READDIR_R */
        return (ARCHIVE_OK);
 }
 
@@ -1804,7 +1817,7 @@ setup_current_filesystem(struct archive_read_disk *a)
 #endif
                t->current_filesystem->noatime = 0;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
        t->current_filesystem->name_max = sfs.f_namelen;
 #endif
@@ -1888,7 +1901,7 @@ setup_current_filesystem(struct archive_read_disk *a)
 #endif
                t->current_filesystem->noatime = 0;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
        t->current_filesystem->name_max = sfs.f_namemax;
 #endif
@@ -1905,7 +1918,7 @@ static int
 setup_current_filesystem(struct archive_read_disk *a)
 {
        struct tree *t = a->tree;
-#if defined(_PC_NAME_MAX) && defined(HAVE_READDIR_R)
+#if defined(_PC_NAME_MAX) && defined(USE_READDIR_R)
        long nm;
 #endif
        t->current_filesystem->synthetic = -1;/* Not supported */
@@ -1917,7 +1930,7 @@ setup_current_filesystem(struct archive_read_disk *a)
        t->current_filesystem->min_xfer_size = -1;
        t->current_filesystem->incr_xfer_size = -1;
 
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        /* Set maximum filename length. */
 #  if defined(_PC_NAME_MAX)
        if (tree_current_is_symblic_link_target(t)) {
@@ -1945,7 +1958,7 @@ setup_current_filesystem(struct archive_read_disk *a)
        else
                t->current_filesystem->name_max = nm;
 #  endif /* _PC_NAME_MAX */
-#endif /* HAVE_READDIR_R */
+#endif /* USE_READDIR_R */
        return (ARCHIVE_OK);
 }
 
@@ -2353,7 +2366,7 @@ tree_dir_next_posix(struct tree *t)
        size_t namelen;
 
        if (t->d == NULL) {
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
                size_t dirent_size;
 #endif
 
@@ -2374,7 +2387,7 @@ tree_dir_next_posix(struct tree *t)
                        t->visit_type = r != 0 ? r : TREE_ERROR_DIR;
                        return (t->visit_type);
                }
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
                dirent_size = offsetof(struct dirent, d_name) +
                  t->filesystem_table[t->current->filesystem_id].name_max + 1;
                if (t->dirent == NULL || t->dirent_allocated < dirent_size) {
@@ -2391,11 +2404,11 @@ tree_dir_next_posix(struct tree *t)
                        }
                        t->dirent_allocated = dirent_size;
                }
-#endif /* HAVE_READDIR_R */
+#endif /* USE_READDIR_R */
        }
        for (;;) {
                errno = 0;
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
                r = readdir_r(t->d, t->dirent, &t->de);
 #ifdef _AIX
                /* Note: According to the man page, return value 9 indicates
@@ -2647,7 +2660,7 @@ tree_free(struct tree *t)
        if (t == NULL)
                return;
        archive_string_free(&t->path);
-#if defined(HAVE_READDIR_R)
+#if defined(USE_READDIR_R)
        free(t->dirent);
 #endif
        free(t->sparse_list);
index d6b2d55..c7fd247 100644 (file)
@@ -232,6 +232,7 @@ static const char *
 lookup_uname_helper(struct name_cache *cache, id_t id)
 {
        struct passwd   *result;
+       (void)cache; /* UNUSED */
 
        result = getpwuid((uid_t)id);
 
@@ -298,6 +299,7 @@ static const char *
 lookup_gname_helper(struct name_cache *cache, id_t id)
 {
        struct group    *result;
+       (void)cache; /* UNUSED */
 
        result = getgrgid((gid_t)id);
 
index 566d264..1fd158f 100644 (file)
@@ -803,7 +803,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
                r = archive_match_path_excluded(a->matching, entry);
                if (r < 0) {
                        archive_set_error(&(a->archive), errno,
-                           "Faild : %s", archive_error_string(a->matching));
+                           "Failed : %s", archive_error_string(a->matching));
                        return (r);
                }
                if (r) {
@@ -875,7 +875,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
                r = archive_match_time_excluded(a->matching, entry);
                if (r < 0) {
                        archive_set_error(&(a->archive), errno,
-                           "Faild : %s", archive_error_string(a->matching));
+                           "Failed : %s", archive_error_string(a->matching));
                        return (r);
                }
                if (r) {
@@ -901,7 +901,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
                r = archive_match_owner_excluded(a->matching, entry);
                if (r < 0) {
                        archive_set_error(&(a->archive), errno,
-                           "Faild : %s", archive_error_string(a->matching));
+                           "Failed : %s", archive_error_string(a->matching));
                        return (r);
                }
                if (r) {
index 9b61a53..8eb5435 100644 (file)
@@ -221,7 +221,7 @@ struct archive_read {
        struct {
                struct archive_read_passphrase *first;
                struct archive_read_passphrase **last;
-               int candiate;
+               int candidate;
                archive_passphrase_callback *callback;
                void *client_data;
        }               passphrases;
index e877917..37b2f59 100644 (file)
@@ -595,7 +595,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
 #endif
        }
 
-       /* Check if an error happend in decompression process. */
+       /* Check if an error occurred in the decompression process. */
        if (uncompressed_size < 0) {
                archive_set_error(&(self->archive->archive),
                    ARCHIVE_ERRNO_MISC, "lz4 decompression failed");
index 1dfe52b..c0a536c 100644 (file)
@@ -2431,6 +2431,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
 
                switch (type) {
                case kEmptyStream:
+                       if (h->emptyStreamBools != NULL)
+                               return (-1);
                        h->emptyStreamBools = calloc((size_t)zip->numFiles,
                            sizeof(*h->emptyStreamBools));
                        if (h->emptyStreamBools == NULL)
@@ -2451,6 +2453,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
                                        return (-1);
                                break;
                        }
+                       if (h->emptyFileBools != NULL)
+                               return (-1);
                        h->emptyFileBools = calloc(empty_streams,
                            sizeof(*h->emptyFileBools));
                        if (h->emptyFileBools == NULL)
@@ -2465,6 +2469,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
                                        return (-1);
                                break;
                        }
+                       if (h->antiBools != NULL)
+                               return (-1);
                        h->antiBools = calloc(empty_streams,
                            sizeof(*h->antiBools));
                        if (h->antiBools == NULL)
@@ -2491,6 +2497,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
                        if ((ll & 1) || ll < zip->numFiles * 4)
                                return (-1);
 
+                       if (zip->entry_names != NULL)
+                               return (-1);
                        zip->entry_names = malloc(ll);
                        if (zip->entry_names == NULL)
                                return (-1);
@@ -2543,6 +2551,8 @@ read_Header(struct archive_read *a, struct _7z_header_info *h,
                        if ((p = header_bytes(a, 2)) == NULL)
                                return (-1);
                        allAreDefined = *p;
+                       if (h->attrBools != NULL)
+                               return (-1);
                        h->attrBools = calloc((size_t)zip->numFiles,
                            sizeof(*h->attrBools));
                        if (h->attrBools == NULL)
index c359d83..a7f1d8d 100644 (file)
@@ -1712,10 +1712,14 @@ lha_crc16(uint16_t crc, const void *pp, size_t len)
        for (;len >= 8; len -= 8) {
                /* This if statement expects compiler optimization will
                 * remove the stament which will not be executed. */
+#undef bswap16
 #if defined(_MSC_VER) && _MSC_VER >= 1400  /* Visual Studio */
 #  define bswap16(x) _byteswap_ushort(x)
-#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8) \
-      || defined(__clang__)
+#elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4)
+/* GCC 4.8 and later has __builtin_bswap16() */
+#  define bswap16(x) __builtin_bswap16(x)
+#elif defined(__clang__)
+/* All clang versions have __builtin_bswap16() */
 #  define bswap16(x) __builtin_bswap16(x)
 #else
 #  define bswap16(x) ((((x) >> 8) & 0xff) | ((x) << 8))
index 8c3be9a..ae58e87 100644 (file)
@@ -301,6 +301,15 @@ get_line_size(const char *b, ssize_t avail, ssize_t *nlsize)
        return (avail);
 }
 
+/*
+ *  <---------------- ravail --------------------->
+ *  <-- diff ------> <---  avail ----------------->
+ *                   <---- len ----------->
+ * | Previous lines | line being parsed  nl extra |
+ *                  ^
+ *                  b
+ *
+ */
 static ssize_t
 next_line(struct archive_read *a,
     const char **b, ssize_t *avail, ssize_t *ravail, ssize_t *nl)
@@ -339,7 +348,7 @@ next_line(struct archive_read *a,
                *b += diff;
                *avail -= diff;
                tested = len;/* Skip some bytes we already determinated. */
-               len = get_line_size(*b, *avail, nl);
+               len = get_line_size(*b + len, *avail - len, nl);
                if (len >= 0)
                        len += tested;
        }
index b0521a6..469666e 100644 (file)
@@ -136,6 +136,7 @@ struct tar {
        int64_t                  entry_padding;
        int64_t                  entry_bytes_unconsumed;
        int64_t                  realsize;
+       int                      sparse_allowed;
        struct sparse_block     *sparse_list;
        struct sparse_block     *sparse_last;
        int64_t                  sparse_offset;
@@ -1128,8 +1129,15 @@ header_common(struct archive_read *a, struct tar *tar,
        if (tar->entry_bytes_remaining < 0) {
                tar->entry_bytes_remaining = 0;
                archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-                   "Tar entry has negative size?");
-               err = ARCHIVE_WARN;
+                   "Tar entry has negative size");
+               return (ARCHIVE_FATAL);
+       }
+       if (tar->entry_bytes_remaining == INT64_MAX) {
+               /* Note: tar_atol returns INT64_MAX on overflow */
+               tar->entry_bytes_remaining = 0;
+               archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+                   "Tar entry size overflow");
+               return (ARCHIVE_FATAL);
        }
        tar->realsize = tar->entry_bytes_remaining;
        archive_entry_set_size(entry, tar->entry_bytes_remaining);
@@ -1264,6 +1272,14 @@ header_common(struct archive_read *a, struct tar *tar,
                 * sparse information in the extended area.
                 */
                /* FALLTHROUGH */
+       case '0':
+               /*
+                * Enable sparse file "read" support only for regular
+                * files and explicit GNU sparse files.  However, we
+                * don't allow non-standard file types to be sparse.
+                */
+               tar->sparse_allowed = 1;
+               /* FALLTHROUGH */
        default: /* Regular file  and non-standard types */
                /*
                 * Per POSIX: non-recognized types should always be
@@ -1721,6 +1737,14 @@ pax_attribute(struct archive_read *a, struct tar *tar,
                                 * NULL pointer to strlen().  */
        switch (key[0]) {
        case 'G':
+               /* Reject GNU.sparse.* headers on non-regular files. */
+               if (strncmp(key, "GNU.sparse", 10) == 0 &&
+                   !tar->sparse_allowed) {
+                       archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+                           "Non-regular file cannot be sparse");
+                       return (ARCHIVE_FATAL);
+               }
+
                /* GNU "0.0" sparse pax format. */
                if (strcmp(key, "GNU.sparse.numblocks") == 0) {
                        tar->sparse_offset = -1;
index 46a59ea..deeaa9e 100644 (file)
@@ -318,7 +318,7 @@ start_over:
                }
                memcpy(w->pool.str, fnam.str, fnam.len);
                w->pool.str[fnam.len] = '\0';
-               /* let noone else know about the pool, it's a secret, shhh */
+               /* let no one else know about the pool, it's a secret, shhh */
                fnam.str = w->pool.str;
 
                /* snarf mtime or deduce from rtime
@@ -535,7 +535,8 @@ xstrpisotime(const char *s, char **endptr)
 
        /* as a courtesy to our callers, and since this is a non-standard
         * routine, we skip leading whitespace */
-       for (; isspace(*s); s++);
+       while (isspace((unsigned char)*s))
+               ++s;
 
        /* read year */
        if ((tm.tm_year = strtoi_lim(s, &s, 1583, 4095)) < 0 || *s++ != '-') {
@@ -639,7 +640,9 @@ _warc_rdtyp(const char *buf, size_t bsz)
                return WT_NONE;
        }
        /* overread whitespace */
-       for (val += sizeof(_key) - 1U; val < eob && isspace(*val); val++);
+       val += sizeof(_key) - 1U;
+       while (val < eob && isspace((unsigned char)*val))
+               ++val;
 
        if (val + 8U > eob) {
                ;
@@ -676,7 +679,9 @@ _warc_rduri(const char *buf, size_t bsz)
                return res;
        }
        /* overread whitespace */
-       for (val += sizeof(_key) - 1U; val < eob && isspace(*val); val++);
+       val += sizeof(_key) - 1U;
+       while (val < eob && isspace((unsigned char)*val))
+               ++val;
 
        /* overread URL designators */
        if ((uri = xmemmem(val, eob - val, "://", 3U)) == NULL) {
@@ -692,7 +697,8 @@ _warc_rduri(const char *buf, size_t bsz)
        /* also massage eol to point to the first whitespace
         * after the last non-whitespace character before
         * the end of the line */
-       for (; eol > uri && isspace(eol[-1]); eol--);
+       while (eol > uri && isspace((unsigned char)eol[-1]))
+               --eol;
 
        /* now then, inspect the URI */
        if (memcmp(val, "file", 4U) == 0) {
@@ -727,7 +733,7 @@ _warc_rdlen(const char *buf, size_t bsz)
        /* strtol kindly overreads whitespace for us, so use that */
        val += sizeof(_key) - 1U;
        len = strtol(val, &on, 10);
-       if (on == NULL || !isspace(*on)) {
+       if (on == NULL || !isspace((unsigned char)*on)) {
                /* hm, can we trust that number?  Best not. */
                return -1;
        }
@@ -750,7 +756,7 @@ _warc_rdrtm(const char *buf, size_t bsz)
        /* xstrpisotime() kindly overreads whitespace for us, so use that */
        val += sizeof(_key) - 1U;
        res = xstrpisotime(val, &on);
-       if (on == NULL || !isspace(*on)) {
+       if (on == NULL || !isspace((unsigned char)*on)) {
                /* hm, can we trust that number?  Best not. */
                return (time_t)-1;
        }
@@ -773,7 +779,7 @@ _warc_rdmtm(const char *buf, size_t bsz)
        /* xstrpisotime() kindly overreads whitespace for us, so use that */
        val += sizeof(_key) - 1U;
        res = xstrpisotime(val, &on);
-       if (on == NULL || !isspace(*on)) {
+       if (on == NULL || !isspace((unsigned char)*on)) {
                /* hm, can we trust that number?  Best not. */
                return (time_t)-1;
        }
index 34ab04e..9796fca 100644 (file)
@@ -418,18 +418,30 @@ zip_time(const char *p)
  *     id1+size1+data1 + id2+size2+data2 ...
  *  triplets.  id and size are 2 bytes each.
  */
-static void
-process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
+static int
+process_extra(struct archive_read *a, const char *p, size_t extra_length, struct zip_entry* zip_entry)
 {
        unsigned offset = 0;
 
-       while (offset < extra_length - 4) {
+       if (extra_length == 0) {
+               return ARCHIVE_OK;
+       }
+
+       if (extra_length < 4) {
+               archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                   "Too-small extra data: Need at least 4 bytes, but only found %d bytes", (int)extra_length);
+               return ARCHIVE_FAILED;
+       }
+       while (offset <= extra_length - 4) {
                unsigned short headerid = archive_le16dec(p + offset);
                unsigned short datasize = archive_le16dec(p + offset + 2);
 
                offset += 4;
                if (offset + datasize > extra_length) {
-                       break;
+                       archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                           "Extra data overflow: Need %d bytes but only found %d bytes",
+                           (int)datasize, (int)(extra_length - offset));
+                       return ARCHIVE_FAILED;
                }
 #ifdef DEBUG
                fprintf(stderr, "Header id 0x%04x, length %d\n",
@@ -715,13 +727,13 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
                }
                offset += datasize;
        }
-#ifdef DEBUG
-       if (offset != extra_length)
-       {
-               fprintf(stderr,
-                   "Extra data field contents do not match reported size!\n");
+       if (offset != extra_length) {
+               archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                   "Malformed extra data: Consumed %d bytes of %d bytes",
+                   (int)offset, (int)extra_length);
+               return ARCHIVE_FAILED;
        }
-#endif
+       return ARCHIVE_OK;
 }
 
 /*
@@ -840,7 +852,9 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
                return (ARCHIVE_FATAL);
        }
 
-       process_extra(h, extra_length, zip_entry);
+       if (ARCHIVE_OK != process_extra(a, h, extra_length, zip_entry)) {
+               return ARCHIVE_FATAL;
+       }
        __archive_read_consume(a, extra_length);
 
        /* Work around a bug in Info-Zip: When reading from a pipe, it
@@ -1293,7 +1307,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
            && bytes_avail > zip->entry_bytes_remaining) {
                bytes_avail = (ssize_t)zip->entry_bytes_remaining;
        }
-       if (bytes_avail <= 0) {
+       if (bytes_avail < 0) {
                archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                    "Truncated ZIP file body");
                return (ARCHIVE_FATAL);
@@ -2691,7 +2705,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
                            "Truncated ZIP file header");
                        return ARCHIVE_FATAL;
                }
-               process_extra(p + filename_length, extra_length, zip_entry);
+               if (ARCHIVE_OK != process_extra(a, p + filename_length, extra_length, zip_entry)) {
+                       return ARCHIVE_FATAL;
+               }
 
                /*
                 * Mac resource fork files are stored under the
index 282c58e..33094f4 100644 (file)
@@ -559,7 +559,8 @@ archive_wstring_append_from_mbs_in_codepage(struct archive_wstring *dest,
                        }
                        if (count == 0 && length != 0)
                                ret = -1;
-               } while (0);
+                       break;
+               } while (1);
        }
        dest->length += count;
        dest->s[dest->length] = L'\0';
@@ -3552,18 +3553,19 @@ win_strncat_from_utf16(struct archive_string *as, const void *_p, size_t bytes,
                ll = WideCharToMultiByte(sc->to_cp, 0,
                    (LPCWSTR)u16, (int)bytes>>1, mbs, (int)mbs_size,
                        NULL, &defchar);
-               if (ll == 0 &&
-                   GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-                       /* Need more buffer for MBS. */
-                       ll = WideCharToMultiByte(sc->to_cp, 0,
-                           (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL);
-                       if (archive_string_ensure(as, ll +1) == NULL)
-                               return (-1);
-                       mbs = as->s + as->length;
-                       mbs_size = as->buffer_length - as->length -1;
-                       continue;
+               /* Exit loop if we succeeded */
+               if (ll != 0 ||
+                   GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+                       break;
                }
-       } while (0);
+               /* Else expand buffer and loop to try again. */
+               ll = WideCharToMultiByte(sc->to_cp, 0,
+                   (LPCWSTR)u16, (int)bytes, NULL, 0, NULL, NULL);
+               if (archive_string_ensure(as, ll +1) == NULL)
+                       return (-1);
+               mbs = as->s + as->length;
+               mbs_size = as->buffer_length - as->length -1;
+       } while (1);
        archive_string_free(&tmp);
        as->length += ll;
        as->s[as->length] = '\0';
@@ -3634,19 +3636,20 @@ win_strncat_to_utf16(struct archive_string *as16, const void *_p,
        do {
                count = MultiByteToWideChar(sc->from_cp,
                    MB_PRECOMPOSED, s, (int)length, (LPWSTR)u16, (int)avail>>1);
-               if (count == 0 &&
-                   GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
-                       /* Need more buffer for UTF-16 string */
-                       count = MultiByteToWideChar(sc->from_cp,
-                           MB_PRECOMPOSED, s, (int)length, NULL, 0);
-                       if (archive_string_ensure(as16, (count +1) * 2)
-                           == NULL)
-                               return (-1);
-                       u16 = as16->s + as16->length;
-                       avail = as16->buffer_length - 2;
-                       continue;
+               /* Exit loop if we succeeded */
+               if (count != 0 ||
+                   GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
+                       break;
                }
-       } while (0);
+               /* Expand buffer and try again */
+               count = MultiByteToWideChar(sc->from_cp,
+                   MB_PRECOMPOSED, s, (int)length, NULL, 0);
+               if (archive_string_ensure(as16, (count +1) * 2)
+                   == NULL)
+                       return (-1);
+               u16 = as16->s + as16->length;
+               avail = as16->buffer_length - 2;
+       } while (1);
        as16->length += count * 2;
        as16->s[as16->length] = 0;
        as16->s[as16->length+1] = 0;
index cc3d1c4..6b3bd61 100644 (file)
@@ -580,7 +580,7 @@ void
 __archive_ensure_cloexec_flag(int fd)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__)
-       (void)fd; /* UNSED */
+       (void)fd; /* UNUSED */
 #else
        int flags;
 
index 5cbba54..e47384a 100644 (file)
@@ -138,6 +138,7 @@ set_acl(struct archive *a, int fd, const char *name,
        acl_permset_t    acl_permset;
 #ifdef ACL_TYPE_NFS4
        acl_flagset_t    acl_flagset;
+       int              r;
 #endif
        int              ret;
        int              ae_type, ae_permset, ae_tag, ae_id;
@@ -152,9 +153,19 @@ set_acl(struct archive *a, int fd, const char *name,
        if (entries == 0)
                return (ARCHIVE_OK);
        acl = acl_init(entries);
+       if (acl == (acl_t)NULL) {
+               archive_set_error(a, errno,
+                   "Failed to initialize ACL working storage");
+               return (ARCHIVE_FAILED);
+       }
        while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
                   &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
-               acl_create_entry(&acl, &acl_entry);
+               if (acl_create_entry(&acl, &acl_entry) != 0) {
+                       archive_set_error(a, errno,
+                           "Failed to create a new ACL entry");
+                       ret = ARCHIVE_FAILED;
+                       goto exit_free;
+               }
 
                switch (ae_tag) {
                case ARCHIVE_ENTRY_ACL_USER:
@@ -185,50 +196,97 @@ set_acl(struct archive *a, int fd, const char *name,
                        break;
 #endif
                default:
-                       /* XXX */
-                       break;
+                       archive_set_error(a, ARCHIVE_ERRNO_MISC,
+                           "Unknown ACL tag");
+                       ret = ARCHIVE_FAILED;
+                       goto exit_free;
                }
 
 #ifdef ACL_TYPE_NFS4
+               r = 0;
                switch (ae_type) {
                case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
-                       acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
+                       r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
                        break;
                case ARCHIVE_ENTRY_ACL_TYPE_DENY:
-                       acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY);
+                       r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY);
                        break;
                case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
-                       acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT);
+                       r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT);
                        break;
                case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
-                       acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM);
+                       r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM);
                        break;
                case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
                case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
                        // These don't translate directly into the system ACL.
                        break;
                default:
-                       // XXX error handling here.
-                       break;
+                       archive_set_error(a, ARCHIVE_ERRNO_MISC,
+                           "Unknown ACL entry type");
+                       ret = ARCHIVE_FAILED;
+                       goto exit_free;
+               }
+               if (r != 0) {
+                       archive_set_error(a, errno,
+                           "Failed to set ACL entry type");
+                       ret = ARCHIVE_FAILED;
+                       goto exit_free;
                }
 #endif
 
-               acl_get_permset(acl_entry, &acl_permset);
-               acl_clear_perms(acl_permset);
+               if (acl_get_permset(acl_entry, &acl_permset) != 0) {
+                       archive_set_error(a, errno,
+                           "Failed to get ACL permission set");
+                       ret = ARCHIVE_FAILED;
+                       goto exit_free;
+               }
+               if (acl_clear_perms(acl_permset) != 0) {
+                       archive_set_error(a, errno,
+                           "Failed to clear ACL permissions");
+                       ret = ARCHIVE_FAILED;
+                       goto exit_free;
+               }
 
                for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
                        if (ae_permset & acl_perm_map[i].archive_perm)
-                               acl_add_perm(acl_permset,
-                                            acl_perm_map[i].platform_perm);
+                               if (acl_add_perm(acl_permset,
+                                   acl_perm_map[i].platform_perm) != 0) {
+                                       archive_set_error(a, errno,
+                                           "Failed to add ACL permission");
+                                       ret = ARCHIVE_FAILED;
+                                       goto exit_free;
+                               }
                }
 
 #ifdef ACL_TYPE_NFS4
-               acl_get_flagset_np(acl_entry, &acl_flagset);
-               acl_clear_flags_np(acl_flagset);
-               for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
-                       if (ae_permset & acl_inherit_map[i].archive_inherit)
-                               acl_add_flag_np(acl_flagset,
-                                               acl_inherit_map[i].platform_inherit);
+               if (acl_type == ACL_TYPE_NFS4) {
+                       /*
+                        * acl_get_flagset_np() fails with non-NFSv4 ACLs
+                        */
+                       if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
+                               archive_set_error(a, errno,
+                                   "Failed to get flagset from an NFSv4 ACL entry");
+                               ret = ARCHIVE_FAILED;
+                               goto exit_free;
+                       }
+                       if (acl_clear_flags_np(acl_flagset) != 0) {
+                               archive_set_error(a, errno,
+                                   "Failed to clear flags from an NFSv4 ACL flagset");
+                               ret = ARCHIVE_FAILED;
+                               goto exit_free;
+                       }
+                       for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
+                               if (ae_permset & acl_inherit_map[i].archive_inherit) {
+                                       if (acl_add_flag_np(acl_flagset,
+                                                       acl_inherit_map[i].platform_inherit) != 0) {
+                                               archive_set_error(a, errno,
+                                                   "Failed to add flag to NFSv4 ACL flagset");
+                                               ret = ARCHIVE_FAILED;
+                                               goto exit_free;
+                                       }
+                               }
+                       }
                }
 #endif
        }
@@ -257,6 +315,7 @@ set_acl(struct archive *a, int fd, const char *name,
                ret = ARCHIVE_WARN;
        }
 #endif
+exit_free:
        acl_free(acl);
        return (ret);
 }
index 6737cd7..17c23b0 100644 (file)
@@ -140,7 +140,17 @@ __FBSDID("$FreeBSD$");
 #define O_BINARY 0
 #endif
 #ifndef O_CLOEXEC
-#define O_CLOEXEC      0
+#define O_CLOEXEC 0
+#endif
+
+/* Ignore non-int O_NOFOLLOW constant. */
+/* gnulib's fcntl.h does this on AIX, but it seems practical everywhere */
+#if defined O_NOFOLLOW && !(INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
+#undef O_NOFOLLOW
+#endif
+
+#ifndef O_NOFOLLOW
+#define O_NOFOLLOW 0
 #endif
 
 struct fixup_entry {
@@ -326,12 +336,14 @@ struct archive_write_disk {
 
 #define HFS_BLOCKS(s)  ((s) >> 12)
 
+static int     check_symlinks_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags);
 static int     check_symlinks(struct archive_write_disk *);
 static int     create_filesystem_object(struct archive_write_disk *);
 static struct fixup_entry *current_fixup(struct archive_write_disk *, const char *pathname);
 #if defined(HAVE_FCHDIR) && defined(PATH_MAX)
 static void    edit_deep_directories(struct archive_write_disk *ad);
 #endif
+static int     cleanup_pathname_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags);
 static int     cleanup_pathname(struct archive_write_disk *);
 static int     create_dir(struct archive_write_disk *, char *);
 static int     create_parent_dir(struct archive_write_disk *, char *);
@@ -1796,7 +1808,7 @@ edit_deep_directories(struct archive_write_disk *a)
        char *tail = a->name;
 
        /* If path is short, avoid the open() below. */
-       if (strlen(tail) <= PATH_MAX)
+       if (strlen(tail) < PATH_MAX)
                return;
 
        /* Try to record our starting dir. */
@@ -1806,7 +1818,7 @@ edit_deep_directories(struct archive_write_disk *a)
                return;
 
        /* As long as the path is too long... */
-       while (strlen(tail) > PATH_MAX) {
+       while (strlen(tail) >= PATH_MAX) {
                /* Locate a dir prefix shorter than PATH_MAX. */
                tail += PATH_MAX - 8;
                while (tail > a->name && *tail != '/')
@@ -2014,6 +2026,10 @@ create_filesystem_object(struct archive_write_disk *a)
        const char *linkname;
        mode_t final_mode, mode;
        int r;
+       /* these for check_symlinks_fsobj */
+       char *linkname_copy;    /* non-const copy of linkname */
+       struct archive_string error_string;
+       int error_number;
 
        /* We identify hard/symlinks according to the link names. */
        /* Since link(2) and symlink(2) don't handle modes, we're done here. */
@@ -2022,6 +2038,27 @@ create_filesystem_object(struct archive_write_disk *a)
 #if !HAVE_LINK
                return (EPERM);
 #else
+               archive_string_init(&error_string);
+               linkname_copy = strdup(linkname);
+               if (linkname_copy == NULL) {
+                   return (EPERM);
+               }
+               /* TODO: consider using the cleaned-up path as the link target? */
+               r = cleanup_pathname_fsobj(linkname_copy, &error_number, &error_string, a->flags);
+               if (r != ARCHIVE_OK) {
+                       archive_set_error(&a->archive, error_number, "%s", error_string.s);
+                       free(linkname_copy);
+                       /* EPERM is more appropriate than error_number for our callers */
+                       return (EPERM);
+               }
+               r = check_symlinks_fsobj(linkname_copy, &error_number, &error_string, a->flags);
+               if (r != ARCHIVE_OK) {
+                       archive_set_error(&a->archive, error_number, "%s", error_string.s);
+                       free(linkname_copy);
+                       /* EPERM is more appropriate than error_number for our callers */
+                       return (EPERM);
+               }
+               free(linkname_copy);
                r = link(linkname, a->name) ? errno : 0;
                /*
                 * New cpio and pax formats allow hardlink entries
@@ -2040,7 +2077,7 @@ create_filesystem_object(struct archive_write_disk *a)
                        a->deferred = 0;
                } else if (r == 0 && a->filesize > 0) {
                        a->fd = open(a->name,
-                                    O_WRONLY | O_TRUNC | O_BINARY | O_CLOEXEC);
+                                    O_WRONLY | O_TRUNC | O_BINARY | O_CLOEXEC | O_NOFOLLOW);
                        __archive_ensure_cloexec_flag(a->fd);
                        if (a->fd < 0)
                                r = errno;
@@ -2351,116 +2388,233 @@ current_fixup(struct archive_write_disk *a, const char *pathname)
        return (a->current_fixup);
 }
 
-/* TODO: Make this work. */
-/*
- * TODO: The deep-directory support bypasses this; disable deep directory
- * support if we're doing symlink checks.
- */
 /*
  * TODO: Someday, integrate this with the deep dir support; they both
  * scan the path and both can be optimized by comparing against other
  * recent paths.
  */
 /* TODO: Extend this to support symlinks on Windows Vista and later. */
+
+/*
+ * Checks the given path to see if any elements along it are symlinks.  Returns
+ * ARCHIVE_OK if there are none, otherwise puts an error in errmsg.
+ */
 static int
-check_symlinks(struct archive_write_disk *a)
+check_symlinks_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags)
 {
 #if !defined(HAVE_LSTAT)
        /* Platform doesn't have lstat, so we can't look for symlinks. */
-       (void)a; /* UNUSED */
+       (void)path; /* UNUSED */
+       (void)error_number; /* UNUSED */
+       (void)error_string; /* UNUSED */
+       (void)flags; /* UNUSED */
        return (ARCHIVE_OK);
 #else
-       char *pn;
+       int res = ARCHIVE_OK;
+       char *tail;
+       char *head;
+       int last;
        char c;
        int r;
        struct stat st;
+       int restore_pwd;
+
+       /* Nothing to do here if name is empty */
+       if(path[0] == '\0')
+           return (ARCHIVE_OK);
 
        /*
         * Guard against symlink tricks.  Reject any archive entry whose
         * destination would be altered by a symlink.
+        *
+        * Walk the filename in chunks separated by '/'.  For each segment:
+        *  - if it doesn't exist, continue
+        *  - if it's symlink, abort or remove it
+        *  - if it's a directory and it's not the last chunk, cd into it
+        * As we go:
+        *  head points to the current (relative) path
+        *  tail points to the temporary \0 terminating the segment we're currently examining
+        *  c holds what used to be in *tail
+        *  last is 1 if this is the last tail
         */
-       /* Whatever we checked last time doesn't need to be re-checked. */
-       pn = a->name;
-       if (archive_strlen(&(a->path_safe)) > 0) {
-               char *p = a->path_safe.s;
-               while ((*pn != '\0') && (*p == *pn))
-                       ++p, ++pn;
-       }
+       restore_pwd = open(".", O_RDONLY | O_BINARY | O_CLOEXEC);
+       __archive_ensure_cloexec_flag(restore_pwd);
+       if (restore_pwd < 0)
+               return (ARCHIVE_FATAL);
+       head = path;
+       tail = path;
+       last = 0;
+       /* TODO: reintroduce a safe cache here? */
        /* Skip the root directory if the path is absolute. */
-       if(pn == a->name && pn[0] == '/')
-               ++pn;
-       c = pn[0];
-       /* Keep going until we've checked the entire name. */
-       while (pn[0] != '\0' && (pn[0] != '/' || pn[1] != '\0')) {
+       if(tail == path && tail[0] == '/')
+               ++tail;
+       /* Keep going until we've checked the entire name.
+        * head, tail, path all alias the same string, which is
+        * temporarily zeroed at tail, so be careful restoring the
+        * stashed (c=tail[0]) for error messages.
+        * Exiting the loop with break is okay; continue is not.
+        */
+       while (!last) {
+               /* Skip the separator we just consumed, plus any adjacent ones */
+               while (*tail == '/')
+                   ++tail;
                /* Skip the next path element. */
-               while (*pn != '\0' && *pn != '/')
-                       ++pn;
-               c = pn[0];
-               pn[0] = '\0';
+               while (*tail != '\0' && *tail != '/')
+                       ++tail;
+               /* is this the last path component? */
+               last = (tail[0] == '\0') || (tail[0] == '/' && tail[1] == '\0');
+               /* temporarily truncate the string here */
+               c = tail[0];
+               tail[0] = '\0';
                /* Check that we haven't hit a symlink. */
-               r = lstat(a->name, &st);
+               r = lstat(head, &st);
                if (r != 0) {
+                       tail[0] = c;
                        /* We've hit a dir that doesn't exist; stop now. */
-                       if (errno == ENOENT)
+                       if (errno == ENOENT) {
                                break;
+                       } else {
+                               /* Treat any other error as fatal - best to be paranoid here
+                                * Note: This effectively disables deep directory
+                                * support when security checks are enabled.
+                                * Otherwise, very long pathnames that trigger
+                                * an error here could evade the sandbox.
+                                * TODO: We could do better, but it would probably
+                                * require merging the symlink checks with the
+                                * deep-directory editing. */
+                               if (error_number) *error_number = errno;
+                               if (error_string)
+                                       archive_string_sprintf(error_string,
+                                                       "Could not stat %s",
+                                                       path);
+                               res = ARCHIVE_FAILED;
+                               break;
+                       }
+               } else if (S_ISDIR(st.st_mode)) {
+                       if (!last) {
+                               if (chdir(head) != 0) {
+                                       tail[0] = c;
+                                       if (error_number) *error_number = errno;
+                                       if (error_string)
+                                               archive_string_sprintf(error_string,
+                                                               "Could not chdir %s",
+                                                               path);
+                                       res = (ARCHIVE_FATAL);
+                                       break;
+                               }
+                               /* Our view is now from inside this dir: */
+                               head = tail + 1;
+                       }
                } else if (S_ISLNK(st.st_mode)) {
-                       if (c == '\0') {
+                       if (last) {
                                /*
                                 * Last element is symlink; remove it
                                 * so we can overwrite it with the
                                 * item being extracted.
                                 */
-                               if (unlink(a->name)) {
-                                       archive_set_error(&a->archive, errno,
-                                           "Could not remove symlink %s",
-                                           a->name);
-                                       pn[0] = c;
-                                       return (ARCHIVE_FAILED);
+                               if (unlink(head)) {
+                                       tail[0] = c;
+                                       if (error_number) *error_number = errno;
+                                       if (error_string)
+                                               archive_string_sprintf(error_string,
+                                                               "Could not remove symlink %s",
+                                                               path);
+                                       res = ARCHIVE_FAILED;
+                                       break;
                                }
-                               a->pst = NULL;
                                /*
                                 * Even if we did remove it, a warning
                                 * is in order.  The warning is silly,
                                 * though, if we're just replacing one
                                 * symlink with another symlink.
                                 */
-                               if (!S_ISLNK(a->mode)) {
-                                       archive_set_error(&a->archive, 0,
-                                           "Removing symlink %s",
-                                           a->name);
+                               tail[0] = c;
+                               /* FIXME:  not sure how important this is to restore
+                               if (!S_ISLNK(path)) {
+                                       if (error_number) *error_number = 0;
+                                       if (error_string)
+                                               archive_string_sprintf(error_string,
+                                                               "Removing symlink %s",
+                                                               path);
                                }
+                               */
                                /* Symlink gone.  No more problem! */
-                               pn[0] = c;
-                               return (0);
-                       } else if (a->flags & ARCHIVE_EXTRACT_UNLINK) {
+                               res = ARCHIVE_OK;
+                               break;
+                       } else if (flags & ARCHIVE_EXTRACT_UNLINK) {
                                /* User asked us to remove problems. */
-                               if (unlink(a->name) != 0) {
-                                       archive_set_error(&a->archive, 0,
-                                           "Cannot remove intervening symlink %s",
-                                           a->name);
-                                       pn[0] = c;
-                                       return (ARCHIVE_FAILED);
+                               if (unlink(head) != 0) {
+                                       tail[0] = c;
+                                       if (error_number) *error_number = 0;
+                                       if (error_string)
+                                               archive_string_sprintf(error_string,
+                                                               "Cannot remove intervening symlink %s",
+                                                               path);
+                                       res = ARCHIVE_FAILED;
+                                       break;
                                }
-                               a->pst = NULL;
+                               tail[0] = c;
                        } else {
-                               archive_set_error(&a->archive, 0,
-                                   "Cannot extract through symlink %s",
-                                   a->name);
-                               pn[0] = c;
-                               return (ARCHIVE_FAILED);
+                               tail[0] = c;
+                               if (error_number) *error_number = 0;
+                               if (error_string)
+                                       archive_string_sprintf(error_string,
+                                                       "Cannot extract through symlink %s",
+                                                       path);
+                               res = ARCHIVE_FAILED;
+                               break;
                        }
                }
-               pn[0] = c;
-               if (pn[0] != '\0')
-                       pn++; /* Advance to the next segment. */
+               /* be sure to always maintain this */
+               tail[0] = c;
+               if (tail[0] != '\0')
+                       tail++; /* Advance to the next segment. */
+       }
+       /* Catches loop exits via break */
+       tail[0] = c;
+#ifdef HAVE_FCHDIR
+       /* If we changed directory above, restore it here. */
+       if (restore_pwd >= 0) {
+               r = fchdir(restore_pwd);
+               if (r != 0) {
+                       if(error_number) *error_number = errno;
+                       if(error_string)
+                               archive_string_sprintf(error_string,
+                                               "chdir() failure");
+               }
+               close(restore_pwd);
+               restore_pwd = -1;
+               if (r != 0) {
+                       res = (ARCHIVE_FATAL);
+               }
        }
-       pn[0] = c;
-       /* We've checked and/or cleaned the whole path, so remember it. */
-       archive_strcpy(&a->path_safe, a->name);
-       return (ARCHIVE_OK);
+#endif
+       /* TODO: reintroduce a safe cache here? */
+       return res;
 #endif
 }
 
+/*
+ * Check a->name for symlinks, returning ARCHIVE_OK if its clean, otherwise
+ * calls archive_set_error and returns ARCHIVE_{FATAL,FAILED}
+ */
+static int
+check_symlinks(struct archive_write_disk *a)
+{
+       struct archive_string error_string;
+       int error_number;
+       int rc;
+       archive_string_init(&error_string);
+       rc = check_symlinks_fsobj(a->name, &error_number, &error_string, a->flags);
+       if (rc != ARCHIVE_OK) {
+               archive_set_error(&a->archive, error_number, "%s", error_string.s);
+       }
+       archive_string_free(&error_string);
+       a->pst = NULL;  /* to be safe */
+       return rc;
+}
+
+
 #if defined(__CYGWIN__)
 /*
  * 1. Convert a path separator from '\' to '/' .
@@ -2534,15 +2688,17 @@ cleanup_pathname_win(struct archive_write_disk *a)
  * is set) if the path is absolute.
  */
 static int
-cleanup_pathname(struct archive_write_disk *a)
+cleanup_pathname_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags)
 {
        char *dest, *src;
        char separator = '\0';
 
-       dest = src = a->name;
+       dest = src = path;
        if (*src == '\0') {
-               archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-                   "Invalid empty pathname");
+               if (error_number) *error_number = ARCHIVE_ERRNO_MISC;
+               if (error_string)
+                   archive_string_sprintf(error_string,
+                           "Invalid empty pathname");
                return (ARCHIVE_FAILED);
        }
 
@@ -2551,9 +2707,11 @@ cleanup_pathname(struct archive_write_disk *a)
 #endif
        /* Skip leading '/'. */
        if (*src == '/') {
-               if (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {
-                       archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
-                                         "Path is absolute");
+               if (flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {
+                       if (error_number) *error_number = ARCHIVE_ERRNO_MISC;
+                       if (error_string)
+                           archive_string_sprintf(error_string,
+                                   "Path is absolute");
                        return (ARCHIVE_FAILED);
                }
 
@@ -2580,10 +2738,11 @@ cleanup_pathname(struct archive_write_disk *a)
                        } else if (src[1] == '.') {
                                if (src[2] == '/' || src[2] == '\0') {
                                        /* Conditionally warn about '..' */
-                                       if (a->flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) {
-                                               archive_set_error(&a->archive,
-                                                   ARCHIVE_ERRNO_MISC,
-                                                   "Path contains '..'");
+                                       if (flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) {
+                                               if (error_number) *error_number = ARCHIVE_ERRNO_MISC;
+                                               if (error_string)
+                                                   archive_string_sprintf(error_string,
+                                                           "Path contains '..'");
                                                return (ARCHIVE_FAILED);
                                        }
                                }
@@ -2614,7 +2773,7 @@ cleanup_pathname(struct archive_write_disk *a)
         * We've just copied zero or more path elements, not including the
         * final '/'.
         */
-       if (dest == a->name) {
+       if (dest == path) {
                /*
                 * Nothing got copied.  The path must have been something
                 * like '.' or '/' or './' or '/././././/./'.
@@ -2629,6 +2788,21 @@ cleanup_pathname(struct archive_write_disk *a)
        return (ARCHIVE_OK);
 }
 
+static int
+cleanup_pathname(struct archive_write_disk *a)
+{
+       struct archive_string error_string;
+       int error_number;
+       int rc;
+       archive_string_init(&error_string);
+       rc = cleanup_pathname_fsobj(a->name, &error_number, &error_string, a->flags);
+       if (rc != ARCHIVE_OK) {
+               archive_set_error(&a->archive, error_number, "%s", error_string.s);
+       }
+       archive_string_free(&error_string);
+       return rc;
+}
+
 /*
  * Create the parent directory of the specified path, assuming path
  * is already in mutable storage.
@@ -3487,6 +3661,9 @@ exit_xattr:
 static int
 copy_acls(struct archive_write_disk *a, int tmpfd, int dffd)
 {
+#ifndef HAVE_SYS_ACL_H
+       return 0;
+#else
        acl_t acl, dfacl = NULL;
        int acl_r, ret = ARCHIVE_OK;
 
@@ -3514,6 +3691,7 @@ exit_acl:
        if (dfacl)
                acl_free(dfacl);
        return (ret);
+#endif
 }
 
 static int
index cb3e54e..c20e088 100644 (file)
@@ -436,7 +436,7 @@ struct iso_option {
         * Type   : string
         * Default: Auto detect
         *        : We check a size of boot image;
-        *        : If ths size is just 1.22M/1.44M/2.88M,
+        *        : If the size is just 1.22M/1.44M/2.88M,
         *        : we assume boot_type is 'fd';
         *        : otherwise boot_type is 'no-emulation'.
         * COMPAT :
index 484ab34..797b533 100644 (file)
@@ -307,7 +307,7 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry)
                 * case getting WCS failed. On POSIX, this is a
                 * normal operation.
                 */
-               if (p != NULL && p[strlen(p) - 1] != '/') {
+               if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') {
                        struct archive_string as;
 
                        archive_string_init(&as);
index 2073431..d3ce373 100644 (file)
@@ -28,6 +28,7 @@
 /* FreeBSD 5.0 and later have ACL and extattr support. */
 #if __FreeBSD__ > 4
 #define        HAVE_ACL_CREATE_ENTRY 1
+#define        HAVE_ACL_GET_FD_NP 1
 #define        HAVE_ACL_GET_LINK_NP 1
 #define        HAVE_ACL_GET_PERM_NP 1
 #define        HAVE_ACL_INIT 1
index 124aa3a..1cb21f9 100644 (file)
@@ -6,7 +6,7 @@
 IF(ENABLE_TEST)
   SET(libarchive_test_SOURCES
     ../../test_utils/test_utils.c
-   main.c
+    main.c
     read_open_memory.c
     test.h
     test_acl_freebsd_nfs4.c
@@ -138,6 +138,7 @@ IF(ENABLE_TEST)
     test_read_format_lha_bugfix_0.c
     test_read_format_lha_filename.c
     test_read_format_mtree.c
+    test_read_format_mtree_crash747.c
     test_read_format_pax_bz2.c
     test_read_format_rar.c
     test_read_format_rar_encryption_data.c
@@ -164,6 +165,7 @@ IF(ENABLE_TEST)
     test_read_format_zip_encryption_header.c
     test_read_format_zip_encryption_partially.c
     test_read_format_zip_filename.c
+    test_read_format_zip_high_compression.c
     test_read_format_zip_mac_metadata.c
     test_read_format_zip_malformed.c
     test_read_format_zip_msdos.c
@@ -198,6 +200,9 @@ IF(ENABLE_TEST)
     test_write_disk_no_hfs_compression.c
     test_write_disk_perms.c
     test_write_disk_secure.c
+    test_write_disk_secure744.c
+    test_write_disk_secure745.c
+    test_write_disk_secure746.c
     test_write_disk_sparse.c
     test_write_disk_symlink.c
     test_write_disk_times.c
@@ -295,7 +300,7 @@ IF(ENABLE_TEST)
 
   # Experimental new test handling
   ADD_CUSTOM_TARGET(run_libarchive_test
-       COMMAND libarchive_test -r ${CMAKE_CURRENT_SOURCE_DIR})
+       COMMAND libarchive_test -r ${CMAKE_CURRENT_SOURCE_DIR} -vv)
   ADD_DEPENDENCIES(run_all_tests run_libarchive_test)
 ENDIF(ENABLE_TEST)
 
index 89b22c6..4ddccbc 100644 (file)
@@ -1,5 +1,6 @@
 DEFINE_TEST(test_acl_freebsd_nfs4)
-DEFINE_TEST(test_acl_freebsd_posix1e)
+DEFINE_TEST(test_acl_freebsd_posix1e_restore)
+DEFINE_TEST(test_acl_freebsd_posix1e_read)
 DEFINE_TEST(test_acl_nfs4)
 DEFINE_TEST(test_acl_pax)
 DEFINE_TEST(test_acl_posix1e)
@@ -260,6 +261,7 @@ DEFINE_TEST(test_read_format_mtree_nomagic_v1_form)
 DEFINE_TEST(test_read_format_mtree_nomagic_v2_form)
 DEFINE_TEST(test_read_format_mtree_nomagic_v2_netbsd_form)
 DEFINE_TEST(test_read_format_mtree_nonexistent_contents_file)
+DEFINE_TEST(test_read_format_mtree_crash747)
 DEFINE_TEST(test_read_format_pax_bz2)
 DEFINE_TEST(test_read_format_rar_basic)
 DEFINE_TEST(test_read_format_rar_subblock)
@@ -321,6 +323,8 @@ DEFINE_TEST(test_read_format_zip_filename_CP866_CP1251_win)
 DEFINE_TEST(test_read_format_zip_filename_KOI8R_CP1251)
 DEFINE_TEST(test_read_format_zip_filename_UTF8_CP1251)
 DEFINE_TEST(test_read_format_zip_filename_KOI8R_UTF8_2)
+DEFINE_TEST(test_read_format_zip_high_compression)
+DEFINE_TEST(test_read_format_zip_high_compression2)
 DEFINE_TEST(test_read_format_zip_mac_metadata)
 DEFINE_TEST(test_read_format_zip_malformed)
 DEFINE_TEST(test_read_format_zip_msdos)
@@ -379,6 +383,10 @@ DEFINE_TEST(test_write_disk_lookup)
 DEFINE_TEST(test_write_disk_mac_metadata)
 DEFINE_TEST(test_write_disk_no_hfs_compression)
 DEFINE_TEST(test_write_disk_perms)
+DEFINE_TEST(test_write_disk_secure744)
+DEFINE_TEST(test_write_disk_secure745)
+DEFINE_TEST(test_write_disk_secure746a)
+DEFINE_TEST(test_write_disk_secure746b)
 DEFINE_TEST(test_write_disk_secure)
 DEFINE_TEST(test_write_disk_sparse)
 DEFINE_TEST(test_write_disk_symlink)
index 0f50e94..32a1f78 100644 (file)
@@ -128,6 +128,13 @@ __FBSDID("$FreeBSD: head/lib/libarchive/test/main.c 201247 2009-12-30 05:59:21Z
 # include <crtdbg.h>
 #endif
 
+mode_t umasked(mode_t expected_mode)
+{
+       mode_t mode = umask(0);
+       umask(mode);
+       return expected_mode & ~mode;
+}
+
 /* Path to working directory for current test */
 const char *testworkdir;
 #ifdef PROGRAM
@@ -1155,6 +1162,35 @@ assertion_file_contains_lines_any_order(const char *file, int line,
        return (0);
 }
 
+/* Verify that a text file does not contains the specified strings */
+int
+assertion_file_contains_no_invalid_strings(const char *file, int line,
+    const char *pathname, const char *strings[])
+{
+       char *buff;
+       int i;
+
+       buff = slurpfile(NULL, "%s", pathname);
+       if (buff == NULL) {
+               failure_start(file, line, "Can't read file: %s", pathname);
+               failure_finish(NULL);
+               return (0);
+       }
+
+       for (i = 0; strings[i] != NULL; ++i) {
+               if (strstr(buff, strings[i]) != NULL) {
+                       failure_start(file, line, "Invalid string in %s: %s", pathname,
+                           strings[i]);
+                       failure_finish(NULL);
+                       free(buff);
+                       return(0);
+               }
+       }
+
+       free(buff);
+       return (0);
+}
+
 /* Test that two paths point to the same file. */
 /* As a side-effect, asserts that both files exist. */
 static int
@@ -1292,6 +1328,11 @@ assertion_file_time(const char *file, int line,
        switch (type) {
        case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
        case 'b': filet = st.st_birthtime;
+               /* FreeBSD filesystems that don't support birthtime
+                * (e.g., UFS1) always return -1 here. */
+               if (filet == -1) {
+                       return (1);
+               }
                filet_nsec = st.st_birthtimespec.tv_nsec; break;
        case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
        default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
@@ -1359,6 +1400,33 @@ assertion_file_birthtime_recent(const char *file, int line,
        return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
 }
 
+/* Verify mode of 'pathname'. */
+int
+assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
+{
+       int mode;
+       int r;
+
+       assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       failure_start(file, line, "assertFileMode not yet implemented for Windows");
+       (void)mode; /* UNUSED */
+       (void)r; /* UNUSED */
+#else
+       {
+               struct stat st;
+               r = lstat(pathname, &st);
+               mode = (int)(st.st_mode & 0777);
+       }
+       if (r == 0 && mode == expected_mode)
+                       return (1);
+       failure_start(file, line, "File %s has mode %o, expected %o",
+           pathname, mode, expected_mode);
+#endif
+       failure_finish(NULL);
+       return (0);
+}
+
 /* Verify mtime of 'pathname'. */
 int
 assertion_file_mtime(const char *file, int line,
@@ -1398,7 +1466,7 @@ assertion_file_nlinks(const char *file, int line,
        assertion_count(file, line);
        r = lstat(pathname, &st);
        if (r == 0 && (int)st.st_nlink == nlinks)
-                       return (1);
+               return (1);
        failure_start(file, line, "File %s has %d links, expected %d",
            pathname, st.st_nlink, nlinks);
        failure_finish(NULL);
@@ -1577,8 +1645,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
        if (0 == _mkdir(dirname))
                return (1);
 #else
-       if (0 == mkdir(dirname, mode))
-               return (1);
+       if (0 == mkdir(dirname, mode)) {
+               if (0 == chmod(dirname, mode)) {
+                       assertion_file_mode(file, line, dirname, mode);
+                       return (1);
+               }
+       }
 #endif
        failure_start(file, line, "Could not create directory %s", dirname);
        failure_finish(NULL);
@@ -1627,6 +1699,12 @@ assertion_make_file(const char *file, int line,
                failure_finish(NULL);
                return (0);
        }
+       if (0 != chmod(path, mode)) {
+               failure_start(file, line, "Could not chmod %s", path);
+               failure_finish(NULL);
+               close(fd);
+               return (0);
+       }
        if (contents != NULL) {
                ssize_t wsize;
 
@@ -1639,10 +1717,12 @@ assertion_make_file(const char *file, int line,
                        failure_start(file, line,
                            "Could not write to %s", path);
                        failure_finish(NULL);
+                       close(fd);
                        return (0);
                }
        }
        close(fd);
+       assertion_file_mode(file, line, path, mode);
        return (1);
 #endif
 }
index 1117d6a..a48c426 100644 (file)
 /* Assert that file contents match a string. */
 #define assertFileContents(data, data_size, pathname) \
   assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
+/* Verify that a file does not contain invalid strings */
+#define assertFileContainsNoInvalidStrings(pathname, strings) \
+  assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
 #define assertFileMtime(pathname, sec, nsec)   \
   assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileMtimeRecent(pathname) \
   assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
 #define assertFileSize(pathname, size)  \
   assertion_file_size(__FILE__, __LINE__, pathname, size)
+#define assertFileMode(pathname, mode)  \
+  assertion_file_mode(__FILE__, __LINE__, pathname, mode)
 #define assertTextFileContents(text, pathname) \
   assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
 #define assertFileContainsLinesAnyOrder(pathname, lines)       \
@@ -239,8 +244,10 @@ int assertion_file_atime_recent(const char *, int, const char *);
 int assertion_file_birthtime(const char *, int, const char *, long, long);
 int assertion_file_birthtime_recent(const char *, int, const char *);
 int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
+int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
 int assertion_file_contents(const char *, int, const void *, int, const char *);
 int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mode(const char *, int, const char *, int);
 int assertion_file_mtime(const char *, int, const char *, long, long);
 int assertion_file_mtime_recent(const char *, int, const char *);
 int assertion_file_nlinks(const char *, int, const char *, int);
@@ -326,6 +333,9 @@ void copy_reference_file(const char *);
  */
 void extract_reference_files(const char **);
 
+/* Subtract umask from mode */
+mode_t umasked(mode_t expected_mode);
+
 /* Path to working directory for current test */
 extern const char *testworkdir;
 
index fd2301d..89861d6 100644 (file)
@@ -93,7 +93,7 @@ static struct myacl_t acls_reg[] = {
 
 static struct myacl_t acls_dir[] = {
        /* For this test, we need to be able to read and write the ACL. */
-       { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_ACL,
+       { ARCHIVE_ENTRY_ACL_TYPE_ALLOW, ARCHIVE_ENTRY_ACL_READ_DATA | ARCHIVE_ENTRY_ACL_READ_ACL,
          ARCHIVE_ENTRY_ACL_USER_OBJ, -1, ""},
 
        /* An entry for each type. */
index 36f9499..2eb0a00 100644 (file)
@@ -70,15 +70,9 @@ set_acls(struct archive_entry *ae, struct myacl_t *acls)
 }
 
 static int
-acl_match(acl_entry_t aclent, struct myacl_t *myacl)
-{
-       gid_t g, *gp;
-       uid_t u, *up;
-       acl_tag_t tag_type;
-       acl_permset_t opaque_ps;
+acl_entry_get_perm(acl_entry_t aclent) {
        int permset = 0;
-
-       acl_get_tag_type(aclent, &tag_type);
+       acl_permset_t opaque_ps;
 
        /* translate the silly opaque permset to a bitmap */
        acl_get_permset(aclent, &opaque_ps);
@@ -88,10 +82,61 @@ acl_match(acl_entry_t aclent, struct myacl_t *myacl)
                permset |= ARCHIVE_ENTRY_ACL_WRITE;
        if (acl_get_perm_np(opaque_ps, ACL_READ))
                permset |= ARCHIVE_ENTRY_ACL_READ;
+       return permset;
+}
+
+#if 0
+static int
+acl_get_specific_entry(acl_t acl, acl_tag_t requested_tag_type, int requested_tag) {
+       int entry_id = ACL_FIRST_ENTRY;
+       acl_entry_t acl_entry;
+       acl_tag_t acl_tag_type;
+       
+       while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
+               /* After the first time... */
+               entry_id = ACL_NEXT_ENTRY;
+
+               /* If this matches, return perm mask */
+               acl_get_tag_type(acl_entry, &acl_tag_type);
+               if (acl_tag_type == requested_tag_type) {
+                       switch (acl_tag_type) {
+                       case ACL_USER_OBJ:
+                               if ((uid_t)requested_tag == *(uid_t *)(acl_get_qualifier(acl_entry))) {
+                                       return acl_entry_get_perm(acl_entry);
+                               }
+                               break;
+                       case ACL_GROUP_OBJ:
+                               if ((gid_t)requested_tag == *(gid_t *)(acl_get_qualifier(acl_entry))) {
+                                       return acl_entry_get_perm(acl_entry);
+                               }
+                               break;
+                       case ACL_USER:
+                       case ACL_GROUP:
+                       case ACL_OTHER:
+                               return acl_entry_get_perm(acl_entry);
+                       default:
+                               failure("Unexpected ACL tag type");
+                               assert(0);
+                       }
+               }
+
 
-       if (permset != myacl->permset)
+       }
+       return -1;
+}
+#endif
+
+static int
+acl_match(acl_entry_t aclent, struct myacl_t *myacl)
+{
+       gid_t g, *gp;
+       uid_t u, *up;
+       acl_tag_t tag_type;
+
+       if (myacl->permset != acl_entry_get_perm(aclent))
                return (0);
 
+       acl_get_tag_type(aclent, &tag_type);
        switch (tag_type) {
        case ACL_USER_OBJ:
                if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0);
@@ -190,7 +235,7 @@ compare_acls(acl_t acl, struct myacl_t *myacls)
  * Verify ACL restore-to-disk.  This test is FreeBSD-specific.
  */
 
-DEFINE_TEST(test_acl_freebsd_posix1e)
+DEFINE_TEST(test_acl_freebsd_posix1e_restore)
 {
 #if !defined(__FreeBSD__)
        skipping("FreeBSD-specific ACL restore test");
@@ -263,3 +308,111 @@ DEFINE_TEST(test_acl_freebsd_posix1e)
        acl_free(acl);
 #endif
 }
+
+/*
+ * Verify ACL reaed-from-disk.  This test is FreeBSD-specific.
+ */
+DEFINE_TEST(test_acl_freebsd_posix1e_read)
+{
+#if !defined(__FreeBSD__)
+       skipping("FreeBSD-specific ACL read test");
+#elif __FreeBSD__ < 5
+       skipping("ACL read supported only on FreeBSD 5.0 and later");
+#else
+       struct archive *a;
+       struct archive_entry *ae;
+       int n, fd;
+       const char *acl1_text, *acl2_text;
+       acl_t acl1, acl2;
+
+       /*
+        * Manually construct a directory and two files with
+        * different ACLs.  This also serves to verify that ACLs
+        * are supported on the local filesystem.
+        */
+
+       /* Create a test file f1 with acl1 */
+       acl1_text = "user::rwx,group::rwx,other::rwx,user:1:rw-,group:15:r-x,mask::rwx";
+       acl1 = acl_from_text(acl1_text);
+       assert((void *)acl1 != NULL);
+       fd = open("f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
+       failure("Could not create test file?!");
+       if (!assert(fd >= 0)) {
+               acl_free(acl1);
+               return;
+       }
+       n = acl_set_fd(fd, acl1);
+       acl_free(acl1);
+       if (n != 0 && errno == EOPNOTSUPP) {
+               close(fd);
+               skipping("ACL tests require that ACL support be enabled on the filesystem");
+               return;
+       }
+       if (n != 0 && errno == EINVAL) {
+               close(fd);
+               skipping("This filesystem does not support POSIX.1e ACLs");
+               return;
+       }
+       failure("acl_set_fd(): errno = %d (%s)",
+           errno, strerror(errno));
+       assertEqualInt(0, n);
+       close(fd);
+
+       assertMakeDir("d", 0700);
+
+       /*
+        * Create file d/f1 with acl2
+        *
+        * This differs from acl1 in the u:1: and g:15: permissions.
+        *
+        * This file deliberately has the same name but a different ACL.
+        * Github Issue #777 explains how libarchive's directory traversal
+        * did not always correctly enter directories before attempting
+        * to read ACLs, resulting in reading the ACL from a like-named
+        * file in the wrong directory.
+        */
+       acl2_text = "user::rwx,group::rwx,other::---,user:1:r--,group:15:r--,mask::rwx";
+       acl2 = acl_from_text(acl2_text);
+       assert((void *)acl2 != NULL);
+       fd = open("d/f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
+       failure("Could not create test file?!");
+       if (!assert(fd >= 0)) {
+               acl_free(acl2);
+               return;
+       }
+       n = acl_set_fd(fd, acl2);
+       acl_free(acl2);
+       if (n != 0 && errno == EOPNOTSUPP) {
+               close(fd);
+               skipping("ACL tests require that ACL support be enabled on the filesystem");
+               return;
+       }
+       if (n != 0 && errno == EINVAL) {
+               close(fd);
+               skipping("This filesystem does not support POSIX.1e ACLs");
+               return;
+       }
+       failure("acl_set_fd(): errno = %d (%s)",
+           errno, strerror(errno));
+       assertEqualInt(0, n);
+       close(fd);
+
+       /* Create a read-from-disk object. */
+       assert(NULL != (a = archive_read_disk_new()));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_disk_open(a, "."));
+       assert(NULL != (ae = archive_entry_new()));
+
+       /* Walk the dir until we see both of the files */
+       while (ARCHIVE_OK == archive_read_next_header2(a, ae)) {
+               archive_read_disk_descend(a);
+               if (strcmp(archive_entry_pathname(ae), "./f1") == 0) {
+                       assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl1_text);
+                           
+               } else if (strcmp(archive_entry_pathname(ae), "./d/f1") == 0) {
+                       assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl2_text);
+               }
+       }
+
+       archive_free(a);
+#endif
+}
index fea141d..e86f97c 100644 (file)
@@ -800,8 +800,8 @@ DEFINE_TEST(test_archive_string_conversion)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assert((fp = fopen(testdata, "w")) != NULL);
        while ((size = archive_read_data(a, buff, 512)) > 0)
-               fwrite(buff, 1, size, fp);
-       fclose(fp);
+               assertEqualInt(size, fwrite(buff, 1, size, fp));
+       assertEqualInt(0, fclose(fp));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 
        test_archive_string_normalization_nfc(testdata);
index 76fda62..602b894 100644 (file)
@@ -110,13 +110,17 @@ test_fuzz(const struct files *filesets)
                        for (i = 0; filesets[n].names[i] != NULL; ++i)
                        {
                                tmp = slurpfile(&size, filesets[n].names[i]);
-                               rawimage = (char *)realloc(rawimage, oldsize + size);
+                               char *newraw = (char *)realloc(rawimage, oldsize + size);
+                               if (!assert(newraw != NULL))
+                               {
+                                       free(rawimage);
+                                       continue;
+                               }
+                               rawimage = newraw;
                                memcpy(rawimage + oldsize, tmp, size);
                                oldsize += size;
                                size = oldsize;
                                free(tmp);
-                               if (!assert(rawimage != NULL))
-                                       continue;
                        }
                }
                if (size == 0)
diff --git a/libarchive/test/test_read_format_mtree_crash747.c b/libarchive/test/test_read_format_mtree_crash747.c
new file mode 100644 (file)
index 0000000..9500bba
--- /dev/null
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2003-2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+
+
+/*
+ * Reproduce the crash reported in Github Issue #747.
+ */
+DEFINE_TEST(test_read_format_mtree_crash747)
+{
+       const char *reffile = "test_read_format_mtree_crash747.mtree.bz2";
+       struct archive *a;
+
+       if (archive_bzlib_version() == NULL) {
+               skipping("This test requires bzlib");
+               return;
+       }
+
+       extract_reference_file(reffile);
+
+       assert((a = archive_read_new()) != NULL);
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_bzip2(a));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_mtree(a));
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_read_open_filename(a, reffile, 10240));
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
diff --git a/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu b/libarchive/test/test_read_format_mtree_crash747.mtree.bz2.uu
new file mode 100644 (file)
index 0000000..84f3895
--- /dev/null
@@ -0,0 +1,6 @@
+begin 600 test_read_format_mtree_crash747.mtree.bz2
+M0EIH.3%!62936:OH@(@``'/[@,`0`@!``'^```)A@9\`$`@@`'4)049!IIH!
+MM021-0,F@&@6````9%>$(K!GIC*XFR0`$```J0+:$XP```!D-F)H[#SE9+2'
+4+E"L=ASXUI%R(I"HD'ZA(5?1`Q``
+`
+end
index 5870323..6392d8f 100644 (file)
@@ -3603,7 +3603,7 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
   assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
 
   /*
-   * Eigth header.
+   * Eighth header.
    */
   assertA(0 == archive_read_next_header(a, &ae));
   assertEqualString("testdir/testsymlink6", archive_entry_pathname(ae));
diff --git a/libarchive/test/test_read_format_zip_high_compression.c b/libarchive/test/test_read_format_zip_high_compression.c
new file mode 100644 (file)
index 0000000..42faed3
--- /dev/null
@@ -0,0 +1,153 @@
+/*-
+ * Copyright (c) 2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD");
+
+#include <locale.h>
+
+
+/*
+ * Github Issue 748 reported problems with end-of-entry handling
+ * with highly-compressible data.  This resulted in the end of the
+ * data being truncated (extracted as zero bytes).
+ */
+
+/*
+ * Extract the specific test archive that was used to diagnose
+ * Issue 748:
+ */
+DEFINE_TEST(test_read_format_zip_high_compression)
+{
+       const char *refname = "test_read_format_zip_high_compression.zip";
+       char *p;
+       size_t archive_size;
+       struct archive *a;
+       struct archive_entry *entry;
+
+       const void *pv;
+       size_t s;
+       int64_t o;
+
+       if (archive_zlib_version() == NULL) {
+               skipping("Zip compression test requires zlib");
+               return;
+       }
+
+       extract_reference_file(refname);
+       p = slurpfile(&archive_size, refname);
+
+       assert((a = archive_read_new()) != NULL);
+        assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
+        assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, archive_size, 16 * 1024));
+       assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
+
+       assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
+       assertEqualInt(262144, s);
+       assertEqualInt(0, o);
+
+       assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
+       assertEqualInt(160, s);
+       assertEqualInt(262144, o);
+
+       assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
+
+       assertEqualInt(ARCHIVE_OK, archive_free(a));
+       free(p);
+}
+
+/*
+ * Synthesize a lot of varying inputs that are highly compressible.
+ */
+DEFINE_TEST(test_read_format_zip_high_compression2)
+{
+       const size_t body_size = 1024 * 1024;
+       const size_t buff_size = 2 * 1024 * 1024;
+       char *body, *body_read, *buff;
+       int n;
+
+       if (archive_zlib_version() == NULL) {
+               skipping("Zip compression test requires zlib");
+               return;
+       }
+
+       assert((body = malloc(body_size)) != NULL);
+       assert((body_read = malloc(body_size)) != NULL);
+       assert((buff = malloc(buff_size)) != NULL);
+
+       /* Highly-compressible data: all bytes 255, except for a
+        * single 1 byte.
+        * The body is always 256k + 6 bytes long (the internal deflation
+        * buffer is exactly 256k).
+        */
+
+       for(n = 1024; n < (int)body_size; n += 1024) {
+               struct archive *a;
+               struct archive_entry *entry;
+               size_t used = 0;
+               const void *pv;
+               size_t s;
+               int64_t o;
+
+               memset(body, 255, body_size);
+               body[n] = 1;
+
+               /* Write an archive with a single entry of n bytes. */
+               assert((a = archive_write_new()) != NULL);
+               assertEqualInt(ARCHIVE_OK, archive_write_set_format_zip(a));
+               assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, buff_size, &used));
+
+               entry = archive_entry_new2(a);
+               archive_entry_set_pathname(entry, "test");
+               archive_entry_set_filetype(entry, AE_IFREG);
+               archive_entry_set_size(entry, 262150);
+               assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
+               archive_entry_free(entry);
+               assertEqualInt(262150, archive_write_data(a, body, 262150));
+               assertEqualInt(ARCHIVE_OK, archive_write_free(a));
+
+               /* Read back the entry and verify the contents. */
+               assert((a = archive_read_new()) != NULL);
+               assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+               assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
+               assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, buff, used, 17));
+               assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
+
+               assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
+               assertEqualInt(262144, s);
+               assertEqualInt(0, o);
+
+               assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
+               assertEqualInt(6, s);
+               assertEqualInt(262144, o);
+
+               assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
+
+               assertEqualInt(ARCHIVE_OK, archive_free(a));
+       }
+
+       free(body);
+       free(body_read);
+       free(buff);
+}
diff --git a/libarchive/test/test_read_format_zip_high_compression.zip.uu b/libarchive/test/test_read_format_zip_high_compression.zip.uu
new file mode 100644 (file)
index 0000000..0942880
--- /dev/null
@@ -0,0 +1,18 @@
+begin 644 test_read_format_zip_high_compression.zip
+M4$L#!!0`"``(`*=Y]4@``````````*``!``(`"``8VAA<BYB:6Y55`T`!\L>
+MD5>>))%7GB215W5X"P`!!/8!```$%````.W=06K#,!`%T&E)P8LL?*2XC@N%
+M)#5QO>AM<K0<+2=0:!OBP>@9WDJ6!%\6$K/Q6T3LAX]N/GQ'Z9G&KA^*K1'S
+M.`[GOIM*[TP_Q_>O0[G_:3X.Y\^^V/X2<<GT&IM=$]OK?[71_LJ],3;1+*(T
+M_U)99\T+````````````````````````````````````````L`:E?]*S#FVT
+MJY:='SPB>_]DR\X?`("_R:X_U"Y[_:F;;Q``ZN+L!P"H3W;]$_5G`&!9V?</
+M````X/FRZP_9LO,'@`S9YR^0P_Z'NF7?/P``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+MJ%L3VVM-LO,&8/UN4$L'"!<='%^U`0``H``$`%!+`0(4`Q0`"``(`*=Y]4@7
+M'1Q?M0$``*``!``(`"````````````"D@0````!C:&%R+F)I;E54#0`'RQZ1
+M5YXDD5>>))%7=7@+``$$]@$```04````4$L%!@`````!``$`5@````L"````
+!````
+`
+end
index 9208833..fb5e004 100644 (file)
@@ -133,11 +133,12 @@ DEFINE_TEST(test_read_append_filter)
   assert((a = archive_read_new()) != NULL);
   assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR));
   r = archive_read_append_filter(a, ARCHIVE_FILTER_GZIP);
-  if (r == ARCHIVE_WARN && !canGzip()) {
-    skipping("gzip reading not fully supported on this platform");
+  if (r != ARCHIVE_OK && archive_zlib_version() == NULL && !canGzip()) {
+    skipping("gzip tests require zlib or working gzip command");
     assertEqualInt(ARCHIVE_OK, archive_read_free(a));
     return;
   }
+  assertEqualIntA(a, ARCHIVE_OK, r);
   assertEqualInt(ARCHIVE_OK,
       archive_read_open_memory(a, archive, sizeof(archive)));
   assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
@@ -200,14 +201,28 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
 {
   struct archive_entry *ae;
   struct archive *a;
+#if !defined(_WIN32) || defined(__CYGWIN__)
+  FILE * fp;
+  int fd;
+  fpos_t pos;
+#endif
 
   /*
    * If we have "bunzip2 -q", try using that.
    */
-  if (!canRunCommand("bunzip2 -V")) {
+  if (!canRunCommand("bunzip2 -h")) {
     skipping("Can't run bunzip2 program on this platform");
     return;
   }
+
+#if !defined(_WIN32) || defined(__CYGWIN__)
+  /* bunzip2 will write to stderr, redirect it to a file */
+  fflush(stderr);
+  fgetpos(stderr, &pos);
+  fd = dup(fileno(stderr));
+  fp = freopen("stderr1", "w", stderr); 
+#endif
+
   assert((a = archive_read_new()) != NULL);
   assertA(0 == archive_read_set_format(a, ARCHIVE_FORMAT_TAR));
   assertEqualIntA(a, ARCHIVE_OK,
@@ -217,4 +232,16 @@ DEFINE_TEST(test_read_append_filter_wrong_program)
   assertA(archive_read_next_header(a, &ae) < (ARCHIVE_WARN));
   assertEqualIntA(a, ARCHIVE_WARN, archive_read_close(a));
   assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+
+#if !defined(_WIN32) || defined(__CYGWIN__)
+  /* restore stderr and verify results */
+  if (fp != NULL) {
+    fflush(stderr);
+    dup2(fd, fileno(stderr));
+    close(fd);
+    clearerr(stderr);
+    fsetpos(stderr, &pos);
+  }
+  assertTextFileContents("bunzip2: (stdin) is not a bzip2 file.\n", "stderr1");
+#endif
 }
diff --git a/libarchive/test/test_write_disk_secure744.c b/libarchive/test/test_write_disk_secure744.c
new file mode 100644 (file)
index 0000000..08c725e
--- /dev/null
@@ -0,0 +1,95 @@
+/*-
+ * Copyright (c) 2003-2007,2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+#define UMASK 022
+
+/*
+ * Github Issue #744 describes a bug in the sandboxing code that
+ * causes very long pathnames to not get checked for symlinks.
+ */
+
+DEFINE_TEST(test_write_disk_secure744)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       skipping("archive_write_disk security checks not supported on Windows");
+#else
+       struct archive *a;
+       struct archive_entry *ae;
+       size_t buff_size = 8192;
+       char *buff = malloc(buff_size);
+       char *p = buff;
+       int n = 0;
+       int t;
+
+       assert(buff != NULL);
+
+       /* Start with a known umask. */
+       assertUmask(UMASK);
+
+       /* Create an archive_write_disk object. */
+       assert((a = archive_write_disk_new()) != NULL);
+       archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
+
+       while (p + 500 < buff + buff_size) {
+               memset(p, 'x', 100);
+               p += 100;
+               p[0] = '\0';
+
+               buff[0] = ((n / 1000) % 10) + '0';
+               buff[1] = ((n / 100) % 10)+ '0';
+               buff[2] = ((n / 10) % 10)+ '0';
+               buff[3] = ((n / 1) % 10)+ '0';
+               buff[4] = '_';
+               ++n;
+
+               /* Create a symlink pointing to the testworkdir */
+               assert((ae = archive_entry_new()) != NULL);
+               archive_entry_copy_pathname(ae, buff);
+               archive_entry_set_mode(ae, S_IFREG | 0777);
+               archive_entry_copy_symlink(ae, testworkdir);
+               assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+               archive_entry_free(ae);
+
+               *p++ = '/';
+               sprintf(p, "target%d", n);
+
+               /* Try to create a file through the symlink, should fail. */
+               assert((ae = archive_entry_new()) != NULL);
+               archive_entry_copy_pathname(ae, buff);
+               archive_entry_set_mode(ae, S_IFDIR | 0777);
+
+               t = archive_write_header(a, ae);
+               archive_entry_free(ae);
+               failure("Attempt to create target%d via %d-character symlink should have failed", n, (int)strlen(buff));
+               if(!assertEqualInt(ARCHIVE_FAILED, t)) {
+                       break;
+               }
+       }
+       archive_free(a);
+       free(buff);
+#endif
+}
diff --git a/libarchive/test/test_write_disk_secure745.c b/libarchive/test/test_write_disk_secure745.c
new file mode 100644 (file)
index 0000000..870b064
--- /dev/null
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2003-2007,2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+#define UMASK 022
+
+/*
+ * Github Issue #745 describes a bug in the sandboxing code that
+ * allows one to use a symlink to edit the permissions on a file or
+ * directory outside of the sandbox.
+ */
+
+DEFINE_TEST(test_write_disk_secure745)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       skipping("archive_write_disk security checks not supported on Windows");
+#else
+       struct archive *a;
+       struct archive_entry *ae;
+
+       /* Start with a known umask. */
+       assertUmask(UMASK);
+
+       /* Create an archive_write_disk object. */
+       assert((a = archive_write_disk_new()) != NULL);
+       archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
+
+       /* The target dir:  The one we're going to try to change permission on */
+       assertMakeDir("target", 0700);
+
+       /* The sandbox dir we're going to run inside of. */
+       assertMakeDir("sandbox", 0700);
+       assertChdir("sandbox");
+
+       /* Create a symlink pointing to the target directory */
+       assert((ae = archive_entry_new()) != NULL);
+       archive_entry_copy_pathname(ae, "sym");
+       archive_entry_set_mode(ae, AE_IFLNK | 0777);
+       archive_entry_copy_symlink(ae, "../target");
+       assert(0 == archive_write_header(a, ae));
+       archive_entry_free(ae);
+
+       /* Try to alter the target dir through the symlink; this should fail. */
+       assert((ae = archive_entry_new()) != NULL);
+       archive_entry_copy_pathname(ae, "sym");
+       archive_entry_set_mode(ae, S_IFDIR | 0777);
+       assert(0 == archive_write_header(a, ae));
+       archive_entry_free(ae);
+
+       /* Permission of target dir should not have changed. */
+       assertFileMode("../target", 0700);
+
+       assert(0 == archive_write_close(a));
+       archive_write_free(a);
+#endif
+}
diff --git a/libarchive/test/test_write_disk_secure746.c b/libarchive/test/test_write_disk_secure746.c
new file mode 100644 (file)
index 0000000..460aafe
--- /dev/null
@@ -0,0 +1,129 @@
+/*-
+ * Copyright (c) 2003-2007,2016 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+#define UMASK 022
+
+/*
+ * Github Issue #746 describes a problem in which hardlink targets are
+ * not adequately checked and can be used to modify entries outside of
+ * the sandbox.
+ */
+
+/*
+ * Verify that ARCHIVE_EXTRACT_SECURE_NODOTDOT disallows '..' in hardlink
+ * targets.
+ */
+DEFINE_TEST(test_write_disk_secure746a)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       skipping("archive_write_disk security checks not supported on Windows");
+#else
+       struct archive *a;
+       struct archive_entry *ae;
+
+       /* Start with a known umask. */
+       assertUmask(UMASK);
+
+       /* The target directory we're going to try to affect. */
+       assertMakeDir("target", 0700);
+       assertMakeFile("target/foo", 0700, "unmodified");
+
+       /* The sandbox dir we're going to work within. */
+       assertMakeDir("sandbox", 0700);
+       assertChdir("sandbox");
+
+       /* Create an archive_write_disk object. */
+       assert((a = archive_write_disk_new()) != NULL);
+       archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_NODOTDOT);
+
+       /* Attempt to hardlink to the target directory. */
+       assert((ae = archive_entry_new()) != NULL);
+       archive_entry_copy_pathname(ae, "bar");
+       archive_entry_set_mode(ae, AE_IFREG | 0777);
+       archive_entry_set_size(ae, 8);
+       archive_entry_copy_hardlink(ae, "../target/foo");
+       assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
+       assertEqualInt(ARCHIVE_FATAL, archive_write_data(a, "modified", 8));
+       archive_entry_free(ae);
+
+       /* Verify that target file contents are unchanged. */
+       assertTextFileContents("unmodified", "../target/foo");
+#endif
+}
+
+/*
+ * Verify that ARCHIVE_EXTRACT_SECURE_NOSYMLINK disallows symlinks in hardlink
+ * targets.
+ */
+DEFINE_TEST(test_write_disk_secure746b)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       skipping("archive_write_disk security checks not supported on Windows");
+#else
+       struct archive *a;
+       struct archive_entry *ae;
+
+       /* Start with a known umask. */
+       assertUmask(UMASK);
+
+       /* The target directory we're going to try to affect. */
+       assertMakeDir("target", 0700);
+       assertMakeFile("target/foo", 0700, "unmodified");
+
+       /* The sandbox dir we're going to work within. */
+       assertMakeDir("sandbox", 0700);
+       assertChdir("sandbox");
+
+       /* Create an archive_write_disk object. */
+       assert((a = archive_write_disk_new()) != NULL);
+       archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
+
+       /* Create a symlink to the target directory. */
+       assert((ae = archive_entry_new()) != NULL);
+       archive_entry_copy_pathname(ae, "symlink");
+       archive_entry_set_mode(ae, AE_IFLNK | 0777);
+       archive_entry_copy_symlink(ae, "../target");
+       assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+       archive_entry_free(ae);
+
+       /* Attempt to hardlink to the target directory via the symlink. */
+       assert((ae = archive_entry_new()) != NULL);
+       archive_entry_copy_pathname(ae, "bar");
+       archive_entry_set_mode(ae, AE_IFREG | 0777);
+       archive_entry_set_size(ae, 8);
+       archive_entry_copy_hardlink(ae, "symlink/foo");
+       assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae));
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_write_data(a, "modified", 8));
+       archive_entry_free(ae);
+
+       /* Verify that target file contents are unchanged. */
+       assertTextFileContents("unmodified", "../target/foo");
+
+       assertEqualIntA(a, ARCHIVE_FATAL, archive_write_close(a));
+       archive_write_free(a);
+#endif
+}
index 38b4ca9..655e998 100644 (file)
@@ -42,6 +42,7 @@ DEFINE_TEST(test_write_format_gnutar_filenames)
        struct archive_entry *ae, *template;
        struct archive *a;
        size_t used;
+       int i;
 
        buff = malloc(buffsize); /* million bytes of work area */
        assert(buff != NULL);
@@ -55,7 +56,7 @@ DEFINE_TEST(test_write_format_gnutar_filenames)
        archive_entry_set_mode(template, S_IFREG | 0755);
        archive_entry_set_size(template, 8);
 
-       for (int i = 0; i < 2000; ++i) {
+       for (i = 0; i < 2000; ++i) {
                filename[i] = 'a';
                filename[i + 1] = '\0';
                archive_entry_copy_pathname(template, filename);
@@ -97,6 +98,11 @@ DEFINE_TEST(test_write_format_gnutar_linknames)
        struct archive_entry *ae, *template;
        struct archive *a;
        size_t used;
+       int i;
+
+#ifdef S_IFLNK
+       assertEqualInt(S_IFLNK, AE_IFLNK);
+#endif
 
        buff = malloc(buffsize); /* million bytes of work area */
        assert(buff != NULL);
@@ -107,10 +113,10 @@ DEFINE_TEST(test_write_format_gnutar_linknames)
        archive_entry_set_birthtime(template, 3, 30);
        archive_entry_set_ctime(template, 4, 40);
        archive_entry_set_mtime(template, 5, 50);
-       archive_entry_set_mode(template, S_IFLNK | 0755);
+       archive_entry_set_mode(template, AE_IFLNK | 0755);
        archive_entry_copy_pathname(template, "link");
 
-       for (int i = 0; i < 2000; ++i) {
+       for (i = 0; i < 2000; ++i) {
                filename[i] = 'a';
                filename[i + 1] = '\0';
                archive_entry_copy_symlink(template, filename);
index 1ea69a1..ee6db6f 100644 (file)
@@ -117,8 +117,8 @@ DEFINE_TEST(test_write_format_iso9660)
         */
        dirname[0] = '\0';
        strcpy(dir, "/dir0");
-       for (i = 0; i < 10; i++) {
-               dir[4] = '0' + i;
+       for (i = 0; i < 13; i++) {
+               dir[4] = "0123456789ABCDEF"[i];
                if (i == 0)
                        strcat(dirname, dir+1);
                else
@@ -134,6 +134,19 @@ DEFINE_TEST(test_write_format_iso9660)
                archive_entry_free(ae);
        }
 
+       strcat(dirname, "/file");
+       assert((ae = archive_entry_new()) != NULL);
+       archive_entry_set_atime(ae, 2, 20);
+       archive_entry_set_birthtime(ae, 3, 30);
+       archive_entry_set_ctime(ae, 4, 40);
+       archive_entry_set_mtime(ae, 5, 50);
+       archive_entry_copy_pathname(ae, dirname);
+       archive_entry_set_mode(ae, S_IFREG | 0755);
+       archive_entry_set_size(ae, 8);
+       assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+       archive_entry_free(ae);
+       assertEqualIntA(a, 8, archive_write_data(a, "12345678", 9));
+
        /*
         * "dir0/dir1/file1" has 8 bytes of data.
         */
@@ -333,6 +346,45 @@ DEFINE_TEST(test_write_format_iso9660)
        assertEqualInt(2048, archive_entry_size(ae));
 
        /*
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(2, archive_entry_atime(ae));
+       assertEqualInt(3, archive_entry_birthtime(ae));
+       assertEqualInt(4, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0555) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(2, archive_entry_atime(ae));
+       assertEqualInt(3, archive_entry_birthtime(ae));
+       assertEqualInt(4, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0555) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(2, archive_entry_atime(ae));
+       assertEqualInt(3, archive_entry_birthtime(ae));
+       assertEqualInt(4, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0555) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
         * Read "hardlnk"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
@@ -386,6 +438,21 @@ DEFINE_TEST(test_write_format_iso9660)
        assertEqualMem(buff2, "12345678", 8);
 
        /*
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(2, archive_entry_atime(ae));
+       assertEqualInt(3, archive_entry_birthtime(ae));
+       assertEqualInt(4, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file", archive_entry_pathname(ae));
+       assert((AE_IFREG | 0555) == archive_entry_mode(ae));
+       assertEqualInt(1, archive_entry_nlink(ae));
+       assertEqualInt(8, archive_entry_size(ae));
+       assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+       assertEqualMem(buff2, "12345678", 8);
+
+       /*
         * Read "dir0/dir1/file1"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
@@ -580,29 +647,65 @@ DEFINE_TEST(test_write_format_iso9660)
        assertEqualInt(2048, archive_entry_size(ae));
 
        /*
-        * Read "hardlnk"
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
        assertEqualInt(5, archive_entry_atime(ae));
        assertEqualInt(5, archive_entry_ctime(ae));
        assertEqualInt(5, archive_entry_mtime(ae));
-       assertEqualString("hardlnk", archive_entry_pathname(ae));
+       assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0700) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0700) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0700) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
+        * Read "file"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("file", archive_entry_pathname(ae));
        assert((AE_IFREG | 0400) == archive_entry_mode(ae));
-       assertEqualInt(2, archive_entry_nlink(ae));
        assertEqualInt(8, archive_entry_size(ae));
        assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
        assertEqualMem(buff2, "12345678", 8);
 
        /*
-        * Read "file"
+        * Read "hardlnk"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
        assertEqualInt(5, archive_entry_atime(ae));
        assertEqualInt(5, archive_entry_ctime(ae));
        assertEqualInt(5, archive_entry_mtime(ae));
-       assertEqualString("file", archive_entry_pathname(ae));
-       assertEqualString("hardlnk", archive_entry_hardlink(ae));
+       assertEqualString("hardlnk", archive_entry_pathname(ae));
+       assertEqualString("file", archive_entry_hardlink(ae));
        assert((AE_IFREG | 0400) == archive_entry_mode(ae));
+       assertEqualInt(2, archive_entry_nlink(ae));
        assertEqualInt(0, archive_entry_size(ae));
        assertEqualIntA(a, 0, archive_read_data(a, buff2, 10));
 
@@ -625,6 +728,22 @@ DEFINE_TEST(test_write_format_iso9660)
        assertEqualMem(buff2, "12345678", 8);
 
        /*
+        * Read "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString(
+               "dir0/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dirA/dirB/dirC/file",
+               archive_entry_pathname(ae));
+       assert((AE_IFREG | 0400) == archive_entry_mode(ae));
+       assertEqualInt(1, archive_entry_nlink(ae));
+       assertEqualInt(8, archive_entry_size(ae));
+       assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+       assertEqualMem(buff2, "12345678", 8);
+
+       /*
         * Read "dir0/dir1/file1"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
@@ -746,6 +865,42 @@ DEFINE_TEST(test_write_format_iso9660)
        assertEqualInt(2048, archive_entry_size(ae));
 
        /*
+        * Read "rr_moved/dir7/dir8/dir9/dira"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("RR_MOVED/DIR7/DIR8/DIR9/DIRA",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0700) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
+        * Read "rr_moved/dir7/dir8/dir9/dira/dirB"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("RR_MOVED/DIR7/DIR8/DIR9/DIRA/DIRB",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0700) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
+        * Read "rr_moved/dir7/dir8/dir9/dirA/dirB/dirC"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString("RR_MOVED/DIR7/DIR8/DIR9/DIRA/DIRB/DIRC",
+           archive_entry_pathname(ae));
+       assert((S_IFDIR | 0700) == archive_entry_mode(ae));
+       assertEqualInt(2048, archive_entry_size(ae));
+
+       /*
         * Read "dir0"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
@@ -827,33 +982,35 @@ DEFINE_TEST(test_write_format_iso9660)
        assertEqualInt(2048, archive_entry_size(ae));
 
        /*
-        * Read "file"
+        * Read "hardlink"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
        assertEqualInt(5, archive_entry_atime(ae));
-       assertEqualInt(0, archive_entry_birthtime(ae));
        assertEqualInt(5, archive_entry_ctime(ae));
        assertEqualInt(5, archive_entry_mtime(ae));
-       assertEqualString("FILE", archive_entry_pathname(ae));
+       assertEqualString("HARDLNK", archive_entry_pathname(ae));
+       assertEqualString(NULL, archive_entry_hardlink(ae));
        assert((AE_IFREG | 0400) == archive_entry_mode(ae));
-       assertEqualInt(2, archive_entry_nlink(ae));
        assertEqualInt(8, archive_entry_size(ae));
        assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
        assertEqualMem(buff2, "12345678", 8);
 
        /*
-        * Read "hardlink"
+        * Read "file"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
        assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(0, archive_entry_birthtime(ae));
        assertEqualInt(5, archive_entry_ctime(ae));
        assertEqualInt(5, archive_entry_mtime(ae));
-       assertEqualString("HARDLNK", archive_entry_pathname(ae));
-       assertEqualString("FILE", archive_entry_hardlink(ae));
+       assertEqualString("FILE", archive_entry_pathname(ae));
+       assertEqualString("HARDLNK", archive_entry_hardlink(ae));
        assert((AE_IFREG | 0400) == archive_entry_mode(ae));
+       assertEqualInt(2, archive_entry_nlink(ae));
        assertEqualInt(0, archive_entry_size(ae));
        assertEqualIntA(a, 0, archive_read_data(a, buff2, 10));
 
+
        /*
         * Read longname
         */
@@ -871,6 +1028,22 @@ DEFINE_TEST(test_write_format_iso9660)
        assertEqualMem(buff2, "12345678", 8);
 
        /*
+        * Read "rr_moved/dir7/dir8/dir9/dirA/dirB/dirC/file"
+        */
+       assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+       assertEqualInt(5, archive_entry_atime(ae));
+       assertEqualInt(5, archive_entry_ctime(ae));
+       assertEqualInt(5, archive_entry_mtime(ae));
+       assertEqualString(
+               "RR_MOVED/DIR7/DIR8/DIR9/DIRA/DIRB/DIRC/FILE",
+               archive_entry_pathname(ae));
+       assert((AE_IFREG | 0400) == archive_entry_mode(ae));
+       assertEqualInt(1, archive_entry_nlink(ae));
+       assertEqualInt(8, archive_entry_size(ae));
+       assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+       assertEqualMem(buff2, "12345678", 8);
+
+       /*
         * Read "dir0/dir1/file1"
         */
        assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
index 1eae0b8..8c38ad7 100644 (file)
@@ -121,16 +121,21 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
 
 #else /* _WIN32 && !__CYGWIN__ */
 
-#include <termios.h>
-#include <signal.h>
+#include <assert.h>
 #include <ctype.h>
 #include <fcntl.h>
 #ifdef HAVE_PATHS_H
 #include <paths.h>
 #endif
+#include <signal.h>
 #include <string.h>
+#include <termios.h>
 #include <unistd.h>
 
+#ifndef _PATH_TTY
+#define _PATH_TTY "/dev/tty"
+#endif
+
 #ifdef TCSASOFT
 # define _T_FLUSH      (TCSAFLUSH|TCSASOFT)
 #else
@@ -142,11 +147,18 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
 #  define _POSIX_VDISABLE       VDISABLE
 #endif
 
-static volatile sig_atomic_t *signo;
+#define M(a,b) (a > b ? a : b)
+#define MAX_SIGNO M(M(M(SIGALRM, SIGHUP), \
+                      M(SIGINT, SIGPIPE)), \
+                    M(M(SIGQUIT, SIGTERM), \
+                      M(M(SIGTSTP, SIGTTIN), SIGTTOU)))
+
+static volatile sig_atomic_t signo[MAX_SIGNO + 1];
 
 static void
 handler(int s)
 {
+       assert(s <= MAX_SIGNO);
        signo[s] = 1;
 }
 
@@ -166,12 +178,8 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
                return(NULL);
        }
 
-       if (signo == NULL) {
-               signo = calloc(SIGRTMAX, sizeof(sig_atomic_t));
-       }
-
 restart:
-       for (i = 0; i < SIGRTMAX; i++)
+       for (i = 0; i <= MAX_SIGNO; i++)
                signo[i] = 0;
        nr = -1;
        save_errno = 0;
@@ -198,6 +206,7 @@ restart:
        sigemptyset(&sa.sa_mask);
        sa.sa_flags = 0;                /* don't restart system calls */
        sa.sa_handler = handler;
+       /* Keep this list in sync with MAX_SIGNO! */
        (void)sigaction(SIGALRM, &sa, &savealrm);
        (void)sigaction(SIGHUP, &sa, &savehup);
        (void)sigaction(SIGINT, &sa, &saveint);
@@ -237,11 +246,11 @@ restart:
                        if (p < end) {
                                if ((flags & RPP_SEVENBIT))
                                        ch &= 0x7f;
-                               if (isalpha(ch)) {
+                               if (isalpha((unsigned char)ch)) {
                                        if ((flags & RPP_FORCELOWER))
-                                               ch = (char)tolower(ch);
+                                               ch = (char)tolower((unsigned char)ch);
                                        if ((flags & RPP_FORCEUPPER))
-                                               ch = (char)toupper(ch);
+                                               ch = (char)toupper((unsigned char)ch);
                                }
                                *p++ = ch;
                        }
@@ -276,7 +285,7 @@ restart:
         * If we were interrupted by a signal, resend it to ourselves
         * now that we have restored the signal handlers.
         */
-       for (i = 0; i < SIGRTMAX; i++) {
+       for (i = 0; i <= MAX_SIGNO; i++) {
                if (signo[i]) {
                        kill(getpid(), i);
                        switch (i) {
index fd0712a..c87741c 100644 (file)
@@ -68,6 +68,7 @@ static const struct bsdtar_option {
        { "auto-compress",        0, 'a' },
        { "b64encode",            0, OPTION_B64ENCODE },
        { "block-size",           1, 'b' },
+       { "blocking-factor",      1, 'b' },
        { "bunzip2",              0, 'j' },
        { "bzip",                 0, 'j' },
        { "bzip2",                0, 'j' },
index 4710e06..39c54ac 100644 (file)
@@ -84,6 +84,7 @@ add_substitution(struct bsdtar *bsdtar, const char *rule_text)
        if (rule == NULL)
                lafe_errc(1, errno, "Out of memory");
        rule->next = NULL;
+       rule->result = NULL;
 
        if (subst->last_rule == NULL)
                subst->first_rule = rule;
index f19a5f6..0d2da36 100644 (file)
@@ -100,7 +100,8 @@ IF(ENABLE_TAR AND ENABLE_TEST)
   # Experimental new test handling
   ADD_CUSTOM_TARGET(run_bsdtar_test
        COMMAND bsdtar_test -p $<TARGET_FILE:bsdtar>
-                           -r ${CMAKE_CURRENT_SOURCE_DIR})
+                           -r ${CMAKE_CURRENT_SOURCE_DIR}
+                           -vv)
   ADD_DEPENDENCIES(run_bsdtar_test bsdtar)
   ADD_DEPENDENCIES(run_all_tests run_bsdtar_test)
 
index 08ac627..d35d335 100644 (file)
@@ -130,6 +130,13 @@ __FBSDID("$FreeBSD: src/usr.bin/tar/test/main.c,v 1.6 2008/11/05 06:40:53 kientz
 # include <crtdbg.h>
 #endif
 
+mode_t umasked(mode_t expected_mode)
+{
+       mode_t mode = umask(0);
+       umask(mode);
+       return expected_mode & ~mode;
+}
+
 /* Path to working directory for current test */
 const char *testworkdir;
 #ifdef PROGRAM
@@ -1157,6 +1164,35 @@ assertion_file_contains_lines_any_order(const char *file, int line,
        return (0);
 }
 
+/* Verify that a text file does not contains the specified strings */
+int
+assertion_file_contains_no_invalid_strings(const char *file, int line,
+    const char *pathname, const char *strings[])
+{
+       char *buff;
+       int i;
+
+       buff = slurpfile(NULL, "%s", pathname);
+       if (buff == NULL) {
+               failure_start(file, line, "Can't read file: %s", pathname);
+               failure_finish(NULL);
+               return (0);
+       }
+
+       for (i = 0; strings[i] != NULL; ++i) {
+               if (strstr(buff, strings[i]) != NULL) {
+                       failure_start(file, line, "Invalid string in %s: %s", pathname,
+                           strings[i]);
+                       failure_finish(NULL);
+                       free(buff);
+                       return(0);
+               }
+       }
+
+       free(buff);
+       return (0);
+}
+
 /* Test that two paths point to the same file. */
 /* As a side-effect, asserts that both files exist. */
 static int
@@ -1294,6 +1330,11 @@ assertion_file_time(const char *file, int line,
        switch (type) {
        case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
        case 'b': filet = st.st_birthtime;
+               /* FreeBSD filesystems that don't support birthtime
+                * (e.g., UFS1) always return -1 here. */
+               if (filet == -1) {
+                       return (1);
+               }
                filet_nsec = st.st_birthtimespec.tv_nsec; break;
        case 'm': filet_nsec = st.st_mtimespec.tv_nsec; break;
        default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
@@ -1361,6 +1402,33 @@ assertion_file_birthtime_recent(const char *file, int line,
        return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
 }
 
+/* Verify mode of 'pathname'. */
+int
+assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
+{
+       int mode;
+       int r;
+
+       assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       failure_start(file, line, "assertFileMode not yet implemented for Windows");
+       (void)mode; /* UNUSED */
+       (void)r; /* UNUSED */
+#else
+       {
+               struct stat st;
+               r = lstat(pathname, &st);
+               mode = (int)(st.st_mode & 0777);
+       }
+       if (r == 0 && mode == expected_mode)
+                       return (1);
+       failure_start(file, line, "File %s has mode %o, expected %o",
+           pathname, mode, expected_mode);
+#endif
+       failure_finish(NULL);
+       return (0);
+}
+
 /* Verify mtime of 'pathname'. */
 int
 assertion_file_mtime(const char *file, int line,
@@ -1400,7 +1468,7 @@ assertion_file_nlinks(const char *file, int line,
        assertion_count(file, line);
        r = lstat(pathname, &st);
        if (r == 0 && (int)st.st_nlink == nlinks)
-                       return (1);
+               return (1);
        failure_start(file, line, "File %s has %d links, expected %d",
            pathname, st.st_nlink, nlinks);
        failure_finish(NULL);
@@ -1579,8 +1647,12 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
        if (0 == _mkdir(dirname))
                return (1);
 #else
-       if (0 == mkdir(dirname, mode))
-               return (1);
+       if (0 == mkdir(dirname, mode)) {
+               if (0 == chmod(dirname, mode)) {
+                       assertion_file_mode(file, line, dirname, mode);
+                       return (1);
+               }
+       }
 #endif
        failure_start(file, line, "Could not create directory %s", dirname);
        failure_finish(NULL);
@@ -1629,6 +1701,12 @@ assertion_make_file(const char *file, int line,
                failure_finish(NULL);
                return (0);
        }
+       if (0 != chmod(path, mode)) {
+               failure_start(file, line, "Could not chmod %s", path);
+               failure_finish(NULL);
+               close(fd);
+               return (0);
+       }
        if (contents != NULL) {
                ssize_t wsize;
 
@@ -1641,10 +1719,12 @@ assertion_make_file(const char *file, int line,
                        failure_start(file, line,
                            "Could not write to %s", path);
                        failure_finish(NULL);
+                       close(fd);
                        return (0);
                }
        }
        close(fd);
+       assertion_file_mode(file, line, path, mode);
        return (1);
 #endif
 }
index 704a137..3a23a05 100644 (file)
 /* Assert that file contents match a string. */
 #define assertFileContents(data, data_size, pathname) \
   assertion_file_contents(__FILE__, __LINE__, data, data_size, pathname)
+/* Verify that a file does not contain invalid strings */
+#define assertFileContainsNoInvalidStrings(pathname, strings) \
+  assertion_file_contains_no_invalid_strings(__FILE__, __LINE__, pathname, strings)
 #define assertFileMtime(pathname, sec, nsec)   \
   assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
 #define assertFileMtimeRecent(pathname) \
   assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
 #define assertFileSize(pathname, size)  \
   assertion_file_size(__FILE__, __LINE__, pathname, size)
+#define assertFileMode(pathname, mode)  \
+  assertion_file_mode(__FILE__, __LINE__, pathname, mode)
 #define assertTextFileContents(text, pathname) \
   assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
 #define assertFileContainsLinesAnyOrder(pathname, lines)       \
@@ -239,8 +244,10 @@ int assertion_file_atime_recent(const char *, int, const char *);
 int assertion_file_birthtime(const char *, int, const char *, long, long);
 int assertion_file_birthtime_recent(const char *, int, const char *);
 int assertion_file_contains_lines_any_order(const char *, int, const char *, const char **);
+int assertion_file_contains_no_invalid_strings(const char *, int, const char *, const char **);
 int assertion_file_contents(const char *, int, const void *, int, const char *);
 int assertion_file_exists(const char *, int, const char *);
+int assertion_file_mode(const char *, int, const char *, int);
 int assertion_file_mtime(const char *, int, const char *, long, long);
 int assertion_file_mtime_recent(const char *, int, const char *);
 int assertion_file_nlinks(const char *, int, const char *, int);
@@ -326,6 +333,9 @@ void copy_reference_file(const char *);
  */
 void extract_reference_files(const char **);
 
+/* Subtract umask from mode */
+mode_t umasked(mode_t expected_mode);
+
 /* Path to working directory for current test */
 extern const char *testworkdir;
 
index e2e5da5..808e384 100644 (file)
@@ -27,11 +27,15 @@ __FBSDID("$FreeBSD$");
 
 DEFINE_TEST(test_missing_file)
 {
+       const char * invalid_stderr[] = { "INTERNAL ERROR", NULL };
        assertMakeFile("file1", 0644, "file1");
        assertMakeFile("file2", 0644, "file2");
        assert(0 == systemf("%s -cf archive.tar file1 file2 2>stderr1", testprog));
        assertEmptyFile("stderr1");
        assert(0 != systemf("%s -cf archive.tar file1 file2 file3 2>stderr2", testprog));
+       assertFileContainsNoInvalidStrings("stderr2", invalid_stderr);
        assert(0 != systemf("%s -cf archive.tar 2>stderr3", testprog));
-       assert(0 != systemf("%s -cf archive.tar file3 2>stderr4", testprog));
+       assertFileContainsNoInvalidStrings("stderr3", invalid_stderr);
+       assert(0 != systemf("%s -cf archive.tar file3 file4 2>stderr4", testprog));
+       assertFileContainsNoInvalidStrings("stderr4", invalid_stderr);
 }
index 7ddd917..adc294b 100644 (file)
@@ -83,10 +83,10 @@ DEFINE_TEST(test_option_H_upper)
        assertChdir("test3");
        assertEqualInt(0,
            systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
-       assertIsDir("ld1", 0755);
+       assertIsDir("ld1", umasked(0755));
        assertIsSymlink("d1/linkX", "fileX");
        assertIsSymlink("d1/link1", "file1");
-       assertIsReg("link2", 0644);
+       assertIsReg("link2", umasked(0644));
        assertIsSymlink("linkY", "d1/fileY");
        assertChdir("..");
 }
index 57abe41..f5a3c5a 100644 (file)
@@ -69,10 +69,10 @@ DEFINE_TEST(test_option_L_upper)
        assertChdir("test2");
        assertEqualInt(0,
            systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
-       assertIsDir("ld1", 0755);
-       assertIsReg("d1/link1", 0644);
+       assertIsDir("ld1", umasked(0755));
+       assertIsReg("d1/link1", umasked(0644));
        assertIsSymlink("d1/linkX", "fileX");
-       assertIsReg("link2", 0644);
+       assertIsReg("link2", umasked(0644));
        assertIsSymlink("linkY", "d1/fileY");
        assertChdir("..");
 
@@ -83,10 +83,10 @@ DEFINE_TEST(test_option_L_upper)
        assertChdir("test3");
        assertEqualInt(0,
            systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
-       assertIsDir("ld1", 0755);
-       assertIsReg("d1/link1", 0644);
+       assertIsDir("ld1", umasked(0755));
+       assertIsReg("d1/link1", umasked(0644));
        assertIsSymlink("d1/linkX", "fileX");
-       assertIsReg("link2", 0644);
+       assertIsReg("link2", umasked(0644));
        assertIsSymlink("linkY", "d1/fileY");
        assertChdir("..");
 }
index 4d77cb0..2c43e00 100644 (file)
@@ -135,7 +135,7 @@ DEFINE_TEST(test_option_U_upper)
        assertMakeSymlink("d1/file1", "d1/realfile1");
        assertEqualInt(0,
            systemf("%s -xf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
-       assertIsReg("d1/file1", 0644);
+       assertIsReg("d1/file1", umasked(0644));
        assertFileContents("d1/file1", 8, "d1/file1");
        assertFileContents("realfile1", 9, "d1/realfile1");
        assertEmptyFile("test.out");
@@ -150,7 +150,7 @@ DEFINE_TEST(test_option_U_upper)
        assertMakeSymlink("d1/file1", "d1/realfile1");
        assertEqualInt(0,
            systemf("%s -xPUf ../archive.tar d1/file1 >test.out 2>test.err", testprog));
-       assertIsReg("d1/file1", 0644);
+       assertIsReg("d1/file1", umasked(0644));
        assertFileContents("d1/file1", 8, "d1/file1");
        assertFileContents("realfile1", 9, "d1/realfile1");
        assertEmptyFile("test.out");
index 81f50be..7c2f604 100644 (file)
@@ -33,7 +33,7 @@ DEFINE_TEST(test_option_b)
 
        assertMakeFile("file1", 0644, "file1");
        if (systemf("cat file1 > test_cat.out 2> test_cat.err") != 0) {
-               skipping("Platform doesn't have cat");
+               skipping("This test requires a `cat` program");
                return;
        }
        testprog_ustar = malloc(strlen(testprog) + sizeof(USTAR_OPT) + 1);
index 4017dd9..18ab614 100644 (file)
@@ -55,7 +55,7 @@ DEFINE_TEST(test_option_n)
            systemf("%s -xf archive.tar >x.out 2>x.err", testprog));
        assertEmptyFile("x.out");
        assertEmptyFile("x.err");
-       assertIsDir("d1", 0755);
+       assertIsDir("d1", umasked(0755));
        assertFileNotExists("d1/file1");
        assertChdir("..");
 }
index f6e9966..25bd8b1 100644 (file)
@@ -63,7 +63,7 @@ DEFINE_TEST(test_symlink_dir)
                /* "dir2" is a symlink to a non-existing "real_dir2" */
                assertMakeSymlink("dest1/dir2", "real_dir2");
        } else {
-               skipping("some symlink checks");
+               skipping("Symlinks are not supported on this platform");
        }
        /* "dir3" is a symlink to an existing "non_dir3" */
        assertMakeFile("dest1/non_dir3", 0755, "abcdef");
index 5474261..04d9e6c 100644 (file)
@@ -88,7 +88,7 @@ DEFINE_TEST(test_version)
        if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
                ++q;
        /* Skip arbitrary third-party version numbers. */
-       while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
+       while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
                ++q;
                --s;
        }
index 9ff22f2..2b4aebe 100644 (file)
@@ -182,7 +182,7 @@ safe_fprintf(FILE *f, const char *fmt, ...)
                }
 
                /* If our output buffer is full, dump it and keep going. */
-               if (i > (sizeof(outbuff) - 20)) {
+               if (i > (sizeof(outbuff) - 128)) {
                        outbuff[i] = '\0';
                        fprintf(f, "%s", outbuff);
                        i = 0;
index 2d076f4..da5a128 100644 (file)
@@ -886,6 +886,8 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
                            "%s", archive_error_string(disk));
                        if (r == ARCHIVE_FATAL || r == ARCHIVE_FAILED) {
                                bsdtar->return_value = 1;
+                               archive_entry_free(entry);
+                               archive_read_close(disk);
                                return;
                        } else if (r < ARCHIVE_WARN)
                                continue;