summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/libarchive
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libarchive/files/libarchive')
-rw-r--r--archivers/libarchive/files/libarchive/CMakeLists.txt139
-rw-r--r--archivers/libarchive/files/libarchive/archive.h241
-rw-r--r--archivers/libarchive/files/libarchive/archive_check_magic.c26
-rw-r--r--archivers/libarchive/files/libarchive/archive_endian.h24
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.c491
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry.h83
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry_copy_bhfi.c74
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry_copy_stat.c20
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry_link_resolver.c22
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry_private.h21
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry_stat.c22
-rw-r--r--archivers/libarchive/files/libarchive/archive_entry_xattr.c158
-rw-r--r--archivers/libarchive/files/libarchive/archive_hash.h196
-rw-r--r--archivers/libarchive/files/libarchive/archive_platform.h57
-rw-r--r--archivers/libarchive/files/libarchive/archive_private.h41
-rw-r--r--archivers/libarchive/files/libarchive/archive_read.3123
-rw-r--r--archivers/libarchive/files/libarchive/archive_read.c840
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_disk.3308
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_disk.c198
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_disk_entry_from_file.c563
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_disk_private.h62
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_disk_set_standard_lookup.c272
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_open_fd.c71
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_open_file.c52
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_open_filename.c171
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_private.h158
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_all.c27
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c479
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c257
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c698
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_none.c340
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_program.c518
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_rpm.c287
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_uu.c627
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_compression_xz.c708
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_all.c3
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_ar.c81
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_cpio.c168
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_empty.c11
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c2584
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c102
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_raw.c185
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_tar.c189
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_xar.c3150
-rw-r--r--archivers/libarchive/files/libarchive/archive_read_support_format_zip.c214
-rw-r--r--archivers/libarchive/files/libarchive/archive_string.c334
-rw-r--r--archivers/libarchive/files/libarchive/archive_string.h23
-rw-r--r--archivers/libarchive/files/libarchive/archive_string_sprintf.c38
-rw-r--r--archivers/libarchive/files/libarchive/archive_util.311
-rw-r--r--archivers/libarchive/files/libarchive/archive_util.c232
-rw-r--r--archivers/libarchive/files/libarchive/archive_virtual.c21
-rw-r--r--archivers/libarchive/files/libarchive/archive_windows.c1310
-rw-r--r--archivers/libarchive/files/libarchive/archive_windows.h396
-rw-r--r--archivers/libarchive/files/libarchive/archive_write.385
-rw-r--r--archivers/libarchive/files/libarchive/archive_write.c118
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_disk.36
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_disk.c731
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_disk_private.h6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_disk_set_standard_lookup.c68
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_open_fd.c11
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_open_filename.c49
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_private.h13
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c208
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c255
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_compression_none.c6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_compression_program.c8
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_compression_xz.c438
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format.c4
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_ar.c7
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_by_name.c6
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c111
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c46
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_mtree.c1050
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_pax.c97
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_shar.c448
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c11
-rw-r--r--archivers/libarchive/files/libarchive/archive_write_set_format_zip.c667
-rw-r--r--archivers/libarchive/files/libarchive/config_freebsd.h44
-rw-r--r--archivers/libarchive/files/libarchive/filter_fork.c16
-rw-r--r--archivers/libarchive/files/libarchive/filter_fork.h6
-rw-r--r--archivers/libarchive/files/libarchive/filter_fork_windows.c113
-rw-r--r--archivers/libarchive/files/libarchive/libarchive-formats.5133
-rw-r--r--archivers/libarchive/files/libarchive/tar.5153
-rw-r--r--archivers/libarchive/files/libarchive/test/CMakeLists.txt158
-rw-r--r--archivers/libarchive/files/libarchive/test/README63
-rw-r--r--archivers/libarchive/files/libarchive/test/list.h51
-rw-r--r--archivers/libarchive/files/libarchive/test/main.c2110
-rw-r--r--archivers/libarchive/files/libarchive/test/read_open_memory.c53
-rw-r--r--archivers/libarchive/files/libarchive/test/test.h237
-rw-r--r--archivers/libarchive/files/libarchive/test/test_acl_basic.c13
-rw-r--r--archivers/libarchive/files/libarchive/test/test_acl_freebsd.c255
-rw-r--r--archivers/libarchive/files/libarchive/test/test_acl_pax.c42
-rw-r--r--archivers/libarchive/files/libarchive/test/test_bad_fd.c8
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_bzip2.c85
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_bzip2_1.tbz.uu24
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_bzip2_2.tbz.uu11
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_cpio.c106
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_cpio_1.cpio.uu19
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_gtar.c25
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_gtar_1.tar.uu232
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_gzip.c97
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_gzip_1.tgz.uu24
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_gzip_2.tgz.uu11
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_lzma.c155
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_lzma_1.tlz.uu10
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_lzma_2.tlz.uu9
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_lzma_3.tlz.uu9
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.c128
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.tar.uu61
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c6
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_xz.c84
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_xz_1.txz.uu13
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_zip.c23
-rw-r--r--archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu1
-rw-r--r--archivers/libarchive/files/libarchive/test/test_empty_write.c87
-rw-r--r--archivers/libarchive/files/libarchive/test/test_entry.c213
-rw-r--r--archivers/libarchive/files/libarchive/test/test_entry_strmode.c33
-rw-r--r--archivers/libarchive/files/libarchive/test/test_extattr_freebsd.c172
-rw-r--r--archivers/libarchive/files/libarchive/test/test_fuzz.c166
-rw-r--r--archivers/libarchive/files/libarchive/test/test_fuzz_1.iso.Z.uu495
-rw-r--r--archivers/libarchive/files/libarchive/test/test_open_fd.c128
-rw-r--r--archivers/libarchive/files/libarchive/test/test_open_file.c108
-rw-r--r--archivers/libarchive/files/libarchive/test/test_open_filename.c109
-rw-r--r--archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c52
-rw-r--r--archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.uu118
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_compress_program.c61
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_data_large.c44
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_disk.c172
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_disk_entry_from_file.c80
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_extract.c103
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_file_nonexistent.c37
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_ar.ar.uu12
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_ar.c44
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c8
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c30
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.c55
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.cpio.uu8
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c24
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c34
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_lzma.c60
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_xz.c70
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c8
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c127
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu47
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c33
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c127
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu46
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c28
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_empty.c14
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c32
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_lzma.c78
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c43
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu1370
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu1370
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu1597
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu1370
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu1370
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu1
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso.iso.Z.uu26
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c57
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet.iso.Z.uu66
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu71
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu68
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.c94
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu67
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge.iso.Z.uu206
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu63
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu208
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu304
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_iso_zisofs.iso.Z.uu63
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_bz2.c134
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_long.c141
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_rr.c159
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c212
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isorr_ce.c223
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isorr_new_bz2.c204
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isorr_rr_moved.c270
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_isozisofs_bz2.c187
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_mtree.c98
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_mtree.mtree.uu13
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c30
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_raw.c89
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_raw.data.Z.uu5
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_raw.data.uu5
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tar.c33
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c8
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu1
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tbz.c30
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tgz.c32
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tlz.c60
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_txz.c63
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_tz.c27
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_xar.c697
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_zip.c36
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu23
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_large.c41
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c89
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_position.c71
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_truncated.c24
-rw-r--r--archivers/libarchive/files/libarchive/test/test_read_uu.c134
-rw-r--r--archivers/libarchive/files/libarchive/test/test_tar_filenames.c20
-rw-r--r--archivers/libarchive/files/libarchive/test/test_tar_large.c64
-rw-r--r--archivers/libarchive/files/libarchive/test/test_ustar_filenames.c18
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_compress.c20
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_compress_bzip2.c228
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_compress_gzip.c252
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_compress_lzma.c245
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_compress_program.c67
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_compress_xz.c253
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk.c196
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_failures.c72
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c158
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_perms.c20
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_secure.c86
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_sparse.c280
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_symlink.c117
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_disk_times.c167
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_ar.c108
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_cpio.c47
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c10
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c21
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c37
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_mtree.c155
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_pax.c146
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c8
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_tar.c18
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c20
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c11
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_zip.c180
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_zip_empty.c56
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_format_zip_no_compression.c304
-rw-r--r--archivers/libarchive/files/libarchive/test/test_write_open_memory.c10
233 files changed, 38911 insertions, 5568 deletions
diff --git a/archivers/libarchive/files/libarchive/CMakeLists.txt b/archivers/libarchive/files/libarchive/CMakeLists.txt
new file mode 100644
index 00000000000..459a5ddbb90
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/CMakeLists.txt
@@ -0,0 +1,139 @@
+
+############################################
+#
+# How to build libarchive
+#
+############################################
+
+# Public headers
+SET(include_HEADERS
+ archive.h
+ archive_entry.h
+)
+
+# Sources and private headers
+SET(libarchive_SOURCES
+ archive_check_magic.c
+ archive_endian.h
+ archive_entry.c
+ archive_entry.h
+ archive_entry_copy_stat.c
+ archive_entry_link_resolver.c
+ archive_entry_private.h
+ archive_entry_stat.c
+ archive_entry_strmode.c
+ archive_entry_xattr.c
+ archive_hash.h
+ archive_platform.h
+ archive_private.h
+ archive_read.c
+ archive_read_data_into_fd.c
+ archive_read_disk.c
+ archive_read_disk_entry_from_file.c
+ archive_read_disk_private.h
+ archive_read_disk_set_standard_lookup.c
+ archive_read_extract.c
+ archive_read_open_fd.c
+ archive_read_open_file.c
+ archive_read_open_filename.c
+ archive_read_open_memory.c
+ archive_read_private.h
+ archive_read_support_compression_all.c
+ archive_read_support_compression_bzip2.c
+ archive_read_support_compression_compress.c
+ archive_read_support_compression_gzip.c
+ archive_read_support_compression_none.c
+ archive_read_support_compression_program.c
+ archive_read_support_compression_rpm.c
+ archive_read_support_compression_uu.c
+ archive_read_support_compression_xz.c
+ archive_read_support_format_all.c
+ archive_read_support_format_ar.c
+ archive_read_support_format_cpio.c
+ archive_read_support_format_empty.c
+ archive_read_support_format_iso9660.c
+ archive_read_support_format_mtree.c
+ archive_read_support_format_raw.c
+ archive_read_support_format_tar.c
+ archive_read_support_format_xar.c
+ archive_read_support_format_zip.c
+ archive_string.c
+ archive_string.h
+ archive_string_sprintf.c
+ archive_util.c
+ archive_virtual.c
+ archive_write.c
+ archive_write_disk.c
+ archive_write_disk_private.h
+ archive_write_disk_set_standard_lookup.c
+ archive_write_private.h
+ archive_write_open_fd.c
+ archive_write_open_file.c
+ archive_write_open_filename.c
+ archive_write_open_memory.c
+ archive_write_set_compression_bzip2.c
+ archive_write_set_compression_compress.c
+ archive_write_set_compression_gzip.c
+ archive_write_set_compression_none.c
+ archive_write_set_compression_program.c
+ archive_write_set_compression_xz.c
+ archive_write_set_format.c
+ archive_write_set_format_ar.c
+ archive_write_set_format_by_name.c
+ archive_write_set_format_cpio.c
+ archive_write_set_format_cpio_newc.c
+ archive_write_set_format_mtree.c
+ archive_write_set_format_pax.c
+ archive_write_set_format_shar.c
+ archive_write_set_format_ustar.c
+ archive_write_set_format_zip.c
+ filter_fork.c
+ filter_fork.h
+)
+
+# Man pages
+SET(libarchive_MANS
+ archive_entry.3
+ archive_read.3
+ archive_read_disk.3
+ archive_util.3
+ archive_write.3
+ archive_write_disk.3
+ cpio.5
+ libarchive.3
+ libarchive_internals.3
+ libarchive-formats.5
+ mtree.5
+ tar.5
+)
+
+IF(WIN32 AND NOT CYGWIN)
+ LIST(APPEND libarchive_SOURCES archive_entry_copy_bhfi.c)
+ LIST(APPEND libarchive_SOURCES archive_windows.c)
+ LIST(APPEND libarchive_SOURCES archive_windows.h)
+ LIST(APPEND libarchive_SOURCES filter_fork_windows.c)
+ENDIF(WIN32 AND NOT CYGWIN)
+
+# Libarchive is a shared library
+ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS})
+TARGET_LINK_LIBRARIES(archive ${ADDITIONAL_LIBS})
+SET_TARGET_PROPERTIES(archive PROPERTIES SOVERSION ${SOVERSION})
+
+# archive_static is a static library
+ADD_LIBRARY(archive_static STATIC ${libarchive_SOURCES} ${include_HEADERS})
+SET_TARGET_PROPERTIES(archive_static PROPERTIES COMPILE_DEFINITIONS
+ LIBARCHIVE_STATIC)
+# On Posix systems, libarchive.so and libarchive.a can co-exist.
+IF(NOT WIN32 OR CYGWIN)
+ SET_TARGET_PROPERTIES(archive_static PROPERTIES OUTPUT_NAME archive)
+ENDIF(NOT WIN32 OR CYGWIN)
+
+# How to install the libraries
+INSTALL(TARGETS archive archive_static
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib)
+INSTALL_MAN(${libarchive_MANS})
+INSTALL(FILES ${include_HEADERS} DESTINATION include)
+
+add_subdirectory(test)
diff --git a/archivers/libarchive/files/libarchive/archive.h b/archivers/libarchive/files/libarchive/archive.h
index 3f9f6e1cf67..53851c6e149 100644
--- a/archivers/libarchive/files/libarchive/archive.h
+++ b/archivers/libarchive/files/libarchive/archive.h
@@ -35,22 +35,40 @@
* this header! If you must conditionalize, use predefined compiler and/or
* platform macros.
*/
+#if defined(__BORLANDC__) && __BORLANDC__ >= 0x560
+# define __LA_STDINT_H <stdint.h>
+#elif !defined(__WATCOMC__) && !defined(_MSC_VER) && !defined(__INTERIX) && !defined(__BORLANDC__)
+# define __LA_STDINT_H <inttypes.h>
+#endif
+#include <sys/stat.h>
#include <sys/types.h> /* Linux requires this for off_t */
-#if !defined(__WATCOMC__) && !defined(_MSC_VER)
-/* Header unavailable on Watcom C or MS Visual C++. */
-#include <inttypes.h> /* int64_t, etc. */
+#ifdef __LA_STDINT_H
+# include __LA_STDINT_H /* int64_t, etc. */
#endif
#include <stdio.h> /* For FILE * */
/* Get appropriate definitions of standard POSIX-style types. */
/* These should match the types used in 'struct stat' */
-#ifdef _WIN32
-#define __LA_SSIZE_T long
-#define __LA_UID_T unsigned int
-#define __LA_GID_T unsigned int
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define __LA_INT64_T __int64
+# if defined(_SSIZE_T_DEFINED)
+# define __LA_SSIZE_T ssize_t
+# elif defined(_WIN64)
+# define __LA_SSIZE_T __int64
+# else
+# define __LA_SSIZE_T long
+# endif
+# if defined(__BORLANDC__)
+# define __LA_UID_T uid_t
+# define __LA_GID_T gid_t
+# else
+# define __LA_UID_T short
+# define __LA_GID_T short
+# endif
#else
#include <unistd.h> /* ssize_t, uid_t, and gid_t */
+#define __LA_INT64_T int64_t
#define __LA_SSIZE_T ssize_t
#define __LA_UID_T uid_t
#define __LA_GID_T gid_t
@@ -61,7 +79,7 @@
* .lib. The default here assumes you're building a DLL. Only
* libarchive source should ever define __LIBARCHIVE_BUILD.
*/
-#if ((defined __WIN32__) || (defined _WIN32)) && (!defined LIBARCHIVE_STATIC)
+#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
# ifdef __LIBARCHIVE_BUILD
# ifdef __GNUC__
# define __LA_DECL __attribute__((dllexport)) extern
@@ -80,7 +98,6 @@
# define __LA_DECL
#endif
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -112,13 +129,13 @@ extern "C" {
* (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
* #endif
*/
-#define ARCHIVE_VERSION_NUMBER 2005005
+#define ARCHIVE_VERSION_NUMBER 2008000
__LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
-#define ARCHIVE_VERSION_STRING "libarchive 2.5.5"
+#define ARCHIVE_VERSION_STRING "libarchive 2.8.0"
__LA_DECL const char * archive_version_string(void);
#if ARCHIVE_VERSION_NUMBER < 3000000
@@ -183,20 +200,37 @@ struct archive_entry;
*/
/* Returns pointer and size of next block of data from archive. */
-typedef __LA_SSIZE_T archive_read_callback(struct archive *, void *_client_data,
- const void **_buffer);
+typedef __LA_SSIZE_T archive_read_callback(struct archive *,
+ void *_client_data, const void **_buffer);
+
/* Skips at most request bytes from archive and returns the skipped amount */
#if ARCHIVE_VERSION_NUMBER < 2000000
-typedef __LA_SSIZE_T archive_skip_callback(struct archive *, void *_client_data,
- size_t request);
+/* Libarchive 1.0 used ssize_t for the return, which is only 32 bits
+ * on most 32-bit platforms; not large enough. */
+typedef __LA_SSIZE_T archive_skip_callback(struct archive *,
+ void *_client_data, size_t request);
+#elif ARCHIVE_VERSION_NUMBER < 3000000
+/* Libarchive 2.0 used off_t here, but that is a bad idea on Linux and a
+ * few other platforms where off_t varies with build settings. */
+typedef off_t archive_skip_callback(struct archive *,
+ void *_client_data, off_t request);
#else
-typedef off_t archive_skip_callback(struct archive *, void *_client_data,
- off_t request);
+/* Libarchive 3.0 uses int64_t here, which is actually guaranteed to be
+ * 64 bits on every platform. */
+typedef __LA_INT64_T archive_skip_callback(struct archive *,
+ void *_client_data, __LA_INT64_T request);
#endif
+
/* Returns size actually written, zero on EOF, -1 on error. */
-typedef __LA_SSIZE_T archive_write_callback(struct archive *, void *_client_data,
- const void *_buffer, size_t _length);
+typedef __LA_SSIZE_T archive_write_callback(struct archive *,
+ void *_client_data,
+ const void *_buffer, size_t _length);
+
+#if ARCHIVE_VERSION_NUMBER < 3000000
+/* Open callback is actually never needed; remove it in libarchive 3.0. */
typedef int archive_open_callback(struct archive *, void *_client_data);
+#endif
+
typedef int archive_close_callback(struct archive *, void *_client_data);
/*
@@ -207,6 +241,10 @@ typedef int archive_close_callback(struct archive *, void *_client_data);
#define ARCHIVE_COMPRESSION_BZIP2 2
#define ARCHIVE_COMPRESSION_COMPRESS 3
#define ARCHIVE_COMPRESSION_PROGRAM 4
+#define ARCHIVE_COMPRESSION_LZMA 5
+#define ARCHIVE_COMPRESSION_XZ 6
+#define ARCHIVE_COMPRESSION_UU 7
+#define ARCHIVE_COMPRESSION_RPM 8
/*
* Codes returned by archive_format.
@@ -247,8 +285,8 @@ typedef int archive_close_callback(struct archive *, void *_client_data);
#define ARCHIVE_FORMAT_AR_GNU (ARCHIVE_FORMAT_AR | 1)
#define ARCHIVE_FORMAT_AR_BSD (ARCHIVE_FORMAT_AR | 2)
#define ARCHIVE_FORMAT_MTREE 0x80000
-#define ARCHIVE_FORMAT_MTREE_V1 (ARCHIVE_FORMAT_MTREE | 1)
-#define ARCHIVE_FORMAT_MTREE_V2 (ARCHIVE_FORMAT_MTREE | 2)
+#define ARCHIVE_FORMAT_RAW 0x90000
+#define ARCHIVE_FORMAT_XAR 0xA0000
/*-
* Basic outline for reading an archive:
@@ -275,9 +313,17 @@ __LA_DECL int archive_read_support_compression_all(struct archive *);
__LA_DECL int archive_read_support_compression_bzip2(struct archive *);
__LA_DECL int archive_read_support_compression_compress(struct archive *);
__LA_DECL int archive_read_support_compression_gzip(struct archive *);
+__LA_DECL int archive_read_support_compression_lzma(struct archive *);
__LA_DECL int archive_read_support_compression_none(struct archive *);
__LA_DECL int archive_read_support_compression_program(struct archive *,
const char *command);
+__LA_DECL int archive_read_support_compression_program_signature
+ (struct archive *, const char *,
+ const void * /* match */, size_t);
+
+__LA_DECL int archive_read_support_compression_rpm(struct archive *);
+__LA_DECL int archive_read_support_compression_uu(struct archive *);
+__LA_DECL int archive_read_support_compression_xz(struct archive *);
__LA_DECL int archive_read_support_format_all(struct archive *);
__LA_DECL int archive_read_support_format_ar(struct archive *);
@@ -286,7 +332,9 @@ __LA_DECL int archive_read_support_format_empty(struct archive *);
__LA_DECL int archive_read_support_format_gnutar(struct archive *);
__LA_DECL int archive_read_support_format_iso9660(struct archive *);
__LA_DECL int archive_read_support_format_mtree(struct archive *);
+__LA_DECL int archive_read_support_format_raw(struct archive *);
__LA_DECL int archive_read_support_format_tar(struct archive *);
+__LA_DECL int archive_read_support_format_xar(struct archive *);
__LA_DECL int archive_read_support_format_zip(struct archive *);
@@ -326,22 +374,34 @@ __LA_DECL int archive_read_open_FILE(struct archive *, FILE *_file);
__LA_DECL int archive_read_next_header(struct archive *,
struct archive_entry **);
+/* Parses and returns next entry header using the archive_entry passed in */
+__LA_DECL int archive_read_next_header2(struct archive *,
+ struct archive_entry *);
+
/*
* Retrieve the byte offset in UNCOMPRESSED data where last-read
* header started.
*/
-__LA_DECL int64_t archive_read_header_position(struct archive *);
+__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *);
/* Read data from the body of an entry. Similar to read(2). */
-__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *, void *, size_t);
+__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *,
+ void *, size_t);
+
/*
* A zero-copy version of archive_read_data that also exposes the file offset
* of each returned block. Note that the client has no way to specify
* the desired size of the block. The API does guarantee that offsets will
* be strictly increasing and that returned blocks will not overlap.
*/
+#if ARCHIVE_VERSION_NUMBER < 3000000
__LA_DECL int archive_read_data_block(struct archive *a,
- const void **buff, size_t *size, off_t *offset);
+ const void **buff, size_t *size, off_t *offset);
+#else
+__LA_DECL int archive_read_data_block(struct archive *a,
+ const void **buff, size_t *size,
+ __LA_INT64_T *offset);
+#endif
/*-
* Some convenience functions that are built on archive_read_data:
@@ -350,10 +410,23 @@ __LA_DECL int archive_read_data_block(struct archive *a,
* 'into_fd': writes data to specified filedes
*/
__LA_DECL int archive_read_data_skip(struct archive *);
-__LA_DECL int archive_read_data_into_buffer(struct archive *, void *buffer,
- __LA_SSIZE_T len);
+__LA_DECL int archive_read_data_into_buffer(struct archive *,
+ void *buffer, __LA_SSIZE_T len);
__LA_DECL int archive_read_data_into_fd(struct archive *, int fd);
+/*
+ * Set read options.
+ */
+/* Apply option string to the format only. */
+__LA_DECL int archive_read_set_format_options(struct archive *_a,
+ const char *s);
+/* Apply option string to the filter only. */
+__LA_DECL int archive_read_set_filter_options(struct archive *_a,
+ const char *s);
+/* Apply option string to both the format and the filter. */
+__LA_DECL int archive_read_set_options(struct archive *_a,
+ const char *s);
+
/*-
* Convenience function to recreate the current entry (whose header
* has just been read) on disk.
@@ -414,12 +487,11 @@ __LA_DECL void archive_read_extract_set_skip_file(struct archive *,
__LA_DECL int archive_read_close(struct archive *);
/* Release all resources and destroy the object. */
/* Note that archive_read_finish will call archive_read_close for you. */
-#if ARCHIVE_VERSION_NUMBER >= 2000000
-__LA_DECL int archive_read_finish(struct archive *);
-#else
-/* Temporarily allow library to compile with either 1.x or 2.0 API. */
+#if ARCHIVE_VERSION_NUMBER < 2000000
/* Erroneously declared to return void in libarchive 1.x */
__LA_DECL void archive_read_finish(struct archive *);
+#else
+__LA_DECL int archive_read_finish(struct archive *);
#endif
/*-
@@ -453,9 +525,11 @@ __LA_DECL int archive_write_set_skip_file(struct archive *, dev_t, ino_t);
__LA_DECL int archive_write_set_compression_bzip2(struct archive *);
__LA_DECL int archive_write_set_compression_compress(struct archive *);
__LA_DECL int archive_write_set_compression_gzip(struct archive *);
+__LA_DECL int archive_write_set_compression_lzma(struct archive *);
__LA_DECL int archive_write_set_compression_none(struct archive *);
__LA_DECL int archive_write_set_compression_program(struct archive *,
const char *cmd);
+__LA_DECL int archive_write_set_compression_xz(struct archive *);
/* A convenience function to set the format based on the code or name. */
__LA_DECL int archive_write_set_format(struct archive *, int format_code);
__LA_DECL int archive_write_set_format_by_name(struct archive *,
@@ -465,12 +539,14 @@ __LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
__LA_DECL int archive_write_set_format_cpio(struct archive *);
__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
+__LA_DECL int archive_write_set_format_mtree(struct archive *);
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
__LA_DECL int archive_write_set_format_pax(struct archive *);
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
__LA_DECL int archive_write_set_format_shar(struct archive *);
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
__LA_DECL int archive_write_set_format_ustar(struct archive *);
+__LA_DECL int archive_write_set_format_zip(struct archive *);
__LA_DECL int archive_write_open(struct archive *, void *,
archive_open_callback *, archive_write_callback *,
archive_close_callback *);
@@ -490,29 +566,59 @@ __LA_DECL int archive_write_open_memory(struct archive *,
*/
__LA_DECL int archive_write_header(struct archive *,
struct archive_entry *);
-#if ARCHIVE_VERSION_NUMBER >= 2000000
-__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *, const void *, size_t);
-#else
-/* Temporarily allow library to compile with either 1.x or 2.0 API. */
+#if ARCHIVE_VERSION_NUMBER < 2000000
/* This was erroneously declared to return "int" in libarchive 1.x. */
-__LA_DECL int archive_write_data(struct archive *, const void *, size_t);
+__LA_DECL int archive_write_data(struct archive *,
+ const void *, size_t);
+#else
+/* Libarchive 2.0 and later return ssize_t here. */
+__LA_DECL __LA_SSIZE_T archive_write_data(struct archive *,
+ const void *, size_t);
+#endif
+
+#if ARCHIVE_VERSION_NUMBER < 3000000
+/* Libarchive 1.x and 2.x use off_t for the argument, but that's not
+ * stable on Linux. */
+__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *,
+ const void *, size_t, off_t);
+#else
+/* Libarchive 3.0 uses explicit int64_t to ensure consistent 64-bit support. */
+__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *,
+ const void *, size_t, __LA_INT64_T);
#endif
-__LA_DECL __LA_SSIZE_T archive_write_data_block(struct archive *, const void *, size_t, off_t);
__LA_DECL int archive_write_finish_entry(struct archive *);
__LA_DECL int archive_write_close(struct archive *);
-#if ARCHIVE_VERSION_NUMBER >= 2000000
-__LA_DECL int archive_write_finish(struct archive *);
-#else
-/* Temporarily allow library to compile with either 1.x or 2.0 API. */
+#if ARCHIVE_VERSION_NUMBER < 2000000
/* Return value was incorrect in libarchive 1.x. */
__LA_DECL void archive_write_finish(struct archive *);
+#else
+/* Libarchive 2.x and later returns an error if this fails. */
+/* It can fail if the archive wasn't already closed, in which case
+ * archive_write_finish() will implicitly call archive_write_close(). */
+__LA_DECL int archive_write_finish(struct archive *);
#endif
+/*
+ * Set write options.
+ */
+/* Apply option string to the format only. */
+__LA_DECL int archive_write_set_format_options(struct archive *_a,
+ const char *s);
+/* Apply option string to the compressor only. */
+__LA_DECL int archive_write_set_compressor_options(struct archive *_a,
+ const char *s);
+/* Apply option string to both the format and the compressor. */
+__LA_DECL int archive_write_set_options(struct archive *_a,
+ const char *s);
+
+
/*-
+ * ARCHIVE_WRITE_DISK API
+ *
* To create objects on disk:
* 1) Ask archive_write_disk_new for a new archive_write_disk object.
- * 2) Set any global properties. In particular, you should set
- * the compression and format to use.
+ * 2) Set any global properties. In particular, you probably
+ * want to set the options.
* 3) For each entry:
* - construct an appropriate struct archive_entry structure
* - archive_write_header to create the file/dir/etc on disk
@@ -526,7 +632,8 @@ __LA_DECL struct archive *archive_write_disk_new(void);
/* This file will not be overwritten. */
__LA_DECL int archive_write_disk_set_skip_file(struct archive *,
dev_t, ino_t);
-/* Set flags to control how the next item gets created. */
+/* Set flags to control how the next item gets created.
+ * This accepts a bitmask of ARCHIVE_EXTRACT_XXX flags defined above. */
__LA_DECL int archive_write_disk_set_options(struct archive *,
int flags);
/*
@@ -562,13 +669,47 @@ __LA_DECL int archive_write_disk_set_user_lookup(struct archive *,
void (* /* cleanup */)(void *));
/*
+ * ARCHIVE_READ_DISK API
+ *
+ * This is still evolving and somewhat experimental.
+ */
+__LA_DECL struct archive *archive_read_disk_new(void);
+/* The names for symlink modes here correspond to an old BSD
+ * command-line argument convention: -L, -P, -H */
+/* Follow all symlinks. */
+__LA_DECL int archive_read_disk_set_symlink_logical(struct archive *);
+/* Follow no symlinks. */
+__LA_DECL int archive_read_disk_set_symlink_physical(struct archive *);
+/* Follow symlink initially, then not. */
+__LA_DECL int archive_read_disk_set_symlink_hybrid(struct archive *);
+/* TODO: Handle Linux stat32/stat64 ugliness. <sigh> */
+__LA_DECL int archive_read_disk_entry_from_file(struct archive *,
+ struct archive_entry *, int /* fd */, const struct stat *);
+/* Look up gname for gid or uname for uid. */
+/* Default implementations are very, very stupid. */
+__LA_DECL const char *archive_read_disk_gname(struct archive *, __LA_GID_T);
+__LA_DECL const char *archive_read_disk_uname(struct archive *, __LA_UID_T);
+/* "Standard" implementation uses getpwuid_r, getgrgid_r and caches the
+ * results for performance. */
+__LA_DECL int archive_read_disk_set_standard_lookup(struct archive *);
+/* You can install your own lookups if you like. */
+__LA_DECL int archive_read_disk_set_gname_lookup(struct archive *,
+ void * /* private_data */,
+ const char *(* /* lookup_fn */)(void *, __LA_GID_T),
+ void (* /* cleanup_fn */)(void *));
+__LA_DECL int archive_read_disk_set_uname_lookup(struct archive *,
+ void * /* private_data */,
+ const char *(* /* lookup_fn */)(void *, __LA_UID_T),
+ void (* /* cleanup_fn */)(void *));
+
+/*
* Accessor functions to read/set various information in
* the struct archive object:
*/
/* Bytes written after compression or read before decompression. */
-__LA_DECL int64_t archive_position_compressed(struct archive *);
+__LA_DECL __LA_INT64_T archive_position_compressed(struct archive *);
/* Bytes written to compressor or read from decompressor. */
-__LA_DECL int64_t archive_position_uncompressed(struct archive *);
+__LA_DECL __LA_INT64_T archive_position_uncompressed(struct archive *);
__LA_DECL const char *archive_compression_name(struct archive *);
__LA_DECL int archive_compression(struct archive *);
@@ -581,12 +722,20 @@ __LA_DECL void archive_set_error(struct archive *, int _err,
const char *fmt, ...);
__LA_DECL void archive_copy_error(struct archive *dest,
struct archive *src);
+__LA_DECL int archive_file_count(struct archive *);
#ifdef __cplusplus
}
#endif
-/* This is meaningless outside of this header. */
+/* These are meaningless outside of this header. */
#undef __LA_DECL
+#undef __LA_GID_T
+#undef __LA_UID_T
+
+/* These need to remain defined because they're used in the
+ * callback type definitions. XXX Fix this. This is ugly. XXX */
+/* #undef __LA_INT64_T */
+/* #undef __LA_SSIZE_T */
#endif /* !ARCHIVE_H_INCLUDED */
diff --git a/archivers/libarchive/files/libarchive/archive_check_magic.c b/archivers/libarchive/files/libarchive/archive_check_magic.c
index 715486dcfeb..e27e5d82708 100644
--- a/archivers/libarchive/files/libarchive/archive_check_magic.c
+++ b/archivers/libarchive/files/libarchive/archive_check_magic.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_check_magic.c,v 1.8 2007/04/02 00:15:45 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_check_magic.c 201089 2009-12-28 02:20:23Z kientzle $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -40,20 +40,36 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_check_magic.c,v 1.8 2007/04/02 00
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+#include <winbase.h>
+#endif
#include "archive_private.h"
static void
errmsg(const char *m)
{
- write(STDERR_FILENO, m, strlen(m));
+ size_t s = strlen(m);
+ ssize_t written;
+
+ while (s > 0) {
+ written = write(2, m, strlen(m));
+ if (written <= 0)
+ return;
+ m += written;
+ s -= written;
+ }
}
static void
diediedie(void)
{
- *(char *)0 = 1; /* Deliberately segfault and force a coredump. */
- _exit(1); /* If that didn't work, just exit with an error. */
+#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
+ /* Cause a breakpoint exception */
+ DebugBreak();
+#endif
+ abort(); /* Terminate the program abnormally. */
}
static const char *
@@ -77,7 +93,7 @@ write_all_states(unsigned int states)
unsigned int lowbit;
/* A trick for computing the lowest set bit. */
- while ((lowbit = states & (-states)) != 0) {
+ while ((lowbit = states & (1 + ~states)) != 0) {
states &= ~lowbit; /* Clear the low bit. */
errmsg(state_name(lowbit));
if (states != 0)
diff --git a/archivers/libarchive/files/libarchive/archive_endian.h b/archivers/libarchive/files/libarchive/archive_endian.h
index 550be164029..edc90ee6a84 100644
--- a/archivers/libarchive/files/libarchive/archive_endian.h
+++ b/archivers/libarchive/files/libarchive/archive_endian.h
@@ -23,11 +23,15 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_endian.h,v 1.3 2008/05/26 17:00:22 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_endian.h 201085 2009-12-28 02:17:15Z kientzle $
*
* Borrowed from FreeBSD's <sys/endian.h>
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
/* Note: This is a purely internal header! */
/* Do not use this outside of libarchive internal code! */
@@ -35,14 +39,16 @@
#define ARCHIVE_ENDIAN_H_INCLUDED
-/* Watcom C++ doesn't support 'inline' in C code. (For any version?) */
-#if defined( __WATCOMC__ )
- #define inline
-#endif
-
-/* Visual C++ 6.0 doesn't support 'inline' in C code. (Does VC7? VC8?) */
-#if defined(_MSC_VER)
- #define inline
+/*
+ * Disabling inline keyword for compilers known to choke on it:
+ * - Watcom C++ in C code. (For any version?)
+ * - SGI MIPSpro
+ * - Microsoft Visual C++ 6.0 (supposedly newer versions too)
+ */
+#if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__)
+#define inline
+#elif defined(_MSC_VER)
+#define inline __inline
#endif
/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
diff --git a/archivers/libarchive/files/libarchive/archive_entry.c b/archivers/libarchive/files/libarchive/archive_entry.c
index 69921c309f1..f734b8c4f51 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.c
+++ b/archivers/libarchive/files/libarchive/archive_entry.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.52 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry.c 201096 2009-12-28 02:41:27Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -32,15 +32,12 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.52 2008/05/26 17:00:2
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#ifdef MAJOR_IN_MKDEV
+#if MAJOR_IN_MKDEV
#include <sys/mkdev.h>
-#else
-#ifdef MAJOR_IN_SYSMACROS
+#define HAVE_MAJOR
+#elif MAJOR_IN_SYSMACROS
#include <sys/sysmacros.h>
-#endif
-#endif
-#ifdef HAVE_EXT2FS_EXT2_FS_H
-#include <ext2fs/ext2_fs.h> /* for Linux file flags */
+#define HAVE_MAJOR
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
@@ -48,9 +45,16 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.52 2008/05/26 17:00:2
#ifdef HAVE_LINUX_FS_H
#include <linux/fs.h> /* for Linux file flags */
#endif
+/*
+ * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.
+ * As the include guards don't agree, the order of include is important.
+ */
#ifdef HAVE_LINUX_EXT2_FS_H
#include <linux/ext2_fs.h> /* for Linux file flags */
#endif
+#if defined(HAVE_EXT2FS_EXT2_FS_H) && !defined(__CYGWIN__)
+#include <ext2fs/ext2_fs.h> /* for Linux file flags */
+#endif
#include <stddef.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
@@ -71,6 +75,13 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.52 2008/05/26 17:00:2
#undef max
#define max(a, b) ((a)>(b)?(a):(b))
+#if !defined(HAVE_MAJOR) && !defined(major)
+/* Replacement for major/minor/makedev. */
+#define major(x) ((int)(0x00ff & ((x) >> 8)))
+#define minor(x) ((int)(0xffff00ff & (x)))
+#define makedev(maj,min) ((0xff00 & ((maj)<<8)) | (0xffff00ff & (min)))
+#endif
+
/* Play games to come up with a suitable makedev() definition. */
#ifdef __QNXNTO__
/* QNX. <sigh> */
@@ -79,7 +90,7 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.52 2008/05/26 17:00:2
#elif defined makedev
/* There's a "makedev" macro. */
#define ae_makedev(maj, min) makedev((maj), (min))
-#elif defined mkdev || defined _WIN32 || defined __WIN32__
+#elif defined mkdev || ((defined _WIN32 || defined __WIN32__) && !defined(__CYGWIN__))
/* Windows. <sigh> */
#define ae_makedev(maj, min) mkdev((maj), (min))
#else
@@ -111,6 +122,7 @@ static int acl_special(struct archive_entry *entry,
static struct ae_acl *acl_new_entry(struct archive_entry *entry,
int type, int permset, int tag, int id);
static int isint_w(const wchar_t *start, const wchar_t *end, int *result);
+static int ismode_w(const wchar_t *start, const wchar_t *end, int *result);
static void next_field_w(const wchar_t **wp, const wchar_t **start,
const wchar_t **end, wchar_t *sep);
static int prefix_w(const wchar_t *start, const wchar_t *end,
@@ -210,7 +222,7 @@ static const wchar_t *
aes_get_wcs(struct aes *aes)
{
wchar_t *w;
- int r;
+ size_t r;
/* Return WCS form if we already have it. */
if (aes->aes_set & AES_SET_WCS)
@@ -228,8 +240,8 @@ aes_get_wcs(struct aes *aes)
if (w == NULL)
__archive_errx(1, "No memory for aes_get_wcs()");
r = mbstowcs(w, aes->aes_mbs.s, wcs_length);
- w[wcs_length] = 0;
- if (r > 0) {
+ if (r != (size_t)-1 && r != 0) {
+ w[r] = 0;
aes->aes_set |= AES_SET_WCS;
return (aes->aes_wcs = w);
}
@@ -239,7 +251,8 @@ aes_get_wcs(struct aes *aes)
if (aes->aes_set & AES_SET_UTF8) {
/* Try converting UTF8 to WCS. */
aes->aes_wcs = __archive_string_utf8_w(&(aes->aes_utf8));
- aes->aes_set |= AES_SET_WCS;
+ if (aes->aes_wcs != NULL)
+ aes->aes_set |= AES_SET_WCS;
return (aes->aes_wcs);
}
return (NULL);
@@ -365,6 +378,7 @@ archive_entry_clear(struct archive_entry *entry)
aes_clean(&entry->ae_gname);
aes_clean(&entry->ae_hardlink);
aes_clean(&entry->ae_pathname);
+ aes_clean(&entry->ae_sourcepath);
aes_clean(&entry->ae_symlink);
aes_clean(&entry->ae_uname);
archive_entry_acl_clear(entry);
@@ -394,9 +408,9 @@ archive_entry_clone(struct archive_entry *entry)
aes_copy(&entry2->ae_gname, &entry->ae_gname);
aes_copy(&entry2->ae_hardlink, &entry->ae_hardlink);
aes_copy(&entry2->ae_pathname, &entry->ae_pathname);
+ aes_copy(&entry2->ae_sourcepath, &entry->ae_sourcepath);
aes_copy(&entry2->ae_symlink, &entry->ae_symlink);
- entry2->ae_hardlinkset = entry->ae_hardlinkset;
- entry2->ae_symlinkset = entry->ae_symlinkset;
+ entry2->ae_set = entry->ae_set;
aes_copy(&entry2->ae_uname, &entry->ae_uname);
/* Copy ACL data over. */
@@ -455,12 +469,42 @@ archive_entry_atime_nsec(struct archive_entry *entry)
return (entry->ae_stat.aest_atime_nsec);
}
+int
+archive_entry_atime_is_set(struct archive_entry *entry)
+{
+ return (entry->ae_set & AE_SET_ATIME);
+}
+
+time_t
+archive_entry_birthtime(struct archive_entry *entry)
+{
+ return (entry->ae_stat.aest_birthtime);
+}
+
+long
+archive_entry_birthtime_nsec(struct archive_entry *entry)
+{
+ return (entry->ae_stat.aest_birthtime_nsec);
+}
+
+int
+archive_entry_birthtime_is_set(struct archive_entry *entry)
+{
+ return (entry->ae_set & AE_SET_BIRTHTIME);
+}
+
time_t
archive_entry_ctime(struct archive_entry *entry)
{
return (entry->ae_stat.aest_ctime);
}
+int
+archive_entry_ctime_is_set(struct archive_entry *entry)
+{
+ return (entry->ae_set & AE_SET_CTIME);
+}
+
long
archive_entry_ctime_nsec(struct archive_entry *entry)
{
@@ -562,17 +606,17 @@ archive_entry_gname_w(struct archive_entry *entry)
const char *
archive_entry_hardlink(struct archive_entry *entry)
{
- if (!entry->ae_hardlinkset)
- return (NULL);
- return (aes_get_mbs(&entry->ae_hardlink));
+ if (entry->ae_set & AE_SET_HARDLINK)
+ return (aes_get_mbs(&entry->ae_hardlink));
+ return (NULL);
}
const wchar_t *
archive_entry_hardlink_w(struct archive_entry *entry)
{
- if (!entry->ae_hardlinkset)
- return (NULL);
- return (aes_get_wcs(&entry->ae_hardlink));
+ if (entry->ae_set & AE_SET_HARDLINK)
+ return (aes_get_wcs(&entry->ae_hardlink));
+ return (NULL);
}
ino_t
@@ -581,6 +625,12 @@ archive_entry_ino(struct archive_entry *entry)
return (entry->ae_stat.aest_ino);
}
+int64_t
+archive_entry_ino64(struct archive_entry *entry)
+{
+ return (entry->ae_stat.aest_ino);
+}
+
mode_t
archive_entry_mode(struct archive_entry *entry)
{
@@ -599,6 +649,12 @@ archive_entry_mtime_nsec(struct archive_entry *entry)
return (entry->ae_stat.aest_mtime_nsec);
}
+int
+archive_entry_mtime_is_set(struct archive_entry *entry)
+{
+ return (entry->ae_set & AE_SET_MTIME);
+}
+
unsigned int
archive_entry_nlink(struct archive_entry *entry)
{
@@ -651,6 +707,12 @@ archive_entry_size(struct archive_entry *entry)
return (entry->ae_stat.aest_size);
}
+int
+archive_entry_size_is_set(struct archive_entry *entry)
+{
+ return (entry->ae_set & AE_SET_SIZE);
+}
+
const char *
archive_entry_sourcepath(struct archive_entry *entry)
{
@@ -660,17 +722,17 @@ archive_entry_sourcepath(struct archive_entry *entry)
const char *
archive_entry_symlink(struct archive_entry *entry)
{
- if (!entry->ae_symlinkset)
- return (NULL);
- return (aes_get_mbs(&entry->ae_symlink));
+ if (entry->ae_set & AE_SET_SYMLINK)
+ return (aes_get_mbs(&entry->ae_symlink));
+ return (NULL);
}
const wchar_t *
archive_entry_symlink_w(struct archive_entry *entry)
{
- if (!entry->ae_symlinkset)
- return (NULL);
- return (aes_get_wcs(&entry->ae_symlink));
+ if (entry->ae_set & AE_SET_SYMLINK)
+ return (aes_get_wcs(&entry->ae_symlink));
+ return (NULL);
}
uid_t
@@ -769,11 +831,20 @@ archive_entry_set_ino(struct archive_entry *entry, unsigned long ino)
}
void
+archive_entry_set_ino64(struct archive_entry *entry, int64_t ino)
+{
+ entry->stat_valid = 0;
+ entry->ae_stat.aest_ino = ino;
+}
+
+void
archive_entry_set_hardlink(struct archive_entry *entry, const char *target)
{
aes_set_mbs(&entry->ae_hardlink, target);
if (target != NULL)
- entry->ae_hardlinkset = 1;
+ entry->ae_set |= AE_SET_HARDLINK;
+ else
+ entry->ae_set &= ~AE_SET_HARDLINK;
}
void
@@ -781,7 +852,9 @@ archive_entry_copy_hardlink(struct archive_entry *entry, const char *target)
{
aes_copy_mbs(&entry->ae_hardlink, target);
if (target != NULL)
- entry->ae_hardlinkset = 1;
+ entry->ae_set |= AE_SET_HARDLINK;
+ else
+ entry->ae_set &= ~AE_SET_HARDLINK;
}
void
@@ -789,26 +862,70 @@ archive_entry_copy_hardlink_w(struct archive_entry *entry, const wchar_t *target
{
aes_copy_wcs(&entry->ae_hardlink, target);
if (target != NULL)
- entry->ae_hardlinkset = 1;
+ entry->ae_set |= AE_SET_HARDLINK;
+ else
+ entry->ae_set &= ~AE_SET_HARDLINK;
+}
+
+int
+archive_entry_update_hardlink_utf8(struct archive_entry *entry, const char *target)
+{
+ if (target != NULL)
+ entry->ae_set |= AE_SET_HARDLINK;
+ else
+ entry->ae_set &= ~AE_SET_HARDLINK;
+ return (aes_update_utf8(&entry->ae_hardlink, target));
}
void
archive_entry_set_atime(struct archive_entry *entry, time_t t, long ns)
{
entry->stat_valid = 0;
+ entry->ae_set |= AE_SET_ATIME;
entry->ae_stat.aest_atime = t;
entry->ae_stat.aest_atime_nsec = ns;
}
void
+archive_entry_unset_atime(struct archive_entry *entry)
+{
+ archive_entry_set_atime(entry, 0, 0);
+ entry->ae_set &= ~AE_SET_ATIME;
+}
+
+void
+archive_entry_set_birthtime(struct archive_entry *entry, time_t m, long ns)
+{
+ entry->stat_valid = 0;
+ entry->ae_set |= AE_SET_BIRTHTIME;
+ entry->ae_stat.aest_birthtime = m;
+ entry->ae_stat.aest_birthtime_nsec = ns;
+}
+
+void
+archive_entry_unset_birthtime(struct archive_entry *entry)
+{
+ archive_entry_set_birthtime(entry, 0, 0);
+ entry->ae_set &= ~AE_SET_BIRTHTIME;
+}
+
+void
archive_entry_set_ctime(struct archive_entry *entry, time_t t, long ns)
{
entry->stat_valid = 0;
+ entry->ae_set |= AE_SET_CTIME;
entry->ae_stat.aest_ctime = t;
entry->ae_stat.aest_ctime_nsec = ns;
}
void
+archive_entry_unset_ctime(struct archive_entry *entry)
+{
+ archive_entry_set_ctime(entry, 0, 0);
+ entry->ae_set &= ~AE_SET_CTIME;
+}
+
+void
archive_entry_set_dev(struct archive_entry *entry, dev_t d)
{
entry->stat_valid = 0;
@@ -836,7 +953,7 @@ archive_entry_set_devminor(struct archive_entry *entry, dev_t m)
void
archive_entry_set_link(struct archive_entry *entry, const char *target)
{
- if (entry->ae_symlinkset)
+ if (entry->ae_set & AE_SET_SYMLINK)
aes_set_mbs(&entry->ae_symlink, target);
else
aes_set_mbs(&entry->ae_hardlink, target);
@@ -846,7 +963,7 @@ archive_entry_set_link(struct archive_entry *entry, const char *target)
void
archive_entry_copy_link(struct archive_entry *entry, const char *target)
{
- if (entry->ae_symlinkset)
+ if (entry->ae_set & AE_SET_SYMLINK)
aes_copy_mbs(&entry->ae_symlink, target);
else
aes_copy_mbs(&entry->ae_hardlink, target);
@@ -856,7 +973,7 @@ archive_entry_copy_link(struct archive_entry *entry, const char *target)
void
archive_entry_copy_link_w(struct archive_entry *entry, const wchar_t *target)
{
- if (entry->ae_symlinkset)
+ if (entry->ae_set & AE_SET_SYMLINK)
aes_copy_wcs(&entry->ae_symlink, target);
else
aes_copy_wcs(&entry->ae_hardlink, target);
@@ -865,7 +982,7 @@ archive_entry_copy_link_w(struct archive_entry *entry, const wchar_t *target)
int
archive_entry_update_link_utf8(struct archive_entry *entry, const char *target)
{
- if (entry->ae_symlinkset)
+ if (entry->ae_set & AE_SET_SYMLINK)
return (aes_update_utf8(&entry->ae_symlink, target));
else
return (aes_update_utf8(&entry->ae_hardlink, target));
@@ -882,11 +999,19 @@ void
archive_entry_set_mtime(struct archive_entry *entry, time_t m, long ns)
{
entry->stat_valid = 0;
+ entry->ae_set |= AE_SET_MTIME;
entry->ae_stat.aest_mtime = m;
entry->ae_stat.aest_mtime_nsec = ns;
}
void
+archive_entry_unset_mtime(struct archive_entry *entry)
+{
+ archive_entry_set_mtime(entry, 0, 0);
+ entry->ae_set &= ~AE_SET_MTIME;
+}
+
+void
archive_entry_set_nlink(struct archive_entry *entry, unsigned int nlink)
{
entry->stat_valid = 0;
@@ -954,6 +1079,14 @@ archive_entry_set_size(struct archive_entry *entry, int64_t s)
{
entry->stat_valid = 0;
entry->ae_stat.aest_size = s;
+ entry->ae_set |= AE_SET_SIZE;
+}
+
+void
+archive_entry_unset_size(struct archive_entry *entry)
+{
+ archive_entry_set_size(entry, 0);
+ entry->ae_set &= ~AE_SET_SIZE;
}
void
@@ -967,7 +1100,9 @@ archive_entry_set_symlink(struct archive_entry *entry, const char *linkname)
{
aes_set_mbs(&entry->ae_symlink, linkname);
if (linkname != NULL)
- entry->ae_symlinkset = 1;
+ entry->ae_set |= AE_SET_SYMLINK;
+ else
+ entry->ae_set &= ~AE_SET_SYMLINK;
}
void
@@ -975,7 +1110,9 @@ archive_entry_copy_symlink(struct archive_entry *entry, const char *linkname)
{
aes_copy_mbs(&entry->ae_symlink, linkname);
if (linkname != NULL)
- entry->ae_symlinkset = 1;
+ entry->ae_set |= AE_SET_SYMLINK;
+ else
+ entry->ae_set &= ~AE_SET_SYMLINK;
}
void
@@ -983,7 +1120,19 @@ archive_entry_copy_symlink_w(struct archive_entry *entry, const wchar_t *linknam
{
aes_copy_wcs(&entry->ae_symlink, linkname);
if (linkname != NULL)
- entry->ae_symlinkset = 1;
+ entry->ae_set |= AE_SET_SYMLINK;
+ else
+ entry->ae_set &= ~AE_SET_SYMLINK;
+}
+
+int
+archive_entry_update_symlink_utf8(struct archive_entry *entry, const char *linkname)
+{
+ if (linkname != NULL)
+ entry->ae_set |= AE_SET_SYMLINK;
+ else
+ entry->ae_set &= ~AE_SET_SYMLINK;
+ return (aes_update_utf8(&entry->ae_symlink, linkname));
}
void
@@ -1077,7 +1226,7 @@ archive_entry_acl_add_entry_w(struct archive_entry *entry,
archive_entry_acl_add_entry_w_len(entry, type, permset, tag, id, name, wcslen(name));
}
-void
+static void
archive_entry_acl_add_entry_w_len(struct archive_entry *entry,
int type, int permset, int tag, int id, const wchar_t *name, size_t len)
{
@@ -1130,7 +1279,7 @@ static struct ae_acl *
acl_new_entry(struct archive_entry *entry,
int type, int permset, int tag, int id)
{
- struct ae_acl *ap;
+ struct ae_acl *ap, *aq;
if (type != ARCHIVE_ENTRY_ACL_TYPE_ACCESS &&
type != ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
@@ -1143,20 +1292,26 @@ acl_new_entry(struct archive_entry *entry,
/* XXX TODO: More sanity-checks on the arguments XXX */
/* If there's a matching entry already in the list, overwrite it. */
- for (ap = entry->acl_head; ap != NULL; ap = ap->next) {
+ ap = entry->acl_head;
+ aq = NULL;
+ while (ap != NULL) {
if (ap->type == type && ap->tag == tag && ap->id == id) {
ap->permset = permset;
return (ap);
}
+ aq = ap;
+ ap = ap->next;
}
- /* Add a new entry to the list. */
+ /* Add a new entry to the end of the list. */
ap = (struct ae_acl *)malloc(sizeof(*ap));
if (ap == NULL)
return (NULL);
memset(ap, 0, sizeof(*ap));
- ap->next = entry->acl_head;
- entry->acl_head = ap;
+ if (aq == NULL)
+ entry->acl_head = ap;
+ else
+ aq->next = ap;
ap->type = type;
ap->tag = tag;
ap->id = id;
@@ -1478,11 +1633,10 @@ __archive_entry_acl_parse_w(struct archive_entry *entry,
struct {
const wchar_t *start;
const wchar_t *end;
- } field[4];
+ } field[4], name;
- int fields;
+ int fields, n;
int type, tag, permset, id;
- const wchar_t *p;
wchar_t sep;
while (text != NULL && *text != L'\0') {
@@ -1501,8 +1655,9 @@ __archive_entry_acl_parse_w(struct archive_entry *entry,
++fields;
} while (sep == L':');
- if (fields < 3)
- return (ARCHIVE_WARN);
+ /* Set remaining fields to blank. */
+ for (n = fields; n < 4; ++n)
+ field[n].start = field[n].end = NULL;
/* Check for a numeric ID in field 1 or 3. */
id = -1;
@@ -1511,54 +1666,58 @@ __archive_entry_acl_parse_w(struct archive_entry *entry,
if (id == -1 && fields > 3)
isint_w(field[3].start, field[3].end, &id);
- /* Parse the permissions from field 2. */
- permset = 0;
- p = field[2].start;
- while (p < field[2].end) {
- switch (*p++) {
- case 'r': case 'R':
- permset |= ARCHIVE_ENTRY_ACL_READ;
- break;
- case 'w': case 'W':
- permset |= ARCHIVE_ENTRY_ACL_WRITE;
- break;
- case 'x': case 'X':
- permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
- break;
- case '-':
- break;
- default:
- return (ARCHIVE_WARN);
- }
- }
-
/*
* Solaris extension: "defaultuser::rwx" is the
* default ACL corresponding to "user::rwx", etc.
*/
- if (field[0].end-field[0].start > 7
+ if (field[0].end - field[0].start > 7
&& wmemcmp(field[0].start, L"default", 7) == 0) {
type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;
field[0].start += 7;
} else
type = default_type;
+ name.start = name.end = NULL;
if (prefix_w(field[0].start, field[0].end, L"user")) {
- if (id != -1 || field[1].start < field[1].end)
+ if (!ismode_w(field[2].start, field[2].end, &permset))
+ return (ARCHIVE_WARN);
+ if (id != -1 || field[1].start < field[1].end) {
tag = ARCHIVE_ENTRY_ACL_USER;
- else
+ name = field[1];
+ } else
tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
} else if (prefix_w(field[0].start, field[0].end, L"group")) {
- if (id != -1 || field[1].start < field[1].end)
+ if (!ismode_w(field[2].start, field[2].end, &permset))
+ return (ARCHIVE_WARN);
+ if (id != -1 || field[1].start < field[1].end) {
tag = ARCHIVE_ENTRY_ACL_GROUP;
- else
+ name = field[1];
+ } else
tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
} else if (prefix_w(field[0].start, field[0].end, L"other")) {
- if (id != -1 || field[1].start < field[1].end)
+ if (fields == 2
+ && field[1].start < field[1].end
+ && ismode_w(field[1].start, field[1].end, &permset)) {
+ /* This is Solaris-style "other:rwx" */
+ } else if (fields == 3
+ && field[1].start == field[1].end
+ && field[2].start < field[2].end
+ && ismode_w(field[2].start, field[2].end, &permset)) {
+ /* This is FreeBSD-style "other::rwx" */
+ } else
return (ARCHIVE_WARN);
tag = ARCHIVE_ENTRY_ACL_OTHER;
} else if (prefix_w(field[0].start, field[0].end, L"mask")) {
- if (id != -1 || field[1].start < field[1].end)
+ if (fields == 2
+ && field[1].start < field[1].end
+ && ismode_w(field[1].start, field[1].end, &permset)) {
+ /* This is Solaris-style "mask:rwx" */
+ } else if (fields == 3
+ && field[1].start == field[1].end
+ && field[2].start < field[2].end
+ && ismode_w(field[2].start, field[2].end, &permset)) {
+ /* This is FreeBSD-style "mask::rwx" */
+ } else
return (ARCHIVE_WARN);
tag = ARCHIVE_ENTRY_ACL_MASK;
} else
@@ -1566,104 +1725,12 @@ __archive_entry_acl_parse_w(struct archive_entry *entry,
/* Add entry to the internal list. */
archive_entry_acl_add_entry_w_len(entry, type, permset,
- tag, id, field[1].start, field[1].end - field[1].start);
+ tag, id, name.start, name.end - name.start);
}
return (ARCHIVE_OK);
}
/*
- * extended attribute handling
- */
-
-void
-archive_entry_xattr_clear(struct archive_entry *entry)
-{
- struct ae_xattr *xp;
-
- while (entry->xattr_head != NULL) {
- xp = entry->xattr_head->next;
- free(entry->xattr_head->name);
- free(entry->xattr_head->value);
- free(entry->xattr_head);
- entry->xattr_head = xp;
- }
-
- entry->xattr_head = NULL;
-}
-
-void
-archive_entry_xattr_add_entry(struct archive_entry *entry,
- const char *name, const void *value, size_t size)
-{
- struct ae_xattr *xp;
-
- for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
- ;
-
- if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL)
- /* XXX Error XXX */
- return;
-
- xp->name = strdup(name);
- if ((xp->value = malloc(size)) != NULL) {
- memcpy(xp->value, value, size);
- xp->size = size;
- } else
- xp->size = 0;
-
- xp->next = entry->xattr_head;
- entry->xattr_head = xp;
-}
-
-
-/*
- * returns number of the extended attribute entries
- */
-int
-archive_entry_xattr_count(struct archive_entry *entry)
-{
- struct ae_xattr *xp;
- int count = 0;
-
- for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
- count++;
-
- return count;
-}
-
-int
-archive_entry_xattr_reset(struct archive_entry * entry)
-{
- entry->xattr_p = entry->xattr_head;
-
- return archive_entry_xattr_count(entry);
-}
-
-int
-archive_entry_xattr_next(struct archive_entry * entry,
- const char **name, const void **value, size_t *size)
-{
- if (entry->xattr_p) {
- *name = entry->xattr_p->name;
- *value = entry->xattr_p->value;
- *size = entry->xattr_p->size;
-
- entry->xattr_p = entry->xattr_p->next;
-
- return (ARCHIVE_OK);
- } else {
- *name = NULL;
- *value = NULL;
- *size = (size_t)0;
- return (ARCHIVE_WARN);
- }
-}
-
-/*
- * end of xattr handling
- */
-
-/*
* Parse a string to a positive decimal integer. Returns true if
* the string is non-empty and consists only of decimal digits,
* false otherwise.
@@ -1690,6 +1757,40 @@ isint_w(const wchar_t *start, const wchar_t *end, int *result)
}
/*
+ * Parse a string as a mode field. Returns true if
+ * the string is non-empty and consists only of mode characters,
+ * false otherwise.
+ */
+static int
+ismode_w(const wchar_t *start, const wchar_t *end, int *permset)
+{
+ const wchar_t *p;
+
+ if (start >= end)
+ return (0);
+ p = start;
+ *permset = 0;
+ while (p < end) {
+ switch (*p++) {
+ case 'r': case 'R':
+ *permset |= ARCHIVE_ENTRY_ACL_READ;
+ break;
+ case 'w': case 'W':
+ *permset |= ARCHIVE_ENTRY_ACL_WRITE;
+ break;
+ case 'x': case 'X':
+ *permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+ break;
+ case '-':
+ break;
+ default:
+ return (0);
+ }
+ }
+ return (1);
+}
+
+/*
* Match "[:whitespace:]*(.*)[:whitespace:]*[:,\n]". *wp is updated
* to point to just after the separator. *start points to the first
* character of the matched text and *end just after the last
@@ -1841,6 +1942,18 @@ static struct flag {
{ "nouunlnk", L"nouunlnk", UF_NOUNLINK, 0 },
{ "nouunlink", L"nouunlink", UF_NOUNLINK, 0 },
#endif
+#ifdef EXT2_UNRM_FL
+ { "nouunlink", L"nouunlink", EXT2_UNRM_FL, 0},
+#endif
+
+#ifdef EXT2_BTREE_FL
+ { "nobtree", L"nobtree", EXT2_BTREE_FL, 0 },
+#endif
+
+#ifdef EXT2_ECOMPR_FL
+ { "nocomperr", L"nocomperr", EXT2_ECOMPR_FL, 0 },
+#endif
+
#ifdef EXT2_COMPR_FL /* 'c' */
{ "nocompress", L"nocompress", EXT2_COMPR_FL, 0 },
#endif
@@ -1848,6 +1961,46 @@ static struct flag {
#ifdef EXT2_NOATIME_FL /* 'A' */
{ "noatime", L"noatime", 0, EXT2_NOATIME_FL},
#endif
+
+#ifdef EXT2_DIRTY_FL
+ { "nocompdirty",L"nocompdirty", EXT2_DIRTY_FL, 0},
+#endif
+
+#ifdef EXT2_COMPRBLK_FL
+#ifdef EXT2_NOCOMPR_FL
+ { "nocomprblk", L"nocomprblk", EXT2_COMPRBLK_FL, EXT2_NOCOMPR_FL},
+#else
+ { "nocomprblk", L"nocomprblk", EXT2_COMPRBLK_FL, 0},
+#endif
+#endif
+#ifdef EXT2_DIRSYNC_FL
+ { "nodirsync", L"nodirsync", EXT2_DIRSYNC_FL, 0},
+#endif
+#ifdef EXT2_INDEX_FL
+ { "nohashidx", L"nohashidx", EXT2_INDEX_FL, 0},
+#endif
+#ifdef EXT2_IMAGIC_FL
+ { "noimagic", L"noimagic", EXT2_IMAGIC_FL, 0},
+#endif
+#ifdef EXT3_JOURNAL_DATA_FL
+ { "nojournal", L"nojournal", EXT3_JOURNAL_DATA_FL, 0},
+#endif
+#ifdef EXT2_SECRM_FL
+ { "nosecuredeletion",L"nosecuredeletion",EXT2_SECRM_FL, 0},
+#endif
+#ifdef EXT2_SYNC_FL
+ { "nosync", L"nosync", EXT2_SYNC_FL, 0},
+#endif
+#ifdef EXT2_NOTAIL_FL
+ { "notail", L"notail", 0, EXT2_NOTAIL_FL},
+#endif
+#ifdef EXT2_TOPDIR_FL
+ { "notopdir", L"notopdir", EXT2_TOPDIR_FL, 0},
+#endif
+#ifdef EXT2_RESERVED_FL
+ { "noreserved", L"noreserved", EXT2_RESERVED_FL, 0},
+#endif
+
{ NULL, NULL, 0, 0 }
};
diff --git a/archivers/libarchive/files/libarchive/archive_entry.h b/archivers/libarchive/files/libarchive/archive_entry.h
index ee96c56a79d..d5728179eb7 100644
--- a/archivers/libarchive/files/libarchive/archive_entry.h
+++ b/archivers/libarchive/files/libarchive/archive_entry.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2008 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.27 2008/05/26 17:00:22 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_entry.h 201096 2009-12-28 02:41:27Z kientzle $
*/
#ifndef ARCHIVE_ENTRY_H_INCLUDED
@@ -40,15 +40,28 @@
#include <stddef.h> /* for wchar_t */
#include <time.h>
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+#endif
+
/* Get appropriate definitions of standard POSIX-style types. */
/* These should match the types used in 'struct stat' */
-#ifdef _WIN32
-#define __LA_UID_T unsigned int
-#define __LA_GID_T unsigned int
-#define __LA_DEV_T unsigned int
-#define __LA_MODE_T unsigned short
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define __LA_INT64_T __int64
+# if defined(__BORLANDC__)
+# define __LA_UID_T uid_t
+# define __LA_GID_T gid_t
+# define __LA_DEV_T dev_t
+# define __LA_MODE_T mode_t
+# else
+# define __LA_UID_T short
+# define __LA_GID_T short
+# define __LA_DEV_T unsigned int
+# define __LA_MODE_T unsigned short
+# endif
#else
#include <unistd.h>
+#define __LA_INT64_T int64_t
#define __LA_UID_T uid_t
#define __LA_GID_T gid_t
#define __LA_DEV_T dev_t
@@ -69,7 +82,7 @@
* .lib. The default here assumes you're building a DLL. Only
* libarchive source should ever define __LIBARCHIVE_BUILD.
*/
-#if ((defined __WIN32__) || (defined _WIN32)) && (!defined LIBARCHIVE_STATIC)
+#if ((defined __WIN32__) || (defined _WIN32) || defined(__CYGWIN__)) && (!defined LIBARCHIVE_STATIC)
# ifdef __LIBARCHIVE_BUILD
# ifdef __GNUC__
# define __LA_DECL __attribute__((dllexport)) extern
@@ -152,12 +165,32 @@ __LA_DECL struct archive_entry *archive_entry_new(void);
/*
* Retrieve fields from an archive_entry.
+ *
+ * There are a number of implicit conversions among these fields. For
+ * example, if a regular string field is set and you read the _w wide
+ * character field, the entry will implicitly convert narrow-to-wide
+ * using the current locale. Similarly, dev values are automatically
+ * updated when you write devmajor or devminor and vice versa.
+ *
+ * In addition, fields can be "set" or "unset." Unset string fields
+ * return NULL, non-string fields have _is_set() functions to test
+ * whether they've been set. You can "unset" a string field by
+ * assigning NULL; non-string fields have _unset() functions to
+ * unset them.
+ *
+ * Note: There is one ambiguity in the above; string fields will
+ * also return NULL when implicit character set conversions fail.
+ * This is usually what you want.
*/
-
__LA_DECL time_t archive_entry_atime(struct archive_entry *);
__LA_DECL long archive_entry_atime_nsec(struct archive_entry *);
+__LA_DECL int archive_entry_atime_is_set(struct archive_entry *);
+__LA_DECL time_t archive_entry_birthtime(struct archive_entry *);
+__LA_DECL long archive_entry_birthtime_nsec(struct archive_entry *);
+__LA_DECL int archive_entry_birthtime_is_set(struct archive_entry *);
__LA_DECL time_t archive_entry_ctime(struct archive_entry *);
__LA_DECL long archive_entry_ctime_nsec(struct archive_entry *);
+__LA_DECL int archive_entry_ctime_is_set(struct archive_entry *);
__LA_DECL dev_t archive_entry_dev(struct archive_entry *);
__LA_DECL dev_t archive_entry_devmajor(struct archive_entry *);
__LA_DECL dev_t archive_entry_devminor(struct archive_entry *);
@@ -172,9 +205,11 @@ __LA_DECL const wchar_t *archive_entry_gname_w(struct archive_entry *);
__LA_DECL const char *archive_entry_hardlink(struct archive_entry *);
__LA_DECL const wchar_t *archive_entry_hardlink_w(struct archive_entry *);
__LA_DECL __LA_INO_T archive_entry_ino(struct archive_entry *);
+__LA_DECL __LA_INT64_T archive_entry_ino64(struct archive_entry *);
__LA_DECL __LA_MODE_T archive_entry_mode(struct archive_entry *);
__LA_DECL time_t archive_entry_mtime(struct archive_entry *);
__LA_DECL long archive_entry_mtime_nsec(struct archive_entry *);
+__LA_DECL int archive_entry_mtime_is_set(struct archive_entry *);
__LA_DECL unsigned int archive_entry_nlink(struct archive_entry *);
__LA_DECL const char *archive_entry_pathname(struct archive_entry *);
__LA_DECL const wchar_t *archive_entry_pathname_w(struct archive_entry *);
@@ -182,7 +217,8 @@ __LA_DECL dev_t archive_entry_rdev(struct archive_entry *);
__LA_DECL dev_t archive_entry_rdevmajor(struct archive_entry *);
__LA_DECL dev_t archive_entry_rdevminor(struct archive_entry *);
__LA_DECL const char *archive_entry_sourcepath(struct archive_entry *);
-__LA_DECL int64_t archive_entry_size(struct archive_entry *);
+__LA_DECL __LA_INT64_T archive_entry_size(struct archive_entry *);
+__LA_DECL int archive_entry_size_is_set(struct archive_entry *);
__LA_DECL const char *archive_entry_strmode(struct archive_entry *);
__LA_DECL const char *archive_entry_symlink(struct archive_entry *);
__LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *);
@@ -195,10 +231,22 @@ __LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);
*
* Note that string 'set' functions do not copy the string, only the pointer.
* In contrast, 'copy' functions do copy the object pointed to.
+ *
+ * Note: As of libarchive 2.4, 'set' functions do copy the string and
+ * are therefore exact synonyms for the 'copy' versions. The 'copy'
+ * names will be retired in libarchive 3.0.
*/
__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_unset_atime(struct archive_entry *);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *,
+ BY_HANDLE_FILE_INFORMATION *);
+#endif
+__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_unset_birthtime(struct archive_entry *);
__LA_DECL void archive_entry_set_ctime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_unset_ctime(struct archive_entry *);
__LA_DECL void archive_entry_set_dev(struct archive_entry *, dev_t);
__LA_DECL void archive_entry_set_devmajor(struct archive_entry *, dev_t);
__LA_DECL void archive_entry_set_devminor(struct archive_entry *, dev_t);
@@ -219,13 +267,21 @@ __LA_DECL int archive_entry_update_gname_utf8(struct archive_entry *, const char
__LA_DECL void archive_entry_set_hardlink(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_hardlink(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_hardlink_w(struct archive_entry *, const wchar_t *);
+__LA_DECL int archive_entry_update_hardlink_utf8(struct archive_entry *, const char *);
+#if ARCHIVE_VERSION_NUMBER >= 3000000
+/* Starting with libarchive 3.0, this will be synonym for ino64. */
+__LA_DECL void archive_entry_set_ino(struct archive_entry *, __LA_INT64_T);
+#else
__LA_DECL void archive_entry_set_ino(struct archive_entry *, unsigned long);
+#endif
+__LA_DECL void archive_entry_set_ino64(struct archive_entry *, __LA_INT64_T);
__LA_DECL void archive_entry_set_link(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_link(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_link_w(struct archive_entry *, const wchar_t *);
__LA_DECL int archive_entry_update_link_utf8(struct archive_entry *, const char *);
__LA_DECL void archive_entry_set_mode(struct archive_entry *, __LA_MODE_T);
__LA_DECL void archive_entry_set_mtime(struct archive_entry *, time_t, long);
+__LA_DECL void archive_entry_unset_mtime(struct archive_entry *);
__LA_DECL void archive_entry_set_nlink(struct archive_entry *, unsigned int);
__LA_DECL void archive_entry_set_pathname(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_pathname(struct archive_entry *, const char *);
@@ -235,11 +291,13 @@ __LA_DECL void archive_entry_set_perm(struct archive_entry *, __LA_MODE_T);
__LA_DECL void archive_entry_set_rdev(struct archive_entry *, dev_t);
__LA_DECL void archive_entry_set_rdevmajor(struct archive_entry *, dev_t);
__LA_DECL void archive_entry_set_rdevminor(struct archive_entry *, dev_t);
-__LA_DECL void archive_entry_set_size(struct archive_entry *, int64_t);
+__LA_DECL void archive_entry_set_size(struct archive_entry *, __LA_INT64_T);
+__LA_DECL void archive_entry_unset_size(struct archive_entry *);
__LA_DECL void archive_entry_copy_sourcepath(struct archive_entry *, const char *);
__LA_DECL void archive_entry_set_symlink(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_symlink(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_symlink_w(struct archive_entry *, const wchar_t *);
+__LA_DECL int archive_entry_update_symlink_utf8(struct archive_entry *, const char *);
__LA_DECL void archive_entry_set_uid(struct archive_entry *, __LA_UID_T);
__LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *);
@@ -257,6 +315,7 @@ __LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char
__LA_DECL const struct stat *archive_entry_stat(struct archive_entry *);
__LA_DECL void archive_entry_copy_stat(struct archive_entry *, const struct stat *);
+
/*
* ACL routines. This used to simply store and return text-format ACL
* strings, but that proved insufficient for a number of reasons:
@@ -406,7 +465,7 @@ __LA_DECL int archive_entry_xattr_next(struct archive_entry *,
* Note that archive_entry_size() is reset to zero if the file
* body should not be written to the archive. Pay attention!
*/
-__LA_DECL struct archive_entry_linkresolver;
+struct archive_entry_linkresolver;
/*
* There are three different strategies for marking hardlinks.
diff --git a/archivers/libarchive/files/libarchive/archive_entry_copy_bhfi.c b/archivers/libarchive/files/libarchive/archive_entry_copy_bhfi.c
new file mode 100644
index 00000000000..8339032c5c3
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_entry_copy_bhfi.c
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD$");
+
+#include "archive_private.h"
+#include "archive_entry.h"
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
+
+__inline static void
+fileTimeToUtc(const FILETIME *filetime, time_t *time, long *ns)
+{
+ ULARGE_INTEGER utc;
+
+ utc.HighPart = filetime->dwHighDateTime;
+ utc.LowPart = filetime->dwLowDateTime;
+ if (utc.QuadPart >= EPOC_TIME) {
+ utc.QuadPart -= EPOC_TIME;
+ *time = (time_t)(utc.QuadPart / 10000000); /* milli seconds base */
+ *ns = (long)(utc.QuadPart % 10000000) * 100;/* nano seconds base */
+ } else {
+ *time = 0;
+ *ns = 0;
+ }
+}
+
+void
+archive_entry_copy_bhfi(struct archive_entry *entry,
+ BY_HANDLE_FILE_INFORMATION *bhfi)
+{
+ time_t secs;
+ long nsecs;
+
+ fileTimeToUtc(&bhfi->ftLastAccessTime, &secs, &nsecs);
+ archive_entry_set_atime(entry, secs, nsecs);
+ fileTimeToUtc(&bhfi->ftLastWriteTime, &secs, &nsecs);
+ archive_entry_set_mtime(entry, secs, nsecs);
+ fileTimeToUtc(&bhfi->ftCreationTime, &secs, &nsecs);
+ archive_entry_set_birthtime(entry, secs, nsecs);
+ archive_entry_set_dev(entry, bhfi->dwVolumeSerialNumber);
+ archive_entry_set_ino64(entry, (((int64_t)bhfi->nFileIndexHigh) << 32)
+ + bhfi->nFileIndexLow);
+ archive_entry_set_nlink(entry, bhfi->nNumberOfLinks);
+ archive_entry_set_size(entry, (((int64_t)bhfi->nFileSizeHigh) << 32)
+ + bhfi->nFileSizeLow);
+// archive_entry_set_mode(entry, st->st_mode);
+}
+#endif
diff --git a/archivers/libarchive/files/libarchive/archive_entry_copy_stat.c b/archivers/libarchive/files/libarchive/archive_entry_copy_stat.c
index 514db02743b..ef59a5e78a0 100644
--- a/archivers/libarchive/files/libarchive/archive_entry_copy_stat.c
+++ b/archivers/libarchive/files/libarchive/archive_entry_copy_stat.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_copy_stat.c,v 1.1 2007/05/29 01:00:18 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_copy_stat.c 189466 2009-03-07 00:52:02Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -43,10 +43,28 @@ archive_entry_copy_stat(struct archive_entry *entry, const struct stat *st)
archive_entry_set_atime(entry, st->st_atime, st->st_atim.tv_nsec);
archive_entry_set_ctime(entry, st->st_ctime, st->st_ctim.tv_nsec);
archive_entry_set_mtime(entry, st->st_mtime, st->st_mtim.tv_nsec);
+#elif HAVE_STRUCT_STAT_ST_MTIME_N
+ archive_entry_set_atime(entry, st->st_atime, st->st_atime_n);
+ archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_n);
+ archive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_n);
+#elif HAVE_STRUCT_STAT_ST_UMTIME
+ archive_entry_set_atime(entry, st->st_atime, st->st_uatime * 1000);
+ archive_entry_set_ctime(entry, st->st_ctime, st->st_uctime * 1000);
+ archive_entry_set_mtime(entry, st->st_mtime, st->st_umtime * 1000);
+#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
+ archive_entry_set_atime(entry, st->st_atime, st->st_atime_usec * 1000);
+ archive_entry_set_ctime(entry, st->st_ctime, st->st_ctime_usec * 1000);
+ archive_entry_set_mtime(entry, st->st_mtime, st->st_mtime_usec * 1000);
#else
archive_entry_set_atime(entry, st->st_atime, 0);
archive_entry_set_ctime(entry, st->st_ctime, 0);
archive_entry_set_mtime(entry, st->st_mtime, 0);
+#if HAVE_STRUCT_STAT_ST_BIRTHTIME
+ archive_entry_set_birthtime(entry, st->st_birthtime, 0);
+#endif
+#endif
+#if HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
+ archive_entry_set_birthtime(entry, st->st_birthtime, st->st_birthtimespec.tv_nsec);
#endif
archive_entry_set_dev(entry, st->st_dev);
archive_entry_set_gid(entry, st->st_gid);
diff --git a/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c b/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c
index 4deee260d49..3b13e19c8bf 100644
--- a/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c
+++ b/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_link_resolver.c,v 1.3 2008/06/15 04:31:43 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_link_resolver.c 201100 2009-12-28 03:05:31Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -181,15 +181,17 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
/* If it has only one link, then we're done. */
if (archive_entry_nlink(*e) == 1)
return;
- /* Directories never have hardlinks. */
- if (archive_entry_filetype(*e) == AE_IFDIR)
+ /* Directories, devices never have hardlinks. */
+ if (archive_entry_filetype(*e) == AE_IFDIR
+ || archive_entry_filetype(*e) == AE_IFBLK
+ || archive_entry_filetype(*e) == AE_IFCHR)
return;
switch (res->strategy) {
case ARCHIVE_ENTRY_LINKIFY_LIKE_TAR:
le = find_entry(res, *e);
if (le != NULL) {
- archive_entry_set_size(*e, 0);
+ archive_entry_unset_size(*e);
archive_entry_copy_hardlink(*e,
archive_entry_pathname(le->canonical));
} else
@@ -217,7 +219,7 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
*e = le->entry;
le->entry = t;
/* Make the old entry into a hardlink. */
- archive_entry_set_size(*e, 0);
+ archive_entry_unset_size(*e);
archive_entry_copy_hardlink(*e,
archive_entry_pathname(le->canonical));
/* If we ran out of links, return the
@@ -249,7 +251,7 @@ find_entry(struct archive_entry_linkresolver *res,
struct links_entry *le;
int hash, bucket;
dev_t dev;
- ino_t ino;
+ int64_t ino;
/* Free a held entry. */
if (res->spare != NULL) {
@@ -264,15 +266,15 @@ find_entry(struct archive_entry_linkresolver *res,
return (NULL);
dev = archive_entry_dev(entry);
- ino = archive_entry_ino(entry);
- hash = dev ^ ino;
+ ino = archive_entry_ino64(entry);
+ hash = (int)(dev ^ ino);
/* Try to locate this entry in the links cache. */
bucket = hash % res->number_buckets;
for (le = res->buckets[bucket]; le != NULL; le = le->next) {
if (le->hash == hash
&& dev == archive_entry_dev(le->canonical)
- && ino == archive_entry_ino(le->canonical)) {
+ && ino == archive_entry_ino64(le->canonical)) {
/*
* Decrement link count each time and release
* the entry if it hits zero. This saves
@@ -350,7 +352,7 @@ insert_entry(struct archive_entry_linkresolver *res,
if (res->number_entries > res->number_buckets * 2)
grow_hash(res);
- hash = archive_entry_dev(entry) ^ archive_entry_ino(entry);
+ hash = archive_entry_dev(entry) ^ archive_entry_ino64(entry);
bucket = hash % res->number_buckets;
/* If we could allocate the entry, record it. */
diff --git a/archivers/libarchive/files/libarchive/archive_entry_private.h b/archivers/libarchive/files/libarchive/archive_entry_private.h
index 0289290b198..5ab4f75f0bc 100644
--- a/archivers/libarchive/files/libarchive/archive_entry_private.h
+++ b/archivers/libarchive/files/libarchive/archive_entry_private.h
@@ -22,9 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_entry_private.h,v 1.4 2008/05/26 17:00:22 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_entry_private.h 201096 2009-12-28 02:41:27Z kientzle $
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
#ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
#define ARCHIVE_ENTRY_PRIVATE_H_INCLUDED
@@ -112,8 +116,10 @@ struct archive_entry {
uint32_t aest_ctime_nsec;
int64_t aest_mtime;
uint32_t aest_mtime_nsec;
+ int64_t aest_birthtime;
+ uint32_t aest_birthtime_nsec;
gid_t aest_gid;
- ino_t aest_ino;
+ int64_t aest_ino;
mode_t aest_mode;
uint32_t aest_nlink;
uint64_t aest_size;
@@ -136,6 +142,15 @@ struct archive_entry {
dev_t aest_rdevminor;
} ae_stat;
+ int ae_set; /* bitmap of fields that are currently set */
+#define AE_SET_HARDLINK 1
+#define AE_SET_SYMLINK 2
+#define AE_SET_ATIME 4
+#define AE_SET_CTIME 8
+#define AE_SET_MTIME 16
+#define AE_SET_BIRTHTIME 32
+#define AE_SET_SIZE 64
+
/*
* Use aes here so that we get transparent mbs<->wcs conversions.
*/
@@ -147,8 +162,6 @@ struct archive_entry {
struct aes ae_pathname; /* Name of entry */
struct aes ae_symlink; /* symlink contents */
struct aes ae_uname; /* Name of owner */
- unsigned char ae_hardlinkset;
- unsigned char ae_symlinkset;
/* Not used within libarchive; useful for some clients. */
struct aes ae_sourcepath; /* Path this entry is sourced from. */
diff --git a/archivers/libarchive/files/libarchive/archive_entry_stat.c b/archivers/libarchive/files/libarchive/archive_entry_stat.c
index 6ef5b37287f..ad772c9564b 100644
--- a/archivers/libarchive/files/libarchive/archive_entry_stat.c
+++ b/archivers/libarchive/files/libarchive/archive_entry_stat.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_stat.c,v 1.1 2007/05/29 01:00:18 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_stat.c 201100 2009-12-28 03:05:31Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -64,12 +64,15 @@ archive_entry_stat(struct archive_entry *entry)
* the appropriate conversions get invoked.
*/
st->st_atime = archive_entry_atime(entry);
+#if HAVE_STRUCT_STAT_ST_BIRTHTIME
+ st->st_birthtime = archive_entry_birthtime(entry);
+#endif
st->st_ctime = archive_entry_ctime(entry);
st->st_mtime = archive_entry_mtime(entry);
st->st_dev = archive_entry_dev(entry);
st->st_gid = archive_entry_gid(entry);
st->st_uid = archive_entry_uid(entry);
- st->st_ino = archive_entry_ino(entry);
+ st->st_ino = archive_entry_ino64(entry);
st->st_nlink = archive_entry_nlink(entry);
st->st_rdev = archive_entry_rdev(entry);
st->st_size = archive_entry_size(entry);
@@ -87,6 +90,21 @@ archive_entry_stat(struct archive_entry *entry)
st->st_atim.tv_nsec = archive_entry_atime_nsec(entry);
st->st_ctim.tv_nsec = archive_entry_ctime_nsec(entry);
st->st_mtim.tv_nsec = archive_entry_mtime_nsec(entry);
+#elif HAVE_STRUCT_STAT_ST_MTIME_N
+ st->st_atime_n = archive_entry_atime_nsec(entry);
+ st->st_ctime_n = archive_entry_ctime_nsec(entry);
+ st->st_mtime_n = archive_entry_mtime_nsec(entry);
+#elif HAVE_STRUCT_STAT_ST_UMTIME
+ st->st_uatime = archive_entry_atime_nsec(entry) / 1000;
+ st->st_uctime = archive_entry_ctime_nsec(entry) / 1000;
+ st->st_umtime = archive_entry_mtime_nsec(entry) / 1000;
+#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
+ st->st_atime_usec = archive_entry_atime_nsec(entry) / 1000;
+ st->st_ctime_usec = archive_entry_ctime_nsec(entry) / 1000;
+ st->st_mtime_usec = archive_entry_mtime_nsec(entry) / 1000;
+#endif
+#if HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC
+ st->st_birthtimespec.tv_nsec = archive_entry_birthtime_nsec(entry);
#endif
/*
diff --git a/archivers/libarchive/files/libarchive/archive_entry_xattr.c b/archivers/libarchive/files/libarchive/archive_entry_xattr.c
new file mode 100644
index 00000000000..a3efe7ca8d9
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_entry_xattr.c
@@ -0,0 +1,158 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_entry_xattr.c 201096 2009-12-28 02:41:27Z kientzle $");
+
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_LINUX_FS_H
+#include <linux/fs.h> /* for Linux file flags */
+#endif
+/*
+ * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.
+ * As the include guards don't agree, the order of include is important.
+ */
+#ifdef HAVE_LINUX_EXT2_FS_H
+#include <linux/ext2_fs.h> /* for Linux file flags */
+#endif
+#if defined(HAVE_EXT2FS_EXT2_FS_H) && !defined(__CYGWIN__)
+#include <ext2fs/ext2_fs.h> /* for Linux file flags */
+#endif
+#include <stddef.h>
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_WCHAR_H
+#include <wchar.h>
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_entry_private.h"
+
+/*
+ * extended attribute handling
+ */
+
+void
+archive_entry_xattr_clear(struct archive_entry *entry)
+{
+ struct ae_xattr *xp;
+
+ while (entry->xattr_head != NULL) {
+ xp = entry->xattr_head->next;
+ free(entry->xattr_head->name);
+ free(entry->xattr_head->value);
+ free(entry->xattr_head);
+ entry->xattr_head = xp;
+ }
+
+ entry->xattr_head = NULL;
+}
+
+void
+archive_entry_xattr_add_entry(struct archive_entry *entry,
+ const char *name, const void *value, size_t size)
+{
+ struct ae_xattr *xp;
+
+ for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
+ ;
+
+ if ((xp = (struct ae_xattr *)malloc(sizeof(struct ae_xattr))) == NULL)
+ /* XXX Error XXX */
+ return;
+
+ xp->name = strdup(name);
+ if ((xp->value = malloc(size)) != NULL) {
+ memcpy(xp->value, value, size);
+ xp->size = size;
+ } else
+ xp->size = 0;
+
+ xp->next = entry->xattr_head;
+ entry->xattr_head = xp;
+}
+
+
+/*
+ * returns number of the extended attribute entries
+ */
+int
+archive_entry_xattr_count(struct archive_entry *entry)
+{
+ struct ae_xattr *xp;
+ int count = 0;
+
+ for (xp = entry->xattr_head; xp != NULL; xp = xp->next)
+ count++;
+
+ return count;
+}
+
+int
+archive_entry_xattr_reset(struct archive_entry * entry)
+{
+ entry->xattr_p = entry->xattr_head;
+
+ return archive_entry_xattr_count(entry);
+}
+
+int
+archive_entry_xattr_next(struct archive_entry * entry,
+ const char **name, const void **value, size_t *size)
+{
+ if (entry->xattr_p) {
+ *name = entry->xattr_p->name;
+ *value = entry->xattr_p->value;
+ *size = entry->xattr_p->size;
+
+ entry->xattr_p = entry->xattr_p->next;
+
+ return (ARCHIVE_OK);
+ } else {
+ *name = NULL;
+ *value = NULL;
+ *size = (size_t)0;
+ return (ARCHIVE_WARN);
+ }
+}
+
+/*
+ * end of xattr handling
+ */
diff --git a/archivers/libarchive/files/libarchive/archive_hash.h b/archivers/libarchive/files/libarchive/archive_hash.h
new file mode 100644
index 00000000000..1a3b3344dc8
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_hash.h
@@ -0,0 +1,196 @@
+/*-
+ * Copyright (c) 2009 Joerg Sonnenberger
+ * 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.
+ *
+ * $FreeBSD: head/lib/libarchive/archive_hash.h 201171 2009-12-29 06:39:07Z kientzle $
+ */
+
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
+/*
+ * Hash function support in various Operating Systems:
+ *
+ * NetBSD:
+ * - MD5 and SHA1 in libc: without _ after algorithm name
+ * - SHA2 in libc: with _ after algorithm name
+ *
+ * OpenBSD:
+ * - MD5, SHA1 and SHA2 in libc: without _ after algorithm name
+ * - OpenBSD 4.4 and earlier have SHA2 in libc with _ after algorithm name
+ *
+ * DragonFly and FreeBSD (XXX not used yet):
+ * - MD5 and SHA1 in libmd: without _ after algorithm name
+ * - SHA256: with _ after algorithm name
+ *
+ * OpenSSL:
+ * - MD5, SHA1 and SHA2 in libcrypto: with _ after algorithm name
+ */
+
+#if defined(HAVE_MD5_H) && defined(HAVE_MD5INIT)
+# include <md5.h>
+# define ARCHIVE_HAS_MD5
+typedef MD5_CTX archive_md5_ctx;
+# define archive_md5_init(ctx) MD5Init(ctx)
+# define archive_md5_final(ctx, buf) MD5Final(buf, ctx)
+# define archive_md5_update(ctx, buf, n) MD5Update(ctx, buf, n)
+#elif defined(HAVE_OPENSSL_MD5_H)
+# include <openssl/md5.h>
+# define ARCHIVE_HAS_MD5
+typedef MD5_CTX archive_md5_ctx;
+# define archive_md5_init(ctx) MD5_Init(ctx)
+# define archive_md5_final(ctx, buf) MD5_Final(buf, ctx)
+# define archive_md5_update(ctx, buf, n) MD5_Update(ctx, buf, n)
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_MD5)
+# define ARCHIVE_HAS_MD5
+typedef MD5_CTX archive_md5_ctx;
+# define archive_md5_init(ctx) MD5_Init(ctx)
+# define archive_md5_final(ctx, buf) MD5_Final(buf, ctx)
+# define archive_md5_update(ctx, buf, n) MD5_Update(ctx, buf, n)
+#endif
+
+#if defined(HAVE_RMD160_H) && defined(HAVE_RMD160INIT)
+# include <rmd160.h>
+# define ARCHIVE_HAS_RMD160
+typedef RMD160_CTX archive_rmd160_ctx;
+# define archive_rmd160_init(ctx) RMD160Init(ctx)
+# define archive_rmd160_final(ctx, buf) RMD160Final(buf, ctx)
+# define archive_rmd160_update(ctx, buf, n) RMD160Update(ctx, buf, n)
+#elif defined(HAVE_OPENSSL_RIPEMD_H)
+# include <openssl/ripemd.h>
+# define ARCHIVE_HAS_RMD160
+typedef RIPEMD160_CTX archive_rmd160_ctx;
+# define archive_rmd160_init(ctx) RIPEMD160_Init(ctx)
+# define archive_rmd160_final(ctx, buf) RIPEMD160_Final(buf, ctx)
+# define archive_rmd160_update(ctx, buf, n) RIPEMD160_Update(ctx, buf, n)
+#endif
+
+#if defined(HAVE_SHA1_H) && defined(HAVE_SHA1INIT)
+# include <sha1.h>
+# define ARCHIVE_HAS_SHA1
+typedef SHA1_CTX archive_sha1_ctx;
+# define archive_sha1_init(ctx) SHA1Init(ctx)
+# define archive_sha1_final(ctx, buf) SHA1Final(buf, ctx)
+# define archive_sha1_update(ctx, buf, n) SHA1Update(ctx, buf, n)
+#elif defined(HAVE_OPENSSL_SHA_H)
+# include <openssl/sha.h>
+# define ARCHIVE_HAS_SHA1
+typedef SHA_CTX archive_sha1_ctx;
+# define archive_sha1_init(ctx) SHA1_Init(ctx)
+# define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx)
+# define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n)
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA1)
+# define ARCHIVE_HAS_SHA1
+typedef SHA1_CTX archive_sha1_ctx;
+# define archive_sha1_init(ctx) SHA1_Init(ctx)
+# define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx)
+# define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n)
+#endif
+
+#if defined(HAVE_SHA2_H) && defined(HAVE_SHA256_INIT)
+# include <sha2.h>
+# define ARCHIVE_HAS_SHA256
+typedef SHA256_CTX archive_sha256_ctx;
+# define archive_sha256_init(ctx) SHA256_Init(ctx)
+# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx)
+# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n)
+#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA256INIT)
+# include <sha2.h>
+# define ARCHIVE_HAS_SHA256
+typedef SHA256_CTX archive_sha256_ctx;
+# define archive_sha256_init(ctx) SHA256Init(ctx)
+# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx)
+# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n)
+#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA256_INIT)
+# include <openssl/sha.h>
+# define ARCHIVE_HAS_SHA256
+typedef SHA256_CTX archive_sha256_ctx;
+# define archive_sha256_init(ctx) SHA256_Init(ctx)
+# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx)
+# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n)
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_256)
+# define ARCHIVE_HAS_SHA256
+typedef SHA256_CTX archive_sha256_ctx;
+# define archive_sha256_init(ctx) SHA256_Init(ctx)
+# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx)
+# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n)
+#endif
+
+#if defined(HAVE_SHA2_H) && defined(HAVE_SHA384_INIT)
+# include <sha2.h>
+# define ARCHIVE_HAS_SHA384
+typedef SHA384_CTX archive_sha384_ctx;
+# define archive_sha384_init(ctx) SHA384_Init(ctx)
+# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx)
+# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n)
+#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA384INIT)
+# include <sha2.h>
+# define ARCHIVE_HAS_SHA384
+typedef SHA384_CTX archive_sha384_ctx;
+# define archive_sha384_init(ctx) SHA384Init(ctx)
+# define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx)
+# define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n)
+#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA384_INIT)
+# include <openssl/sha.h>
+# define ARCHIVE_HAS_SHA384
+typedef SHA512_CTX archive_sha384_ctx;
+# define archive_sha384_init(ctx) SHA384_Init(ctx)
+# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx)
+# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n)
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_384)
+# define ARCHIVE_HAS_SHA384
+typedef SHA512_CTX archive_sha384_ctx;
+# define archive_sha384_init(ctx) SHA384_Init(ctx)
+# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx)
+# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n)
+#endif
+
+#if defined(HAVE_SHA2_H) && defined(HAVE_SHA512_INIT)
+# include <sha2.h>
+# define ARCHIVE_HAS_SHA512
+typedef SHA512_CTX archive_sha512_ctx;
+# define archive_sha512_init(ctx) SHA512_Init(ctx)
+# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx)
+# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n)
+#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA512INIT)
+# include <sha2.h>
+# define ARCHIVE_HAS_SHA512
+typedef SHA512_CTX archive_sha512_ctx;
+# define archive_sha512_init(ctx) SHA512Init(ctx)
+# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx)
+# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n)
+#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA512_INIT)
+# include <openssl/sha.h>
+# define ARCHIVE_HAS_SHA512
+typedef SHA512_CTX archive_sha512_ctx;
+# define archive_sha512_init(ctx) SHA512_Init(ctx)
+# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx)
+# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n)
+#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_512)
+# define ARCHIVE_HAS_SHA512
+typedef SHA512_CTX archive_sha512_ctx;
+# define archive_sha512_init(ctx) SHA512_Init(ctx)
+# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx)
+# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n)
+#endif
diff --git a/archivers/libarchive/files/libarchive/archive_platform.h b/archivers/libarchive/files/libarchive/archive_platform.h
index 99dfacc50f5..ce2f482ba04 100644
--- a/archivers/libarchive/files/libarchive/archive_platform.h
+++ b/archivers/libarchive/files/libarchive/archive_platform.h
@@ -22,9 +22,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_platform.h,v 1.30 2008/05/26 17:00:22 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_platform.h 201090 2009-12-28 02:22:04Z kientzle $
*/
+/* !!ONLY FOR USE INTERNALLY TO LIBARCHIVE!! */
+
/*
* This header is the first thing included in any of the libarchive
* source files. As far as possible, platform-specific issues should
@@ -39,45 +41,76 @@
/* archive.h and archive_entry.h require this. */
#define __LIBARCHIVE_BUILD 1
-#ifdef _WIN32
-#include "config_windows.h"
-#include "archive_windows.h"
-#elif defined(PLATFORM_CONFIG_H)
+#if defined(PLATFORM_CONFIG_H)
/* Use hand-built config.h in environments that need it. */
#include PLATFORM_CONFIG_H
#elif defined(HAVE_CONFIG_H)
/* Most POSIX platforms use the 'configure' script to build config.h */
-#include "../config.h"
+#include "config.h"
#else
/* Warn if the library hasn't been (automatically or manually) configured. */
#error Oops: No config.h and no pre-built configuration in archive_platform.h.
#endif
+/* It should be possible to get rid of this by extending the feature-test
+ * macros to cover Windows API functions, probably along with non-trivial
+ * refactoring of code to find structures that sit more cleanly on top of
+ * either Windows or Posix APIs. */
+#if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
+#include "archive_windows.h"
+#endif
+
/*
* The config files define a lot of feature macros. The following
* uses those macros to select/define replacements and include key
* headers as required.
*/
-/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
-#ifdef __FreeBSD__
-#include <sys/cdefs.h> /* For __FBSDID */
-#else
-/* Just leaving this macro replacement empty leads to a dangling semicolon. */
+/* Get a real definition for __FBSDID if we can */
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+
+/* If not, define it so as to avoid dangling semicolons. */
+#ifndef __FBSDID
#define __FBSDID(a) struct _undefined_hack
#endif
/* Try to get standard C99-style integer type definitions. */
#if HAVE_INTTYPES_H
#include <inttypes.h>
-#elif HAVE_STDINT_H
+#endif
+#if HAVE_STDINT_H
#include <stdint.h>
#endif
+/* Borland warns about its own constants! */
+#if defined(__BORLANDC__)
+# if HAVE_DECL_UINT64_MAX
+# undef UINT64_MAX
+# undef HAVE_DECL_UINT64_MAX
+# endif
+# if HAVE_DECL_UINT64_MIN
+# undef UINT64_MIN
+# undef HAVE_DECL_UINT64_MIN
+# endif
+# if HAVE_DECL_INT64_MAX
+# undef INT64_MAX
+# undef HAVE_DECL_INT64_MAX
+# endif
+# if HAVE_DECL_INT64_MIN
+# undef INT64_MIN
+# undef HAVE_DECL_INT64_MIN
+# endif
+#endif
+
/* Some platforms lack the standard *_MAX definitions. */
#if !HAVE_DECL_SIZE_MAX
#define SIZE_MAX (~(size_t)0)
#endif
+#if !HAVE_DECL_SSIZE_MAX
+#define SSIZE_MAX ((ssize_t)(SIZE_MAX >> 1))
+#endif
#if !HAVE_DECL_UINT32_MAX
#define UINT32_MAX (~(uint32_t)0)
#endif
diff --git a/archivers/libarchive/files/libarchive/archive_private.h b/archivers/libarchive/files/libarchive/archive_private.h
index 9ca5893d80a..63384b82fed 100644
--- a/archivers/libarchive/files/libarchive/archive_private.h
+++ b/archivers/libarchive/files/libarchive/archive_private.h
@@ -22,31 +22,43 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_private.h,v 1.29 2007/04/02 00:15:45 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_private.h 201098 2009-12-28 02:58:14Z kientzle $
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
#ifndef ARCHIVE_PRIVATE_H_INCLUDED
#define ARCHIVE_PRIVATE_H_INCLUDED
#include "archive.h"
#include "archive_string.h"
+#if defined(__GNUC__) && (__GNUC__ > 2 || \
+ (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define __LA_DEAD __attribute__((__noreturn__))
+#else
+#define __LA_DEAD
+#endif
+
#define ARCHIVE_WRITE_MAGIC (0xb0c5c0deU)
#define ARCHIVE_READ_MAGIC (0xdeb0c5U)
-#define ARCHIVE_WRITE_DISK_MAGIC (0xc001b0c5U)
+#define ARCHIVE_WRITE_DISK_MAGIC (0xc001b0c5U)
+#define ARCHIVE_READ_DISK_MAGIC (0xbadb0c5U)
#define ARCHIVE_STATE_ANY 0xFFFFU
#define ARCHIVE_STATE_NEW 1U
#define ARCHIVE_STATE_HEADER 2U
#define ARCHIVE_STATE_DATA 4U
-#define ARCHIVE_STATE_DATA_END 8U
+#define ARCHIVE_STATE_DATA_END 8U
#define ARCHIVE_STATE_EOF 0x10U
#define ARCHIVE_STATE_CLOSED 0x20U
#define ARCHIVE_STATE_FATAL 0x8000U
struct archive_vtable {
- int (*archive_write_close)(struct archive *);
- int (*archive_write_finish)(struct archive *);
+ int (*archive_close)(struct archive *);
+ int (*archive_finish)(struct archive *);
int (*archive_write_header)(struct archive *,
struct archive_entry *);
int (*archive_write_finish_entry)(struct archive *);
@@ -79,9 +91,11 @@ struct archive {
const char *compression_name;
/* Position in UNCOMPRESSED data stream. */
- off_t file_position;
+ int64_t file_position;
/* Position in COMPRESSED data stream. */
- off_t raw_position;
+ int64_t raw_position;
+ /* Number of file entries processed. */
+ int file_count;
int archive_error_number;
const char *error;
@@ -92,8 +106,19 @@ struct archive {
void __archive_check_magic(struct archive *, unsigned int magic,
unsigned int state, const char *func);
-void __archive_errx(int retvalue, const char *msg);
+void __archive_errx(int retvalue, const char *msg) __LA_DEAD;
+
+int __archive_parse_options(const char *p, const char *fn,
+ int keysize, char *key, int valsize, char *val);
#define err_combine(a,b) ((a) < (b) ? (a) : (b))
+#if defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER <= 1300)
+# define ARCHIVE_LITERAL_LL(x) x##i64
+# define ARCHIVE_LITERAL_ULL(x) x##ui64
+#else
+# define ARCHIVE_LITERAL_LL(x) x##ll
+# define ARCHIVE_LITERAL_ULL(x) x##ull
+#endif
+
#endif
diff --git a/archivers/libarchive/files/libarchive/archive_read.3 b/archivers/libarchive/files/libarchive/archive_read.3
index 13063d917c7..43f3c76327a 100644
--- a/archivers/libarchive/files/libarchive/archive_read.3
+++ b/archivers/libarchive/files/libarchive/archive_read.3
@@ -22,23 +22,32 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_read.3,v 1.37 2008/05/26 17:00:22 kientzle Exp $
+.\" $FreeBSD: head/lib/libarchive/archive_read.3 191595 2009-04-27 20:13:13Z kientzle $
.\"
-.Dd August 19, 2006
+.Dd April 13, 2009
.Dt archive_read 3
.Os
.Sh NAME
.Nm archive_read_new ,
+.Nm archive_read_set_filter_options ,
+.Nm archive_read_set_format_options ,
+.Nm archive_read_set_options ,
.Nm archive_read_support_compression_all ,
.Nm archive_read_support_compression_bzip2 ,
.Nm archive_read_support_compression_compress ,
.Nm archive_read_support_compression_gzip ,
+.Nm archive_read_support_compression_lzma ,
.Nm archive_read_support_compression_none ,
+.Nm archive_read_support_compression_xz ,
.Nm archive_read_support_compression_program ,
+.Nm archive_read_support_compression_program_signature ,
.Nm archive_read_support_format_all ,
+.Nm archive_read_support_format_ar ,
.Nm archive_read_support_format_cpio ,
.Nm archive_read_support_format_empty ,
.Nm archive_read_support_format_iso9660 ,
+.Nm archive_read_support_format_mtree,
+.Nm archive_read_support_format_raw,
.Nm archive_read_support_format_tar ,
.Nm archive_read_support_format_zip ,
.Nm archive_read_open ,
@@ -48,6 +57,7 @@
.Nm archive_read_open_filename ,
.Nm archive_read_open_memory ,
.Nm archive_read_next_header ,
+.Nm archive_read_next_header2 ,
.Nm archive_read_data ,
.Nm archive_read_data_block ,
.Nm archive_read_data_skip ,
@@ -74,25 +84,48 @@
.Ft int
.Fn archive_read_support_compression_gzip "struct archive *"
.Ft int
+.Fn archive_read_support_compression_lzma "struct archive *"
+.Ft int
.Fn archive_read_support_compression_none "struct archive *"
.Ft int
+.Fn archive_read_support_compression_xz "struct archive *"
+.Ft int
.Fo archive_read_support_compression_program
.Fa "struct archive *"
.Fa "const char *cmd"
.Fc
.Ft int
+.Fo archive_read_support_compression_program_signature
+.Fa "struct archive *"
+.Fa "const char *cmd"
+.Fa "const void *signature"
+.Fa "size_t signature_length"
+.Fc
+.Ft int
.Fn archive_read_support_format_all "struct archive *"
.Ft int
+.Fn archive_read_support_format_ar "struct archive *"
+.Ft int
.Fn archive_read_support_format_cpio "struct archive *"
.Ft int
.Fn archive_read_support_format_empty "struct archive *"
.Ft int
.Fn archive_read_support_format_iso9660 "struct archive *"
.Ft int
+.Fn archive_read_support_format_mtree "struct archive *"
+.Ft int
+.Fn archive_read_support_format_raw "struct archive *"
+.Ft int
.Fn archive_read_support_format_tar "struct archive *"
.Ft int
.Fn archive_read_support_format_zip "struct archive *"
.Ft int
+.Fn archive_read_set_filter_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_read_set_format_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_read_set_options "struct archive *" "const char *"
+.Ft int
.Fo archive_read_open
.Fa "struct archive *"
.Fa "void *client_data"
@@ -123,6 +156,8 @@
.Fn archive_read_open_memory "struct archive *" "void *buff" "size_t size"
.Ft int
.Fn archive_read_next_header "struct archive *" "struct archive_entry **"
+.Ft int
+.Fn archive_read_next_header2 "struct archive *" "struct archive_entry *"
.Ft ssize_t
.Fn archive_read_data "struct archive *" "void *buff" "size_t len"
.Ft int
@@ -177,30 +212,43 @@ Allocates and initializes a
.Tn struct archive
object suitable for reading from an archive.
.It Xo
-.Fn archive_read_support_compression_all ,
.Fn archive_read_support_compression_bzip2 ,
.Fn archive_read_support_compression_compress ,
.Fn archive_read_support_compression_gzip ,
-.Fn archive_read_support_compression_none
+.Fn archive_read_support_compression_lzma ,
+.Fn archive_read_support_compression_none ,
+.Fn archive_read_support_compression_xz
.Xc
Enables auto-detection code and decompression support for the
specified compression.
+Returns
+.Cm ARCHIVE_OK
+if the compression is fully supported, or
+.Cm ARCHIVE_WARN
+if the compression is supported only through an external program.
+Note that decompression using an external program is usually slower than
+decompression through built-in libraries.
Note that
.Dq none
is always enabled by default.
-For convenience,
-.Fn archive_read_support_compression_all
-enables all available decompression code.
+.It Fn archive_read_support_compression_all
+Enables all available decompression filters.
.It Fn archive_read_support_compression_program
Data is fed through the specified external program before being dearchived.
Note that this disables automatic detection of the compression format,
so it makes no sense to specify this in conjunction with any other
decompression option.
+.It Fn archive_read_support_compression_program_signature
+This feeds data through the specified external program
+but only if the initial bytes of the data match the specified
+signature value.
.It Xo
.Fn archive_read_support_format_all ,
+.Fn archive_read_support_format_ar ,
.Fn archive_read_support_format_cpio ,
.Fn archive_read_support_format_empty ,
.Fn archive_read_support_format_iso9660 ,
+.Fn archive_read_support_format_mtree ,
.Fn archive_read_support_format_tar ,
.Fn archive_read_support_format_zip
.Xc
@@ -214,6 +262,59 @@ For convenience,
.Fn archive_read_support_format_all
enables support for all available formats.
Only empty archives are supported by default.
+.It Fn archive_read_support_format_raw
+The
+.Dq raw
+format handler allows libarchive to be used to read arbitrary data.
+It treats any data stream as an archive with a single entry.
+The pathname of this entry is
+.Dq data ;
+all other entry fields are unset.
+This is not enabled by
+.Fn archive_read_support_format_all
+in order to avoid erroneous handling of damaged archives.
+.It Xo
+.Fn archive_read_set_filter_options ,
+.Fn archive_read_set_format_options ,
+.Fn archive_read_set_options
+.Xc
+Specifies options that will be passed to currently-registered
+filters (including decompression filters) and/or format readers.
+The argument is a comma-separated list of individual options.
+Individual options have one of the following forms:
+.Bl -tag -compact -width indent
+.It Ar option=value
+The option/value pair will be provided to every module.
+Modules that do not accept an option with this name will ignore it.
+.It Ar option
+The option will be provided to every module with a value of
+.Dq 1 .
+.It Ar !option
+The option will be provided to every module with a NULL value.
+.It Ar module:option=value , Ar module:option , Ar module:!option
+As above, but the corresponding option and value will be provided
+only to modules whose name matches
+.Ar module .
+.El
+The return value will be
+.Cm ARCHIVE_OK
+if any module accepts the option, or
+.Cm ARCHIVE_WARN
+if no module accepted the option, or
+.Cm ARCHIVE_FATAL
+if there was a fatal error while attempting to process the option.
+.Pp
+The currently supported options are:
+.Bl -tag -compact -width indent
+.It Format iso9660
+.Bl -tag -compact -width indent
+.It Cm joliet
+Support Joliet extensions.
+Defaults to enabled, use
+.Cm !joliet
+to disable.
+.El
+.El
.It Fn archive_read_open
The same as
.Fn archive_read_open2 ,
@@ -266,6 +367,14 @@ memory containing the archive data.
Read the header for the next entry and return a pointer to
a
.Tn struct archive_entry .
+This is a convenience wrapper around
+.Fn archive_read_next_header2
+that reuses an internal
+.Tn struct archive_entry
+object for each request.
+.It Fn archive_read_next_header2
+Read the header for the next entry and populate the provided
+.Tn struct archive_entry .
.It Fn archive_read_data
Read data associated with the header just read.
Internally, this is a convenience function that calls
diff --git a/archivers/libarchive/files/libarchive/archive_read.c b/archivers/libarchive/files/libarchive/archive_read.c
index 327969f4185..f39f5cec29d 100644
--- a/archivers/libarchive/files/libarchive/archive_read.c
+++ b/archivers/libarchive/files/libarchive/archive_read.c
@@ -32,7 +32,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read.c,v 1.38 2008/03/12 04:58:32 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read.c 201157 2009-12-29 05:30:23Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -53,9 +53,27 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read.c,v 1.38 2008/03/12 04:58:32
#include "archive_private.h"
#include "archive_read_private.h"
-static void choose_decompressor(struct archive_read *, const void*, size_t);
+#define minimum(a, b) (a < b ? a : b)
+
+static int build_stream(struct archive_read *);
static int choose_format(struct archive_read *);
-static off_t dummy_skip(struct archive_read *, off_t);
+static int cleanup_filters(struct archive_read *);
+static struct archive_vtable *archive_read_vtable(void);
+static int _archive_read_close(struct archive *);
+static int _archive_read_finish(struct archive *);
+
+static struct archive_vtable *
+archive_read_vtable(void)
+{
+ static struct archive_vtable av;
+ static int inited = 0;
+
+ if (!inited) {
+ av.archive_finish = _archive_read_finish;
+ av.archive_close = _archive_read_close;
+ }
+ return (&av);
+}
/*
* Allocate, initialize and return a struct archive object.
@@ -73,9 +91,7 @@ archive_read_new(void)
a->archive.state = ARCHIVE_STATE_NEW;
a->entry = archive_entry_new();
-
- /* We always support uncompressed archives. */
- archive_read_support_compression_none(&a->archive);
+ a->archive.vtable = archive_read_vtable();
return (&a->archive);
}
@@ -93,6 +109,121 @@ archive_read_extract_set_skip_file(struct archive *_a, dev_t d, ino_t i)
a->skip_file_ino = i;
}
+/*
+ * Set read options for the format.
+ */
+int
+archive_read_set_format_options(struct archive *_a, const char *s)
+{
+ struct archive_read *a;
+ struct archive_format_descriptor *format;
+ char key[64], val[64];
+ char *valp;
+ size_t i;
+ int len, r;
+
+ __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+ "archive_read_set_format_options");
+
+ if (s == NULL || *s == '\0')
+ return (ARCHIVE_OK);
+ a = (struct archive_read *)_a;
+ __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_read_set_format_options");
+ len = 0;
+ for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) {
+ format = &a->formats[i];
+ if (format == NULL || format->options == NULL ||
+ format->name == NULL)
+ /* This format does not support option. */
+ continue;
+
+ while ((len = __archive_parse_options(s, format->name,
+ sizeof(key), key, sizeof(val), val)) > 0) {
+ valp = val[0] == '\0' ? NULL : val;
+ a->format = format;
+ r = format->options(a, key, valp);
+ a->format = NULL;
+ if (r == ARCHIVE_FATAL)
+ return (r);
+ s += len;
+ }
+ }
+ if (len < 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Illegal format options.");
+ return (ARCHIVE_WARN);
+ }
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Set read options for the filter.
+ */
+int
+archive_read_set_filter_options(struct archive *_a, const char *s)
+{
+ struct archive_read *a;
+ struct archive_read_filter *filter;
+ struct archive_read_filter_bidder *bidder;
+ char key[64], val[64];
+ int len, r;
+
+ __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+ "archive_read_set_filter_options");
+
+ if (s == NULL || *s == '\0')
+ return (ARCHIVE_OK);
+ a = (struct archive_read *)_a;
+ __archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_read_set_filter_options");
+ len = 0;
+ for (filter = a->filter; filter != NULL; filter = filter->upstream) {
+ bidder = filter->bidder;
+ if (bidder == NULL)
+ continue;
+ if (bidder->options == NULL)
+ /* This bidder does not support option */
+ continue;
+ while ((len = __archive_parse_options(s, filter->name,
+ sizeof(key), key, sizeof(val), val)) > 0) {
+ if (val[0] == '\0')
+ r = bidder->options(bidder, key, NULL);
+ else
+ r = bidder->options(bidder, key, val);
+ if (r == ARCHIVE_FATAL)
+ return (r);
+ s += len;
+ }
+ }
+ if (len < 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Illegal format options.");
+ return (ARCHIVE_WARN);
+ }
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Set read options for the format and the filter.
+ */
+int
+archive_read_set_options(struct archive *_a, const char *s)
+{
+ int r;
+
+ __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+ "archive_read_set_options");
+ archive_clear_error(_a);
+
+ r = archive_read_set_format_options(_a, s);
+ if (r != ARCHIVE_OK)
+ return (r);
+ r = archive_read_set_filter_options(_a, s);
+ if (r != ARCHIVE_OK)
+ return (r);
+ return (ARCHIVE_OK);
+}
/*
* Open the archive
@@ -108,6 +239,54 @@ archive_read_open(struct archive *a, void *client_data,
client_reader, NULL, client_closer);
}
+static ssize_t
+client_read_proxy(struct archive_read_filter *self, const void **buff)
+{
+ ssize_t r;
+ r = (self->archive->client.reader)(&self->archive->archive,
+ self->data, buff);
+ self->archive->archive.raw_position += r;
+ return (r);
+}
+
+static int64_t
+client_skip_proxy(struct archive_read_filter *self, int64_t request)
+{
+ int64_t ask, get, total;
+ /* Limit our maximum seek request to 1GB on platforms
+ * with 32-bit off_t (such as Windows). */
+ int64_t skip_limit = ((int64_t)1) << (sizeof(off_t) * 8 - 2);
+
+ if (self->archive->client.skipper == NULL)
+ return (0);
+ total = 0;
+ for (;;) {
+ ask = request;
+ if (ask > skip_limit)
+ ask = skip_limit;
+ get = (self->archive->client.skipper)(&self->archive->archive,
+ self->data, ask);
+ if (get == 0)
+ return (total);
+ request -= get;
+ self->archive->archive.raw_position += get;
+ total += get;
+ }
+}
+
+static int
+client_close_proxy(struct archive_read_filter *self)
+{
+ int r = ARCHIVE_OK;
+
+ if (self->archive->client.closer != NULL)
+ r = (self->archive->client.closer)((struct archive *)self->archive,
+ self->data);
+ self->data = NULL;
+ return (r);
+}
+
+
int
archive_read_open2(struct archive *_a, void *client_data,
archive_open_callback *client_opener,
@@ -116,28 +295,17 @@ archive_read_open2(struct archive *_a, void *client_data,
archive_close_callback *client_closer)
{
struct archive_read *a = (struct archive_read *)_a;
- const void *buffer;
- ssize_t bytes_read;
+ struct archive_read_filter *filter;
int e;
- __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_open");
+ __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
+ "archive_read_open");
+ archive_clear_error(&a->archive);
if (client_reader == NULL)
__archive_errx(1,
"No reader function provided to archive_read_open");
- /*
- * Set these NULL initially. If the open or initial read fails,
- * we'll leave them NULL to indicate that the file is invalid.
- * (In particular, this helps ensure that the closer doesn't
- * get called more than once.)
- */
- a->client_opener = NULL;
- a->client_reader = NULL;
- a->client_skipper = NULL;
- a->client_closer = NULL;
- a->client_data = NULL;
-
/* Open data source. */
if (client_opener != NULL) {
e =(client_opener)(&a->archive, client_data);
@@ -149,147 +317,107 @@ archive_read_open2(struct archive *_a, void *client_data,
}
}
- /* Read first block now for compress format detection. */
- bytes_read = (client_reader)(&a->archive, client_data, &buffer);
+ /* Save the client functions and mock up the initial source. */
+ a->client.reader = client_reader;
+ a->client.skipper = client_skipper;
+ a->client.closer = client_closer;
- if (bytes_read < 0) {
- /* If the first read fails, close before returning error. */
- if (client_closer)
- (client_closer)(&a->archive, client_data);
- /* client_reader should have already set error information. */
+ filter = calloc(1, sizeof(*filter));
+ if (filter == NULL)
return (ARCHIVE_FATAL);
- }
-
- /* Now that the client callbacks have worked, remember them. */
- a->client_opener = client_opener; /* Do we need to remember this? */
- a->client_reader = client_reader;
- a->client_skipper = client_skipper;
- a->client_closer = client_closer;
- a->client_data = client_data;
-
- /* Select a decompression routine. */
- choose_decompressor(a, buffer, (size_t)bytes_read);
- if (a->decompressor == NULL)
- return (ARCHIVE_FATAL);
-
- /* Initialize decompression routine with the first block of data. */
- e = (a->decompressor->init)(a, buffer, (size_t)bytes_read);
-
+ filter->bidder = NULL;
+ filter->upstream = NULL;
+ filter->archive = a;
+ filter->data = client_data;
+ filter->read = client_read_proxy;
+ filter->skip = client_skip_proxy;
+ filter->close = client_close_proxy;
+ filter->name = "none";
+ filter->code = ARCHIVE_COMPRESSION_NONE;
+ a->filter = filter;
+
+ /* Build out the input pipeline. */
+ e = build_stream(a);
if (e == ARCHIVE_OK)
a->archive.state = ARCHIVE_STATE_HEADER;
- /*
- * If the decompressor didn't register a skip function, provide a
- * dummy compression-layer skip function.
- */
- if (a->decompressor->skip == NULL)
- a->decompressor->skip = dummy_skip;
-
return (e);
}
/*
- * Allow each registered decompression routine to bid on whether it
- * wants to handle this stream. Return index of winning bidder.
+ * Allow each registered stream transform to bid on whether
+ * it wants to handle this stream. Repeat until we've finished
+ * building the pipeline.
*/
-static void
-choose_decompressor(struct archive_read *a,
- const void *buffer, size_t bytes_read)
+static int
+build_stream(struct archive_read *a)
{
- int decompression_slots, i, bid, best_bid;
- struct decompressor_t *decompressor, *best_decompressor;
+ int number_bidders, i, bid, best_bid;
+ struct archive_read_filter_bidder *bidder, *best_bidder;
+ struct archive_read_filter *filter;
+ ssize_t avail;
+ int r;
- decompression_slots = sizeof(a->decompressors) /
- sizeof(a->decompressors[0]);
+ for (;;) {
+ number_bidders = sizeof(a->bidders) / sizeof(a->bidders[0]);
- best_bid = 0;
- a->decompressor = NULL;
- best_decompressor = NULL;
+ best_bid = 0;
+ best_bidder = NULL;
- decompressor = a->decompressors;
- for (i = 0; i < decompression_slots; i++) {
- if (decompressor->bid) {
- bid = (decompressor->bid)(buffer, bytes_read);
- if (bid > best_bid || best_decompressor == NULL) {
- best_bid = bid;
- best_decompressor = decompressor;
+ bidder = a->bidders;
+ for (i = 0; i < number_bidders; i++, bidder++) {
+ if (bidder->bid != NULL) {
+ bid = (bidder->bid)(bidder, a->filter);
+ if (bid > best_bid) {
+ best_bid = bid;
+ best_bidder = bidder;
+ }
}
}
- decompressor ++;
- }
-
- /*
- * There were no bidders; this is a serious programmer error
- * and demands a quick and definitive abort.
- */
- if (best_decompressor == NULL)
- __archive_errx(1, "No decompressors were registered; you "
- "must call at least one "
- "archive_read_support_compression_XXX function in order "
- "to successfully read an archive.");
-
- /*
- * There were bidders, but no non-zero bids; this means we can't
- * support this stream.
- */
- if (best_bid < 1) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Unrecognized archive format");
- return;
- }
-
- /* Record the best decompressor for this stream. */
- a->decompressor = best_decompressor;
-}
-/*
- * Dummy skip function, for use if the compression layer doesn't provide
- * one: This code just reads data and discards it.
- */
-static off_t
-dummy_skip(struct archive_read * a, off_t request)
-{
- const void * dummy_buffer;
- ssize_t bytes_read;
- off_t bytes_skipped;
+ /* If no bidder, we're done. */
+ if (best_bidder == NULL) {
+ a->archive.compression_name = a->filter->name;
+ a->archive.compression_code = a->filter->code;
+ return (ARCHIVE_OK);
+ }
- for (bytes_skipped = 0; request > 0;) {
- bytes_read = (a->decompressor->read_ahead)(a, &dummy_buffer, 1);
- if (bytes_read < 0)
- return (bytes_read);
- if (bytes_read == 0) {
- /* Premature EOF. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Truncated input file (need to skip %jd bytes)",
- (intmax_t)request);
+ filter
+ = (struct archive_read_filter *)calloc(1, sizeof(*filter));
+ if (filter == NULL)
+ return (ARCHIVE_FATAL);
+ filter->bidder = best_bidder;
+ filter->archive = a;
+ filter->upstream = a->filter;
+ r = (best_bidder->init)(filter);
+ if (r != ARCHIVE_OK) {
+ free(filter);
+ return (r);
+ }
+ a->filter = filter;
+ /* Verify the filter by asking it for some data. */
+ __archive_read_filter_ahead(filter, 1, &avail);
+ if (avail < 0) {
+ cleanup_filters(a);
return (ARCHIVE_FATAL);
}
- if (bytes_read > request)
- bytes_read = (ssize_t)request;
- (a->decompressor->consume)(a, (size_t)bytes_read);
- request -= bytes_read;
- bytes_skipped += bytes_read;
}
-
- return (bytes_skipped);
}
/*
* Read header of next entry.
*/
int
-archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
+archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_entry *entry;
int slot, ret;
__archive_check_magic(_a, ARCHIVE_READ_MAGIC,
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_read_next_header");
- *entryp = NULL;
- entry = a->entry;
+ ++_a->file_count;
archive_entry_clear(entry);
archive_clear_error(&a->archive);
@@ -347,12 +475,22 @@ archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
break;
}
- *entryp = entry;
a->read_data_output_offset = 0;
a->read_data_remaining = 0;
return (ret);
}
+int
+archive_read_next_header(struct archive *_a, struct archive_entry **entryp)
+{
+ int ret;
+ struct archive_read *a = (struct archive_read *)_a;
+ *entryp = NULL;
+ ret = archive_read_next_header2(_a, a->entry);
+ *entryp = a->entry;
+ return ret;
+}
+
/*
* Allow each registered format to bid on whether it wants to handle
* the next entry. Return index of winning bidder.
@@ -581,8 +719,8 @@ archive_read_data_block(struct archive *_a,
* Don't assume we actually read anything or performed any non-trivial
* initialization.
*/
-int
-archive_read_close(struct archive *_a)
+static int
+_archive_read_close(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
int r = ARCHIVE_OK, r1 = ARCHIVE_OK;
@@ -590,44 +728,58 @@ archive_read_close(struct archive *_a)
__archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
ARCHIVE_STATE_ANY, "archive_read_close");
+ archive_clear_error(&a->archive);
a->archive.state = ARCHIVE_STATE_CLOSED;
+
/* Call cleanup functions registered by optional components. */
if (a->cleanup_archive_extract != NULL)
r = (a->cleanup_archive_extract)(a);
/* TODO: Clean up the formatters. */
- /* Clean up the decompressors. */
- n = sizeof(a->decompressors)/sizeof(a->decompressors[0]);
+ /* Release the filter objects. */
+ r1 = cleanup_filters(a);
+ if (r1 < r)
+ r = r1;
+
+ /* Release the bidder objects. */
+ n = sizeof(a->bidders)/sizeof(a->bidders[0]);
for (i = 0; i < n; i++) {
- if (a->decompressors[i].finish != NULL) {
- r1 = (a->decompressors[i].finish)(a);
+ if (a->bidders[i].free != NULL) {
+ r1 = (a->bidders[i].free)(&a->bidders[i]);
if (r1 < r)
r = r1;
}
}
- /* Close the client stream. */
- if (a->client_closer != NULL) {
- r1 = ((a->client_closer)(&a->archive, a->client_data));
- if (r1 < r)
- r = r1;
- }
-
return (r);
}
+static int
+cleanup_filters(struct archive_read *a)
+{
+ int r = ARCHIVE_OK;
+ /* Clean up the filter pipeline. */
+ while (a->filter != NULL) {
+ struct archive_read_filter *t = a->filter->upstream;
+ if (a->filter->close != NULL) {
+ int r1 = (a->filter->close)(a->filter);
+ if (r1 < r)
+ r = r1;
+ }
+ free(a->filter->buffer);
+ free(a->filter);
+ a->filter = t;
+ }
+ return r;
+}
+
/*
* Release memory and other resources.
*/
-#if ARCHIVE_API_VERSION > 1
-int
-#else
-/* Temporarily allow library to compile with either 1.x or 2.0 API. */
-void
-#endif
-archive_read_finish(struct archive *_a)
+static int
+_archive_read_finish(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
int i;
@@ -664,7 +816,9 @@ archive_read_finish(struct archive *_a)
int
__archive_read_register_format(struct archive_read *a,
void *format_data,
+ const char *name,
int (*bid)(struct archive_read *),
+ int (*options)(struct archive_read *, const char *, const char *),
int (*read_header)(struct archive_read *, struct archive_entry *),
int (*read_data)(struct archive_read *, const void **, size_t *, off_t *),
int (*read_data_skip)(struct archive_read *),
@@ -683,11 +837,13 @@ __archive_read_register_format(struct archive_read *a,
return (ARCHIVE_WARN); /* We've already installed */
if (a->formats[i].bid == NULL) {
a->formats[i].bid = bid;
+ a->formats[i].options = options;
a->formats[i].read_header = read_header;
a->formats[i].read_data = read_data;
a->formats[i].read_data_skip = read_data_skip;
a->formats[i].cleanup = cleanup;
a->formats[i].data = format_data;
+ a->formats[i].name = name;
return (ARCHIVE_OK);
}
}
@@ -700,26 +856,21 @@ __archive_read_register_format(struct archive_read *a,
* Used internally by decompression routines to register their bid and
* initialization functions.
*/
-struct decompressor_t *
-__archive_read_register_compression(struct archive_read *a,
- int (*bid)(const void *, size_t),
- int (*init)(struct archive_read *, const void *, size_t))
+struct archive_read_filter_bidder *
+__archive_read_get_bidder(struct archive_read *a)
{
int i, number_slots;
__archive_check_magic(&a->archive,
ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
- "__archive_read_register_compression");
+ "__archive_read_get_bidder");
- number_slots = sizeof(a->decompressors) / sizeof(a->decompressors[0]);
+ number_slots = sizeof(a->bidders) / sizeof(a->bidders[0]);
for (i = 0; i < number_slots; i++) {
- if (a->decompressors[i].bid == bid)
- return (a->decompressors + i);
- if (a->decompressors[i].bid == NULL) {
- a->decompressors[i].bid = bid;
- a->decompressors[i].init = init;
- return (a->decompressors + i);
+ if (a->bidders[i].bid == NULL) {
+ memset(a->bidders + i, 0, sizeof(a->bidders[0]));
+ return (a->bidders + i);
}
}
@@ -727,13 +878,372 @@ __archive_read_register_compression(struct archive_read *a,
return (NULL); /* Never actually executed. */
}
-/* used internally to simplify read-ahead */
+/*
+ * The next three functions comprise the peek/consume internal I/O
+ * system used by archive format readers. This system allows fairly
+ * flexible read-ahead and allows the I/O code to operate in a
+ * zero-copy manner most of the time.
+ *
+ * In the ideal case, filters generate blocks of data
+ * and __archive_read_ahead() just returns pointers directly into
+ * those blocks. Then __archive_read_consume() just bumps those
+ * pointers. Only if your request would span blocks does the I/O
+ * layer use a copy buffer to provide you with a contiguous block of
+ * data. The __archive_read_skip() is an optimization; it scans ahead
+ * very quickly (it usually translates into a seek() operation if
+ * you're reading uncompressed disk files).
+ *
+ * A couple of useful idioms:
+ * * "I just want some data." Ask for 1 byte and pay attention to
+ * the "number of bytes available" from __archive_read_ahead().
+ * You can consume more than you asked for; you just can't consume
+ * more than is available. If you consume everything that's
+ * immediately available, the next read_ahead() call will pull
+ * the next block.
+ * * "I want to output a large block of data." As above, ask for 1 byte,
+ * emit all that's available (up to whatever limit you have), then
+ * repeat until you're done.
+ * * "I want to peek ahead by a large amount." Ask for 4k or so, then
+ * double and repeat until you get an error or have enough. Note
+ * that the I/O layer will likely end up expanding its copy buffer
+ * to fit your request, so use this technique cautiously. This
+ * technique is used, for example, by some of the format tasting
+ * code that has uncertain look-ahead needs.
+ *
+ * TODO: Someday, provide a more generic __archive_read_seek() for
+ * those cases where it's useful. This is tricky because there are lots
+ * of cases where seek() is not available (reading gzip data from a
+ * network socket, for instance), so there needs to be a good way to
+ * communicate whether seek() is available and users of that interface
+ * need to use non-seeking strategies whenever seek() is not available.
+ */
+
+/*
+ * Looks ahead in the input stream:
+ * * If 'avail' pointer is provided, that returns number of bytes available
+ * in the current buffer, which may be much larger than requested.
+ * * If end-of-file, *avail gets set to zero.
+ * * If error, *avail gets error code.
+ * * If request can be met, returns pointer to data, returns NULL
+ * if request is not met.
+ *
+ * Note: If you just want "some data", ask for 1 byte and pay attention
+ * to *avail, which will have the actual amount available. If you
+ * know exactly how many bytes you need, just ask for that and treat
+ * a NULL return as an error.
+ *
+ * Important: This does NOT move the file pointer. See
+ * __archive_read_consume() below.
+ */
+
+/*
+ * This is tricky. We need to provide our clients with pointers to
+ * contiguous blocks of memory but we want to avoid copying whenever
+ * possible.
+ *
+ * Mostly, this code returns pointers directly into the block of data
+ * provided by the client_read routine. It can do this unless the
+ * request would split across blocks. In that case, we have to copy
+ * into an internal buffer to combine reads.
+ */
+const void *
+__archive_read_ahead(struct archive_read *a, size_t min, ssize_t *avail)
+{
+ return (__archive_read_filter_ahead(a->filter, min, avail));
+}
+
const void *
-__archive_read_ahead(struct archive_read *a, size_t len)
+__archive_read_filter_ahead(struct archive_read_filter *filter,
+ size_t min, ssize_t *avail)
{
- const void *h;
+ ssize_t bytes_read;
+ size_t tocopy;
- if ((a->decompressor->read_ahead)(a, &h, len) < (ssize_t)len)
+ if (filter->fatal) {
+ if (avail)
+ *avail = ARCHIVE_FATAL;
return (NULL);
- return (h);
+ }
+
+ /*
+ * Keep pulling more data until we can satisfy the request.
+ */
+ for (;;) {
+
+ /*
+ * If we can satisfy from the copy buffer (and the
+ * copy buffer isn't empty), we're done. In particular,
+ * note that min == 0 is a perfectly well-defined
+ * request.
+ */
+ if (filter->avail >= min && filter->avail > 0) {
+ if (avail != NULL)
+ *avail = filter->avail;
+ return (filter->next);
+ }
+
+ /*
+ * We can satisfy directly from client buffer if everything
+ * currently in the copy buffer is still in the client buffer.
+ */
+ if (filter->client_total >= filter->client_avail + filter->avail
+ && filter->client_avail + filter->avail >= min) {
+ /* "Roll back" to client buffer. */
+ filter->client_avail += filter->avail;
+ filter->client_next -= filter->avail;
+ /* Copy buffer is now empty. */
+ filter->avail = 0;
+ filter->next = filter->buffer;
+ /* Return data from client buffer. */
+ if (avail != NULL)
+ *avail = filter->client_avail;
+ return (filter->client_next);
+ }
+
+ /* Move data forward in copy buffer if necessary. */
+ if (filter->next > filter->buffer &&
+ filter->next + min > filter->buffer + filter->buffer_size) {
+ if (filter->avail > 0)
+ memmove(filter->buffer, filter->next, filter->avail);
+ filter->next = filter->buffer;
+ }
+
+ /* If we've used up the client data, get more. */
+ if (filter->client_avail <= 0) {
+ if (filter->end_of_file) {
+ if (avail != NULL)
+ *avail = 0;
+ return (NULL);
+ }
+ bytes_read = (filter->read)(filter,
+ &filter->client_buff);
+ if (bytes_read < 0) { /* Read error. */
+ filter->client_total = filter->client_avail = 0;
+ filter->client_next = filter->client_buff = NULL;
+ filter->fatal = 1;
+ if (avail != NULL)
+ *avail = ARCHIVE_FATAL;
+ return (NULL);
+ }
+ if (bytes_read == 0) { /* Premature end-of-file. */
+ filter->client_total = filter->client_avail = 0;
+ filter->client_next = filter->client_buff = NULL;
+ filter->end_of_file = 1;
+ /* Return whatever we do have. */
+ if (avail != NULL)
+ *avail = filter->avail;
+ return (NULL);
+ }
+ filter->position += bytes_read;
+ filter->client_total = bytes_read;
+ filter->client_avail = filter->client_total;
+ filter->client_next = filter->client_buff;
+ }
+ else
+ {
+ /*
+ * We can't satisfy the request from the copy
+ * buffer or the existing client data, so we
+ * need to copy more client data over to the
+ * copy buffer.
+ */
+
+ /* Ensure the buffer is big enough. */
+ if (min > filter->buffer_size) {
+ size_t s, t;
+ char *p;
+
+ /* Double the buffer; watch for overflow. */
+ s = t = filter->buffer_size;
+ if (s == 0)
+ s = min;
+ while (s < min) {
+ t *= 2;
+ if (t <= s) { /* Integer overflow! */
+ archive_set_error(
+ &filter->archive->archive,
+ ENOMEM,
+ "Unable to allocate copy buffer");
+ filter->fatal = 1;
+ if (avail != NULL)
+ *avail = ARCHIVE_FATAL;
+ return (NULL);
+ }
+ s = t;
+ }
+ /* Now s >= min, so allocate a new buffer. */
+ p = (char *)malloc(s);
+ if (p == NULL) {
+ archive_set_error(
+ &filter->archive->archive,
+ ENOMEM,
+ "Unable to allocate copy buffer");
+ filter->fatal = 1;
+ if (avail != NULL)
+ *avail = ARCHIVE_FATAL;
+ return (NULL);
+ }
+ /* Move data into newly-enlarged buffer. */
+ if (filter->avail > 0)
+ memmove(p, filter->next, filter->avail);
+ free(filter->buffer);
+ filter->next = filter->buffer = p;
+ filter->buffer_size = s;
+ }
+
+ /* We can add client data to copy buffer. */
+ /* First estimate: copy to fill rest of buffer. */
+ tocopy = (filter->buffer + filter->buffer_size)
+ - (filter->next + filter->avail);
+ /* Don't waste time buffering more than we need to. */
+ if (tocopy + filter->avail > min)
+ tocopy = min - filter->avail;
+ /* Don't copy more than is available. */
+ if (tocopy > filter->client_avail)
+ tocopy = filter->client_avail;
+
+ memcpy(filter->next + filter->avail, filter->client_next,
+ tocopy);
+ /* Remove this data from client buffer. */
+ filter->client_next += tocopy;
+ filter->client_avail -= tocopy;
+ /* add it to copy buffer. */
+ filter->avail += tocopy;
+ }
+ }
+}
+
+/*
+ * Move the file pointer forward. This should be called after
+ * __archive_read_ahead() returns data to you. Don't try to move
+ * ahead by more than the amount of data available according to
+ * __archive_read_ahead().
+ */
+/*
+ * Mark the appropriate data as used. Note that the request here will
+ * often be much smaller than the size of the previous read_ahead
+ * request.
+ */
+ssize_t
+__archive_read_consume(struct archive_read *a, size_t request)
+{
+ ssize_t r;
+ r = __archive_read_filter_consume(a->filter, request);
+ a->archive.file_position += r;
+ return (r);
+}
+
+ssize_t
+__archive_read_filter_consume(struct archive_read_filter * filter,
+ size_t request)
+{
+ if (filter->avail > 0) {
+ /* Read came from copy buffer. */
+ filter->next += request;
+ filter->avail -= request;
+ } else {
+ /* Read came from client buffer. */
+ filter->client_next += request;
+ filter->client_avail -= request;
+ }
+ return (request);
+}
+
+/*
+ * Move the file pointer ahead by an arbitrary amount. If you're
+ * reading uncompressed data from a disk file, this will actually
+ * translate into a seek() operation. Even in cases where seek()
+ * isn't feasible, this at least pushes the read-and-discard loop
+ * down closer to the data source.
+ */
+int64_t
+__archive_read_skip(struct archive_read *a, int64_t request)
+{
+ int64_t skipped = __archive_read_skip_lenient(a, request);
+ if (skipped == request)
+ return (skipped);
+ /* We hit EOF before we satisfied the skip request. */
+ if (skipped < 0) // Map error code to 0 for error message below.
+ skipped = 0;
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Truncated input file (needed %jd bytes, only %jd available)",
+ (intmax_t)request, (intmax_t)skipped);
+ return (ARCHIVE_FATAL);
+}
+
+int64_t
+__archive_read_skip_lenient(struct archive_read *a, int64_t request)
+{
+ int64_t skipped = __archive_read_filter_skip(a->filter, request);
+ if (skipped > 0)
+ a->archive.file_position += skipped;
+ return (skipped);
+}
+
+int64_t
+__archive_read_filter_skip(struct archive_read_filter *filter, int64_t request)
+{
+ int64_t bytes_skipped, total_bytes_skipped = 0;
+ size_t min;
+
+ if (filter->fatal)
+ return (-1);
+ /*
+ * If there is data in the buffers already, use that first.
+ */
+ if (filter->avail > 0) {
+ min = minimum(request, (off_t)filter->avail);
+ bytes_skipped = __archive_read_filter_consume(filter, min);
+ request -= bytes_skipped;
+ total_bytes_skipped += bytes_skipped;
+ }
+ if (filter->client_avail > 0) {
+ min = minimum(request, (int64_t)filter->client_avail);
+ bytes_skipped = __archive_read_filter_consume(filter, min);
+ request -= bytes_skipped;
+ total_bytes_skipped += bytes_skipped;
+ }
+ if (request == 0)
+ return (total_bytes_skipped);
+ /*
+ * If a client_skipper was provided, try that first.
+ */
+#if ARCHIVE_API_VERSION < 2
+ if ((filter->skip != NULL) && (request < SSIZE_MAX)) {
+#else
+ if (filter->skip != NULL) {
+#endif
+ bytes_skipped = (filter->skip)(filter, request);
+ if (bytes_skipped < 0) { /* error */
+ filter->client_total = filter->client_avail = 0;
+ filter->client_next = filter->client_buff = NULL;
+ filter->fatal = 1;
+ return (bytes_skipped);
+ }
+ total_bytes_skipped += bytes_skipped;
+ request -= bytes_skipped;
+ filter->client_next = filter->client_buff;
+ filter->client_avail = filter->client_total = 0;
+ }
+ /*
+ * Note that client_skipper will usually not satisfy the
+ * full request (due to low-level blocking concerns),
+ * so even if client_skipper is provided, we may still
+ * have to use ordinary reads to finish out the request.
+ */
+ while (request > 0) {
+ ssize_t bytes_read;
+ (void)__archive_read_filter_ahead(filter, 1, &bytes_read);
+ if (bytes_read < 0)
+ return (bytes_read);
+ if (bytes_read == 0) {
+ return (total_bytes_skipped);
+ }
+ min = (size_t)(minimum(bytes_read, request));
+ bytes_read = __archive_read_filter_consume(filter, min);
+ total_bytes_skipped += bytes_read;
+ request -= bytes_read;
+ }
+ return (total_bytes_skipped);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_disk.3 b/archivers/libarchive/files/libarchive/archive_read_disk.3
new file mode 100644
index 00000000000..b3a09b52839
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_disk.3
@@ -0,0 +1,308 @@
+.\" Copyright (c) 2003-2009 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 AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD: head/lib/libarchive/archive_read_disk.3 190957 2009-04-12 05:04:02Z kientzle $
+.\"
+.Dd March 10, 2009
+.Dt archive_read_disk 3
+.Os
+.Sh NAME
+.Nm archive_read_disk_new ,
+.Nm archive_read_disk_set_symlink_logical ,
+.Nm archive_read_disk_set_symlink_physical ,
+.Nm archive_read_disk_set_symlink_hybrid ,
+.Nm archive_read_disk_entry_from_file ,
+.Nm archive_read_disk_gname ,
+.Nm archive_read_disk_uname ,
+.Nm archive_read_disk_set_uname_lookup ,
+.Nm archive_read_disk_set_gname_lookup ,
+.Nm archive_read_disk_set_standard_lookup ,
+.Nm archive_read_close ,
+.Nm archive_read_finish
+.Nd functions for reading objects from disk
+.Sh SYNOPSIS
+.In archive.h
+.Ft struct archive *
+.Fn archive_read_disk_new "void"
+.Ft int
+.Fn archive_read_disk_set_symlink_logical "struct archive *"
+.Ft int
+.Fn archive_read_disk_set_symlink_physical "struct archive *"
+.Ft int
+.Fn archive_read_disk_set_symlink_hybrid "struct archive *"
+.Ft int
+.Fn archive_read_disk_gname "struct archive *" "gid_t"
+.Ft int
+.Fn archive_read_disk_uname "struct archive *" "uid_t"
+.Ft int
+.Fo archive_read_disk_set_gname_lookup
+.Fa "struct archive *"
+.Fa "void *"
+.Fa "const char *(*lookup)(void *, gid_t)"
+.Fa "void (*cleanup)(void *)"
+.Fc
+.Ft int
+.Fo archive_read_disk_set_uname_lookup
+.Fa "struct archive *"
+.Fa "void *"
+.Fa "const char *(*lookup)(void *, uid_t)"
+.Fa "void (*cleanup)(void *)"
+.Fc
+.Ft int
+.Fn archive_read_disk_set_standard_lookup "struct archive *"
+.Ft int
+.Fo archive_read_disk_entry_from_file
+.Fa "struct archive *"
+.Fa "struct archive_entry *"
+.Fa "int fd"
+.Fa "const struct stat *"
+.Fc
+.Ft int
+.Fn archive_read_close "struct archive *"
+.Ft int
+.Fn archive_read_finish "struct archive *"
+.Sh DESCRIPTION
+These functions provide an API for reading information about
+objects on disk.
+In particular, they provide an interface for populating
+.Tn struct archive_entry
+objects.
+.Bl -tag -width indent
+.It Fn archive_read_disk_new
+Allocates and initializes a
+.Tn struct archive
+object suitable for reading object information from disk.
+.It Xo
+.Fn archive_read_disk_set_symlink_logical ,
+.Fn archive_read_disk_set_symlink_physical ,
+.Fn archive_read_disk_set_symlink_hybrid
+.Xc
+This sets the mode used for handling symbolic links.
+The
+.Dq logical
+mode follows all symbolic links.
+The
+.Dq physical
+mode does not follow any symbolic links.
+The
+.Dq hybrid
+mode currently behaves identically to the
+.Dq logical
+mode.
+.It Xo
+.Fn archive_read_disk_gname ,
+.Fn archive_read_disk_uname
+.Xc
+Returns a user or group name given a gid or uid value.
+By default, these always return a NULL string.
+.It Xo
+.Fn archive_read_disk_set_gname_lookup ,
+.Fn archive_read_disk_set_uname_lookup
+.Xc
+These allow you to override the functions used for
+user and group name lookups.
+You may also provide a
+.Tn void *
+pointer to a private data structure and a cleanup function for
+that data.
+The cleanup function will be invoked when the
+.Tn struct archive
+object is destroyed or when new lookup functions are registered.
+.It Fn archive_read_disk_set_standard_lookup
+This convenience function installs a standard set of user
+and group name lookup functions.
+These functions use
+.Xr getpwid 3
+and
+.Xr getgrid 3
+to convert ids to names, defaulting to NULL if the names cannot
+be looked up.
+These functions also implement a simple memory cache to reduce
+the number of calls to
+.Xr getpwid 3
+and
+.Xr getgrid 3 .
+.It Fn archive_read_disk_entry_from_file
+Populates a
+.Tn struct archive_entry
+object with information about a particular file.
+The
+.Tn archive_entry
+object must have already been created with
+.Xr archive_entry_new 3
+and at least one of the source path or path fields must already be set.
+(If both are set, the source path will be used.)
+.Pp
+Information is read from disk using the path name from the
+.Tn struct archive_entry
+object.
+If a file descriptor is provided, some information will be obtained using
+that file descriptor, on platforms that support the appropriate
+system calls.
+.Pp
+If a pointer to a
+.Tn struct stat
+is provided, information from that structure will be used instead
+of reading from the disk where appropriate.
+This can provide performance benefits in scenarios where
+.Tn struct stat
+information has already been read from the disk as a side effect
+of some other operation.
+(For example, directory traversal libraries often provide this information.)
+.Pp
+Where necessary, user and group ids are converted to user and group names
+using the currently registered lookup functions above.
+This affects the file ownership fields and ACL values in the
+.Tn struct archive_entry
+object.
+.It Fn archive_read_close
+This currently does nothing.
+.It Fn archive_write_finish
+Invokes
+.Fn archive_write_close
+if it was not invoked manually, then releases all resources.
+.El
+More information about the
+.Va struct archive
+object and the overall design of the library can be found in the
+.Xr libarchive 3
+overview.
+.Sh EXAMPLE
+The following illustrates basic usage of the library by
+showing how to use it to copy an item on disk into an archive.
+.Bd -literal -offset indent
+void
+file_to_archive(struct archive *a, const char *name)
+{
+ char buff[8192];
+ size_t bytes_read;
+ struct archive *ard;
+ struct archive_entry *entry;
+ int fd;
+
+ ard = archive_read_disk_new();
+ archive_read_disk_set_standard_lookup(ard);
+ entry = archive_entry_new();
+ fd = open(name, O_RDONLY);
+ if (fd < 0)
+ return;
+ archive_entry_copy_sourcepath(entry, name);
+ archive_read_disk_entry_from_file(ard, entry, fd, NULL);
+ archive_write_header(a, entry);
+ while ((bytes_read = read(fd, buff, sizeof(buff))) > 0)
+ archive_write_data(a, buff, bytes_read);
+ archive_write_finish_entry(a);
+ archive_read_finish(ard);
+ archive_entry_free(entry);
+}
+.Ed
+.Sh RETURN VALUES
+Most functions return
+.Cm ARCHIVE_OK
+(zero) on success, or one of several negative
+error codes for errors.
+Specific error codes include:
+.Cm ARCHIVE_RETRY
+for operations that might succeed if retried,
+.Cm ARCHIVE_WARN
+for unusual conditions that do not prevent further operations, and
+.Cm ARCHIVE_FATAL
+for serious errors that make remaining operations impossible.
+The
+.Xr archive_errno 3
+and
+.Xr archive_error_string 3
+functions can be used to retrieve an appropriate error code and a
+textual error message.
+(See
+.Xr archive_util 3
+for details.)
+.Pp
+.Fn archive_read_disk_new
+returns a pointer to a newly-allocated
+.Tn struct archive
+object or NULL if the allocation failed for any reason.
+.Pp
+.Fn archive_read_disk_gname
+and
+.Fn archive_read_disk_uname
+return
+.Tn const char *
+pointers to the textual name or NULL if the lookup failed for any reason.
+The returned pointer points to internal storage that
+may be reused on the next call to either of these functions;
+callers should copy the string if they need to continue accessing it.
+.Pp
+.Sh SEE ALSO
+.Xr archive_read 3 ,
+.Xr archive_write 3 ,
+.Xr archive_write_disk 3 ,
+.Xr tar 1 ,
+.Xr libarchive 3
+.Sh HISTORY
+The
+.Nm libarchive
+library first appeared in
+.Fx 5.3 .
+The
+.Nm archive_read_disk
+interface was added to
+.Nm libarchive 2.6
+and first appeared in
+.Fx 8.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm libarchive
+library was written by
+.An Tim Kientzle Aq kientzle@freebsd.org .
+.Sh BUGS
+The
+.Dq standard
+user name and group name lookup functions are not the defaults because
+.Xr getgrid 3
+and
+.Xr getpwid 3
+are sometimes too large for particular applications.
+The current design allows the application author to use a more
+compact implementation when appropriate.
+.Pp
+The full list of metadata read from disk by
+.Fn archive_read_disk_entry_from_file
+is necessarily system-dependent.
+.Pp
+The
+.Fn archive_read_disk_entry_from_file
+function reads as much information as it can from disk.
+Some method should be provided to limit this so that clients who
+do not need ACLs, for instance, can avoid the extra work needed
+to look up such information.
+.Pp
+This API should provide a set of methods for walking a directory tree.
+That would make it a direct parallel of the
+.Xr archive_read 3
+API.
+When such methods are implemented, the
+.Dq hybrid
+symbolic link mode will make sense.
diff --git a/archivers/libarchive/files/libarchive/archive_read_disk.c b/archivers/libarchive/files/libarchive/archive_read_disk.c
new file mode 100644
index 00000000000..8fad7f13733
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_disk.c
@@ -0,0 +1,198 @@
+/*-
+ * Copyright (c) 2003-2009 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
+ * in this position and unchanged.
+ * 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 "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk.c 189429 2009-03-06 04:35:31Z kientzle $");
+
+#include "archive.h"
+#include "archive_string.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_disk_private.h"
+
+static int _archive_read_finish(struct archive *);
+static int _archive_read_close(struct archive *);
+static const char *trivial_lookup_gname(void *, gid_t gid);
+static const char *trivial_lookup_uname(void *, uid_t uid);
+
+static struct archive_vtable *
+archive_read_disk_vtable(void)
+{
+ static struct archive_vtable av;
+ static int inited = 0;
+
+ if (!inited) {
+ av.archive_finish = _archive_read_finish;
+ av.archive_close = _archive_read_close;
+ }
+ return (&av);
+}
+
+const char *
+archive_read_disk_gname(struct archive *_a, gid_t gid)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ if (a->lookup_gname != NULL)
+ return ((*a->lookup_gname)(a->lookup_gname_data, gid));
+ return (NULL);
+}
+
+const char *
+archive_read_disk_uname(struct archive *_a, uid_t uid)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ if (a->lookup_uname != NULL)
+ return ((*a->lookup_uname)(a->lookup_uname_data, uid));
+ return (NULL);
+}
+
+int
+archive_read_disk_set_gname_lookup(struct archive *_a,
+ void *private_data,
+ const char * (*lookup_gname)(void *private, gid_t gid),
+ void (*cleanup_gname)(void *private))
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ __archive_check_magic(&a->archive, ARCHIVE_READ_DISK_MAGIC,
+ ARCHIVE_STATE_ANY, "archive_read_disk_set_gname_lookup");
+
+ if (a->cleanup_gname != NULL && a->lookup_gname_data != NULL)
+ (a->cleanup_gname)(a->lookup_gname_data);
+
+ a->lookup_gname = lookup_gname;
+ a->cleanup_gname = cleanup_gname;
+ a->lookup_gname_data = private_data;
+ return (ARCHIVE_OK);
+}
+
+int
+archive_read_disk_set_uname_lookup(struct archive *_a,
+ void *private_data,
+ const char * (*lookup_uname)(void *private, uid_t uid),
+ void (*cleanup_uname)(void *private))
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ __archive_check_magic(&a->archive, ARCHIVE_READ_DISK_MAGIC,
+ ARCHIVE_STATE_ANY, "archive_read_disk_set_uname_lookup");
+
+ if (a->cleanup_uname != NULL && a->lookup_uname_data != NULL)
+ (a->cleanup_uname)(a->lookup_uname_data);
+
+ a->lookup_uname = lookup_uname;
+ a->cleanup_uname = cleanup_uname;
+ a->lookup_uname_data = private_data;
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Create a new archive_read_disk object and initialize it with global state.
+ */
+struct archive *
+archive_read_disk_new(void)
+{
+ struct archive_read_disk *a;
+
+ a = (struct archive_read_disk *)malloc(sizeof(*a));
+ if (a == NULL)
+ return (NULL);
+ memset(a, 0, sizeof(*a));
+ a->archive.magic = ARCHIVE_READ_DISK_MAGIC;
+ /* We're ready to write a header immediately. */
+ a->archive.state = ARCHIVE_STATE_HEADER;
+ a->archive.vtable = archive_read_disk_vtable();
+ a->lookup_uname = trivial_lookup_uname;
+ a->lookup_gname = trivial_lookup_gname;
+ return (&a->archive);
+}
+
+static int
+_archive_read_finish(struct archive *_a)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+
+ if (a->cleanup_gname != NULL && a->lookup_gname_data != NULL)
+ (a->cleanup_gname)(a->lookup_gname_data);
+ if (a->cleanup_uname != NULL && a->lookup_uname_data != NULL)
+ (a->cleanup_uname)(a->lookup_uname_data);
+ archive_string_free(&a->archive.error_string);
+ free(a);
+ return (ARCHIVE_OK);
+}
+
+static int
+_archive_read_close(struct archive *_a)
+{
+ (void)_a; /* UNUSED */
+ return (ARCHIVE_OK);
+}
+
+int
+archive_read_disk_set_symlink_logical(struct archive *_a)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ a->symlink_mode = 'L';
+ a->follow_symlinks = 1;
+ return (ARCHIVE_OK);
+}
+
+int
+archive_read_disk_set_symlink_physical(struct archive *_a)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ a->symlink_mode = 'P';
+ a->follow_symlinks = 0;
+ return (ARCHIVE_OK);
+}
+
+int
+archive_read_disk_set_symlink_hybrid(struct archive *_a)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ a->symlink_mode = 'H';
+ a->follow_symlinks = 1; /* Follow symlinks initially. */
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Trivial implementations of gname/uname lookup functions.
+ * These are normally overridden by the client, but these stub
+ * versions ensure that we always have something that works.
+ */
+static const char *
+trivial_lookup_gname(void *private_data, gid_t gid)
+{
+ (void)private_data; /* UNUSED */
+ (void)gid; /* UNUSED */
+ return (NULL);
+}
+
+static const char *
+trivial_lookup_uname(void *private_data, uid_t uid)
+{
+ (void)private_data; /* UNUSED */
+ (void)uid; /* UNUSED */
+ return (NULL);
+}
diff --git a/archivers/libarchive/files/libarchive/archive_read_disk_entry_from_file.c b/archivers/libarchive/files/libarchive/archive_read_disk_entry_from_file.c
new file mode 100644
index 00000000000..e3795dec0a4
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_disk_entry_from_file.c
@@ -0,0 +1,563 @@
+/*-
+ * Copyright (c) 2003-2009 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 "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk_entry_from_file.c 201084 2009-12-28 02:14:09Z kientzle $");
+
+#ifdef HAVE_SYS_TYPES_H
+/* Mac OSX requires sys/types.h before sys/acl.h. */
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_ACL_H
+#include <sys/acl.h>
+#endif
+#ifdef HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#endif
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
+#ifdef HAVE_ACL_LIBACL_H
+#include <acl/libacl.h>
+#endif
+#ifdef HAVE_ATTR_XATTR_H
+#include <attr/xattr.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_disk_private.h"
+
+/*
+ * Linux and FreeBSD plug this obvious hole in POSIX.1e in
+ * different ways.
+ */
+#if HAVE_ACL_GET_PERM
+#define ACL_GET_PERM acl_get_perm
+#elif HAVE_ACL_GET_PERM_NP
+#define ACL_GET_PERM acl_get_perm_np
+#endif
+
+static int setup_acls_posix1e(struct archive_read_disk *,
+ struct archive_entry *, int fd);
+static int setup_xattrs(struct archive_read_disk *,
+ struct archive_entry *, int fd);
+
+int
+archive_read_disk_entry_from_file(struct archive *_a,
+ struct archive_entry *entry,
+ int fd, const struct stat *st)
+{
+ struct archive_read_disk *a = (struct archive_read_disk *)_a;
+ const char *path, *name;
+ struct stat s;
+ int initial_fd = fd;
+ int r, r1;
+
+ archive_clear_error(_a);
+ path = archive_entry_sourcepath(entry);
+ if (path == NULL)
+ path = archive_entry_pathname(entry);
+
+#ifdef EXT2_IOC_GETFLAGS
+ /* Linux requires an extra ioctl to pull the flags. Although
+ * this is an extra step, it has a nice side-effect: We get an
+ * open file descriptor which we can use in the subsequent lookups. */
+ if ((S_ISREG(st->st_mode) || S_ISDIR(st->st_mode))) {
+ if (fd < 0)
+ fd = open(pathname, O_RDONLY | O_NONBLOCK | O_BINARY);
+ if (fd >= 0) {
+ unsigned long stflags;
+ int r = ioctl(fd, EXT2_IOC_GETFLAGS, &stflags);
+ if (r == 0 && stflags != 0)
+ archive_entry_set_fflags(entry, stflags, 0);
+ }
+ }
+#endif
+
+ if (st == NULL) {
+ /* TODO: On Windows, use GetFileInfoByHandle() here.
+ * Using Windows stat() call is badly broken, but
+ * even the stat() wrapper has problems because
+ * 'struct stat' is broken on Windows.
+ */
+#if HAVE_FSTAT
+ if (fd >= 0) {
+ if (fstat(fd, &s) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't fstat");
+ return (ARCHIVE_FAILED);
+ }
+ } else
+#endif
+#if HAVE_LSTAT
+ if (!a->follow_symlinks) {
+ if (lstat(path, &s) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't lstat %s", path);
+ return (ARCHIVE_FAILED);
+ }
+ } else
+#endif
+ if (stat(path, &s) != 0) {
+ archive_set_error(&a->archive, errno,
+ "Can't lstat %s", path);
+ return (ARCHIVE_FAILED);
+ }
+ st = &s;
+ }
+ archive_entry_copy_stat(entry, st);
+
+ /* Lookup uname/gname */
+ name = archive_read_disk_uname(_a, archive_entry_uid(entry));
+ if (name != NULL)
+ archive_entry_copy_uname(entry, name);
+ name = archive_read_disk_gname(_a, archive_entry_gid(entry));
+ if (name != NULL)
+ archive_entry_copy_gname(entry, name);
+
+#ifdef HAVE_STRUCT_STAT_ST_FLAGS
+ /* On FreeBSD, we get flags for free with the stat. */
+ /* TODO: Does this belong in copy_stat()? */
+ if (st->st_flags != 0)
+ archive_entry_set_fflags(entry, st->st_flags, 0);
+#endif
+
+#ifdef HAVE_READLINK
+ if (S_ISLNK(st->st_mode)) {
+ char linkbuffer[PATH_MAX + 1];
+ int lnklen = readlink(path, linkbuffer, PATH_MAX);
+ if (lnklen < 0) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't read link data");
+ return (ARCHIVE_FAILED);
+ }
+ linkbuffer[lnklen] = 0;
+ archive_entry_set_symlink(entry, linkbuffer);
+ }
+#endif
+
+ r = setup_acls_posix1e(a, entry, fd);
+ r1 = setup_xattrs(a, entry, fd);
+ if (r1 < r)
+ r = r1;
+ /* If we opened the file earlier in this function, close it. */
+ if (initial_fd != fd)
+ close(fd);
+ return (r);
+}
+
+#ifdef HAVE_POSIX_ACL
+static void setup_acl_posix1e(struct archive_read_disk *a,
+ struct archive_entry *entry, acl_t acl, int archive_entry_acl_type);
+
+static int
+setup_acls_posix1e(struct archive_read_disk *a,
+ struct archive_entry *entry, int fd)
+{
+ const char *accpath;
+ acl_t acl;
+
+ accpath = archive_entry_sourcepath(entry);
+ if (accpath == NULL)
+ accpath = archive_entry_pathname(entry);
+
+ archive_entry_acl_clear(entry);
+
+ /* Retrieve access ACL from file. */
+ if (fd >= 0)
+ acl = acl_get_fd(fd);
+#if HAVE_ACL_GET_LINK_NP
+ else if (!a->follow_symlinks)
+ acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
+#endif
+ else
+ acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
+ if (acl != NULL) {
+ setup_acl_posix1e(a, entry, acl,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
+ acl_free(acl);
+ }
+
+ /* Only directories can have default ACLs. */
+ if (S_ISDIR(archive_entry_mode(entry))) {
+ acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
+ if (acl != NULL) {
+ setup_acl_posix1e(a, entry, acl,
+ ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
+ acl_free(acl);
+ }
+ }
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Translate POSIX.1e ACL into libarchive internal structure.
+ */
+static void
+setup_acl_posix1e(struct archive_read_disk *a,
+ struct archive_entry *entry, acl_t acl, int archive_entry_acl_type)
+{
+ acl_tag_t acl_tag;
+ acl_entry_t acl_entry;
+ acl_permset_t acl_permset;
+ int s, ae_id, ae_tag, ae_perm;
+ const char *ae_name;
+
+ s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
+ while (s == 1) {
+ ae_id = -1;
+ ae_name = NULL;
+
+ acl_get_tag_type(acl_entry, &acl_tag);
+ if (acl_tag == ACL_USER) {
+ ae_id = (int)*(uid_t *)acl_get_qualifier(acl_entry);
+ ae_name = archive_read_disk_uname(&a->archive, ae_id);
+ ae_tag = ARCHIVE_ENTRY_ACL_USER;
+ } else if (acl_tag == ACL_GROUP) {
+ ae_id = (int)*(gid_t *)acl_get_qualifier(acl_entry);
+ ae_name = archive_read_disk_gname(&a->archive, ae_id);
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
+ } else if (acl_tag == ACL_MASK) {
+ ae_tag = ARCHIVE_ENTRY_ACL_MASK;
+ } else if (acl_tag == ACL_USER_OBJ) {
+ ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
+ } else if (acl_tag == ACL_GROUP_OBJ) {
+ ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
+ } else if (acl_tag == ACL_OTHER) {
+ ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
+ } else {
+ /* Skip types that libarchive can't support. */
+ continue;
+ }
+
+ acl_get_permset(acl_entry, &acl_permset);
+ ae_perm = 0;
+ /*
+ * acl_get_perm() is spelled differently on different
+ * platforms; see above.
+ */
+ if (ACL_GET_PERM(acl_permset, ACL_EXECUTE))
+ ae_perm |= ARCHIVE_ENTRY_ACL_EXECUTE;
+ if (ACL_GET_PERM(acl_permset, ACL_READ))
+ ae_perm |= ARCHIVE_ENTRY_ACL_READ;
+ if (ACL_GET_PERM(acl_permset, ACL_WRITE))
+ ae_perm |= ARCHIVE_ENTRY_ACL_WRITE;
+
+ archive_entry_acl_add_entry(entry,
+ archive_entry_acl_type, ae_perm, ae_tag,
+ ae_id, ae_name);
+
+ s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
+ }
+}
+#else
+static int
+setup_acls_posix1e(struct archive_read_disk *a,
+ struct archive_entry *entry, int fd)
+{
+ (void)a; /* UNUSED */
+ (void)entry; /* UNUSED */
+ (void)fd; /* UNUSED */
+ return (ARCHIVE_OK);
+}
+#endif
+
+#if HAVE_LISTXATTR && HAVE_LLISTXATTR && HAVE_GETXATTR && HAVE_LGETXATTR
+
+/*
+ * Linux extended attribute support.
+ *
+ * TODO: By using a stack-allocated buffer for the first
+ * call to getxattr(), we might be able to avoid the second
+ * call entirely. We only need the second call if the
+ * stack-allocated buffer is too small. But a modest buffer
+ * of 1024 bytes or so will often be big enough. Same applies
+ * to listxattr().
+ */
+
+
+static int
+setup_xattr(struct archive_read_disk *a,
+ struct archive_entry *entry, const char *name, int fd)
+{
+ ssize_t size;
+ void *value = NULL;
+ const char *accpath;
+
+ (void)fd; /* UNUSED */
+
+ accpath = archive_entry_sourcepath(entry);
+ if (accpath == NULL)
+ accpath = archive_entry_pathname(entry);
+
+ if (!a->follow_symlinks)
+ size = lgetxattr(accpath, name, NULL, 0);
+ else
+ size = getxattr(accpath, name, NULL, 0);
+
+ if (size == -1) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't query extended attribute");
+ return (ARCHIVE_WARN);
+ }
+
+ if (size > 0 && (value = malloc(size)) == NULL) {
+ archive_set_error(&a->archive, errno, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (!a->follow_symlinks)
+ size = lgetxattr(accpath, name, value, size);
+ else
+ size = getxattr(accpath, name, value, size);
+
+ if (size == -1) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't read extended attribute");
+ return (ARCHIVE_WARN);
+ }
+
+ archive_entry_xattr_add_entry(entry, name, value, size);
+
+ free(value);
+ return (ARCHIVE_OK);
+}
+
+static int
+setup_xattrs(struct archive_read_disk *a,
+ struct archive_entry *entry, int fd)
+{
+ char *list, *p;
+ const char *path;
+ ssize_t list_size;
+
+
+ path = archive_entry_sourcepath(entry);
+ if (path == NULL)
+ path = archive_entry_pathname(entry);
+
+ if (!a->follow_symlinks)
+ list_size = llistxattr(path, NULL, 0);
+ else
+ list_size = listxattr(path, NULL, 0);
+
+ if (list_size == -1) {
+ if (errno == ENOTSUP)
+ return (ARCHIVE_OK);
+ archive_set_error(&a->archive, errno,
+ "Couldn't list extended attributes");
+ return (ARCHIVE_WARN);
+ }
+
+ if (list_size == 0)
+ return (ARCHIVE_OK);
+
+ if ((list = malloc(list_size)) == NULL) {
+ archive_set_error(&a->archive, errno, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (!a->follow_symlinks)
+ list_size = llistxattr(path, list, list_size);
+ else
+ list_size = listxattr(path, list, list_size);
+
+ if (list_size == -1) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't retrieve extended attributes");
+ free(list);
+ return (ARCHIVE_WARN);
+ }
+
+ for (p = list; (p - list) < list_size; p += strlen(p) + 1) {
+ if (strncmp(p, "system.", 7) == 0 ||
+ strncmp(p, "xfsroot.", 8) == 0)
+ continue;
+ setup_xattr(a, entry, p, fd);
+ }
+
+ free(list);
+ return (ARCHIVE_OK);
+}
+
+#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE
+
+/*
+ * FreeBSD extattr interface.
+ */
+
+/* TODO: Implement this. Follow the Linux model above, but
+ * with FreeBSD-specific system calls, of course. Be careful
+ * to not include the system extattrs that hold ACLs; we handle
+ * those separately.
+ */
+int
+setup_xattr(struct archive_read_disk *a, struct archive_entry *entry,
+ int namespace, const char *name, const char *fullname, int fd);
+
+int
+setup_xattr(struct archive_read_disk *a, struct archive_entry *entry,
+ int namespace, const char *name, const char *fullname, int fd)
+{
+ ssize_t size;
+ void *value = NULL;
+ const char *accpath;
+
+ (void)fd; /* UNUSED */
+
+ accpath = archive_entry_sourcepath(entry);
+ if (accpath == NULL)
+ accpath = archive_entry_pathname(entry);
+
+ if (!a->follow_symlinks)
+ size = extattr_get_link(accpath, namespace, name, NULL, 0);
+ else
+ size = extattr_get_file(accpath, namespace, name, NULL, 0);
+
+ if (size == -1) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't query extended attribute");
+ return (ARCHIVE_WARN);
+ }
+
+ if (size > 0 && (value = malloc(size)) == NULL) {
+ archive_set_error(&a->archive, errno, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (!a->follow_symlinks)
+ size = extattr_get_link(accpath, namespace, name, value, size);
+ else
+ size = extattr_get_file(accpath, namespace, name, value, size);
+
+ if (size == -1) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't read extended attribute");
+ return (ARCHIVE_WARN);
+ }
+
+ archive_entry_xattr_add_entry(entry, fullname, value, size);
+
+ free(value);
+ return (ARCHIVE_OK);
+}
+
+static int
+setup_xattrs(struct archive_read_disk *a,
+ struct archive_entry *entry, int fd)
+{
+ char buff[512];
+ char *list, *p;
+ ssize_t list_size;
+ const char *path;
+ int namespace = EXTATTR_NAMESPACE_USER;
+
+ path = archive_entry_sourcepath(entry);
+ if (path == NULL)
+ path = archive_entry_pathname(entry);
+
+ if (!a->follow_symlinks)
+ list_size = extattr_list_link(path, namespace, NULL, 0);
+ else
+ list_size = extattr_list_file(path, namespace, NULL, 0);
+
+ if (list_size == -1 && errno == EOPNOTSUPP)
+ return (ARCHIVE_OK);
+ if (list_size == -1) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't list extended attributes");
+ return (ARCHIVE_WARN);
+ }
+
+ if (list_size == 0)
+ return (ARCHIVE_OK);
+
+ if ((list = malloc(list_size)) == NULL) {
+ archive_set_error(&a->archive, errno, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (!a->follow_symlinks)
+ list_size = extattr_list_link(path, namespace, list, list_size);
+ else
+ list_size = extattr_list_file(path, namespace, list, list_size);
+
+ if (list_size == -1) {
+ archive_set_error(&a->archive, errno,
+ "Couldn't retrieve extended attributes");
+ free(list);
+ return (ARCHIVE_WARN);
+ }
+
+ p = list;
+ while ((p - list) < list_size) {
+ size_t len = 255 & (int)*p;
+ char *name;
+
+ strcpy(buff, "user.");
+ name = buff + strlen(buff);
+ memcpy(name, p + 1, len);
+ name[len] = '\0';
+ setup_xattr(a, entry, namespace, name, buff, fd);
+ p += 1 + len;
+ }
+
+ free(list);
+ return (ARCHIVE_OK);
+}
+
+#else
+
+/*
+ * Generic (stub) extended attribute support.
+ */
+static int
+setup_xattrs(struct archive_read_disk *a,
+ struct archive_entry *entry, int fd)
+{
+ (void)a; /* UNUSED */
+ (void)entry; /* UNUSED */
+ (void)fd; /* UNUSED */
+ return (ARCHIVE_OK);
+}
+
+#endif
diff --git a/archivers/libarchive/files/libarchive/archive_read_disk_private.h b/archivers/libarchive/files/libarchive/archive_read_disk_private.h
new file mode 100644
index 00000000000..b674b7106d7
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_disk_private.h
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 2003-2009 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
+ * in this position and unchanged.
+ * 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.
+ *
+ * $FreeBSD: head/lib/libarchive/archive_read_disk_private.h 201105 2009-12-28 03:20:54Z kientzle $
+ */
+
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
+#ifndef ARCHIVE_READ_DISK_PRIVATE_H_INCLUDED
+#define ARCHIVE_READ_DISK_PRIVATE_H_INCLUDED
+
+struct archive_read_disk {
+ struct archive archive;
+
+ /*
+ * Symlink mode is one of 'L'ogical, 'P'hysical, or 'H'ybrid,
+ * following an old BSD convention. 'L' follows all symlinks,
+ * 'P' follows none, 'H' follows symlinks only for the first
+ * item.
+ */
+ char symlink_mode;
+
+ /*
+ * Since symlink interaction changes, we need to track whether
+ * we're following symlinks for the current item. 'L' mode above
+ * sets this true, 'P' sets it false, 'H' changes it as we traverse.
+ */
+ char follow_symlinks; /* Either 'L' or 'P'. */
+
+ const char * (*lookup_gname)(void *private, gid_t gid);
+ void (*cleanup_gname)(void *private);
+ void *lookup_gname_data;
+ const char * (*lookup_uname)(void *private, gid_t gid);
+ void (*cleanup_uname)(void *private);
+ void *lookup_uname_data;
+};
+
+#endif
diff --git a/archivers/libarchive/files/libarchive/archive_read_disk_set_standard_lookup.c b/archivers/libarchive/files/libarchive/archive_read_disk_set_standard_lookup.c
new file mode 100644
index 00000000000..94f4a3087bd
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_disk_set_standard_lookup.c
@@ -0,0 +1,272 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_disk_set_standard_lookup.c 201109 2009-12-28 03:30:31Z kientzle $");
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "archive.h"
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+int
+archive_read_disk_set_standard_lookup(struct archive *a)
+{
+ archive_set_error(a, -1, "Standard lookups not available on Windows");
+ return (ARCHIVE_FATAL);
+}
+#else /* ! (_WIN32 && !__CYGWIN__) */
+#define name_cache_size 127
+
+static const char * const NO_NAME = "(noname)";
+
+struct name_cache {
+ struct archive *archive;
+ char *buff;
+ size_t buff_size;
+ int probes;
+ int hits;
+ size_t size;
+ struct {
+ id_t id;
+ const char *name;
+ } cache[name_cache_size];
+};
+
+static const char * lookup_gname(void *, gid_t);
+static const char * lookup_uname(void *, uid_t);
+static void cleanup(void *);
+static const char * lookup_gname_helper(struct name_cache *, id_t gid);
+static const char * lookup_uname_helper(struct name_cache *, id_t uid);
+
+/*
+ * Installs functions that use getpwuid()/getgrgid()---along with
+ * a simple cache to accelerate such lookups---into the archive_read_disk
+ * object. This is in a separate file because getpwuid()/getgrgid()
+ * can pull in a LOT of library code (including NIS/LDAP functions, which
+ * pull in DNS resolveers, etc). This can easily top 500kB, which makes
+ * it inappropriate for some space-constrained applications.
+ *
+ * Applications that are size-sensitive may want to just use the
+ * real default functions (defined in archive_read_disk.c) that just
+ * use the uid/gid without the lookup. Or define your own custom functions
+ * if you prefer.
+ */
+int
+archive_read_disk_set_standard_lookup(struct archive *a)
+{
+ struct name_cache *ucache = malloc(sizeof(struct name_cache));
+ struct name_cache *gcache = malloc(sizeof(struct name_cache));
+
+ if (ucache == NULL || gcache == NULL) {
+ archive_set_error(a, ENOMEM,
+ "Can't allocate uname/gname lookup cache");
+ free(ucache);
+ free(gcache);
+ return (ARCHIVE_FATAL);
+ }
+
+ memset(ucache, 0, sizeof(*ucache));
+ ucache->archive = a;
+ ucache->size = name_cache_size;
+ memset(gcache, 0, sizeof(*gcache));
+ gcache->archive = a;
+ gcache->size = name_cache_size;
+
+ archive_read_disk_set_gname_lookup(a, gcache, lookup_gname, cleanup);
+ archive_read_disk_set_uname_lookup(a, ucache, lookup_uname, cleanup);
+
+ return (ARCHIVE_OK);
+}
+
+static void
+cleanup(void *data)
+{
+ struct name_cache *cache = (struct name_cache *)data;
+ size_t i;
+
+ if (cache != NULL) {
+ for (i = 0; i < cache->size; i++) {
+ if (cache->cache[i].name != NULL &&
+ cache->cache[i].name != NO_NAME)
+ free((void *)(uintptr_t)cache->cache[i].name);
+ }
+ free(cache->buff);
+ free(cache);
+ }
+}
+
+/*
+ * Lookup uid/gid from uname/gname, return NULL if no match.
+ */
+static const char *
+lookup_name(struct name_cache *cache,
+ const char * (*lookup_fn)(struct name_cache *, id_t), id_t id)
+{
+ const char *name;
+ int slot;
+
+
+ cache->probes++;
+
+ slot = id % cache->size;
+ if (cache->cache[slot].name != NULL) {
+ if (cache->cache[slot].id == id) {
+ cache->hits++;
+ if (cache->cache[slot].name == NO_NAME)
+ return (NULL);
+ return (cache->cache[slot].name);
+ }
+ if (cache->cache[slot].name != NO_NAME)
+ free((void *)(uintptr_t)cache->cache[slot].name);
+ cache->cache[slot].name = NULL;
+ }
+
+ name = (lookup_fn)(cache, id);
+ if (name == NULL) {
+ /* Cache and return the negative response. */
+ cache->cache[slot].name = NO_NAME;
+ cache->cache[slot].id = id;
+ return (NULL);
+ }
+
+ cache->cache[slot].name = name;
+ cache->cache[slot].id = id;
+ return (cache->cache[slot].name);
+}
+
+static const char *
+lookup_uname(void *data, uid_t uid)
+{
+ struct name_cache *uname_cache = (struct name_cache *)data;
+ return (lookup_name(uname_cache,
+ &lookup_uname_helper, (id_t)uid));
+}
+
+static const char *
+lookup_uname_helper(struct name_cache *cache, id_t id)
+{
+ struct passwd pwent, *result;
+ int r;
+
+ if (cache->buff_size == 0) {
+ cache->buff_size = 256;
+ cache->buff = malloc(cache->buff_size);
+ }
+ if (cache->buff == NULL)
+ return (NULL);
+ for (;;) {
+ result = &pwent; /* Old getpwuid_r ignores last arg. */
+ r = getpwuid_r((uid_t)id, &pwent,
+ cache->buff, cache->buff_size, &result);
+ if (r == 0)
+ break;
+ if (r != ERANGE)
+ break;
+ /* ERANGE means our buffer was too small, but POSIX
+ * doesn't tell us how big the buffer should be, so
+ * we just double it and try again. Because the buffer
+ * is kept around in the cache object, we shouldn't
+ * have to do this very often. */
+ cache->buff_size *= 2;
+ cache->buff = realloc(cache->buff, cache->buff_size);
+ if (cache->buff == NULL)
+ break;
+ }
+ if (r != 0) {
+ archive_set_error(cache->archive, errno,
+ "Can't lookup user for id %d", (int)id);
+ return (NULL);
+ }
+ if (result == NULL)
+ return (NULL);
+
+ return strdup(result->pw_name);
+}
+
+static const char *
+lookup_gname(void *data, gid_t gid)
+{
+ struct name_cache *gname_cache = (struct name_cache *)data;
+ return (lookup_name(gname_cache,
+ &lookup_gname_helper, (id_t)gid));
+}
+
+static const char *
+lookup_gname_helper(struct name_cache *cache, id_t id)
+{
+ struct group grent, *result;
+ int r;
+
+ if (cache->buff_size == 0) {
+ cache->buff_size = 256;
+ cache->buff = malloc(cache->buff_size);
+ }
+ if (cache->buff == NULL)
+ return (NULL);
+ for (;;) {
+ result = &grent; /* Old getgrgid_r ignores last arg. */
+ r = getgrgid_r((gid_t)id, &grent,
+ cache->buff, cache->buff_size, &result);
+ if (r == 0)
+ break;
+ if (r != ERANGE)
+ break;
+ /* ERANGE means our buffer was too small, but POSIX
+ * doesn't tell us how big the buffer should be, so
+ * we just double it and try again. */
+ cache->buff_size *= 2;
+ cache->buff = realloc(cache->buff, cache->buff_size);
+ if (cache->buff == NULL)
+ break;
+ }
+ if (r != 0) {
+ archive_set_error(cache->archive, errno,
+ "Can't lookup group for id %d", (int)id);
+ return (NULL);
+ }
+ if (result == NULL)
+ return (NULL);
+
+ return strdup(result->gr_name);
+}
+#endif /* ! (_WIN32 && !__CYGWIN__) */
diff --git a/archivers/libarchive/files/libarchive/archive_read_open_fd.c b/archivers/libarchive/files/libarchive/archive_read_open_fd.c
index 2ebd46d6cdf..33b7cba1b9b 100644
--- a/archivers/libarchive/files/libarchive/archive_read_open_fd.c
+++ b/archivers/libarchive/files/libarchive/archive_read_open_fd.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_open_fd.c,v 1.13 2007/06/26 03:06:48 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_open_fd.c 201103 2009-12-28 03:13:49Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -32,6 +32,12 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_open_fd.c,v 1.13 2007/06/26
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -52,7 +58,6 @@ struct read_fd_data {
};
static int file_close(struct archive *, void *);
-static int file_open(struct archive *, void *);
static ssize_t file_read(struct archive *, void *, const void **buff);
#if ARCHIVE_API_VERSION < 2
static ssize_t file_skip(struct archive *, void *, size_t request);
@@ -63,50 +68,45 @@ static off_t file_skip(struct archive *, void *, off_t request);
int
archive_read_open_fd(struct archive *a, int fd, size_t block_size)
{
+ struct stat st;
struct read_fd_data *mine;
+ void *b;
- mine = (struct read_fd_data *)malloc(sizeof(*mine));
- if (mine == NULL) {
- archive_set_error(a, ENOMEM, "No memory");
+ archive_clear_error(a);
+ if (fstat(fd, &st) != 0) {
+ archive_set_error(a, errno, "Can't stat fd %d", fd);
return (ARCHIVE_FATAL);
}
- mine->block_size = block_size;
- mine->buffer = malloc(mine->block_size);
- if (mine->buffer == NULL) {
+
+ mine = (struct read_fd_data *)malloc(sizeof(*mine));
+ b = malloc(block_size);
+ if (mine == NULL || b == NULL) {
archive_set_error(a, ENOMEM, "No memory");
free(mine);
+ free(b);
return (ARCHIVE_FATAL);
}
+ mine->block_size = block_size;
+ mine->buffer = b;
mine->fd = fd;
- /* lseek() hardly ever works, so disable it by default. See below. */
- mine->can_skip = 0;
- return (archive_read_open2(a, mine, file_open, file_read, file_skip, file_close));
-}
-
-static int
-file_open(struct archive *a, void *client_data)
-{
- struct read_fd_data *mine = (struct read_fd_data *)client_data;
- struct stat st;
-
- if (fstat(mine->fd, &st) != 0) {
- archive_set_error(a, errno, "Can't stat fd %d", mine->fd);
- return (ARCHIVE_FATAL);
- }
-
+ /*
+ * Skip support is a performance optimization for anything
+ * that supports lseek(). On FreeBSD, only regular files and
+ * raw disk devices support lseek() and there's no portable
+ * way to determine if a device is a raw disk device, so we
+ * only enable this optimization for regular files.
+ */
if (S_ISREG(st.st_mode)) {
archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
- /*
- * Enabling skip here is a performance optimization for
- * anything that supports lseek(). On FreeBSD, only
- * regular files and raw disk devices support lseek() and
- * there's no portable way to determine if a device is
- * a raw disk device, so we only enable this optimization
- * for regular files.
- */
mine->can_skip = 1;
- }
- return (ARCHIVE_OK);
+ } else
+ mine->can_skip = 0;
+#if defined(__CYGWIN__) || defined(_WIN32)
+ setmode(mine->fd, O_BINARY);
+#endif
+
+ return (archive_read_open2(a, mine,
+ NULL, file_read, file_skip, file_close));
}
static ssize_t
@@ -180,8 +180,7 @@ file_close(struct archive *a, void *client_data)
struct read_fd_data *mine = (struct read_fd_data *)client_data;
(void)a; /* UNUSED */
- if (mine->buffer != NULL)
- free(mine->buffer);
+ free(mine->buffer);
free(mine);
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_open_file.c b/archivers/libarchive/files/libarchive/archive_read_open_file.c
index 55c431c7da6..095ae6eb5ce 100644
--- a/archivers/libarchive/files/libarchive/archive_read_open_file.c
+++ b/archivers/libarchive/files/libarchive/archive_read_open_file.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_open_file.c,v 1.20 2007/06/26 03:06:48 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_open_file.c 201093 2009-12-28 02:28:44Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -35,6 +35,9 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_open_file.c,v 1.20 2007/06/2
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -55,7 +58,6 @@ struct read_FILE_data {
};
static int file_close(struct archive *, void *);
-static int file_open(struct archive *, void *);
static ssize_t file_read(struct archive *, void *, const void **buff);
#if ARCHIVE_API_VERSION < 2
static ssize_t file_skip(struct archive *, void *, size_t request);
@@ -66,45 +68,41 @@ static off_t file_skip(struct archive *, void *, off_t request);
int
archive_read_open_FILE(struct archive *a, FILE *f)
{
+ struct stat st;
struct read_FILE_data *mine;
+ size_t block_size = 128 * 1024;
+ void *b;
+ archive_clear_error(a);
mine = (struct read_FILE_data *)malloc(sizeof(*mine));
- if (mine == NULL) {
- archive_set_error(a, ENOMEM, "No memory");
- return (ARCHIVE_FATAL);
- }
- mine->block_size = 128 * 1024;
- mine->buffer = malloc(mine->block_size);
- if (mine->buffer == NULL) {
+ b = malloc(block_size);
+ if (mine == NULL || b == NULL) {
archive_set_error(a, ENOMEM, "No memory");
free(mine);
+ free(b);
return (ARCHIVE_FATAL);
}
+ mine->block_size = block_size;
+ mine->buffer = b;
mine->f = f;
- /* Suppress skip by default. See below. */
- mine->can_skip = 0;
- return (archive_read_open2(a, mine, file_open, file_read,
- file_skip, file_close));
-}
-
-static int
-file_open(struct archive *a, void *client_data)
-{
- struct read_FILE_data *mine = (struct read_FILE_data *)client_data;
- struct stat st;
-
/*
- * If we can't fstat() the file, it may just be that
- * it's not a file. (FILE * objects can wrap many kinds
- * of I/O streams.)
+ * If we can't fstat() the file, it may just be that it's not
+ * a file. (FILE * objects can wrap many kinds of I/O
+ * streams, some of which don't support fileno()).)
*/
if (fstat(fileno(mine->f), &st) == 0 && S_ISREG(st.st_mode)) {
archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
- /* Enable the seek optimization for regular files. */
+ /* Enable the seek optimization only for regular files. */
mine->can_skip = 1;
- }
+ } else
+ mine->can_skip = 0;
- return (ARCHIVE_OK);
+#if defined(__CYGWIN__) || defined(_WIN32)
+ setmode(fileno(mine->f), O_BINARY);
+#endif
+
+ return (archive_read_open2(a, mine, NULL, file_read,
+ file_skip, file_close));
}
static ssize_t
diff --git a/archivers/libarchive/files/libarchive/archive_read_open_filename.c b/archivers/libarchive/files/libarchive/archive_read_open_filename.c
index 3d6376fbcfa..607b80c56c7 100644
--- a/archivers/libarchive/files/libarchive/archive_read_open_filename.c
+++ b/archivers/libarchive/files/libarchive/archive_read_open_filename.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_open_filename.c,v 1.21 2008/02/19 06:10:48 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_open_filename.c 201093 2009-12-28 02:28:44Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -35,6 +35,9 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_open_filename.c,v 1.21 2008/
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -61,7 +64,6 @@ struct read_file_data {
};
static int file_close(struct archive *, void *);
-static int file_open(struct archive *, void *);
static ssize_t file_read(struct archive *, void *, const void **buff);
#if ARCHIVE_API_VERSION < 2
static ssize_t file_skip(struct archive *, void *, size_t request);
@@ -80,78 +82,75 @@ int
archive_read_open_filename(struct archive *a, const char *filename,
size_t block_size)
{
+ struct stat st;
struct read_file_data *mine;
+ void *b;
+ int fd;
+ archive_clear_error(a);
if (filename == NULL || filename[0] == '\0') {
- mine = (struct read_file_data *)malloc(sizeof(*mine));
- if (mine == NULL) {
- archive_set_error(a, ENOMEM, "No memory");
- return (ARCHIVE_FATAL);
- }
- mine->filename[0] = '\0';
+ /* We used to invoke archive_read_open_fd(a,0,block_size)
+ * here, but that doesn't (and shouldn't) handle the
+ * end-of-file flush when reading stdout from a pipe.
+ * Basically, read_open_fd() is intended for folks who
+ * are willing to handle such details themselves. This
+ * API is intended to be a little smarter for folks who
+ * want easy handling of the common case.
+ */
+ filename = ""; /* Normalize NULL to "" */
+ fd = 0;
+#if defined(__CYGWIN__) || defined(_WIN32)
+ setmode(0, O_BINARY);
+#endif
} else {
- mine = (struct read_file_data *)malloc(sizeof(*mine) + strlen(filename));
- if (mine == NULL) {
- archive_set_error(a, ENOMEM, "No memory");
+ fd = open(filename, O_RDONLY | O_BINARY);
+ if (fd < 0) {
+ archive_set_error(a, errno,
+ "Failed to open '%s'", filename);
return (ARCHIVE_FATAL);
}
- strcpy(mine->filename, filename);
}
- mine->block_size = block_size;
- mine->buffer = NULL;
- mine->fd = -1;
- /* lseek() almost never works; disable it by default. See below. */
- mine->can_skip = 0;
- return (archive_read_open2(a, mine, file_open, file_read, file_skip, file_close));
-}
-
-static int
-file_open(struct archive *a, void *client_data)
-{
- struct read_file_data *mine = (struct read_file_data *)client_data;
- struct stat st;
-
- mine->buffer = malloc(mine->block_size);
- if (mine->buffer == NULL) {
- archive_set_error(a, ENOMEM, "No memory");
+ if (fstat(fd, &st) != 0) {
+ archive_set_error(a, errno, "Can't stat '%s'", filename);
return (ARCHIVE_FATAL);
}
- if (mine->filename[0] != '\0')
- mine->fd = open(mine->filename, O_RDONLY | O_BINARY);
- else
- mine->fd = 0; /* Fake "open" for stdin. */
- if (mine->fd < 0) {
- archive_set_error(a, errno, "Failed to open '%s'",
- mine->filename);
+
+ mine = (struct read_file_data *)calloc(1,
+ sizeof(*mine) + strlen(filename));
+ b = malloc(block_size);
+ if (mine == NULL || b == NULL) {
+ archive_set_error(a, ENOMEM, "No memory");
+ free(mine);
+ free(b);
return (ARCHIVE_FATAL);
}
- if (fstat(mine->fd, &st) == 0) {
- /* If we're reading a file from disk, ensure that we don't
- overwrite it with an extracted file. */
- if (S_ISREG(st.st_mode)) {
- archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
- /*
- * Enabling skip here is a performance
- * optimization for anything that supports
- * lseek(). On FreeBSD, only regular files
- * and raw disk devices support lseek() and
- * there's no portable way to determine if a
- * device is a raw disk device, so we only
- * enable this optimization for regular files.
- */
- mine->can_skip = 1;
- }
- /* Remember mode so close can decide whether to flush. */
- mine->st_mode = st.st_mode;
- } else {
- if (mine->filename[0] == '\0')
- archive_set_error(a, errno, "Can't stat stdin");
- else
- archive_set_error(a, errno, "Can't stat '%s'",
- mine->filename);
- return (ARCHIVE_FATAL);
+ strcpy(mine->filename, filename);
+ mine->block_size = block_size;
+ mine->buffer = b;
+ mine->fd = fd;
+ /* Remember mode so close can decide whether to flush. */
+ mine->st_mode = st.st_mode;
+ /* If we're reading a file from disk, ensure that we don't
+ overwrite it with an extracted file. */
+ if (S_ISREG(st.st_mode)) {
+ archive_read_extract_set_skip_file(a, st.st_dev, st.st_ino);
+ /*
+ * Enabling skip here is a performance optimization
+ * for anything that supports lseek(). On FreeBSD
+ * (and probably many other systems), only regular
+ * files and raw disk devices support lseek() (on
+ * other input types, lseek() returns success but
+ * doesn't actually change the file pointer, which
+ * just completely screws up the position-tracking
+ * logic). In addition, I've yet to find a portable
+ * way to determine if a device is a raw disk device.
+ * So I don't see a way to do much better than to only
+ * enable this optimization for regular files.
+ */
+ mine->can_skip = 1;
}
- return (0);
+ return (archive_read_open2(a, mine,
+ NULL, file_read, file_skip, file_close));
}
static ssize_t
@@ -238,30 +237,32 @@ file_close(struct archive *a, void *client_data)
(void)a; /* UNUSED */
- /*
- * Sometimes, we should flush the input before closing.
- * Regular files: faster to just close without flush.
- * Devices: must not flush (user might need to
- * read the "next" item on a non-rewind device).
- * Pipes and sockets: must flush (otherwise, the
- * program feeding the pipe or socket may complain).
- * Here, I flush everything except for regular files and
- * device nodes.
- */
- if (!S_ISREG(mine->st_mode)
- && !S_ISCHR(mine->st_mode)
- && !S_ISBLK(mine->st_mode)) {
- ssize_t bytesRead;
- do {
- bytesRead = read(mine->fd, mine->buffer,
- mine->block_size);
- } while (bytesRead > 0);
+ /* Only flush and close if open succeeded. */
+ if (mine->fd >= 0) {
+ /*
+ * Sometimes, we should flush the input before closing.
+ * Regular files: faster to just close without flush.
+ * Devices: must not flush (user might need to
+ * read the "next" item on a non-rewind device).
+ * Pipes and sockets: must flush (otherwise, the
+ * program feeding the pipe or socket may complain).
+ * Here, I flush everything except for regular files and
+ * device nodes.
+ */
+ if (!S_ISREG(mine->st_mode)
+ && !S_ISCHR(mine->st_mode)
+ && !S_ISBLK(mine->st_mode)) {
+ ssize_t bytesRead;
+ do {
+ bytesRead = read(mine->fd, mine->buffer,
+ mine->block_size);
+ } while (bytesRead > 0);
+ }
+ /* If a named file was opened, then it needs to be closed. */
+ if (mine->filename[0] != '\0')
+ close(mine->fd);
}
- /* If a named file was opened, then it needs to be closed. */
- if (mine->filename[0] != '\0')
- close(mine->fd);
- if (mine->buffer != NULL)
- free(mine->buffer);
+ free(mine->buffer);
free(mine);
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_private.h b/archivers/libarchive/files/libarchive/archive_read_private.h
index f4d0274b509..5a850189042 100644
--- a/archivers/libarchive/files/libarchive/archive_read_private.h
+++ b/archivers/libarchive/files/libarchive/archive_read_private.h
@@ -22,9 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_read_private.h,v 1.6 2008/03/15 11:09:16 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_read_private.h 201088 2009-12-28 02:18:55Z kientzle $
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
#ifndef ARCHIVE_READ_PRIVATE_H_INCLUDED
#define ARCHIVE_READ_PRIVATE_H_INCLUDED
@@ -32,6 +36,86 @@
#include "archive_string.h"
#include "archive_private.h"
+struct archive_read;
+struct archive_read_filter_bidder;
+struct archive_read_filter;
+
+/*
+ * How bidding works for filters:
+ * * The bid manager reads the first block from the current source.
+ * * It shows that block to each registered bidder.
+ * * The bid manager creates a new filter structure for the winning
+ * bidder and gives the winning bidder a chance to initialize it.
+ * * The new filter becomes the top filter in the archive_read structure
+ * and we repeat the process.
+ * This ends only when no bidder provides a non-zero bid.
+ */
+struct archive_read_filter_bidder {
+ /* Configuration data for the bidder. */
+ void *data;
+ /* Taste the upstream filter to see if we handle this. */
+ int (*bid)(struct archive_read_filter_bidder *,
+ struct archive_read_filter *);
+ /* Initialize a newly-created filter. */
+ int (*init)(struct archive_read_filter *);
+ /* Set an option for the filter bidder. */
+ int (*options)(struct archive_read_filter_bidder *,
+ const char *key, const char *value);
+ /* Release the bidder's configuration data. */
+ int (*free)(struct archive_read_filter_bidder *);
+};
+
+/*
+ * This structure is allocated within the archive_read core
+ * and initialized by archive_read and the init() method of the
+ * corresponding bidder above.
+ */
+struct archive_read_filter {
+ /* Essentially all filters will need these values, so
+ * just declare them here. */
+ struct archive_read_filter_bidder *bidder; /* My bidder. */
+ struct archive_read_filter *upstream; /* Who I read from. */
+ struct archive_read *archive; /* Associated archive. */
+ /* Return next block. */
+ ssize_t (*read)(struct archive_read_filter *, const void **);
+ /* Skip forward this many bytes. */
+ int64_t (*skip)(struct archive_read_filter *self, int64_t request);
+ /* Close (just this filter) and free(self). */
+ int (*close)(struct archive_read_filter *self);
+ /* My private data. */
+ void *data;
+
+ const char *name;
+ int code;
+
+ /* Used by reblocking logic. */
+ char *buffer;
+ size_t buffer_size;
+ char *next; /* Current read location. */
+ size_t avail; /* Bytes in my buffer. */
+ const void *client_buff; /* Client buffer information. */
+ size_t client_total;
+ const char *client_next;
+ size_t client_avail;
+ int64_t position;
+ char end_of_file;
+ char fatal;
+};
+
+/*
+ * The client looks a lot like a filter, so we just wrap it here.
+ *
+ * TODO: Make archive_read_filter and archive_read_client identical so
+ * that users of the library can easily register their own
+ * transformation filters. This will probably break the API/ABI and
+ * so should be deferred at least until libarchive 3.0.
+ */
+struct archive_read_client {
+ archive_read_callback *reader;
+ archive_skip_callback *skipper;
+ archive_close_callback *closer;
+};
+
struct archive_read {
struct archive archive;
@@ -50,48 +134,19 @@ struct archive_read {
off_t read_data_output_offset;
size_t read_data_remaining;
- /* Callbacks to open/read/write/close archive stream. */
- archive_open_callback *client_opener;
- archive_read_callback *client_reader;
- archive_skip_callback *client_skipper;
- archive_close_callback *client_closer;
- void *client_data;
+ /* Callbacks to open/read/write/close client archive stream. */
+ struct archive_read_client client;
+
+ /* Registered filter bidders. */
+ struct archive_read_filter_bidder bidders[8];
+
+ /* Last filter in chain */
+ struct archive_read_filter *filter;
/* File offset of beginning of most recently-read header. */
off_t header_position;
/*
- * Decompressors have a very specific lifecycle:
- * public setup function initializes a slot in this table
- * 'config' holds minimal configuration data
- * bid() examines a block of data and returns a bid [1]
- * init() is called for successful bidder
- * 'data' is initialized by init()
- * read() returns a pointer to the next block of data
- * consume() indicates how much data is used
- * skip() ignores bytes of data
- * finish() cleans up and frees 'data' and 'config'
- *
- * [1] General guideline: bid the number of bits that you actually
- * test, e.g., 16 if you test a 2-byte magic value.
- */
- struct decompressor_t {
- void *config;
- void *data;
- int (*bid)(const void *buff, size_t);
- int (*init)(struct archive_read *,
- const void *buff, size_t);
- int (*finish)(struct archive_read *);
- ssize_t (*read_ahead)(struct archive_read *,
- const void **, size_t);
- ssize_t (*consume)(struct archive_read *, size_t);
- off_t (*skip)(struct archive_read *, off_t);
- } decompressors[4];
-
- /* Pointer to current decompressor. */
- struct decompressor_t *decompressor;
-
- /*
* Format detection is mostly the same as compression
* detection, with one significant difference: The bidders
* use the read_ahead calls above to examine the stream rather
@@ -101,12 +156,15 @@ struct archive_read {
struct archive_format_descriptor {
void *data;
+ const char *name;
int (*bid)(struct archive_read *);
+ int (*options)(struct archive_read *, const char *key,
+ const char *value);
int (*read_header)(struct archive_read *, struct archive_entry *);
int (*read_data)(struct archive_read *, const void **, size_t *, off_t *);
int (*read_data_skip)(struct archive_read *);
int (*cleanup)(struct archive_read *);
- } formats[8];
+ } formats[9];
struct archive_format_descriptor *format; /* Active format. */
/*
@@ -118,18 +176,24 @@ struct archive_read {
int __archive_read_register_format(struct archive_read *a,
void *format_data,
+ const char *name,
int (*bid)(struct archive_read *),
+ int (*options)(struct archive_read *, const char *, const char *),
int (*read_header)(struct archive_read *, struct archive_entry *),
int (*read_data)(struct archive_read *, const void **, size_t *, off_t *),
int (*read_data_skip)(struct archive_read *),
int (*cleanup)(struct archive_read *));
-struct decompressor_t
- *__archive_read_register_compression(struct archive_read *a,
- int (*bid)(const void *, size_t),
- int (*init)(struct archive_read *, const void *, size_t));
-
-const void
- *__archive_read_ahead(struct archive_read *, size_t);
-
+struct archive_read_filter_bidder
+ *__archive_read_get_bidder(struct archive_read *a);
+
+const void *__archive_read_ahead(struct archive_read *, size_t, ssize_t *);
+const void *__archive_read_filter_ahead(struct archive_read_filter *,
+ size_t, ssize_t *);
+ssize_t __archive_read_consume(struct archive_read *, size_t);
+ssize_t __archive_read_filter_consume(struct archive_read_filter *, size_t);
+int64_t __archive_read_skip(struct archive_read *, int64_t);
+int64_t __archive_read_skip_lenient(struct archive_read *, int64_t);
+int64_t __archive_read_filter_skip(struct archive_read_filter *, int64_t);
+int __archive_read_program(struct archive_read_filter *, const char *);
#endif
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_all.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_all.c
index da2b246bed5..a6db7364d09 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_compression_all.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_all.c
@@ -24,20 +24,37 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_all.c,v 1.6 2007/01/09 08:05:55 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_all.c 201248 2009-12-30 06:12:03Z kientzle $");
#include "archive.h"
int
archive_read_support_compression_all(struct archive *a)
{
-#if HAVE_BZLIB_H
+ /* Bzip falls back to "bunzip2" command-line */
archive_read_support_compression_bzip2(a);
-#endif
/* The decompress code doesn't use an outside library. */
archive_read_support_compression_compress(a);
-#if HAVE_ZLIB_H
+ /* Gzip decompress falls back to "gunzip" command-line. */
archive_read_support_compression_gzip(a);
-#endif
+ /* The LZMA file format has a very weak signature, so it
+ * may not be feasible to keep this here, but we'll try.
+ * This will come back out if there are problems. */
+ /* Lzma falls back to "unlzma" command-line program. */
+ archive_read_support_compression_lzma(a);
+ /* Xz falls back to "unxz" command-line program. */
+ archive_read_support_compression_xz(a);
+ /* The decode code doesn't use an outside library. */
+ archive_read_support_compression_uu(a);
+ /* The decode code doesn't use an outside library. */
+ archive_read_support_compression_rpm(a);
+
+ /* Note: We always return ARCHIVE_OK here, even if some of the
+ * above return ARCHIVE_WARN. The intent here is to enable
+ * "as much as possible." Clients who need specific
+ * compression should enable those individually so they can
+ * verify the level of support. */
+ /* Clear any warning messages set by the above functions. */
+ archive_clear_error(a);
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c
index 824b0cdeb56..1e45f22023c 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c
@@ -25,7 +25,7 @@
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_bzip2.c,v 1.18 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_bzip2.c 201108 2009-12-28 03:28:21Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -51,30 +51,54 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_bzip2.c,
#if HAVE_BZLIB_H
struct private_data {
bz_stream stream;
- char *uncompressed_buffer;
- size_t uncompressed_buffer_size;
- char *read_next;
- int64_t total_out;
+ char *out_block;
+ size_t out_block_size;
+ char valid; /* True = decompressor is initialized */
char eof; /* True = found end of compressed data. */
};
-static int finish(struct archive_read *);
-static ssize_t read_ahead(struct archive_read *, const void **, size_t);
-static ssize_t read_consume(struct archive_read *, size_t);
-static int drive_decompressor(struct archive_read *a, struct private_data *);
+/* Bzip2 filter */
+static ssize_t bzip2_filter_read(struct archive_read_filter *, const void **);
+static int bzip2_filter_close(struct archive_read_filter *);
#endif
-/* These two functions are defined even if we lack the library. See below. */
-static int bid(const void *, size_t);
-static int init(struct archive_read *, const void *, size_t);
+/*
+ * Note that we can detect bzip2 archives even if we can't decompress
+ * them. (In fact, we like detecting them because we can give better
+ * error messages.) So the bid framework here gets compiled even
+ * if bzlib is unavailable.
+ */
+static int bzip2_reader_bid(struct archive_read_filter_bidder *, struct archive_read_filter *);
+static int bzip2_reader_init(struct archive_read_filter *);
+static int bzip2_reader_free(struct archive_read_filter_bidder *);
int
archive_read_support_compression_bzip2(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- if (__archive_read_register_compression(a, bid, init) != NULL)
- return (ARCHIVE_OK);
- return (ARCHIVE_FATAL);
+ struct archive_read_filter_bidder *reader = __archive_read_get_bidder(a);
+
+ if (reader == NULL)
+ return (ARCHIVE_FATAL);
+
+ reader->data = NULL;
+ reader->bid = bzip2_reader_bid;
+ reader->init = bzip2_reader_init;
+ reader->options = NULL;
+ reader->free = bzip2_reader_free;
+#if HAVE_BZLIB_H
+ return (ARCHIVE_OK);
+#else
+ archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+ "Using external bunzip2 program");
+ return (ARCHIVE_WARN);
+#endif
+}
+
+static int
+bzip2_reader_free(struct archive_read_filter_bidder *self){
+ (void)self; /* UNUSED */
+ return (ARCHIVE_OK);
}
/*
@@ -85,59 +109,38 @@ archive_read_support_compression_bzip2(struct archive *_a)
* from verifying as much as we would like.
*/
static int
-bid(const void *buff, size_t len)
+bzip2_reader_bid(struct archive_read_filter_bidder *self, struct archive_read_filter *filter)
{
const unsigned char *buffer;
+ ssize_t avail;
int bits_checked;
- if (len < 1)
- return (0);
-
- buffer = (const unsigned char *)buff;
- bits_checked = 0;
- if (buffer[0] != 'B') /* Verify first ID byte. */
- return (0);
- bits_checked += 8;
- if (len < 2)
- return (bits_checked);
+ (void)self; /* UNUSED */
- if (buffer[1] != 'Z') /* Verify second ID byte. */
+ /* Minimal bzip2 archive is 14 bytes. */
+ buffer = __archive_read_filter_ahead(filter, 14, &avail);
+ if (buffer == NULL)
return (0);
- bits_checked += 8;
- if (len < 3)
- return (bits_checked);
- if (buffer[2] != 'h') /* Verify third ID byte. */
+ /* First three bytes must be "BZh" */
+ bits_checked = 0;
+ if (buffer[0] != 'B' || buffer[1] != 'Z' || buffer[2] != 'h')
return (0);
- bits_checked += 8;
- if (len < 4)
- return (bits_checked);
+ bits_checked += 24;
+ /* Next follows a compression flag which must be an ASCII digit. */
if (buffer[3] < '1' || buffer[3] > '9')
return (0);
bits_checked += 5;
- if (len < 5)
- return (bits_checked);
/* After BZh[1-9], there must be either a data block
* which begins with 0x314159265359 or an end-of-data
* marker of 0x177245385090. */
-
- if (buffer[4] == 0x31) {
- /* Verify the data block signature. */
- size_t s = len;
- if (s > 10) s = 10;
- if (memcmp(buffer + 4, "\x31\x41\x59\x26\x53\x59", s - 4) != 0)
- return (0);
- bits_checked += 8 * (s - 4);
- } else if (buffer[4] == 0x17) {
- /* Verify the end-of-data marker. */
- size_t s = len;
- if (s > 10) s = 10;
- if (memcmp(buffer + 4, "\x17\x72\x45\x38\x50\x90", s - 4) != 0)
- return (0);
- bits_checked += 8 * (s - 4);
- } else
+ if (memcmp(buffer + 4, "\x31\x41\x59\x26\x53\x59", 6) == 0)
+ bits_checked += 48;
+ else if (memcmp(buffer + 4, "\x17\x72\x45\x38\x50\x90", 6) == 0)
+ bits_checked += 48;
+ else
return (0);
return (bits_checked);
@@ -151,15 +154,17 @@ bid(const void *buff, size_t len)
* and emit a useful message.
*/
static int
-init(struct archive_read *a, const void *buff, size_t n)
+bzip2_reader_init(struct archive_read_filter *self)
{
- (void)a; /* UNUSED */
- (void)buff; /* UNUSED */
- (void)n; /* UNUSED */
-
- archive_set_error(&a->archive, -1,
- "This version of libarchive was compiled without bzip2 support");
- return (ARCHIVE_FATAL);
+ int r;
+
+ r = __archive_read_program(self, "bunzip2");
+ /* Note: We set the format here even if __archive_read_program()
+ * above fails. We do, after all, know what the format is
+ * even if we weren't able to read it. */
+ self->code = ARCHIVE_COMPRESSION_BZIP2;
+ self->name = "bzip2";
+ return (r);
}
@@ -169,258 +174,180 @@ init(struct archive_read *a, const void *buff, size_t n)
* Setup the callbacks.
*/
static int
-init(struct archive_read *a, const void *buff, size_t n)
+bzip2_reader_init(struct archive_read_filter *self)
{
+ static const size_t out_block_size = 64 * 1024;
+ void *out_block;
struct private_data *state;
- int ret;
- a->archive.compression_code = ARCHIVE_COMPRESSION_BZIP2;
- a->archive.compression_name = "bzip2";
+ self->code = ARCHIVE_COMPRESSION_BZIP2;
+ self->name = "bzip2";
- state = (struct private_data *)malloc(sizeof(*state));
- if (state == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate data for %s decompression",
- a->archive.compression_name);
- return (ARCHIVE_FATAL);
- }
- memset(state, 0, sizeof(*state));
-
- state->uncompressed_buffer_size = 64 * 1024;
- state->uncompressed_buffer = (char *)malloc(state->uncompressed_buffer_size);
- state->stream.next_out = state->uncompressed_buffer;
- state->read_next = state->uncompressed_buffer;
- state->stream.avail_out = state->uncompressed_buffer_size;
-
- if (state->uncompressed_buffer == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate %s decompression buffers",
- a->archive.compression_name);
+ state = (struct private_data *)calloc(sizeof(*state), 1);
+ out_block = (unsigned char *)malloc(out_block_size);
+ if (self == NULL || state == NULL || out_block == NULL) {
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Can't allocate data for bzip2 decompression");
+ free(out_block);
free(state);
return (ARCHIVE_FATAL);
}
- /*
- * A bug in bzlib.h: stream.next_in should be marked 'const'
- * but isn't (the library never alters data through the
- * next_in pointer, only reads it). The result: this ugly
- * cast to remove 'const'.
- */
- state->stream.next_in = (char *)(uintptr_t)(const void *)buff;
- state->stream.avail_in = n;
-
- a->decompressor->read_ahead = read_ahead;
- a->decompressor->consume = read_consume;
- a->decompressor->skip = NULL; /* not supported */
- a->decompressor->finish = finish;
-
- /* Initialize compression library. */
- ret = BZ2_bzDecompressInit(&(state->stream),
- 0 /* library verbosity */,
- 0 /* don't use slow low-mem algorithm */);
-
- /* If init fails, try using low-memory algorithm instead. */
- if (ret == BZ_MEM_ERROR) {
- ret = BZ2_bzDecompressInit(&(state->stream),
- 0 /* library verbosity */,
- 1 /* do use slow low-mem algorithm */);
- }
-
- if (ret == BZ_OK) {
- a->decompressor->data = state;
- return (ARCHIVE_OK);
- }
+ self->data = state;
+ state->out_block_size = out_block_size;
+ state->out_block = out_block;
+ self->read = bzip2_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = bzip2_filter_close;
- /* Library setup failed: Clean up. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Internal error initializing %s library",
- a->archive.compression_name);
- free(state->uncompressed_buffer);
- free(state);
-
- /* Override the error message if we know what really went wrong. */
- switch (ret) {
- case BZ_PARAM_ERROR:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Internal error initializing compression library: "
- "invalid setup parameter");
- break;
- case BZ_MEM_ERROR:
- archive_set_error(&a->archive, ENOMEM,
- "Internal error initializing compression library: "
- "out of memory");
- break;
- case BZ_CONFIG_ERROR:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Internal error initializing compression library: "
- "mis-compiled library");
- break;
- }
-
- return (ARCHIVE_FATAL);
+ return (ARCHIVE_OK);
}
/*
- * Return a block of data from the decompression buffer. Decompress more
- * as necessary.
+ * Return the next block of decompressed data.
*/
static ssize_t
-read_ahead(struct archive_read *a, const void **p, size_t min)
+bzip2_filter_read(struct archive_read_filter *self, const void **p)
{
struct private_data *state;
- size_t read_avail, was_avail;
- int ret;
-
- state = (struct private_data *)a->decompressor->data;
- if (!a->client_reader) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
- "No read callback is registered? "
- "This is probably an internal programming error.");
- return (ARCHIVE_FATAL);
- }
+ size_t decompressed;
+ const char *read_buf;
+ ssize_t ret;
- read_avail = state->stream.next_out - state->read_next;
+ state = (struct private_data *)self->data;
- if (read_avail + state->stream.avail_out < min) {
- memmove(state->uncompressed_buffer, state->read_next,
- read_avail);
- state->read_next = state->uncompressed_buffer;
- state->stream.next_out = state->read_next + read_avail;
- state->stream.avail_out
- = state->uncompressed_buffer_size - read_avail;
+ if (state->eof) {
+ *p = NULL;
+ return (0);
}
- while (read_avail < min && /* Haven't satisfied min. */
- read_avail < state->uncompressed_buffer_size) { /* !full */
- was_avail = read_avail;
- if ((ret = drive_decompressor(a, state)) < ARCHIVE_OK)
- return (ret);
- if (ret == ARCHIVE_EOF)
- break; /* Break on EOF even if we haven't met min. */
- read_avail = state->stream.next_out - state->read_next;
- if (was_avail == read_avail) /* No progress? */
- break;
- }
+ /* Empty our output buffer. */
+ state->stream.next_out = state->out_block;
+ state->stream.avail_out = state->out_block_size;
- *p = state->read_next;
- return (read_avail);
-}
+ /* Try to fill the output buffer. */
+ for (;;) {
+ if (!state->valid) {
+ if (bzip2_reader_bid(self->bidder, self->upstream) == 0) {
+ state->eof = 1;
+ *p = state->out_block;
+ decompressed = state->stream.next_out
+ - state->out_block;
+ return (decompressed);
+ }
+ /* Initialize compression library. */
+ ret = BZ2_bzDecompressInit(&(state->stream),
+ 0 /* library verbosity */,
+ 0 /* don't use low-mem algorithm */);
+
+ /* If init fails, try low-memory algorithm instead. */
+ if (ret == BZ_MEM_ERROR)
+ ret = BZ2_bzDecompressInit(&(state->stream),
+ 0 /* library verbosity */,
+ 1 /* do use low-mem algo */);
+
+ if (ret != BZ_OK) {
+ const char *detail = NULL;
+ int err = ARCHIVE_ERRNO_MISC;
+ switch (ret) {
+ case BZ_PARAM_ERROR:
+ detail = "invalid setup parameter";
+ break;
+ case BZ_MEM_ERROR:
+ err = ENOMEM;
+ detail = "out of memory";
+ break;
+ case BZ_CONFIG_ERROR:
+ detail = "mis-compiled library";
+ break;
+ }
+ archive_set_error(&self->archive->archive, err,
+ "Internal error initializing decompressor%s%s",
+ detail == NULL ? "" : ": ",
+ detail);
+ return (ARCHIVE_FATAL);
+ }
+ state->valid = 1;
+ }
-/*
- * Mark a previously-returned block of data as read.
- */
-static ssize_t
-read_consume(struct archive_read *a, size_t n)
-{
- struct private_data *state;
+ /* stream.next_in is really const, but bzlib
+ * doesn't declare it so. <sigh> */
+ read_buf =
+ __archive_read_filter_ahead(self->upstream, 1, &ret);
+ if (read_buf == NULL)
+ return (ARCHIVE_FATAL);
+ state->stream.next_in = (char *)(uintptr_t)read_buf;
+ state->stream.avail_in = ret;
+ /* There is no more data, return whatever we have. */
+ if (ret == 0) {
+ state->eof = 1;
+ *p = state->out_block;
+ decompressed = state->stream.next_out
+ - state->out_block;
+ return (decompressed);
+ }
- state = (struct private_data *)a->decompressor->data;
- a->archive.file_position += n;
- state->read_next += n;
- if (state->read_next > state->stream.next_out)
- __archive_errx(1, "Request to consume too many "
- "bytes from bzip2 decompressor");
- return (n);
-}
+ /* Decompress as much as we can in one pass. */
+ ret = BZ2_bzDecompress(&(state->stream));
+ __archive_read_filter_consume(self->upstream,
+ state->stream.next_in - read_buf);
-/*
- * Clean up the decompressor.
- */
-static int
-finish(struct archive_read *a)
-{
- struct private_data *state;
- int ret;
-
- state = (struct private_data *)a->decompressor->data;
- ret = ARCHIVE_OK;
- switch (BZ2_bzDecompressEnd(&(state->stream))) {
- case BZ_OK:
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Failed to clean up %s compressor",
- a->archive.compression_name);
- ret = ARCHIVE_FATAL;
+ switch (ret) {
+ case BZ_STREAM_END: /* Found end of stream. */
+ switch (BZ2_bzDecompressEnd(&(state->stream))) {
+ case BZ_OK:
+ break;
+ default:
+ archive_set_error(&(self->archive->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up decompressor");
+ return (ARCHIVE_FATAL);
+ }
+ state->valid = 0;
+ /* FALLTHROUGH */
+ case BZ_OK: /* Decompressor made some progress. */
+ /* If we filled our buffer, update stats and return. */
+ if (state->stream.avail_out == 0) {
+ *p = state->out_block;
+ decompressed = state->stream.next_out
+ - state->out_block;
+ return (decompressed);
+ }
+ break;
+ default: /* Return an error. */
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC, "bzip decompression failed");
+ return (ARCHIVE_FATAL);
+ }
}
-
- free(state->uncompressed_buffer);
- free(state);
-
- a->decompressor->data = NULL;
- return (ret);
}
/*
- * Utility function to pull data through decompressor, reading input
- * blocks as necessary.
+ * Clean up the decompressor.
*/
static int
-drive_decompressor(struct archive_read *a, struct private_data *state)
+bzip2_filter_close(struct archive_read_filter *self)
{
- ssize_t ret;
- int decompressed, total_decompressed;
- char *output;
- const void *read_buf;
-
- if (state->eof)
- return (ARCHIVE_EOF);
- total_decompressed = 0;
- for (;;) {
- if (state->stream.avail_in == 0) {
- read_buf = state->stream.next_in;
- ret = (a->client_reader)(&a->archive, a->client_data,
- &read_buf);
- state->stream.next_in = (void *)(uintptr_t)read_buf;
- if (ret < 0) {
- /*
- * TODO: Find a better way to handle
- * this read failure.
- */
- goto fatal;
- }
- if (ret == 0 && total_decompressed == 0) {
- archive_set_error(&a->archive, EIO,
- "Premature end of %s compressed data",
- a->archive.compression_name);
- return (ARCHIVE_FATAL);
- }
- a->archive.raw_position += ret;
- state->stream.avail_in = ret;
- }
-
- {
- output = state->stream.next_out;
-
- /* Decompress some data. */
- ret = BZ2_bzDecompress(&(state->stream));
- decompressed = state->stream.next_out - output;
+ struct private_data *state;
+ int ret = ARCHIVE_OK;
- /* Accumulate the total bytes of output. */
- state->total_out += decompressed;
- total_decompressed += decompressed;
+ state = (struct private_data *)self->data;
- switch (ret) {
- case BZ_OK: /* Decompressor made some progress. */
- if (decompressed > 0)
- return (ARCHIVE_OK);
- break;
- case BZ_STREAM_END: /* Found end of stream. */
- state->eof = 1;
- return (ARCHIVE_OK);
- default:
- /* Any other return value is an error. */
- goto fatal;
- }
+ if (state->valid) {
+ switch (BZ2_bzDecompressEnd(&state->stream)) {
+ case BZ_OK:
+ break;
+ default:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up decompressor");
+ ret = ARCHIVE_FATAL;
}
}
- return (ARCHIVE_OK);
- /* Return a fatal error. */
-fatal:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "%s decompression failed", a->archive.compression_name);
- return (ARCHIVE_FATAL);
+ free(state->out_block);
+ free(state);
+ return (ret);
}
#endif /* HAVE_BZLIB_H */
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c
index 050099b210e..2461975e59b 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_compress.c
@@ -64,7 +64,7 @@
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_compress.c,v 1.10 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_compress.c 201094 2009-12-28 02:29:21Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -100,11 +100,8 @@ struct private_data {
size_t bytes_in_section;
/* Output variables. */
- size_t uncompressed_buffer_size;
- void *uncompressed_buffer;
- unsigned char *read_next; /* Data for client. */
- unsigned char *next_out; /* Where to write new data. */
- size_t avail_out; /* Space at end of buffer. */
+ size_t out_block_size;
+ void *out_block;
/* Decompression status variables. */
int use_reset_code;
@@ -133,21 +130,31 @@ struct private_data {
unsigned char stack[65300];
};
-static int bid(const void *, size_t);
-static int finish(struct archive_read *);
-static int init(struct archive_read *, const void *, size_t);
-static ssize_t read_ahead(struct archive_read *, const void **, size_t);
-static ssize_t read_consume(struct archive_read *, size_t);
-static int getbits(struct archive_read *, struct private_data *, int n);
-static int next_code(struct archive_read *a, struct private_data *state);
+static int compress_bidder_bid(struct archive_read_filter_bidder *, struct archive_read_filter *);
+static int compress_bidder_init(struct archive_read_filter *);
+static int compress_bidder_free(struct archive_read_filter_bidder *);
+
+static ssize_t compress_filter_read(struct archive_read_filter *, const void **);
+static int compress_filter_close(struct archive_read_filter *);
+
+static int getbits(struct archive_read_filter *, int n);
+static int next_code(struct archive_read_filter *);
int
archive_read_support_compression_compress(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- if (__archive_read_register_compression(a, bid, init) != NULL)
- return (ARCHIVE_OK);
- return (ARCHIVE_FATAL);
+ struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a);
+
+ if (bidder == NULL)
+ return (ARCHIVE_FATAL);
+
+ bidder->data = NULL;
+ bidder->bid = compress_bidder_bid;
+ bidder->init = compress_bidder_init;
+ bidder->options = NULL;
+ bidder->free = compress_bidder_free;
+ return (ARCHIVE_OK);
}
/*
@@ -158,27 +165,28 @@ archive_read_support_compression_compress(struct archive *_a)
* from verifying as much as we would like.
*/
static int
-bid(const void *buff, size_t len)
+compress_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *filter)
{
const unsigned char *buffer;
+ ssize_t avail;
int bits_checked;
- if (len < 1)
+ (void)self; /* UNUSED */
+
+ buffer = __archive_read_filter_ahead(filter, 2, &avail);
+
+ if (buffer == NULL)
return (0);
- buffer = (const unsigned char *)buff;
bits_checked = 0;
if (buffer[0] != 037) /* Verify first ID byte. */
return (0);
bits_checked += 8;
- if (len < 2)
- return (bits_checked);
if (buffer[1] != 0235) /* Verify second ID byte. */
return (0);
bits_checked += 8;
- if (len < 3)
- return (bits_checked);
/*
* TODO: Verify more.
@@ -191,60 +199,40 @@ bid(const void *buff, size_t len)
* Setup the callbacks.
*/
static int
-init(struct archive_read *a, const void *buff, size_t n)
+compress_bidder_init(struct archive_read_filter *self)
{
struct private_data *state;
+ static const size_t out_block_size = 64 * 1024;
+ void *out_block;
int code;
- a->archive.compression_code = ARCHIVE_COMPRESSION_COMPRESS;
- a->archive.compression_name = "compress (.Z)";
-
- a->decompressor->read_ahead = read_ahead;
- a->decompressor->consume = read_consume;
- a->decompressor->skip = NULL; /* not supported */
- a->decompressor->finish = finish;
+ self->code = ARCHIVE_COMPRESSION_COMPRESS;
+ self->name = "compress (.Z)";
- state = (struct private_data *)malloc(sizeof(*state));
- if (state == NULL) {
- archive_set_error(&a->archive, ENOMEM,
+ state = (struct private_data *)calloc(sizeof(*state), 1);
+ out_block = malloc(out_block_size);
+ if (state == NULL || out_block == NULL) {
+ free(out_block);
+ free(state);
+ archive_set_error(&self->archive->archive, ENOMEM,
"Can't allocate data for %s decompression",
- a->archive.compression_name);
+ self->name);
return (ARCHIVE_FATAL);
}
- memset(state, 0, sizeof(*state));
- a->decompressor->data = state;
- state->uncompressed_buffer_size = 64 * 1024;
- state->uncompressed_buffer = malloc(state->uncompressed_buffer_size);
+ self->data = state;
+ state->out_block_size = out_block_size;
+ state->out_block = out_block;
+ self->read = compress_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = compress_filter_close;
- if (state->uncompressed_buffer == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate %s decompression buffers",
- a->archive.compression_name);
- goto fatal;
- }
+ /* XXX MOVE THE FOLLOWING OUT OF INIT() XXX */
- state->next_in = (const unsigned char *)buff;
- state->avail_in = n;
- state->read_next = state->next_out = (unsigned char *)state->uncompressed_buffer;
- state->avail_out = state->uncompressed_buffer_size;
-
- code = getbits(a, state, 8);
- if (code != 037) /* This should be impossible. */
- goto fatal;
-
- code = getbits(a, state, 8);
- if (code != 0235) {
- /* This can happen if the library is receiving 1-byte
- * blocks and gzip and compress are both enabled.
- * You can't distinguish gzip and compress only from
- * the first byte. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Compress signature did not match.");
- goto fatal;
- }
+ (void)getbits(self, 8); /* Skip first signature byte. */
+ (void)getbits(self, 8); /* Skip second signature byte. */
- code = getbits(a, state, 8);
+ code = getbits(self, 8);
state->maxcode_bits = code & 0x1f;
state->maxcode = (1 << state->maxcode_bits);
state->use_reset_code = code & 0x80;
@@ -261,12 +249,9 @@ init(struct archive_read *a, const void *buff, size_t n)
state->prefix[code] = 0;
state->suffix[code] = code;
}
- next_code(a, state);
- return (ARCHIVE_OK);
+ next_code(self);
-fatal:
- finish(a);
- return (ARCHIVE_FATAL);
+ return (ARCHIVE_OK);
}
/*
@@ -274,93 +259,57 @@ fatal:
* as necessary.
*/
static ssize_t
-read_ahead(struct archive_read *a, const void **p, size_t min)
+compress_filter_read(struct archive_read_filter *self, const void **pblock)
{
struct private_data *state;
- size_t read_avail;
+ unsigned char *p, *start, *end;
int ret;
- state = (struct private_data *)a->decompressor->data;
- if (!a->client_reader) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
- "No read callback is registered? "
- "This is probably an internal programming error.");
- return (ARCHIVE_FATAL);
- }
-
- read_avail = state->next_out - state->read_next;
-
- if (read_avail < min && state->end_of_stream) {
- if (state->end_of_stream == ARCHIVE_EOF)
- return (0);
- else
- return (-1);
+ state = (struct private_data *)self->data;
+ if (state->end_of_stream) {
+ *pblock = NULL;
+ return (0);
}
-
- if (read_avail < min) {
- memmove(state->uncompressed_buffer, state->read_next,
- read_avail);
- state->read_next = (unsigned char *)state->uncompressed_buffer;
- state->next_out = state->read_next + read_avail;
- state->avail_out
- = state->uncompressed_buffer_size - read_avail;
-
- while (read_avail < state->uncompressed_buffer_size
- && !state->end_of_stream) {
- if (state->stackp > state->stack) {
- *state->next_out++ = *--state->stackp;
- state->avail_out--;
- read_avail++;
- } else {
- ret = next_code(a, state);
- if (ret == ARCHIVE_EOF)
- state->end_of_stream = ret;
- else if (ret != ARCHIVE_OK)
- return (ret);
- }
+ p = start = (unsigned char *)state->out_block;
+ end = start + state->out_block_size;
+
+ while (p < end && !state->end_of_stream) {
+ if (state->stackp > state->stack) {
+ *p++ = *--state->stackp;
+ } else {
+ ret = next_code(self);
+ if (ret == -1)
+ state->end_of_stream = ret;
+ else if (ret != ARCHIVE_OK)
+ return (ret);
}
}
- *p = state->read_next;
- return (read_avail);
+ *pblock = start;
+ return (p - start);
}
/*
- * Mark a previously-returned block of data as read.
+ * Clean up the reader.
*/
-static ssize_t
-read_consume(struct archive_read *a, size_t n)
+static int
+compress_bidder_free(struct archive_read_filter_bidder *self)
{
- struct private_data *state;
-
- state = (struct private_data *)a->decompressor->data;
- a->archive.file_position += n;
- state->read_next += n;
- if (state->read_next > state->next_out)
- __archive_errx(1, "Request to consume too many "
- "bytes from compress decompressor");
- return (n);
+ self->data = NULL;
+ return (ARCHIVE_OK);
}
/*
- * Clean up the decompressor.
+ * Close and release the filter.
*/
static int
-finish(struct archive_read *a)
+compress_filter_close(struct archive_read_filter *self)
{
- struct private_data *state;
- int ret = ARCHIVE_OK;
+ struct private_data *state = (struct private_data *)self->data;
- state = (struct private_data *)a->decompressor->data;
-
- if (state != NULL) {
- if (state->uncompressed_buffer != NULL)
- free(state->uncompressed_buffer);
- free(state);
- }
-
- a->decompressor->data = NULL;
- return (ret);
+ free(state->out_block);
+ free(state);
+ return (ARCHIVE_OK);
}
/*
@@ -369,14 +318,15 @@ finish(struct archive_read *a)
* format error, ARCHIVE_EOF if we hit end of data, ARCHIVE_OK otherwise.
*/
static int
-next_code(struct archive_read *a, struct private_data *state)
+next_code(struct archive_read_filter *self)
{
+ struct private_data *state = (struct private_data *)self->data;
int code, newcode;
static int debug_buff[1024];
static unsigned debug_index;
- code = newcode = getbits(a, state, state->bits);
+ code = newcode = getbits(self, state->bits);
if (code < 0)
return (code);
@@ -398,7 +348,7 @@ next_code(struct archive_read *a, struct private_data *state)
skip_bytes %= state->bits;
state->bits_avail = 0; /* Discard rest of this byte. */
while (skip_bytes-- > 0) {
- code = getbits(a, state, 8);
+ code = getbits(self, 8);
if (code < 0)
return (code);
}
@@ -408,12 +358,13 @@ next_code(struct archive_read *a, struct private_data *state)
state->section_end_code = (1 << state->bits) - 1;
state->free_ent = 257;
state->oldcode = -1;
- return (next_code(a, state));
+ return (next_code(self));
}
if (code > state->free_ent) {
/* An invalid code is a fatal error. */
- archive_set_error(&a->archive, -1, "Invalid compressed data");
+ archive_set_error(&(self->archive->archive), -1,
+ "Invalid compressed data");
return (ARCHIVE_FATAL);
}
@@ -457,27 +408,27 @@ next_code(struct archive_read *a, struct private_data *state)
* -1 indicates end of available data.
*/
static int
-getbits(struct archive_read *a, struct private_data *state, int n)
+getbits(struct archive_read_filter *self, int n)
{
- int code, ret;
+ struct private_data *state = (struct private_data *)self->data;
+ int code;
+ ssize_t ret;
static const int mask[] = {
0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
- const void *read_buf;
while (state->bits_avail < n) {
if (state->avail_in <= 0) {
- read_buf = state->next_in;
- ret = (a->client_reader)(&a->archive, a->client_data,
- &read_buf);
- state->next_in = read_buf;
- if (ret < 0)
- return (ARCHIVE_FATAL);
+ state->next_in
+ = __archive_read_filter_ahead(self->upstream,
+ 1, &ret);
if (ret == 0)
- return (ARCHIVE_EOF);
- a->archive.raw_position += ret;
+ return (-1);
+ if (ret < 0 || state->next_in == NULL)
+ return (ARCHIVE_FATAL);
state->avail_in = ret;
+ __archive_read_filter_consume(self->upstream, ret);
}
state->bit_buffer |= *state->next_in++ << state->bits_avail;
state->avail_in--;
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c
index 2dac54da0cd..8cc924c9fc1 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_gzip.c
@@ -25,7 +25,7 @@
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_gzip.c,v 1.16 2008/02/19 05:44:59 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_gzip.c 201082 2009-12-28 02:05:28Z kientzle $");
#ifdef HAVE_ERRNO_H
@@ -51,499 +51,415 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_gzip.c,v
#ifdef HAVE_ZLIB_H
struct private_data {
z_stream stream;
- unsigned char *uncompressed_buffer;
- size_t uncompressed_buffer_size;
- unsigned char *read_next;
+ char in_stream;
+ unsigned char *out_block;
+ size_t out_block_size;
int64_t total_out;
unsigned long crc;
- char header_done;
char eof; /* True = found end of compressed data. */
};
-static int finish(struct archive_read *);
-static ssize_t read_ahead(struct archive_read *, const void **, size_t);
-static ssize_t read_consume(struct archive_read *, size_t);
-static int drive_decompressor(struct archive_read *a, struct private_data *);
+/* Gzip Filter. */
+static ssize_t gzip_filter_read(struct archive_read_filter *, const void **);
+static int gzip_filter_close(struct archive_read_filter *);
#endif
-/* These two functions are defined even if we lack the library. See below. */
-static int bid(const void *, size_t);
-static int init(struct archive_read *, const void *, size_t);
+/*
+ * Note that we can detect gzip archives even if we can't decompress
+ * them. (In fact, we like detecting them because we can give better
+ * error messages.) So the bid framework here gets compiled even
+ * if zlib is unavailable.
+ *
+ * TODO: If zlib is unavailable, gzip_bidder_init() should
+ * use the compress_program framework to try to fire up an external
+ * gunzip program.
+ */
+static int gzip_bidder_bid(struct archive_read_filter_bidder *,
+ struct archive_read_filter *);
+static int gzip_bidder_init(struct archive_read_filter *);
int
archive_read_support_compression_gzip(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- if (__archive_read_register_compression(a, bid, init) != NULL)
- return (ARCHIVE_OK);
- return (ARCHIVE_FATAL);
+ struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a);
+
+ if (bidder == NULL)
+ return (ARCHIVE_FATAL);
+
+ bidder->data = NULL;
+ bidder->bid = gzip_bidder_bid;
+ bidder->init = gzip_bidder_init;
+ bidder->options = NULL;
+ bidder->free = NULL; /* No data, so no cleanup necessary. */
+ /* Signal the extent of gzip support with the return value here. */
+#if HAVE_ZLIB_H
+ return (ARCHIVE_OK);
+#else
+ archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+ "Using external gunzip program");
+ return (ARCHIVE_WARN);
+#endif
}
/*
- * Test whether we can handle this data.
+ * Read and verify the header.
*
- * This logic returns zero if any part of the signature fails. It
- * also tries to Do The Right Thing if a very short buffer prevents us
- * from verifying as much as we would like.
+ * Returns zero if the header couldn't be validated, else returns
+ * number of bytes in header. If pbits is non-NULL, it receives a
+ * count of bits verified, suitable for use by bidder.
*/
static int
-bid(const void *buff, size_t len)
+peek_at_header(struct archive_read_filter *filter, int *pbits)
{
- const unsigned char *buffer;
- int bits_checked;
-
- if (len < 1)
+ const unsigned char *p;
+ ssize_t avail, len;
+ int bits = 0;
+ int header_flags;
+
+ /* Start by looking at the first ten bytes of the header, which
+ * is all fixed layout. */
+ len = 10;
+ p = __archive_read_filter_ahead(filter, len, &avail);
+ if (p == NULL || avail == 0)
return (0);
-
- buffer = (const unsigned char *)buff;
- bits_checked = 0;
- if (buffer[0] != 037) /* Verify first ID byte. */
+ if (p[0] != 037)
return (0);
- bits_checked += 8;
- if (len < 2)
- return (bits_checked);
-
- if (buffer[1] != 0213) /* Verify second ID byte. */
+ bits += 8;
+ if (p[1] != 0213)
return (0);
- bits_checked += 8;
- if (len < 3)
- return (bits_checked);
-
- if (buffer[2] != 8) /* Compression must be 'deflate'. */
+ bits += 8;
+ if (p[2] != 8) /* We only support deflation. */
return (0);
- bits_checked += 8;
- if (len < 4)
- return (bits_checked);
+ bits += 8;
+ if ((p[3] & 0xE0)!= 0) /* No reserved flags set. */
+ return (0);
+ bits += 3;
+ header_flags = p[3];
+ /* Bytes 4-7 are mod time. */
+ /* Byte 8 is deflate flags. */
+ /* XXXX TODO: return deflate flags back to consume_header for use
+ in initializing the decompressor. */
+ /* Byte 9 is OS. */
+
+ /* Optional extra data: 2 byte length plus variable body. */
+ if (header_flags & 4) {
+ p = __archive_read_filter_ahead(filter, len + 2, &avail);
+ if (p == NULL)
+ return (0);
+ len += ((int)p[len + 1] << 8) | (int)p[len];
+ len += 2;
+ }
- if ((buffer[3] & 0xE0)!= 0) /* No reserved flags set. */
+ /* Null-terminated optional filename. */
+ if (header_flags & 8) {
+ do {
+ ++len;
+ if (avail < len)
+ p = __archive_read_filter_ahead(filter,
+ len, &avail);
+ if (p == NULL)
+ return (0);
+ } while (p[len - 1] != 0);
+ }
+
+ /* Null-terminated optional comment. */
+ if (header_flags & 16) {
+ do {
+ ++len;
+ if (avail < len)
+ p = __archive_read_filter_ahead(filter,
+ len, &avail);
+ if (p == NULL)
+ return (0);
+ } while (p[len - 1] != 0);
+ }
+
+ /* Optional header CRC */
+ if ((header_flags & 2)) {
+ p = __archive_read_filter_ahead(filter, len + 2, &avail);
+ if (p == NULL)
+ return (0);
+#if 0
+ int hcrc = ((int)p[len + 1] << 8) | (int)p[len];
+ int crc = /* XXX TODO: Compute header CRC. */;
+ if (crc != hcrc)
return (0);
- bits_checked += 3;
- if (len < 5)
- return (bits_checked);
+ bits += 16;
+#endif
+ len += 2;
+ }
+
+ if (pbits != NULL)
+ *pbits = bits;
+ return (len);
+}
+
+/*
+ * Bidder just verifies the header and returns the number of verified bits.
+ */
+static int
+gzip_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *filter)
+{
+ int bits_checked;
- /*
- * TODO: Verify more; in particular, gzip has an optional
- * header CRC, which would give us 16 more verified bits. We
- * may also be able to verify certain constraints on other
- * fields.
- */
+ (void)self; /* UNUSED */
- return (bits_checked);
+ if (peek_at_header(filter, &bits_checked))
+ return (bits_checked);
+ return (0);
}
#ifndef HAVE_ZLIB_H
/*
- * If we don't have the library on this system, we can't actually do the
- * decompression. We can, however, still detect compressed archives
- * and emit a useful message.
+ * If we don't have the library on this system, we can't do the
+ * decompression directly. We can, however, try to run gunzip
+ * in case that's available.
*/
static int
-init(struct archive_read *a, const void *buff, size_t n)
+gzip_bidder_init(struct archive_read_filter *self)
{
- (void)a; /* UNUSED */
- (void)buff; /* UNUSED */
- (void)n; /* UNUSED */
-
- archive_set_error(&a->archive, -1,
- "This version of libarchive was compiled without gzip support");
- return (ARCHIVE_FATAL);
+ int r;
+
+ r = __archive_read_program(self, "gunzip");
+ /* Note: We set the format here even if __archive_read_program()
+ * above fails. We do, after all, know what the format is
+ * even if we weren't able to read it. */
+ self->code = ARCHIVE_COMPRESSION_GZIP;
+ self->name = "gzip";
+ return (r);
}
-
#else
/*
- * Setup the callbacks.
+ * Initialize the filter object.
*/
static int
-init(struct archive_read *a, const void *buff, size_t n)
+gzip_bidder_init(struct archive_read_filter *self)
{
struct private_data *state;
- int ret;
+ static const size_t out_block_size = 64 * 1024;
+ void *out_block;
- a->archive.compression_code = ARCHIVE_COMPRESSION_GZIP;
- a->archive.compression_name = "gzip";
+ self->code = ARCHIVE_COMPRESSION_GZIP;
+ self->name = "gzip";
- state = (struct private_data *)malloc(sizeof(*state));
- if (state == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate data for %s decompression",
- a->archive.compression_name);
- return (ARCHIVE_FATAL);
- }
- memset(state, 0, sizeof(*state));
-
- state->crc = crc32(0L, NULL, 0);
- state->header_done = 0; /* We've not yet begun to parse header... */
-
- state->uncompressed_buffer_size = 64 * 1024;
- state->uncompressed_buffer = (unsigned char *)malloc(state->uncompressed_buffer_size);
- state->stream.next_out = state->uncompressed_buffer;
- state->read_next = state->uncompressed_buffer;
- state->stream.avail_out = state->uncompressed_buffer_size;
-
- if (state->uncompressed_buffer == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate %s decompression buffers",
- a->archive.compression_name);
+ state = (struct private_data *)calloc(sizeof(*state), 1);
+ out_block = (unsigned char *)malloc(out_block_size);
+ if (state == NULL || out_block == NULL) {
+ free(out_block);
free(state);
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Can't allocate data for gzip decompression");
return (ARCHIVE_FATAL);
}
- /*
- * A bug in zlib.h: stream.next_in should be marked 'const'
- * but isn't (the library never alters data through the
- * next_in pointer, only reads it). The result: this ugly
- * cast to remove 'const'.
- */
- state->stream.next_in = (Bytef *)(uintptr_t)(const void *)buff;
- state->stream.avail_in = n;
-
- a->decompressor->read_ahead = read_ahead;
- a->decompressor->consume = read_consume;
- a->decompressor->skip = NULL; /* not supported */
- a->decompressor->finish = finish;
-
- /*
- * TODO: Do I need to parse the gzip header before calling
- * inflateInit2()? In particular, one of the header bytes
- * marks "best compression" or "fastest", which may be
- * appropriate for setting the second parameter here.
- * However, I think the only penalty for not setting it
- * correctly is wasted memory. If this is necessary, it
- * should probably go into drive_decompressor() below.
- */
+ self->data = state;
+ state->out_block_size = out_block_size;
+ state->out_block = out_block;
+ self->read = gzip_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = gzip_filter_close;
+
+ state->in_stream = 0; /* We're not actually within a stream yet. */
+
+ return (ARCHIVE_OK);
+}
+
+static int
+consume_header(struct archive_read_filter *self)
+{
+ struct private_data *state;
+ ssize_t avail;
+ size_t len;
+ int ret;
+
+ state = (struct private_data *)self->data;
+
+ /* If this is a real header, consume it. */
+ len = peek_at_header(self->upstream, NULL);
+ if (len == 0)
+ return (ARCHIVE_EOF);
+ __archive_read_filter_consume(self->upstream, len);
+
+ /* Initialize CRC accumulator. */
+ state->crc = crc32(0L, NULL, 0);
/* Initialize compression library. */
+ state->stream.next_in = (unsigned char *)(uintptr_t)
+ __archive_read_filter_ahead(self->upstream, 1, &avail);
+ state->stream.avail_in = avail;
ret = inflateInit2(&(state->stream),
-15 /* Don't check for zlib header */);
- if (ret == Z_OK) {
- a->decompressor->data = state;
- return (ARCHIVE_OK);
- }
-
- /* Library setup failed: Clean up. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Internal error initializing %s library",
- a->archive.compression_name);
- free(state->uncompressed_buffer);
- free(state);
- /* Override the error message if we know what really went wrong. */
+ /* Decipher the error code. */
switch (ret) {
+ case Z_OK:
+ state->in_stream = 1;
+ return (ARCHIVE_OK);
case Z_STREAM_ERROR:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
"Internal error initializing compression library: "
"invalid setup parameter");
break;
case Z_MEM_ERROR:
- archive_set_error(&a->archive, ENOMEM,
+ archive_set_error(&self->archive->archive, ENOMEM,
"Internal error initializing compression library: "
"out of memory");
break;
case Z_VERSION_ERROR:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
"Internal error initializing compression library: "
"invalid library version");
break;
+ default:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Internal error initializing compression library: "
+ " Zlib error %d", ret);
+ break;
}
-
return (ARCHIVE_FATAL);
}
-/*
- * Return a block of data from the decompression buffer. Decompress more
- * as necessary.
- */
-static ssize_t
-read_ahead(struct archive_read *a, const void **p, size_t min)
+static int
+consume_trailer(struct archive_read_filter *self)
{
struct private_data *state;
- size_t read_avail, was_avail;
- int ret;
+ const unsigned char *p;
+ ssize_t avail;
+
+ state = (struct private_data *)self->data;
- state = (struct private_data *)a->decompressor->data;
- if (!a->client_reader) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
- "No read callback is registered? "
- "This is probably an internal programming error.");
+ state->in_stream = 0;
+ switch (inflateEnd(&(state->stream))) {
+ case Z_OK:
+ break;
+ default:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up gzip decompressor");
return (ARCHIVE_FATAL);
}
- read_avail = state->stream.next_out - state->read_next;
+ /* GZip trailer is a fixed 8 byte structure. */
+ p = __archive_read_filter_ahead(self->upstream, 8, &avail);
+ if (p == NULL || avail == 0)
+ return (ARCHIVE_FATAL);
- if (read_avail + state->stream.avail_out < min) {
- memmove(state->uncompressed_buffer, state->read_next,
- read_avail);
- state->read_next = state->uncompressed_buffer;
- state->stream.next_out = state->read_next + read_avail;
- state->stream.avail_out
- = state->uncompressed_buffer_size - read_avail;
- }
+ /* XXX TODO: Verify the length and CRC. */
- while (read_avail < min && /* Haven't satisfied min. */
- read_avail < state->uncompressed_buffer_size) { /* !full */
- was_avail = read_avail;
- if ((ret = drive_decompressor(a, state)) < ARCHIVE_OK)
- return (ret);
- if (ret == ARCHIVE_EOF)
- break; /* Break on EOF even if we haven't met min. */
- read_avail = state->stream.next_out - state->read_next;
- if (was_avail == read_avail) /* No progress? */
- break;
- }
+ /* We've verified the trailer, so consume it now. */
+ __archive_read_filter_consume(self->upstream, 8);
- *p = state->read_next;
- return (read_avail);
+ return (ARCHIVE_OK);
}
-/*
- * Mark a previously-returned block of data as read.
- */
static ssize_t
-read_consume(struct archive_read *a, size_t n)
+gzip_filter_read(struct archive_read_filter *self, const void **p)
{
struct private_data *state;
+ size_t decompressed;
+ ssize_t avail_in;
+ int ret;
- state = (struct private_data *)a->decompressor->data;
- a->archive.file_position += n;
- state->read_next += n;
- if (state->read_next > state->stream.next_out)
- __archive_errx(1, "Request to consume too many "
- "bytes from gzip decompressor");
- return (n);
-}
+ state = (struct private_data *)self->data;
-/*
- * Clean up the decompressor.
- */
-static int
-finish(struct archive_read *a)
-{
- struct private_data *state;
- int ret;
+ /* Empty our output buffer. */
+ state->stream.next_out = state->out_block;
+ state->stream.avail_out = state->out_block_size;
- state = (struct private_data *)a->decompressor->data;
- ret = ARCHIVE_OK;
- switch (inflateEnd(&(state->stream))) {
- case Z_OK:
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Failed to clean up %s compressor",
- a->archive.compression_name);
- ret = ARCHIVE_FATAL;
- }
+ /* Try to fill the output buffer. */
+ while (state->stream.avail_out > 0 && !state->eof) {
+ /* If we're not in a stream, read a header
+ * and initialize the decompression library. */
+ if (!state->in_stream) {
+ ret = consume_header(self);
+ if (ret == ARCHIVE_EOF) {
+ state->eof = 1;
+ break;
+ }
+ if (ret < ARCHIVE_OK)
+ return (ret);
+ }
- free(state->uncompressed_buffer);
- free(state);
+ /* Peek at the next available data. */
+ /* ZLib treats stream.next_in as const but doesn't declare
+ * it so, hence this ugly cast. */
+ state->stream.next_in = (unsigned char *)(uintptr_t)
+ __archive_read_filter_ahead(self->upstream, 1, &avail_in);
+ if (state->stream.next_in == NULL)
+ return (ARCHIVE_FATAL);
+ state->stream.avail_in = avail_in;
+
+ /* Decompress and consume some of that data. */
+ ret = inflate(&(state->stream), 0);
+ switch (ret) {
+ case Z_OK: /* Decompressor made some progress. */
+ __archive_read_filter_consume(self->upstream,
+ avail_in - state->stream.avail_in);
+ break;
+ case Z_STREAM_END: /* Found end of stream. */
+ __archive_read_filter_consume(self->upstream,
+ avail_in - state->stream.avail_in);
+ /* Consume the stream trailer; release the
+ * decompression library. */
+ ret = consume_trailer(self);
+ if (ret < ARCHIVE_OK)
+ return (ret);
+ break;
+ default:
+ /* Return an error. */
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "gzip decompression failed");
+ return (ARCHIVE_FATAL);
+ }
+ }
- a->decompressor->data = NULL;
- return (ret);
+ /* We've read as much as we can. */
+ decompressed = state->stream.next_out - state->out_block;
+ state->total_out += decompressed;
+ if (decompressed == 0)
+ *p = NULL;
+ else
+ *p = state->out_block;
+ return (decompressed);
}
/*
- * Utility function to pull data through decompressor, reading input
- * blocks as necessary.
+ * Clean up the decompressor.
*/
static int
-drive_decompressor(struct archive_read *a, struct private_data *state)
+gzip_filter_close(struct archive_read_filter *self)
{
- ssize_t ret;
- size_t decompressed, total_decompressed;
- int count, flags, header_state;
- unsigned char *output;
- unsigned char b;
- const void *read_buf;
-
- if (state->eof)
- return (ARCHIVE_EOF);
- flags = 0;
- count = 0;
- header_state = 0;
- total_decompressed = 0;
- for (;;) {
- if (state->stream.avail_in == 0) {
- read_buf = state->stream.next_in;
- ret = (a->client_reader)(&a->archive, a->client_data,
- &read_buf);
- state->stream.next_in = (unsigned char *)(uintptr_t)read_buf;
- if (ret < 0) {
- /*
- * TODO: Find a better way to handle
- * this read failure.
- */
- goto fatal;
- }
- if (ret == 0 && total_decompressed == 0) {
- archive_set_error(&a->archive, EIO,
- "Premature end of %s compressed data",
- a->archive.compression_name);
- return (ARCHIVE_FATAL);
- }
- a->archive.raw_position += ret;
- state->stream.avail_in = ret;
- }
+ struct private_data *state;
+ int ret;
- if (!state->header_done) {
- /*
- * If still parsing the header, interpret the
- * next byte.
- */
- b = *(state->stream.next_in++);
- state->stream.avail_in--;
-
- /*
- * Yes, this is somewhat crude, but it works,
- * GZip format isn't likely to change anytime
- * in the near future, and header parsing is
- * certainly not a performance issue, so
- * there's little point in making this more
- * elegant. Of course, if you see an easy way
- * to make this more elegant, please let me
- * know.. ;-)
- */
- switch (header_state) {
- case 0: /* First byte of signature. */
- if (b != 037)
- goto fatal;
- header_state = 1;
- break;
- case 1: /* Second byte of signature. */
- if (b != 0213)
- goto fatal;
- header_state = 2;
- break;
- case 2: /* Compression type must be 8. */
- if (b != 8)
- goto fatal;
- header_state = 3;
- break;
- case 3: /* GZip flags. */
- flags = b;
- header_state = 4;
- break;
- case 4: case 5: case 6: case 7: /* Mod time. */
- header_state++;
- break;
- case 8: /* Deflate flags. */
- header_state = 9;
- break;
- case 9: /* OS. */
- header_state = 10;
- break;
- case 10: /* Optional Extra: First byte of Length. */
- if ((flags & 4)) {
- count = 255 & (int)b;
- header_state = 11;
- break;
- }
- /*
- * Fall through if there is no
- * Optional Extra field.
- */
- case 11: /* Optional Extra: Second byte of Length. */
- if ((flags & 4)) {
- count = (0xff00 & ((int)b << 8)) | count;
- header_state = 12;
- break;
- }
- /*
- * Fall through if there is no
- * Optional Extra field.
- */
- case 12: /* Optional Extra Field: counted length. */
- if ((flags & 4)) {
- --count;
- if (count == 0) header_state = 13;
- else header_state = 12;
- break;
- }
- /*
- * Fall through if there is no
- * Optional Extra field.
- */
- case 13: /* Optional Original Filename. */
- if ((flags & 8)) {
- if (b == 0) header_state = 14;
- else header_state = 13;
- break;
- }
- /*
- * Fall through if no Optional
- * Original Filename.
- */
- case 14: /* Optional Comment. */
- if ((flags & 16)) {
- if (b == 0) header_state = 15;
- else header_state = 14;
- break;
- }
- /* Fall through if no Optional Comment. */
- case 15: /* Optional Header CRC: First byte. */
- if ((flags & 2)) {
- header_state = 16;
- break;
- }
- /* Fall through if no Optional Header CRC. */
- case 16: /* Optional Header CRC: Second byte. */
- if ((flags & 2)) {
- header_state = 17;
- break;
- }
- /* Fall through if no Optional Header CRC. */
- case 17: /* First byte of compressed data. */
- state->header_done = 1; /* done with header */
- state->stream.avail_in++;
- state->stream.next_in--;
- }
+ state = (struct private_data *)self->data;
+ ret = ARCHIVE_OK;
- /*
- * TODO: Consider moving the inflateInit2 call
- * here so it can include the compression type
- * from the header?
- */
- } else {
- output = state->stream.next_out;
-
- /* Decompress some data. */
- ret = inflate(&(state->stream), 0);
- decompressed = state->stream.next_out - output;
-
- /* Accumulate the CRC of the uncompressed data. */
- state->crc = crc32(state->crc, output, decompressed);
-
- /* Accumulate the total bytes of output. */
- state->total_out += decompressed;
- total_decompressed += decompressed;
-
- switch (ret) {
- case Z_OK: /* Decompressor made some progress. */
- if (decompressed > 0)
- return (ARCHIVE_OK);
- break;
- case Z_STREAM_END: /* Found end of stream. */
- /*
- * TODO: Verify gzip trailer
- * (uncompressed length and CRC).
- */
- state->eof = 1;
- return (ARCHIVE_OK);
- default:
- /* Any other return value is an error. */
- goto fatal;
- }
+ if (state->in_stream) {
+ switch (inflateEnd(&(state->stream))) {
+ case Z_OK:
+ break;
+ default:
+ archive_set_error(&(self->archive->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up gzip compressor");
+ ret = ARCHIVE_FATAL;
}
}
- return (ARCHIVE_OK);
- /* Return a fatal error. */
-fatal:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "%s decompression failed", a->archive.compression_name);
- return (ARCHIVE_FATAL);
+ free(state->out_block);
+ free(state);
+ return (ret);
}
#endif /* HAVE_ZLIB_H */
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_none.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_none.c
index 3f17756abae..955d06d9aa1 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_compression_none.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_none.c
@@ -24,347 +24,17 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_none.c,v 1.19 2007/12/30 04:58:21 kientzle Exp $");
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_none.c 185679 2008-12-06 06:45:15Z kientzle $");
#include "archive.h"
-#include "archive_private.h"
-#include "archive_read_private.h"
-
-struct archive_decompress_none {
- char *buffer;
- size_t buffer_size;
- char *next; /* Current read location. */
- size_t avail; /* Bytes in my buffer. */
- const void *client_buff; /* Client buffer information. */
- size_t client_total;
- const char *client_next;
- size_t client_avail;
- char end_of_file;
- char fatal;
-};
/*
- * Size of internal buffer used for combining short reads. This is
- * also an upper limit on the size of a read request. Recall,
- * however, that we can (and will!) return blocks of data larger than
- * this. The read semantics are: you ask for a minimum, I give you a
- * pointer to my best-effort match and tell you how much data is
- * there. It could be less than you asked for, it could be much more.
- * For example, a client might use mmap() to "read" the entire file as
- * a single block. In that case, I will return that entire block to
- * my clients.
+ * Uncompressed streams are handled implicitly by the read core,
+ * so this is now a no-op.
*/
-#define BUFFER_SIZE 65536
-
-#define minimum(a, b) (a < b ? a : b)
-
-static int archive_decompressor_none_bid(const void *, size_t);
-static int archive_decompressor_none_finish(struct archive_read *);
-static int archive_decompressor_none_init(struct archive_read *,
- const void *, size_t);
-static ssize_t archive_decompressor_none_read_ahead(struct archive_read *,
- const void **, size_t);
-static ssize_t archive_decompressor_none_read_consume(struct archive_read *,
- size_t);
-static off_t archive_decompressor_none_skip(struct archive_read *, off_t);
-
int
-archive_read_support_compression_none(struct archive *_a)
+archive_read_support_compression_none(struct archive *a)
{
- struct archive_read *a = (struct archive_read *)_a;
- if (__archive_read_register_compression(a,
- archive_decompressor_none_bid,
- archive_decompressor_none_init) != NULL)
- return (ARCHIVE_OK);
- return (ARCHIVE_FATAL);
-}
-
-/*
- * Try to detect an "uncompressed" archive.
- */
-static int
-archive_decompressor_none_bid(const void *buff, size_t len)
-{
- (void)buff;
- (void)len;
-
- return (1); /* Default: We'll take it if noone else does. */
-}
-
-static int
-archive_decompressor_none_init(struct archive_read *a, const void *buff, size_t n)
-{
- struct archive_decompress_none *state;
-
- a->archive.compression_code = ARCHIVE_COMPRESSION_NONE;
- a->archive.compression_name = "none";
-
- state = (struct archive_decompress_none *)malloc(sizeof(*state));
- if (!state) {
- archive_set_error(&a->archive, ENOMEM, "Can't allocate input data");
- return (ARCHIVE_FATAL);
- }
- memset(state, 0, sizeof(*state));
-
- state->buffer_size = BUFFER_SIZE;
- state->buffer = (char *)malloc(state->buffer_size);
- state->next = state->buffer;
- if (state->buffer == NULL) {
- free(state);
- archive_set_error(&a->archive, ENOMEM, "Can't allocate input buffer");
- return (ARCHIVE_FATAL);
- }
-
- /* Save reference to first block of data. */
- state->client_buff = buff;
- state->client_total = n;
- state->client_next = state->client_buff;
- state->client_avail = state->client_total;
-
- a->decompressor->data = state;
- a->decompressor->read_ahead = archive_decompressor_none_read_ahead;
- a->decompressor->consume = archive_decompressor_none_read_consume;
- a->decompressor->skip = archive_decompressor_none_skip;
- a->decompressor->finish = archive_decompressor_none_finish;
-
- return (ARCHIVE_OK);
-}
-
-/*
- * We just pass through pointers to the client buffer if we can.
- * If the client buffer is short, then we copy stuff to our internal
- * buffer to combine reads.
- */
-static ssize_t
-archive_decompressor_none_read_ahead(struct archive_read *a, const void **buff,
- size_t min)
-{
- struct archive_decompress_none *state;
- ssize_t bytes_read;
-
- state = (struct archive_decompress_none *)a->decompressor->data;
- if (state->fatal)
- return (-1);
-
- /*
- * Don't make special efforts to handle requests larger than
- * the copy buffer.
- */
- if (min > state->buffer_size)
- min = state->buffer_size;
-
- /*
- * Keep pulling more data until we can satisfy the request.
- */
- for (;;) {
-
- /*
- * If we can satisfy from the copy buffer, we're done.
- */
- if (state->avail >= min) {
- *buff = state->next;
- return (state->avail);
- }
-
- /*
- * We can satisfy directly from client buffer if everything
- * currently in the copy buffer is still in the client buffer.
- */
- if (state->client_total >= state->client_avail + state->avail
- && state->client_avail + state->avail >= min) {
- /* "Roll back" to client buffer. */
- state->client_avail += state->avail;
- state->client_next -= state->avail;
- /* Copy buffer is now empty. */
- state->avail = 0;
- state->next = state->buffer;
- /* Return data from client buffer. */
- *buff = state->client_next;
- return (state->client_avail);
- }
-
- /* Move data forward in copy buffer if necessary. */
- if (state->next > state->buffer &&
- state->next + min > state->buffer + state->buffer_size) {
- if (state->avail > 0)
- memmove(state->buffer, state->next, state->avail);
- state->next = state->buffer;
- }
-
- /* If we've used up the client data, get more. */
- if (state->client_avail <= 0) {
- bytes_read = (a->client_reader)(&a->archive,
- a->client_data, &state->client_buff);
- if (bytes_read < 0) { /* Read error. */
- state->client_total = state->client_avail = 0;
- state->client_next = state->client_buff = NULL;
- state->fatal = 1;
- return (-1);
- }
- if (bytes_read == 0) { /* End-of-file. */
- state->client_total = state->client_avail = 0;
- state->client_next = state->client_buff = NULL;
- state->end_of_file = 1;
- /* Return whatever we do have. */
- *buff = state->next;
- return (state->avail);
- }
- a->archive.raw_position += bytes_read;
- state->client_total = bytes_read;
- state->client_avail = state->client_total;
- state->client_next = state->client_buff;
- }
- else
- {
- /* We can add client data to copy buffer. */
- /* First estimate: copy to fill rest of buffer. */
- size_t tocopy = (state->buffer + state->buffer_size)
- - (state->next + state->avail);
- /* Don't copy more than is available. */
- if (tocopy > state->client_avail)
- tocopy = state->client_avail;
- memcpy(state->next + state->avail, state->client_next,
- tocopy);
- /* Remove this data from client buffer. */
- state->client_next += tocopy;
- state->client_avail -= tocopy;
- /* add it to copy buffer. */
- state->avail += tocopy;
- }
- }
-}
-
-/*
- * Mark the appropriate data as used. Note that the request here will
- * often be much smaller than the size of the previous read_ahead
- * request.
- */
-static ssize_t
-archive_decompressor_none_read_consume(struct archive_read *a, size_t request)
-{
- struct archive_decompress_none *state;
-
- state = (struct archive_decompress_none *)a->decompressor->data;
- if (state->avail > 0) {
- /* Read came from copy buffer. */
- state->next += request;
- state->avail -= request;
- } else {
- /* Read came from client buffer. */
- state->client_next += request;
- state->client_avail -= request;
- }
- a->archive.file_position += request;
- return (request);
-}
-
-/*
- * Skip forward by exactly the requested bytes or else return
- * ARCHIVE_FATAL. Note that this differs from the contract for
- * read_ahead, which does not guarantee a minimum count.
- */
-static off_t
-archive_decompressor_none_skip(struct archive_read *a, off_t request)
-{
- struct archive_decompress_none *state;
- off_t bytes_skipped, total_bytes_skipped = 0;
- size_t min;
-
- state = (struct archive_decompress_none *)a->decompressor->data;
- if (state->fatal)
- return (-1);
- /*
- * If there is data in the buffers already, use that first.
- */
- if (state->avail > 0) {
- min = minimum(request, (off_t)state->avail);
- bytes_skipped = archive_decompressor_none_read_consume(a, min);
- request -= bytes_skipped;
- total_bytes_skipped += bytes_skipped;
- }
- if (state->client_avail > 0) {
- min = minimum(request, (off_t)state->client_avail);
- bytes_skipped = archive_decompressor_none_read_consume(a, min);
- request -= bytes_skipped;
- total_bytes_skipped += bytes_skipped;
- }
- if (request == 0)
- return (total_bytes_skipped);
- /*
- * If a client_skipper was provided, try that first.
- */
-#if ARCHIVE_API_VERSION < 2
- if ((a->client_skipper != NULL) && (request < SSIZE_MAX)) {
-#else
- if (a->client_skipper != NULL) {
-#endif
- bytes_skipped = (a->client_skipper)(&a->archive,
- a->client_data, request);
- if (bytes_skipped < 0) { /* error */
- state->client_total = state->client_avail = 0;
- state->client_next = state->client_buff = NULL;
- state->fatal = 1;
- return (bytes_skipped);
- }
- total_bytes_skipped += bytes_skipped;
- a->archive.file_position += bytes_skipped;
- request -= bytes_skipped;
- state->client_next = state->client_buff;
- a->archive.raw_position += bytes_skipped;
- state->client_avail = state->client_total = 0;
- }
- /*
- * Note that client_skipper will usually not satisfy the
- * full request (due to low-level blocking concerns),
- * so even if client_skipper is provided, we may still
- * have to use ordinary reads to finish out the request.
- */
- while (request > 0) {
- const void* dummy_buffer;
- ssize_t bytes_read;
- bytes_read = archive_decompressor_none_read_ahead(a,
- &dummy_buffer, 1);
- if (bytes_read < 0)
- return (bytes_read);
- if (bytes_read == 0) {
- /* We hit EOF before we satisfied the skip request. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Truncated input file (need to skip %jd bytes)",
- (intmax_t)request);
- return (ARCHIVE_FATAL);
- }
- min = (size_t)(minimum(bytes_read, request));
- bytes_read = archive_decompressor_none_read_consume(a, min);
- total_bytes_skipped += bytes_read;
- request -= bytes_read;
- }
- return (total_bytes_skipped);
-}
-
-static int
-archive_decompressor_none_finish(struct archive_read *a)
-{
- struct archive_decompress_none *state;
-
- state = (struct archive_decompress_none *)a->decompressor->data;
- free(state->buffer);
- free(state);
- a->decompressor->data = NULL;
+ (void)a; /* UNUSED */
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c
index 4f25d6ed561..0c63f2e8312 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c
@@ -24,25 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_program.c,v 1.4 2008/06/15 10:45:57 kientzle Exp $");
-
-/* This capability is only available on POSIX systems. */
-#if !defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \
- !(defined(HAVE_FORK) || defined(HAVE_VFORK))
-
-/*
- * On non-Posix systems, allow the program to build, but choke if
- * this function is actually invoked.
- */
-int
-archive_read_support_compression_program(struct archive *_a, const char *cmd)
-{
- archive_set_error(_a, -1,
- "External compression programs not supported on this platform");
- return (ARCHIVE_FATAL);
-}
-
-#else
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_program.c 201112 2009-12-28 06:59:35Z kientzle $");
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -56,6 +38,9 @@ archive_read_support_compression_program(struct archive *_a, const char *cmd)
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
+#ifdef HAVE_SIGNAL_H
+# include <signal.h>
+#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
@@ -70,272 +55,405 @@ archive_read_support_compression_program(struct archive *_a, const char *cmd)
#include "archive_private.h"
#include "archive_read_private.h"
+int
+archive_read_support_compression_program(struct archive *a, const char *cmd)
+{
+ return (archive_read_support_compression_program_signature(a, cmd, NULL, 0));
+}
+
+
+/* This capability is only available on POSIX systems. */
+#if (!defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \
+ !(defined(HAVE_FORK) || defined(HAVE_VFORK))) && (!defined(_WIN32) || defined(__CYGWIN__))
+
+/*
+ * On non-Posix systems, allow the program to build, but choke if
+ * this function is actually invoked.
+ */
+int
+archive_read_support_compression_program_signature(struct archive *_a,
+ const char *cmd, void *signature, size_t signature_len)
+{
+ (void)_a; /* UNUSED */
+ (void)cmd; /* UNUSED */
+ (void)signature; /* UNUSED */
+ (void)signature_len; /* UNUSED */
+
+ archive_set_error(_a, -1,
+ "External compression programs not supported on this platform");
+ return (ARCHIVE_FATAL);
+}
+
+int
+__archive_read_program(struct archive_read_filter *self, const char *cmd)
+{
+ (void)self; /* UNUSED */
+ (void)cmd; /* UNUSED */
+
+ archive_set_error(&self->archive->archive, -1,
+ "External compression programs not supported on this platform");
+ return (ARCHIVE_FATAL);
+}
+
+#else
+
#include "filter_fork.h"
-struct archive_decompress_program {
+/*
+ * The bidder object stores the command and the signature to watch for.
+ * The 'inhibit' entry here is used to ensure that unchecked filters never
+ * bid twice in the same pipeline.
+ */
+struct program_bidder {
+ char *cmd;
+ void *signature;
+ size_t signature_len;
+ int inhibit;
+};
+
+static int program_bidder_bid(struct archive_read_filter_bidder *,
+ struct archive_read_filter *upstream);
+static int program_bidder_init(struct archive_read_filter *);
+static int program_bidder_free(struct archive_read_filter_bidder *);
+
+/*
+ * The actual filter needs to track input and output data.
+ */
+struct program_filter {
char *description;
pid_t child;
+ int exit_status;
+ int waitpid_return;
int child_stdin, child_stdout;
- char *child_out_buf;
- char *child_out_buf_next;
- size_t child_out_buf_len, child_out_buf_avail;
-
- const char *child_in_buf;
- size_t child_in_buf_avail;
+ char *out_buf;
+ size_t out_buf_len;
};
-static int archive_decompressor_program_bid(const void *, size_t);
-static int archive_decompressor_program_finish(struct archive_read *);
-static int archive_decompressor_program_init(struct archive_read *,
- const void *, size_t);
-static ssize_t archive_decompressor_program_read_ahead(struct archive_read *,
- const void **, size_t);
-static ssize_t archive_decompressor_program_read_consume(struct archive_read *,
- size_t);
+static ssize_t program_filter_read(struct archive_read_filter *,
+ const void **);
+static int program_filter_close(struct archive_read_filter *);
int
-archive_read_support_compression_program(struct archive *_a, const char *cmd)
+archive_read_support_compression_program_signature(struct archive *_a,
+ const char *cmd, const void *signature, size_t signature_len)
{
struct archive_read *a = (struct archive_read *)_a;
- struct decompressor_t *decompressor;
+ struct archive_read_filter_bidder *bidder;
+ struct program_bidder *state;
+
+ /*
+ * Get a bidder object from the read core.
+ */
+ bidder = __archive_read_get_bidder(a);
+ if (bidder == NULL)
+ return (ARCHIVE_FATAL);
- if (cmd == NULL || *cmd == '\0')
- return (ARCHIVE_WARN);
+ /*
+ * Allocate our private state.
+ */
+ state = (struct program_bidder *)calloc(sizeof (*state), 1);
+ if (state == NULL)
+ return (ARCHIVE_FATAL);
+ state->cmd = strdup(cmd);
+ if (signature != NULL && signature_len > 0) {
+ state->signature_len = signature_len;
+ state->signature = malloc(signature_len);
+ memcpy(state->signature, signature, signature_len);
+ }
- decompressor = __archive_read_register_compression(a,
- archive_decompressor_program_bid,
- archive_decompressor_program_init);
- if (decompressor == NULL)
- return (ARCHIVE_WARN);
+ /*
+ * Fill in the bidder object.
+ */
+ bidder->data = state;
+ bidder->bid = program_bidder_bid;
+ bidder->init = program_bidder_init;
+ bidder->options = NULL;
+ bidder->free = program_bidder_free;
+ return (ARCHIVE_OK);
+}
- decompressor->config = strdup(cmd);
+static int
+program_bidder_free(struct archive_read_filter_bidder *self)
+{
+ struct program_bidder *state = (struct program_bidder *)self->data;
+ free(state->cmd);
+ free(state->signature);
+ free(self->data);
return (ARCHIVE_OK);
}
/*
- * If the user used us to register, they must really want us to
- * handle it, so this module always bids INT_MAX.
+ * If we do have a signature, bid only if that matches.
+ *
+ * If there's no signature, we bid INT_MAX the first time
+ * we're called, then never bid again.
*/
static int
-archive_decompressor_program_bid(const void *buff, size_t len)
+program_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *upstream)
{
- (void)buff; /* UNUSED */
- (void)len; /* UNUSED */
+ struct program_bidder *state = self->data;
+ const char *p;
+
+ /* If we have a signature, use that to match. */
+ if (state->signature_len > 0) {
+ p = __archive_read_filter_ahead(upstream,
+ state->signature_len, NULL);
+ if (p == NULL)
+ return (0);
+ /* No match, so don't bid. */
+ if (memcmp(p, state->signature, state->signature_len) != 0)
+ return (0);
+ return ((int)state->signature_len * 8);
+ }
- return (INT_MAX); /* Default: We'll take it. */
+ /* Otherwise, bid once and then never bid again. */
+ if (state->inhibit)
+ return (0);
+ state->inhibit = 1;
+ return (INT_MAX);
}
-static ssize_t
-child_read(struct archive_read *a, char *buf, size_t buf_len)
+/*
+ * Shut down the child, return ARCHIVE_OK if it exited normally.
+ *
+ * Note that the return value is sticky; if we're called again,
+ * we won't reap the child again, but we will return the same status
+ * (including error message if the child came to a bad end).
+ */
+static int
+child_stop(struct archive_read_filter *self, struct program_filter *state)
{
- struct archive_decompress_program *state = a->decompressor->data;
- ssize_t ret, requested;
- const void *child_buf;
+ /* Close our side of the I/O with the child. */
+ if (state->child_stdin != -1) {
+ close(state->child_stdin);
+ state->child_stdin = -1;
+ }
+ if (state->child_stdout != -1) {
+ close(state->child_stdout);
+ state->child_stdout = -1;
+ }
- if (state->child_stdout == -1)
- return (-1);
+ if (state->child != 0) {
+ /* Reap the child. */
+ do {
+ state->waitpid_return
+ = waitpid(state->child, &state->exit_status, 0);
+ } while (state->waitpid_return == -1 && errno == EINTR);
+ state->child = 0;
+ }
- if (buf_len == 0)
- return (-1);
+ if (state->waitpid_return < 0) {
+ /* waitpid() failed? This is ugly. */
+ archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
+ "Child process exited badly");
+ return (ARCHIVE_WARN);
+ }
-restart_read:
- requested = buf_len > SSIZE_MAX ? SSIZE_MAX : buf_len;
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ if (WIFSIGNALED(state->exit_status)) {
+#ifdef SIGPIPE
+ /* If the child died because we stopped reading before
+ * it was done, that's okay. Some archive formats
+ * have padding at the end that we routinely ignore. */
+ /* The alternative to this would be to add a step
+ * before close(child_stdout) above to read from the
+ * child until the child has no more to write. */
+ if (WTERMSIG(state->exit_status) == SIGPIPE)
+ return (ARCHIVE_OK);
+#endif
+ archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
+ "Child process exited with signal %d",
+ WTERMSIG(state->exit_status));
+ return (ARCHIVE_WARN);
+ }
+#endif /* !_WIN32 || __CYGWIN__ */
- do {
- ret = read(state->child_stdout, buf, requested);
- } while (ret == -1 && errno == EINTR);
+ if (WIFEXITED(state->exit_status)) {
+ if (WEXITSTATUS(state->exit_status) == 0)
+ return (ARCHIVE_OK);
- if (ret > 0)
- return (ret);
- if (ret == 0 || (ret == -1 && errno == EPIPE)) {
- close(state->child_stdout);
- state->child_stdout = -1;
- return (0);
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Child process exited with status %d",
+ WEXITSTATUS(state->exit_status));
+ return (ARCHIVE_WARN);
}
- if (ret == -1 && errno != EAGAIN)
- return (-1);
- if (state->child_in_buf_avail == 0) {
- child_buf = state->child_in_buf;
- ret = (a->client_reader)(&a->archive,
- a->client_data,&child_buf);
- state->child_in_buf = (const char *)child_buf;
+ return (ARCHIVE_WARN);
+}
+
+/*
+ * Use select() to decide whether the child is ready for read or write.
+ */
+static ssize_t
+child_read(struct archive_read_filter *self, char *buf, size_t buf_len)
+{
+ struct program_filter *state = self->data;
+ ssize_t ret, requested, avail;
+ const char *p;
+
+ requested = buf_len > SSIZE_MAX ? SSIZE_MAX : buf_len;
- if (ret < 0) {
+ for (;;) {
+ do {
+ ret = read(state->child_stdout, buf, requested);
+ } while (ret == -1 && errno == EINTR);
+
+ if (ret > 0)
+ return (ret);
+ if (ret == 0 || (ret == -1 && errno == EPIPE))
+ /* Child has closed its output; reap the child
+ * and return the status. */
+ return (child_stop(self, state));
+ if (ret == -1 && errno != EAGAIN)
+ return (-1);
+
+ if (state->child_stdin == -1) {
+ /* Block until child has some I/O ready. */
+ __archive_check_child(state->child_stdin,
+ state->child_stdout);
+ continue;
+ }
+
+ /* Get some more data from upstream. */
+ p = __archive_read_filter_ahead(self->upstream, 1, &avail);
+ if (p == NULL) {
close(state->child_stdin);
state->child_stdin = -1;
fcntl(state->child_stdout, F_SETFL, 0);
- return (-1);
+ if (avail < 0)
+ return (avail);
+ continue;
}
- if (ret == 0) {
+
+ do {
+ ret = write(state->child_stdin, p, avail);
+ } while (ret == -1 && errno == EINTR);
+
+ if (ret > 0) {
+ /* Consume whatever we managed to write. */
+ __archive_read_filter_consume(self->upstream, ret);
+ } else if (ret == -1 && errno == EAGAIN) {
+ /* Block until child has some I/O ready. */
+ __archive_check_child(state->child_stdin,
+ state->child_stdout);
+ } else {
+ /* Write failed. */
close(state->child_stdin);
state->child_stdin = -1;
fcntl(state->child_stdout, F_SETFL, 0);
- goto restart_read;
+ /* If it was a bad error, we're done; otherwise
+ * it was EPIPE or EOF, and we can still read
+ * from the child. */
+ if (ret == -1 && errno != EPIPE)
+ return (-1);
}
- state->child_in_buf_avail = ret;
- }
-
- if (state->child_stdin == -1) {
- fcntl(state->child_stdout, F_SETFL, 0);
- __archive_check_child(state->child_stdin, state->child_stdout);
- goto restart_read;
- }
-
- do {
- ret = write(state->child_stdin, state->child_in_buf,
- state->child_in_buf_avail);
- } while (ret == -1 && errno == EINTR);
-
- if (ret > 0) {
- state->child_in_buf += ret;
- state->child_in_buf_avail -= ret;
- goto restart_read;
- } else if (ret == -1 && errno == EAGAIN) {
- __archive_check_child(state->child_stdin, state->child_stdout);
- goto restart_read;
- } else if (ret == 0 || (ret == -1 && errno == EPIPE)) {
- close(state->child_stdin);
- state->child_stdin = -1;
- fcntl(state->child_stdout, F_SETFL, 0);
- goto restart_read;
- } else {
- close(state->child_stdin);
- state->child_stdin = -1;
- fcntl(state->child_stdout, F_SETFL, 0);
- return (-1);
}
}
-static int
-archive_decompressor_program_init(struct archive_read *a, const void *buff, size_t n)
+int
+__archive_read_program(struct archive_read_filter *self, const char *cmd)
{
- struct archive_decompress_program *state;
- const char *cmd = a->decompressor->config;
+ struct program_filter *state;
+ static const size_t out_buf_len = 65536;
+ char *out_buf;
+ char *description;
const char *prefix = "Program: ";
-
- state = (struct archive_decompress_program *)malloc(sizeof(*state));
- if (!state) {
- archive_set_error(&a->archive, ENOMEM,
+ state = (struct program_filter *)calloc(1, sizeof(*state));
+ out_buf = (char *)malloc(out_buf_len);
+ description = (char *)malloc(strlen(prefix) + strlen(cmd) + 1);
+ if (state == NULL || out_buf == NULL || description == NULL) {
+ archive_set_error(&self->archive->archive, ENOMEM,
"Can't allocate input data");
+ free(state);
+ free(out_buf);
+ free(description);
return (ARCHIVE_FATAL);
}
- a->archive.compression_code = ARCHIVE_COMPRESSION_PROGRAM;
- state->description = (char *)malloc(strlen(prefix) + strlen(cmd) + 1);
+ self->code = ARCHIVE_COMPRESSION_PROGRAM;
+ state->description = description;
strcpy(state->description, prefix);
strcat(state->description, cmd);
- a->archive.compression_name = state->description;
-
- state->child_out_buf_next = state->child_out_buf = malloc(65536);
- if (!state->child_out_buf) {
- free(state);
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate filter buffer");
- return (ARCHIVE_FATAL);
- }
- state->child_out_buf_len = 65536;
- state->child_out_buf_avail = 0;
+ self->name = state->description;
- state->child_in_buf = buff;
- state->child_in_buf_avail = n;
+ state->out_buf = out_buf;
+ state->out_buf_len = out_buf_len;
if ((state->child = __archive_create_child(cmd,
&state->child_stdin, &state->child_stdout)) == -1) {
- free(state->child_out_buf);
+ free(state->out_buf);
free(state);
- archive_set_error(&a->archive, EINVAL,
+ archive_set_error(&self->archive->archive, EINVAL,
"Can't initialise filter");
return (ARCHIVE_FATAL);
}
- a->decompressor->data = state;
- a->decompressor->read_ahead = archive_decompressor_program_read_ahead;
- a->decompressor->consume = archive_decompressor_program_read_consume;
- a->decompressor->skip = NULL;
- a->decompressor->finish = archive_decompressor_program_finish;
+ self->data = state;
+ self->read = program_filter_read;
+ self->skip = NULL;
+ self->close = program_filter_close;
/* XXX Check that we can read at least one byte? */
return (ARCHIVE_OK);
}
-static ssize_t
-archive_decompressor_program_read_ahead(struct archive_read *a, const void **buff,
- size_t min)
+static int
+program_bidder_init(struct archive_read_filter *self)
{
- struct archive_decompress_program *state;
- ssize_t bytes_read;
-
- state = (struct archive_decompress_program *)a->decompressor->data;
+ struct program_bidder *bidder_state;
- if (min > state->child_out_buf_len)
- min = state->child_out_buf_len;
-
- while (state->child_stdout != -1 && min > state->child_out_buf_avail) {
- if (state->child_out_buf != state->child_out_buf_next) {
- memmove(state->child_out_buf, state->child_out_buf_next,
- state->child_out_buf_avail);
- state->child_out_buf_next = state->child_out_buf;
- }
-
- bytes_read = child_read(a,
- state->child_out_buf + state->child_out_buf_avail,
- state->child_out_buf_len - state->child_out_buf_avail);
- if (bytes_read == -1)
- return (-1);
- if (bytes_read == 0)
- break;
- state->child_out_buf_avail += bytes_read;
- a->archive.raw_position += bytes_read;
- }
-
- *buff = state->child_out_buf_next;
- return (state->child_out_buf_avail);
+ bidder_state = (struct program_bidder *)self->bidder->data;
+ return (__archive_read_program(self, bidder_state->cmd));
}
static ssize_t
-archive_decompressor_program_read_consume(struct archive_read *a, size_t request)
+program_filter_read(struct archive_read_filter *self, const void **buff)
{
- struct archive_decompress_program *state;
-
- state = (struct archive_decompress_program *)a->decompressor->data;
-
- state->child_out_buf_next += request;
- state->child_out_buf_avail -= request;
+ struct program_filter *state;
+ ssize_t bytes;
+ size_t total;
+ char *p;
+
+ state = (struct program_filter *)self->data;
+
+ total = 0;
+ p = state->out_buf;
+ while (state->child_stdout != -1 && total < state->out_buf_len) {
+ bytes = child_read(self, p, state->out_buf_len - total);
+ if (bytes < 0)
+ /* No recovery is possible if we can no longer
+ * read from the child. */
+ return (ARCHIVE_FATAL);
+ if (bytes == 0)
+ /* We got EOF from the child. */
+ break;
+ total += bytes;
+ p += bytes;
+ }
- a->archive.file_position += request;
- return (request);
+ *buff = state->out_buf;
+ return (total);
}
static int
-archive_decompressor_program_finish(struct archive_read *a)
+program_filter_close(struct archive_read_filter *self)
{
- struct archive_decompress_program *state;
- int status;
-
- state = (struct archive_decompress_program *)a->decompressor->data;
+ struct program_filter *state;
+ int e;
- /* Release our configuration data. */
- free(a->decompressor->config);
- a->decompressor->config = NULL;
-
- /* Shut down the child. */
- if (state->child_stdin != -1)
- close(state->child_stdin);
- if (state->child_stdout != -1)
- close(state->child_stdout);
- while (waitpid(state->child, &status, 0) == -1 && errno == EINTR)
- continue;
+ state = (struct program_filter *)self->data;
+ e = child_stop(self, state);
/* Release our private data. */
- free(state->child_out_buf);
+ free(state->out_buf);
free(state->description);
free(state);
- a->decompressor->data = NULL;
- return (ARCHIVE_OK);
+ return (e);
}
#endif /* !defined(HAVE_PIPE) || !defined(HAVE_VFORK) || !defined(HAVE_FCNTL) */
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_rpm.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_rpm.c
new file mode 100644
index 00000000000..051baa5e122
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_rpm.c
@@ -0,0 +1,287 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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 "archive_platform.h"
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+struct rpm {
+ int64_t total_in;
+ size_t hpos;
+ size_t hlen;
+ unsigned char header[16];
+ enum {
+ ST_LEAD, /* Skipping 'Lead' section. */
+ ST_HEADER, /* Reading 'Header' section;
+ * first 16 bytes. */
+ ST_HEADER_DATA, /* Skipping 'Header' section. */
+ ST_PADDING, /* Skipping padding data after the
+ * 'Header' section. */
+ ST_ARCHIVE /* Reading 'Archive' section. */
+ } state;
+ int first_header;
+};
+#define RPM_LEAD_SIZE 96 /* Size of 'Lead' section. */
+
+static int rpm_bidder_bid(struct archive_read_filter_bidder *,
+ struct archive_read_filter *);
+static int rpm_bidder_init(struct archive_read_filter *);
+
+static ssize_t rpm_filter_read(struct archive_read_filter *,
+ const void **);
+static int rpm_filter_close(struct archive_read_filter *);
+
+int
+archive_read_support_compression_rpm(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ struct archive_read_filter_bidder *bidder;
+
+ bidder = __archive_read_get_bidder(a);
+ archive_clear_error(_a);
+ if (bidder == NULL)
+ return (ARCHIVE_FATAL);
+
+ bidder->data = NULL;
+ bidder->bid = rpm_bidder_bid;
+ bidder->init = rpm_bidder_init;
+ bidder->options = NULL;
+ bidder->free = NULL;
+ return (ARCHIVE_OK);
+}
+
+static int
+rpm_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *filter)
+{
+ const unsigned char *b;
+ ssize_t avail;
+ int bits_checked;
+
+ (void)self; /* UNUSED */
+
+ b = __archive_read_filter_ahead(filter, 8, &avail);
+ if (b == NULL)
+ return (0);
+
+ bits_checked = 0;
+ /*
+ * Verify Header Magic Bytes : 0xed 0xab 0xee 0xdb
+ */
+ if (b[0] != 0xed)
+ return (0);
+ bits_checked += 8;
+ if (b[1] != 0xab)
+ return (0);
+ bits_checked += 8;
+ if (b[2] != 0xee)
+ return (0);
+ bits_checked += 8;
+ if (b[3] != 0xdb)
+ return (0);
+ bits_checked += 8;
+ /*
+ * Check major version.
+ */
+ if (b[4] != 3 && b[4] != 4)
+ return (0);
+ bits_checked += 8;
+ /*
+ * Check package type; binary or source.
+ */
+ if (b[6] != 0)
+ return (0);
+ bits_checked += 8;
+ if (b[7] != 0 && b[7] != 1)
+ return (0);
+ bits_checked += 8;
+
+ return (bits_checked);
+}
+
+static int
+rpm_bidder_init(struct archive_read_filter *self)
+{
+ struct rpm *rpm;
+
+ self->code = ARCHIVE_COMPRESSION_RPM;
+ self->name = "rpm";
+ self->read = rpm_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = rpm_filter_close;
+
+ rpm = (struct rpm *)calloc(sizeof(*rpm), 1);
+ if (rpm == NULL) {
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Can't allocate data for rpm");
+ return (ARCHIVE_FATAL);
+ }
+
+ self->data = rpm;
+ rpm->state = ST_LEAD;
+
+ return (ARCHIVE_OK);
+}
+
+static ssize_t
+rpm_filter_read(struct archive_read_filter *self, const void **buff)
+{
+ struct rpm *rpm;
+ const unsigned char *b;
+ ssize_t avail_in, total;
+ size_t used, n;
+ uint32_t section;
+ uint32_t bytes;
+
+ rpm = (struct rpm *)self->data;
+ *buff = NULL;
+ total = avail_in = 0;
+ b = NULL;
+ used = 0;
+ do {
+ if (b == NULL) {
+ b = __archive_read_filter_ahead(self->upstream, 1,
+ &avail_in);
+ if (b == NULL) {
+ if (avail_in < 0)
+ return (ARCHIVE_FATAL);
+ else
+ break;
+ }
+ }
+
+ switch (rpm->state) {
+ case ST_LEAD:
+ if (rpm->total_in + avail_in < RPM_LEAD_SIZE)
+ used += avail_in;
+ else {
+ n = RPM_LEAD_SIZE - rpm->total_in;
+ used += n;
+ b += n;
+ rpm->state = ST_HEADER;
+ rpm->hpos = 0;
+ rpm->hlen = 0;
+ rpm->first_header = 1;
+ }
+ break;
+ case ST_HEADER:
+ n = 16 - rpm->hpos;
+ if (n > avail_in - used)
+ n = avail_in - used;
+ memcpy(rpm->header+rpm->hpos, b, n);
+ b += n;
+ used += n;
+ rpm->hpos += n;
+
+ if (rpm->hpos == 16) {
+ if (rpm->header[0] != 0x8e ||
+ rpm->header[1] != 0xad ||
+ rpm->header[2] != 0xe8 ||
+ rpm->header[3] != 0x01) {
+ if (rpm->first_header) {
+ archive_set_error(
+ &self->archive->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Unrecoginized rpm header");
+ return (ARCHIVE_FATAL);
+ }
+ rpm->state = ST_ARCHIVE;
+ *buff = rpm->header;
+ total = rpm->hpos;
+ break;
+ }
+ /* Calculate 'Header' length. */
+ section = archive_be32dec(rpm->header+8);
+ bytes = archive_be32dec(rpm->header+12);
+ rpm->hlen = 16 + section * 16 + bytes;
+ rpm->state = ST_HEADER_DATA;
+ rpm->first_header = 0;
+ }
+ break;
+ case ST_HEADER_DATA:
+ n = rpm->hlen - rpm->hpos;
+ if (n > avail_in - used)
+ n = avail_in - used;
+ b += n;
+ used += n;
+ rpm->hpos += n;
+ if (rpm->hpos == rpm->hlen)
+ rpm->state = ST_PADDING;
+ break;
+ case ST_PADDING:
+ while (used < (size_t)avail_in) {
+ if (*b != 0) {
+ /* Read next header. */
+ rpm->state = ST_HEADER;
+ rpm->hpos = 0;
+ rpm->hlen = 0;
+ break;
+ }
+ b++;
+ used++;
+ }
+ break;
+ case ST_ARCHIVE:
+ *buff = b;
+ total = avail_in;
+ used = avail_in;
+ break;
+ }
+ if (used == (size_t)avail_in) {
+ rpm->total_in += used;
+ __archive_read_filter_consume(self->upstream, used);
+ b = NULL;
+ used = 0;
+ }
+ } while (total == 0 && avail_in > 0);
+
+ if (used > 0 && b != NULL) {
+ rpm->total_in += used;
+ __archive_read_filter_consume(self->upstream, used);
+ }
+ return (total);
+}
+
+static int
+rpm_filter_close(struct archive_read_filter *self)
+{
+ struct rpm *rpm;
+
+ rpm = (struct rpm *)self->data;
+ free(rpm);
+
+ return (ARCHIVE_OK);
+}
+
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_uu.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_uu.c
new file mode 100644
index 00000000000..1e3052097dc
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_uu.c
@@ -0,0 +1,627 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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 "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_uu.c 201248 2009-12-30 06:12:03Z kientzle $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "archive.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+struct uudecode {
+ int64_t total;
+ unsigned char *in_buff;
+#define IN_BUFF_SIZE (1024)
+ int in_cnt;
+ size_t in_allocated;
+ unsigned char *out_buff;
+#define OUT_BUFF_SIZE (64 * 1024)
+ int state;
+#define ST_FIND_HEAD 0
+#define ST_READ_UU 1
+#define ST_UUEND 2
+#define ST_READ_BASE64 3
+};
+
+static int uudecode_bidder_bid(struct archive_read_filter_bidder *,
+ struct archive_read_filter *filter);
+static int uudecode_bidder_init(struct archive_read_filter *);
+
+static ssize_t uudecode_filter_read(struct archive_read_filter *,
+ const void **);
+static int uudecode_filter_close(struct archive_read_filter *);
+
+int
+archive_read_support_compression_uu(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ struct archive_read_filter_bidder *bidder;
+
+ bidder = __archive_read_get_bidder(a);
+ archive_clear_error(_a);
+ if (bidder == NULL)
+ return (ARCHIVE_FATAL);
+
+ bidder->data = NULL;
+ bidder->bid = uudecode_bidder_bid;
+ bidder->init = uudecode_bidder_init;
+ bidder->options = NULL;
+ bidder->free = NULL;
+ return (ARCHIVE_OK);
+}
+
+static const unsigned char ascii[256] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\n', 0, 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, 0, 0, 0, 0, 0,
+ 0, 0, 0, 62, 0, 0, 0, 63, /* 20 - 2F */
+ 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, 0, 0, 0, 0, 0, 0, /* 30 - 3F */
+ 0, 0, 1, 2, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, /* 40 - 4F */
+ 15, 16, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, 0, 0, 0, 0, 0, /* 50 - 5F */
+ 0, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, /* 60 - 6F */
+ 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 0, 0, 0, 0, 0, /* 70 - 7F */
+};
+
+static ssize_t
+get_line(const unsigned char *b, ssize_t avail, ssize_t *nlsize)
+{
+ ssize_t len;
+
+ len = 0;
+ while (len < avail) {
+ switch (ascii[*b]) {
+ case 0: /* Non-ascii character or control character. */
+ if (nlsize != NULL)
+ *nlsize = 0;
+ return (-1);
+ case '\r':
+ if (avail-len > 1 && b[1] == '\n') {
+ if (nlsize != NULL)
+ *nlsize = 2;
+ return (len+2);
+ }
+ /* FALL THROUGH */
+ case '\n':
+ if (nlsize != NULL)
+ *nlsize = 1;
+ return (len+1);
+ case 1:
+ b++;
+ len++;
+ break;
+ }
+ }
+ if (nlsize != NULL)
+ *nlsize = 0;
+ return (avail);
+}
+
+static ssize_t
+bid_get_line(struct archive_read_filter *filter,
+ const unsigned char **b, ssize_t *avail, ssize_t *ravail, ssize_t *nl)
+{
+ ssize_t len;
+ int quit;
+
+ quit = 0;
+ if (*avail == 0) {
+ *nl = 0;
+ len = 0;
+ } else
+ len = get_line(*b, *avail, nl);
+ /*
+ * Read bytes more while it does not reach the end of line.
+ */
+ while (*nl == 0 && len == *avail && !quit) {
+ ssize_t diff = *ravail - *avail;
+
+ *b = __archive_read_filter_ahead(filter, 160 + *ravail, avail);
+ if (*b == NULL) {
+ if (*ravail >= *avail)
+ return (0);
+ /* Reading bytes reaches the end of file. */
+ *b = __archive_read_filter_ahead(filter, *avail, avail);
+ quit = 1;
+ }
+ *ravail = *avail;
+ *b += diff;
+ *avail -= diff;
+ len = get_line(*b, *avail, nl);
+ }
+ return (len);
+}
+
+#define UUDECODE(c) (((c) - 0x20) & 0x3f)
+
+static int
+uudecode_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *filter)
+{
+ const unsigned char *b;
+ ssize_t avail, ravail;
+ ssize_t len, nl;
+ int l;
+ int firstline;
+
+ (void)self; /* UNUSED */
+
+ b = __archive_read_filter_ahead(filter, 1, &avail);
+ if (b == NULL)
+ return (0);
+
+ firstline = 20;
+ ravail = avail;
+ for (;;) {
+ len = bid_get_line(filter, &b, &avail, &ravail, &nl);
+ if (len < 0 || nl == 0)
+ return (0);/* Binary data. */
+ if (memcmp(b, "begin ", 6) == 0 && len - nl >= 11)
+ l = 6;
+ else if (memcmp(b, "begin-base64 ", 13) == 0 && len - nl >= 18)
+ l = 13;
+ else
+ l = 0;
+
+ if (l > 0 && (b[l] < '0' || b[l] > '7' ||
+ b[l+1] < '0' || b[l+1] > '7' ||
+ b[l+2] < '0' || b[l+2] > '7' || b[l+3] != ' '))
+ l = 0;
+
+ b += len;
+ avail -= len;
+ if (l)
+ break;
+ firstline = 0;
+ }
+ if (!avail)
+ return (0);
+ len = bid_get_line(filter, &b, &avail, &ravail, &nl);
+ if (len < 0 || nl == 0)
+ return (0);/* There are non-ascii characters. */
+ avail -= len;
+
+ if (l == 6) {
+ if (!uuchar[*b])
+ return (0);
+ /* Get a length of decoded bytes. */
+ l = UUDECODE(*b++); len--;
+ if (l > 45)
+ /* Normally, maximum length is 45(character 'M'). */
+ return (0);
+ while (l && len-nl > 0) {
+ if (l > 0) {
+ if (!uuchar[*b++])
+ return (0);
+ if (!uuchar[*b++])
+ return (0);
+ len -= 2;
+ --l;
+ }
+ if (l > 0) {
+ if (!uuchar[*b++])
+ return (0);
+ --len;
+ --l;
+ }
+ if (l > 0) {
+ if (!uuchar[*b++])
+ return (0);
+ --len;
+ --l;
+ }
+ }
+ if (len-nl < 0)
+ return (0);
+ if (len-nl == 1 &&
+ (uuchar[*b] || /* Check sum. */
+ (*b >= 'a' && *b <= 'z'))) {/* Padding data(MINIX). */
+ ++b;
+ --len;
+ }
+ b += nl;
+ if (avail && uuchar[*b])
+ return (firstline+30);
+ }
+ if (l == 13) {
+ while (len-nl > 0) {
+ if (!base64[*b++])
+ return (0);
+ --len;
+ }
+ b += nl;
+
+ if (avail >= 5 && memcmp(b, "====\n", 5) == 0)
+ return (firstline+40);
+ if (avail >= 6 && memcmp(b, "====\r\n", 6) == 0)
+ return (firstline+40);
+ if (avail > 0 && base64[*b])
+ return (firstline+30);
+ }
+
+ return (0);
+}
+
+static int
+uudecode_bidder_init(struct archive_read_filter *self)
+{
+ struct uudecode *uudecode;
+ void *out_buff;
+ void *in_buff;
+
+ self->code = ARCHIVE_COMPRESSION_UU;
+ self->name = "uu";
+ self->read = uudecode_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = uudecode_filter_close;
+
+ uudecode = (struct uudecode *)calloc(sizeof(*uudecode), 1);
+ out_buff = malloc(OUT_BUFF_SIZE);
+ in_buff = malloc(IN_BUFF_SIZE);
+ if (uudecode == NULL || out_buff == NULL || in_buff == NULL) {
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Can't allocate data for uudecode");
+ free(uudecode);
+ free(out_buff);
+ free(in_buff);
+ return (ARCHIVE_FATAL);
+ }
+
+ self->data = uudecode;
+ uudecode->in_buff = in_buff;
+ uudecode->in_cnt = 0;
+ uudecode->in_allocated = IN_BUFF_SIZE;
+ uudecode->out_buff = out_buff;
+ uudecode->state = ST_FIND_HEAD;
+
+ return (ARCHIVE_OK);
+}
+
+static int
+ensure_in_buff_size(struct archive_read_filter *self,
+ struct uudecode *uudecode, size_t size)
+{
+
+ if (size > uudecode->in_allocated) {
+ unsigned char *ptr;
+ size_t newsize;
+
+ newsize = uudecode->in_allocated << 1;
+ ptr = malloc(newsize);
+ if (ptr == NULL ||
+ newsize < uudecode->in_allocated) {
+ free(ptr);
+ archive_set_error(&self->archive->archive,
+ ENOMEM,
+ "Can't allocate data for uudecode");
+ return (ARCHIVE_FATAL);
+ }
+ if (uudecode->in_cnt)
+ memmove(ptr, uudecode->in_buff,
+ uudecode->in_cnt);
+ free(uudecode->in_buff);
+ uudecode->in_buff = ptr;
+ uudecode->in_allocated = newsize;
+ }
+ return (ARCHIVE_OK);
+}
+
+static ssize_t
+uudecode_filter_read(struct archive_read_filter *self, const void **buff)
+{
+ struct uudecode *uudecode;
+ const unsigned char *b, *d;
+ unsigned char *out;
+ ssize_t avail_in, ravail;
+ ssize_t used;
+ ssize_t total;
+ ssize_t len, llen, nl;
+
+ uudecode = (struct uudecode *)self->data;
+
+read_more:
+ d = __archive_read_filter_ahead(self->upstream, 1, &avail_in);
+ if (d == NULL && avail_in < 0)
+ return (ARCHIVE_FATAL);
+ /* Quiet a code analyzer; make sure avail_in must be zero
+ * when d is NULL. */
+ if (d == NULL)
+ avail_in = 0;
+ used = 0;
+ total = 0;
+ out = uudecode->out_buff;
+ ravail = avail_in;
+ if (uudecode->in_cnt) {
+ /*
+ * If there is remaining data which is saved by
+ * previous calling, use it first.
+ */
+ if (ensure_in_buff_size(self, uudecode,
+ avail_in + uudecode->in_cnt) != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ memcpy(uudecode->in_buff + uudecode->in_cnt,
+ d, avail_in);
+ d = uudecode->in_buff;
+ avail_in += uudecode->in_cnt;
+ uudecode->in_cnt = 0;
+ }
+ for (;used < avail_in; d += llen, used += llen) {
+ int l, body;
+
+ b = d;
+ len = get_line(b, avail_in - used, &nl);
+ if (len < 0) {
+ /* Non-ascii character is found. */
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Insufficient compressed data");
+ return (ARCHIVE_FATAL);
+ }
+ llen = len;
+ if (nl == 0) {
+ /*
+ * Save remaining data which does not contain
+ * NL('\n','\r').
+ */
+ if (ensure_in_buff_size(self, uudecode, len)
+ != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ if (uudecode->in_buff != b)
+ memmove(uudecode->in_buff, b, len);
+ uudecode->in_cnt = len;
+ if (total == 0) {
+ /* Do not return 0; it means end-of-file.
+ * We should try to read bytes more. */
+ __archive_read_filter_consume(
+ self->upstream, ravail);
+ goto read_more;
+ }
+ break;
+ }
+ if (total + len * 2 > OUT_BUFF_SIZE)
+ break;
+ switch (uudecode->state) {
+ default:
+ case ST_FIND_HEAD:
+ if (len - nl > 13 && memcmp(b, "begin ", 6) == 0)
+ l = 6;
+ else if (len - nl > 18 &&
+ memcmp(b, "begin-base64 ", 13) == 0)
+ l = 13;
+ else
+ l = 0;
+ if (l != 0 && b[l] >= '0' && b[l] <= '7' &&
+ b[l+1] >= '0' && b[l+1] <= '7' &&
+ b[l+2] >= '0' && b[l+2] <= '7' && b[l+3] == ' ') {
+ if (l == 6)
+ uudecode->state = ST_READ_UU;
+ else
+ uudecode->state = ST_READ_BASE64;
+ }
+ break;
+ case ST_READ_UU:
+ body = len - nl;
+ if (!uuchar[*b] || body <= 0) {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Insufficient compressed data");
+ return (ARCHIVE_FATAL);
+ }
+ /* Get length of undecoded bytes of curent line. */
+ l = UUDECODE(*b++);
+ body--;
+ if (l > body) {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Insufficient compressed data");
+ return (ARCHIVE_FATAL);
+ }
+ if (l == 0) {
+ uudecode->state = ST_UUEND;
+ break;
+ }
+ while (l > 0) {
+ int n = 0;
+
+ if (l > 0) {
+ if (!uuchar[b[0]] || !uuchar[b[1]])
+ break;
+ n = UUDECODE(*b++) << 18;
+ n |= UUDECODE(*b++) << 12;
+ *out++ = n >> 16; total++;
+ --l;
+ }
+ if (l > 0) {
+ if (!uuchar[b[0]])
+ break;
+ n |= UUDECODE(*b++) << 6;
+ *out++ = (n >> 8) & 0xFF; total++;
+ --l;
+ }
+ if (l > 0) {
+ if (!uuchar[b[0]])
+ break;
+ n |= UUDECODE(*b++);
+ *out++ = n & 0xFF; total++;
+ --l;
+ }
+ }
+ if (l) {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Insufficient compressed data");
+ return (ARCHIVE_FATAL);
+ }
+ break;
+ case ST_UUEND:
+ if (len - nl == 3 && memcmp(b, "end ", 3) == 0)
+ uudecode->state = ST_FIND_HEAD;
+ else {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Insufficient compressed data");
+ return (ARCHIVE_FATAL);
+ }
+ break;
+ case ST_READ_BASE64:
+ l = len - nl;
+ if (l >= 3 && b[0] == '=' && b[1] == '=' &&
+ b[2] == '=') {
+ uudecode->state = ST_FIND_HEAD;
+ break;
+ }
+ while (l > 0) {
+ int n = 0;
+
+ if (l > 0) {
+ if (!base64[b[0]] || !base64[b[1]])
+ break;
+ n = base64num[*b++] << 18;
+ n |= base64num[*b++] << 12;
+ *out++ = n >> 16; total++;
+ l -= 2;
+ }
+ if (l > 0) {
+ if (*b == '=')
+ break;
+ if (!base64[*b])
+ break;
+ n |= base64num[*b++] << 6;
+ *out++ = (n >> 8) & 0xFF; total++;
+ --l;
+ }
+ if (l > 0) {
+ if (*b == '=')
+ break;
+ if (!base64[*b])
+ break;
+ n |= base64num[*b++];
+ *out++ = n & 0xFF; total++;
+ --l;
+ }
+ }
+ if (l && *b != '=') {
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Insufficient compressed data");
+ return (ARCHIVE_FATAL);
+ }
+ break;
+ }
+ }
+
+ __archive_read_filter_consume(self->upstream, ravail);
+
+ *buff = uudecode->out_buff;
+ uudecode->total += total;
+ return (total);
+}
+
+static int
+uudecode_filter_close(struct archive_read_filter *self)
+{
+ struct uudecode *uudecode;
+
+ uudecode = (struct uudecode *)self->data;
+ free(uudecode->in_buff);
+ free(uudecode->out_buff);
+ free(uudecode);
+
+ return (ARCHIVE_OK);
+}
+
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_xz.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_xz.c
new file mode 100644
index 00000000000..28c4e2d9fc5
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_xz.c
@@ -0,0 +1,708 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2008 Tim Kientzle and Miklos Vajna
+ * 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 "archive_platform.h"
+
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_compression_xz.c 201167 2009-12-29 06:06:20Z kientzle $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_LZMA_H
+#include <lzma.h>
+#elif HAVE_LZMADEC_H
+#include <lzmadec.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+#if HAVE_LZMA_H && HAVE_LIBLZMA
+
+struct private_data {
+ lzma_stream stream;
+ unsigned char *out_block;
+ size_t out_block_size;
+ int64_t total_out;
+ char eof; /* True = found end of compressed data. */
+};
+
+/* Combined lzma/xz filter */
+static ssize_t xz_filter_read(struct archive_read_filter *, const void **);
+static int xz_filter_close(struct archive_read_filter *);
+static int xz_lzma_bidder_init(struct archive_read_filter *);
+
+#elif HAVE_LZMADEC_H && HAVE_LIBLZMADEC
+
+struct private_data {
+ lzmadec_stream stream;
+ unsigned char *out_block;
+ size_t out_block_size;
+ int64_t total_out;
+ char eof; /* True = found end of compressed data. */
+};
+
+/* Lzma-only filter */
+static ssize_t lzma_filter_read(struct archive_read_filter *, const void **);
+static int lzma_filter_close(struct archive_read_filter *);
+#endif
+
+/*
+ * Note that we can detect xz and lzma compressed files even if we
+ * can't decompress them. (In fact, we like detecting them because we
+ * can give better error messages.) So the bid framework here gets
+ * compiled even if no lzma library is available.
+ */
+static int xz_bidder_bid(struct archive_read_filter_bidder *,
+ struct archive_read_filter *);
+static int xz_bidder_init(struct archive_read_filter *);
+static int lzma_bidder_bid(struct archive_read_filter_bidder *,
+ struct archive_read_filter *);
+static int lzma_bidder_init(struct archive_read_filter *);
+
+int
+archive_read_support_compression_xz(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a);
+
+ archive_clear_error(_a);
+ if (bidder == NULL)
+ return (ARCHIVE_FATAL);
+
+ bidder->data = NULL;
+ bidder->bid = xz_bidder_bid;
+ bidder->init = xz_bidder_init;
+ bidder->options = NULL;
+ bidder->free = NULL;
+#if HAVE_LZMA_H && HAVE_LIBLZMA
+ return (ARCHIVE_OK);
+#else
+ archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+ "Using external unxz program for xz decompression");
+ return (ARCHIVE_WARN);
+#endif
+}
+
+int
+archive_read_support_compression_lzma(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a);
+
+ archive_clear_error(_a);
+ if (bidder == NULL)
+ return (ARCHIVE_FATAL);
+
+ bidder->data = NULL;
+ bidder->bid = lzma_bidder_bid;
+ bidder->init = lzma_bidder_init;
+ bidder->options = NULL;
+ bidder->free = NULL;
+#if HAVE_LZMA_H && HAVE_LIBLZMA
+ return (ARCHIVE_OK);
+#elif HAVE_LZMADEC_H && HAVE_LIBLZMADEC
+ return (ARCHIVE_OK);
+#else
+ archive_set_error(_a, ARCHIVE_ERRNO_MISC,
+ "Using external unlzma program for lzma decompression");
+ return (ARCHIVE_WARN);
+#endif
+}
+
+/*
+ * Test whether we can handle this data.
+ */
+static int
+xz_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *filter)
+{
+ const unsigned char *buffer;
+ ssize_t avail;
+ int bits_checked;
+
+ (void)self; /* UNUSED */
+
+ buffer = __archive_read_filter_ahead(filter, 6, &avail);
+ if (buffer == NULL)
+ return (0);
+
+ /*
+ * Verify Header Magic Bytes : FD 37 7A 58 5A 00
+ */
+ bits_checked = 0;
+ if (buffer[0] != 0xFD)
+ return (0);
+ bits_checked += 8;
+ if (buffer[1] != 0x37)
+ return (0);
+ bits_checked += 8;
+ if (buffer[2] != 0x7A)
+ return (0);
+ bits_checked += 8;
+ if (buffer[3] != 0x58)
+ return (0);
+ bits_checked += 8;
+ if (buffer[4] != 0x5A)
+ return (0);
+ bits_checked += 8;
+ if (buffer[5] != 0x00)
+ return (0);
+ bits_checked += 8;
+
+ return (bits_checked);
+}
+
+/*
+ * Test whether we can handle this data.
+ *
+ * <sigh> LZMA has a rather poor file signature. Zeros do not
+ * make good signature bytes as a rule, and the only non-zero byte
+ * here is an ASCII character. For example, an uncompressed tar
+ * archive whose first file is ']' would satisfy this check. It may
+ * be necessary to exclude LZMA from compression_all() because of
+ * this. Clients of libarchive would then have to explicitly enable
+ * LZMA checking instead of (or in addition to) compression_all() when
+ * they have other evidence (file name, command-line option) to go on.
+ */
+static int
+lzma_bidder_bid(struct archive_read_filter_bidder *self,
+ struct archive_read_filter *filter)
+{
+ const unsigned char *buffer;
+ ssize_t avail;
+ uint32_t dicsize;
+ uint64_t uncompressed_size;
+ int bits_checked;
+
+ (void)self; /* UNUSED */
+
+ buffer = __archive_read_filter_ahead(filter, 14, &avail);
+ if (buffer == NULL)
+ return (0);
+
+ /* First byte of raw LZMA stream is commonly 0x5d.
+ * The first byte is a special number, which consists of
+ * three parameters of LZMA compression, a number of literal
+ * context bits(which is from 0 to 8, default is 3), a number
+ * of literal pos bits(which is from 0 to 4, default is 0),
+ * a number of pos bits(which is from 0 to 4, default is 2).
+ * The first byte is made by
+ * (pos bits * 5 + literal pos bit) * 9 + * literal contest bit,
+ * and so the default value in this field is
+ * (2 * 5 + 0) * 9 + 3 = 0x5d.
+ * lzma of LZMA SDK has options to change those parameters.
+ * It means a range of this field is from 0 to 224. And lzma of
+ * XZ Utils with option -e records 0x5e in this field. */
+ /* NOTE: If this checking of the first byte increases false
+ * recognition, we should allow only 0x5d and 0x5e for the first
+ * byte of LZMA stream. */
+ bits_checked = 0;
+ if (buffer[0] > (4 * 5 + 4) * 9 + 8)
+ return (0);
+ /* Most likely value in the first byte of LZMA stream. */
+ if (buffer[0] == 0x5d || buffer[0] == 0x5e)
+ bits_checked += 8;
+
+ /* Sixth through fourteenth bytes are uncompressed size,
+ * stored in little-endian order. `-1' means uncompressed
+ * size is unknown and lzma of XZ Utils always records `-1'
+ * in this field. */
+ uncompressed_size = archive_le64dec(buffer+5);
+ if (uncompressed_size == (uint64_t)ARCHIVE_LITERAL_LL(-1))
+ bits_checked += 64;
+
+ /* Second through fifth bytes are dictionary size, stored in
+ * little-endian order. The minimum dictionary size is
+ * 1 << 12(4KiB) which the lzma of LZMA SDK uses with option
+ * -d12 and the maxinam dictionary size is 1 << 27(128MiB)
+ * which the one uses with option -d27.
+ * NOTE: A comment of LZMA SDK source code says this dictionary
+ * range is from 1 << 12 to 1 << 30. */
+ dicsize = archive_le32dec(buffer+1);
+ switch (dicsize) {
+ case 0x00001000:/* lzma of LZMA SDK option -d12. */
+ case 0x00002000:/* lzma of LZMA SDK option -d13. */
+ case 0x00004000:/* lzma of LZMA SDK option -d14. */
+ case 0x00008000:/* lzma of LZMA SDK option -d15. */
+ case 0x00010000:/* lzma of XZ Utils option -0 and -1.
+ * lzma of LZMA SDK option -d16. */
+ case 0x00020000:/* lzma of LZMA SDK option -d17. */
+ case 0x00040000:/* lzma of LZMA SDK option -d18. */
+ case 0x00080000:/* lzma of XZ Utils option -2.
+ * lzma of LZMA SDK option -d19. */
+ case 0x00100000:/* lzma of XZ Utils option -3.
+ * lzma of LZMA SDK option -d20. */
+ case 0x00200000:/* lzma of XZ Utils option -4.
+ * lzma of LZMA SDK option -d21. */
+ case 0x00400000:/* lzma of XZ Utils option -5.
+ * lzma of LZMA SDK option -d22. */
+ case 0x00800000:/* lzma of XZ Utils option -6.
+ * lzma of LZMA SDK option -d23. */
+ case 0x01000000:/* lzma of XZ Utils option -7.
+ * lzma of LZMA SDK option -d24. */
+ case 0x02000000:/* lzma of XZ Utils option -8.
+ * lzma of LZMA SDK option -d25. */
+ case 0x04000000:/* lzma of XZ Utils option -9.
+ * lzma of LZMA SDK option -d26. */
+ case 0x08000000:/* lzma of LZMA SDK option -d27. */
+ bits_checked += 32;
+ break;
+ default:
+ /* If a memory usage for encoding was not enough on
+ * the platform where LZMA stream was made, lzma of
+ * XZ Utils automatically decreased the dictionary
+ * size to enough memory for encoding by 1Mi bytes
+ * (1 << 20).*/
+ if (dicsize <= 0x03F00000 && dicsize >= 0x00300000 &&
+ (dicsize & ((1 << 20)-1)) == 0 &&
+ bits_checked == 8 + 64) {
+ bits_checked += 32;
+ break;
+ }
+ /* Otherwise dictionary size is unlikely. But it is
+ * possible that someone makes lzma stream with
+ * liblzma/LZMA SDK in one's dictionary size. */
+ return (0);
+ }
+
+ /* TODO: The above test is still very weak. It would be
+ * good to do better. */
+
+ return (bits_checked);
+}
+
+#if HAVE_LZMA_H && HAVE_LIBLZMA
+
+/*
+ * liblzma 4.999.7 and later support both lzma and xz streams.
+ */
+static int
+xz_bidder_init(struct archive_read_filter *self)
+{
+ self->code = ARCHIVE_COMPRESSION_XZ;
+ self->name = "xz";
+ return (xz_lzma_bidder_init(self));
+}
+
+static int
+lzma_bidder_init(struct archive_read_filter *self)
+{
+ self->code = ARCHIVE_COMPRESSION_LZMA;
+ self->name = "lzma";
+ return (xz_lzma_bidder_init(self));
+}
+
+/*
+ * Setup the callbacks.
+ */
+static int
+xz_lzma_bidder_init(struct archive_read_filter *self)
+{
+ static const size_t out_block_size = 64 * 1024;
+ void *out_block;
+ struct private_data *state;
+ int ret;
+
+ state = (struct private_data *)calloc(sizeof(*state), 1);
+ out_block = (unsigned char *)malloc(out_block_size);
+ if (state == NULL || out_block == NULL) {
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Can't allocate data for xz decompression");
+ free(out_block);
+ free(state);
+ return (ARCHIVE_FATAL);
+ }
+
+ self->data = state;
+ state->out_block_size = out_block_size;
+ state->out_block = out_block;
+ self->read = xz_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = xz_filter_close;
+
+ state->stream.avail_in = 0;
+
+ state->stream.next_out = state->out_block;
+ state->stream.avail_out = state->out_block_size;
+
+ /* Initialize compression library.
+ * TODO: I don't know what value is best for memlimit.
+ * maybe, it needs to check memory size which
+ * running system has.
+ */
+ if (self->code == ARCHIVE_COMPRESSION_XZ)
+ ret = lzma_stream_decoder(&(state->stream),
+ (1U << 30),/* memlimit */
+ LZMA_CONCATENATED);
+ else
+ ret = lzma_alone_decoder(&(state->stream),
+ (1U << 30));/* memlimit */
+
+ if (ret == LZMA_OK)
+ return (ARCHIVE_OK);
+
+ /* Library setup failed: Choose an error message and clean up. */
+ switch (ret) {
+ case LZMA_MEM_ERROR:
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Internal error initializing compression library: "
+ "Cannot allocate memory");
+ break;
+ case LZMA_OPTIONS_ERROR:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Internal error initializing compression library: "
+ "Invalid or unsupported options");
+ break;
+ default:
+ archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
+ "Internal error initializing lzma library");
+ break;
+ }
+
+ free(state->out_block);
+ free(state);
+ self->data = NULL;
+ return (ARCHIVE_FATAL);
+}
+
+/*
+ * Return the next block of decompressed data.
+ */
+static ssize_t
+xz_filter_read(struct archive_read_filter *self, const void **p)
+{
+ struct private_data *state;
+ size_t decompressed;
+ ssize_t avail_in;
+ int ret;
+
+ state = (struct private_data *)self->data;
+
+ /* Empty our output buffer. */
+ state->stream.next_out = state->out_block;
+ state->stream.avail_out = state->out_block_size;
+
+ /* Try to fill the output buffer. */
+ while (state->stream.avail_out > 0 && !state->eof) {
+ state->stream.next_in =
+ __archive_read_filter_ahead(self->upstream, 1, &avail_in);
+ if (state->stream.next_in == NULL && avail_in < 0)
+ return (ARCHIVE_FATAL);
+ state->stream.avail_in = avail_in;
+
+ /* Decompress as much as we can in one pass. */
+ ret = lzma_code(&(state->stream),
+ (state->stream.avail_in == 0)? LZMA_FINISH: LZMA_RUN);
+ switch (ret) {
+ case LZMA_STREAM_END: /* Found end of stream. */
+ state->eof = 1;
+ /* FALL THROUGH */
+ case LZMA_OK: /* Decompressor made some progress. */
+ __archive_read_filter_consume(self->upstream,
+ avail_in - state->stream.avail_in);
+ break;
+ case LZMA_MEM_ERROR:
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Lzma library error: Cannot allocate memory");
+ return (ARCHIVE_FATAL);
+ case LZMA_MEMLIMIT_ERROR:
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Lzma library error: Out of memory");
+ return (ARCHIVE_FATAL);
+ case LZMA_FORMAT_ERROR:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Lzma library error: format not recognized");
+ return (ARCHIVE_FATAL);
+ case LZMA_OPTIONS_ERROR:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Lzma library error: Invalid options");
+ return (ARCHIVE_FATAL);
+ case LZMA_DATA_ERROR:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Lzma library error: Corrupted input data");
+ return (ARCHIVE_FATAL);
+ case LZMA_BUF_ERROR:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Lzma library error: No progress is possible");
+ return (ARCHIVE_FATAL);
+ default:
+ /* Return an error. */
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Lzma decompression failed: Unknown error");
+ return (ARCHIVE_FATAL);
+ }
+ }
+
+ decompressed = state->stream.next_out - state->out_block;
+ state->total_out += decompressed;
+ if (decompressed == 0)
+ *p = NULL;
+ else
+ *p = state->out_block;
+ return (decompressed);
+}
+
+/*
+ * Clean up the decompressor.
+ */
+static int
+xz_filter_close(struct archive_read_filter *self)
+{
+ struct private_data *state;
+
+ state = (struct private_data *)self->data;
+ lzma_end(&(state->stream));
+ free(state->out_block);
+ free(state);
+ return (ARCHIVE_OK);
+}
+
+#else
+
+#if HAVE_LZMADEC_H && HAVE_LIBLZMADEC
+
+/*
+ * If we have the older liblzmadec library, then we can handle
+ * LZMA streams but not XZ streams.
+ */
+
+/*
+ * Setup the callbacks.
+ */
+static int
+lzma_bidder_init(struct archive_read_filter *self)
+{
+ static const size_t out_block_size = 64 * 1024;
+ void *out_block;
+ struct private_data *state;
+ ssize_t ret, avail_in;
+
+ self->code = ARCHIVE_COMPRESSION_LZMA;
+ self->name = "lzma";
+
+ state = (struct private_data *)calloc(sizeof(*state), 1);
+ out_block = (unsigned char *)malloc(out_block_size);
+ if (state == NULL || out_block == NULL) {
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Can't allocate data for lzma decompression");
+ free(out_block);
+ free(state);
+ return (ARCHIVE_FATAL);
+ }
+
+ self->data = state;
+ state->out_block_size = out_block_size;
+ state->out_block = out_block;
+ self->read = lzma_filter_read;
+ self->skip = NULL; /* not supported */
+ self->close = lzma_filter_close;
+
+ /* Prime the lzma library with 18 bytes of input. */
+ state->stream.next_in = (unsigned char *)(uintptr_t)
+ __archive_read_filter_ahead(self->upstream, 18, &avail_in);
+ if (state->stream.next_in == NULL)
+ return (ARCHIVE_FATAL);
+ state->stream.avail_in = avail_in;
+ state->stream.next_out = state->out_block;
+ state->stream.avail_out = state->out_block_size;
+
+ /* Initialize compression library. */
+ ret = lzmadec_init(&(state->stream));
+ __archive_read_filter_consume(self->upstream,
+ avail_in - state->stream.avail_in);
+ if (ret == LZMADEC_OK)
+ return (ARCHIVE_OK);
+
+ /* Library setup failed: Clean up. */
+ archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
+ "Internal error initializing lzma library");
+
+ /* Override the error message if we know what really went wrong. */
+ switch (ret) {
+ case LZMADEC_HEADER_ERROR:
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Internal error initializing compression library: "
+ "invalid header");
+ break;
+ case LZMADEC_MEM_ERROR:
+ archive_set_error(&self->archive->archive, ENOMEM,
+ "Internal error initializing compression library: "
+ "out of memory");
+ break;
+ }
+
+ free(state->out_block);
+ free(state);
+ self->data = NULL;
+ return (ARCHIVE_FATAL);
+}
+
+/*
+ * Return the next block of decompressed data.
+ */
+static ssize_t
+lzma_filter_read(struct archive_read_filter *self, const void **p)
+{
+ struct private_data *state;
+ size_t decompressed;
+ ssize_t avail_in, ret;
+
+ state = (struct private_data *)self->data;
+
+ /* Empty our output buffer. */
+ state->stream.next_out = state->out_block;
+ state->stream.avail_out = state->out_block_size;
+
+ /* Try to fill the output buffer. */
+ while (state->stream.avail_out > 0 && !state->eof) {
+ state->stream.next_in = (unsigned char *)(uintptr_t)
+ __archive_read_filter_ahead(self->upstream, 1, &avail_in);
+ if (state->stream.next_in == NULL && avail_in < 0)
+ return (ARCHIVE_FATAL);
+ state->stream.avail_in = avail_in;
+
+ /* Decompress as much as we can in one pass. */
+ ret = lzmadec_decode(&(state->stream), avail_in == 0);
+ switch (ret) {
+ case LZMADEC_STREAM_END: /* Found end of stream. */
+ state->eof = 1;
+ /* FALL THROUGH */
+ case LZMADEC_OK: /* Decompressor made some progress. */
+ __archive_read_filter_consume(self->upstream,
+ avail_in - state->stream.avail_in);
+ break;
+ case LZMADEC_BUF_ERROR: /* Insufficient input data? */
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Insufficient compressed data");
+ return (ARCHIVE_FATAL);
+ default:
+ /* Return an error. */
+ archive_set_error(&self->archive->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Lzma decompression failed");
+ return (ARCHIVE_FATAL);
+ }
+ }
+
+ decompressed = state->stream.next_out - state->out_block;
+ state->total_out += decompressed;
+ if (decompressed == 0)
+ *p = NULL;
+ else
+ *p = state->out_block;
+ return (decompressed);
+}
+
+/*
+ * Clean up the decompressor.
+ */
+static int
+lzma_filter_close(struct archive_read_filter *self)
+{
+ struct private_data *state;
+ int ret;
+
+ state = (struct private_data *)self->data;
+ ret = ARCHIVE_OK;
+ switch (lzmadec_end(&(state->stream))) {
+ case LZMADEC_OK:
+ break;
+ default:
+ archive_set_error(&(self->archive->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up %s compressor",
+ self->archive->archive.compression_name);
+ ret = ARCHIVE_FATAL;
+ }
+
+ free(state->out_block);
+ free(state);
+ return (ret);
+}
+
+#else
+
+/*
+ *
+ * If we have no suitable library on this system, we can't actually do
+ * the decompression. We can, however, still detect compressed
+ * archives and emit a useful message.
+ *
+ */
+static int
+lzma_bidder_init(struct archive_read_filter *self)
+{
+ int r;
+
+ r = __archive_read_program(self, "unlzma");
+ /* Note: We set the format here even if __archive_read_program()
+ * above fails. We do, after all, know what the format is
+ * even if we weren't able to read it. */
+ self->code = ARCHIVE_COMPRESSION_LZMA;
+ self->name = "lzma";
+ return (r);
+}
+
+#endif /* HAVE_LZMADEC_H */
+
+
+static int
+xz_bidder_init(struct archive_read_filter *self)
+{
+ int r;
+
+ r = __archive_read_program(self, "unxz");
+ /* Note: We set the format here even if __archive_read_program()
+ * above fails. We do, after all, know what the format is
+ * even if we weren't able to read it. */
+ self->code = ARCHIVE_COMPRESSION_XZ;
+ self->name = "xz";
+ return (r);
+}
+
+
+#endif /* HAVE_LZMA_H */
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_all.c b/archivers/libarchive/files/libarchive/archive_read_support_format_all.c
index 24e31ef54f5..96778388594 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_all.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_all.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_all.c,v 1.10 2007/12/30 04:58:21 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_all.c 174991 2007-12-30 04:58:22Z kientzle $");
#include "archive.h"
@@ -37,6 +37,7 @@ archive_read_support_format_all(struct archive *a)
archive_read_support_format_iso9660(a);
archive_read_support_format_mtree(a);
archive_read_support_format_tar(a);
+ archive_read_support_format_xar(a);
archive_read_support_format_zip(a);
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c
index baf80bd62fc..7c1ca3a0c87 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c
@@ -26,7 +26,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_ar.c,v 1.10 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_ar.c 201101 2009-12-28 03:06:27Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -40,6 +40,9 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_ar.c,v 1.10 2
#ifdef HAVE_STRING_H
#include <string.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
#include "archive.h"
#include "archive_entry.h"
@@ -72,8 +75,6 @@ struct ar {
#define AR_fmag_offset 58
#define AR_fmag_size 2
-#define isdigit(x) (x) >= '0' && (x) <= '9'
-
static int archive_read_format_ar_bid(struct archive_read *a);
static int archive_read_format_ar_cleanup(struct archive_read *a);
static int archive_read_format_ar_read_data(struct archive_read *a,
@@ -105,7 +106,9 @@ archive_read_support_format_ar(struct archive *_a)
r = __archive_read_register_format(a,
ar,
+ "ar",
archive_read_format_ar_bid,
+ NULL,
archive_read_format_ar_read_header,
archive_read_format_ar_read_data,
archive_read_format_ar_skip,
@@ -134,8 +137,6 @@ archive_read_format_ar_cleanup(struct archive_read *a)
static int
archive_read_format_ar_bid(struct archive_read *a)
{
- struct ar *ar;
- ssize_t bytes_read;
const void *h;
if (a->archive.archive_format != 0 &&
@@ -143,14 +144,11 @@ archive_read_format_ar_bid(struct archive_read *a)
ARCHIVE_FORMAT_AR)
return(0);
- ar = (struct ar *)(a->format->data);
-
/*
* Verify the 8-byte file signature.
* TODO: Do we need to check more than this?
*/
- bytes_read = (a->decompressor->read_ahead)(a, &h, 8);
- if (bytes_read < 8)
+ if ((h = __archive_read_ahead(a, 8, NULL)) == NULL)
return (-1);
if (strncmp((const char*)h, "!<arch>\n", 8) == 0) {
return (64);
@@ -166,7 +164,7 @@ archive_read_format_ar_read_header(struct archive_read *a,
struct ar *ar;
uint64_t number; /* Used to hold parsed numbers before validation. */
ssize_t bytes_read;
- size_t bsd_name_length, entry_size, s;
+ size_t bsd_name_length, entry_size;
char *p, *st;
const void *b;
const char *h;
@@ -179,24 +177,22 @@ archive_read_format_ar_read_header(struct archive_read *a,
* We are now at the beginning of the archive,
* so we need first consume the ar global header.
*/
- (a->decompressor->consume)(a, 8);
+ __archive_read_consume(a, 8);
/* Set a default format code for now. */
a->archive.archive_format = ARCHIVE_FORMAT_AR;
}
/* Read the header for the next file entry. */
- bytes_read = (a->decompressor->read_ahead)(a, &b, 60);
- if (bytes_read < 60) {
+ if ((b = __archive_read_ahead(a, 60, &bytes_read)) == NULL)
/* Broken header. */
return (ARCHIVE_EOF);
- }
- (a->decompressor->consume)(a, 60);
+ __archive_read_consume(a, 60);
h = (const char *)b;
/* Verify the magic signature on the file header. */
if (strncmp(h + AR_fmag_offset, "`\n", 2) != 0) {
archive_set_error(&a->archive, EINVAL,
- "Consistency check failed");
+ "Incorrect file header signature");
return (ARCHIVE_WARN);
}
@@ -296,16 +292,10 @@ archive_read_format_ar_read_header(struct archive_read *a,
}
ar->strtab = st;
ar->strtab_size = entry_size;
- for (s = entry_size; s > 0; s -= bytes_read) {
- bytes_read = (a->decompressor->read_ahead)(a, &b, s);
- if (bytes_read <= 0)
- return (ARCHIVE_FATAL);
- if (bytes_read > (ssize_t)s)
- bytes_read = s;
- memcpy(st, b, bytes_read);
- st += bytes_read;
- (a->decompressor->consume)(a, bytes_read);
- }
+ if ((b = __archive_read_ahead(a, entry_size, NULL)) == NULL)
+ return (ARCHIVE_FATAL);
+ memcpy(st, b, entry_size);
+ __archive_read_consume(a, entry_size);
/* All contents are consumed. */
ar->entry_bytes_remaining = 0;
archive_entry_set_size(entry, ar->entry_bytes_remaining);
@@ -317,8 +307,10 @@ archive_read_format_ar_read_header(struct archive_read *a,
/*
* GNU variant handles long filenames by storing /<number>
* to indicate a name stored in the filename table.
+ * XXX TODO: Verify that it's all digits... Don't be fooled
+ * by "/9xyz" XXX
*/
- if (filename[0] == '/' && isdigit(filename[1])) {
+ if (filename[0] == '/' && filename[1] >= '0' && filename[1] <= '9') {
number = ar_atol10(h + AR_name_offset + 1, AR_name_size - 1);
/*
* If we can't look up the real name, warn and return
@@ -365,15 +357,12 @@ archive_read_format_ar_read_header(struct archive_read *a,
archive_entry_set_size(entry, ar->entry_bytes_remaining);
/* Read the long name into memory. */
- bytes_read = (a->decompressor->read_ahead)(a, &b, bsd_name_length);
- if (bytes_read <= 0)
- return (ARCHIVE_FATAL);
- if ((size_t)bytes_read < bsd_name_length) {
+ if ((b = __archive_read_ahead(a, bsd_name_length, NULL)) == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Truncated input file");
return (ARCHIVE_FATAL);
}
- (a->decompressor->consume)(a, bsd_name_length);
+ __archive_read_consume(a, bsd_name_length);
/* Store it in the entry. */
p = (char *)malloc(bsd_name_length + 1);
@@ -453,7 +442,7 @@ archive_read_format_ar_read_data(struct archive_read *a,
ar = (struct ar *)(a->format->data);
if (ar->entry_bytes_remaining > 0) {
- bytes_read = (a->decompressor->read_ahead)(a, buff, 1);
+ *buff = __archive_read_ahead(a, 1, &bytes_read);
if (bytes_read == 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Truncated ar archive");
@@ -467,16 +456,16 @@ archive_read_format_ar_read_data(struct archive_read *a,
*offset = ar->entry_offset;
ar->entry_offset += bytes_read;
ar->entry_bytes_remaining -= bytes_read;
- (a->decompressor->consume)(a, (size_t)bytes_read);
+ __archive_read_consume(a, (size_t)bytes_read);
return (ARCHIVE_OK);
} else {
while (ar->entry_padding > 0) {
- bytes_read = (a->decompressor->read_ahead)(a, buff, 1);
+ *buff = __archive_read_ahead(a, 1, &bytes_read);
if (bytes_read <= 0)
return (ARCHIVE_FATAL);
if (bytes_read > ar->entry_padding)
bytes_read = (ssize_t)ar->entry_padding;
- (a->decompressor->consume)(a, (size_t)bytes_read);
+ __archive_read_consume(a, (size_t)bytes_read);
ar->entry_padding -= bytes_read;
}
*buff = NULL;
@@ -491,20 +480,11 @@ archive_read_format_ar_skip(struct archive_read *a)
{
off_t bytes_skipped;
struct ar* ar;
- int r = ARCHIVE_OK;
- const void *b; /* Dummy variables */
- size_t s;
- off_t o;
ar = (struct ar *)(a->format->data);
- if (a->decompressor->skip == NULL) {
- while (r == ARCHIVE_OK)
- r = archive_read_format_ar_read_data(a, &b, &s, &o);
- return (r);
- }
- bytes_skipped = (a->decompressor->skip)(a, ar->entry_bytes_remaining +
- ar->entry_padding);
+ bytes_skipped = __archive_read_skip(a,
+ ar->entry_bytes_remaining + ar->entry_padding);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
@@ -533,11 +513,10 @@ ar_parse_gnu_filename_table(struct archive_read *a)
}
}
/*
- * Sanity check, last two chars must be `/\n' or '\n\n',
- * depending on whether the string table is padded by a '\n'
- * (string table produced by GNU ar always has a even size).
+ * GNU ar always pads the table to an even size.
+ * The pad character is either '\n' or '`'.
*/
- if (p != ar->strtab + size && *p != '\n')
+ if (p != ar->strtab + size && *p != '\n' && *p != '`')
goto bad_string_table;
/* Enforce zero termination. */
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_cpio.c b/archivers/libarchive/files/libarchive/archive_read_support_format_cpio.c
index 2c50abc6b88..1def0006a6e 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_cpio.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_cpio.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_cpio.c,v 1.26 2008/01/15 04:56:48 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_cpio.c 201163 2009-12-29 05:50:34Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -92,7 +92,7 @@ struct links_entry {
struct links_entry *previous;
int links;
dev_t dev;
- ino_t ino;
+ int64_t ino;
char *name;
};
@@ -150,7 +150,9 @@ archive_read_support_format_cpio(struct archive *_a)
r = __archive_read_register_format(a,
cpio,
+ "cpio",
archive_read_format_cpio_bid,
+ NULL,
archive_read_format_cpio_read_header,
archive_read_format_cpio_read_data,
NULL,
@@ -165,7 +167,6 @@ archive_read_support_format_cpio(struct archive *_a)
static int
archive_read_format_cpio_bid(struct archive_read *a)
{
- int bytes_read;
const void *h;
const unsigned char *p;
struct cpio *cpio;
@@ -173,11 +174,7 @@ archive_read_format_cpio_bid(struct archive_read *a)
cpio = (struct cpio *)(a->format->data);
- bytes_read = (a->decompressor->read_ahead)(a, &h, 6);
- /* Convert error code into error return. */
- if (bytes_read < 0)
- return ((int)bytes_read);
- if (bytes_read < 6)
+ if ((h = __archive_read_ahead(a, 6, NULL)) == NULL)
return (-1);
p = (const unsigned char *)h;
@@ -228,7 +225,6 @@ archive_read_format_cpio_read_header(struct archive_read *a,
struct archive_entry *entry)
{
struct cpio *cpio;
- size_t bytes;
const void *h;
size_t namelength;
size_t name_pad;
@@ -241,27 +237,31 @@ archive_read_format_cpio_read_header(struct archive_read *a,
return (r);
/* Read name from buffer. */
- bytes = (a->decompressor->read_ahead)(a, &h, namelength + name_pad);
- if (bytes < namelength + name_pad)
+ h = __archive_read_ahead(a, namelength + name_pad, NULL);
+ if (h == NULL)
return (ARCHIVE_FATAL);
- (a->decompressor->consume)(a, namelength + name_pad);
+ __archive_read_consume(a, namelength + name_pad);
archive_strncpy(&cpio->entry_name, (const char *)h, namelength);
archive_entry_set_pathname(entry, cpio->entry_name.s);
cpio->entry_offset = 0;
/* If this is a symlink, read the link contents. */
if (archive_entry_filetype(entry) == AE_IFLNK) {
- bytes = (a->decompressor->read_ahead)(a, &h,
- cpio->entry_bytes_remaining);
- if ((off_t)bytes < cpio->entry_bytes_remaining)
+ h = __archive_read_ahead(a, cpio->entry_bytes_remaining, NULL);
+ if (h == NULL)
return (ARCHIVE_FATAL);
- (a->decompressor->consume)(a, cpio->entry_bytes_remaining);
+ __archive_read_consume(a, cpio->entry_bytes_remaining);
archive_strncpy(&cpio->entry_linkname, (const char *)h,
cpio->entry_bytes_remaining);
archive_entry_set_symlink(entry, cpio->entry_linkname.s);
cpio->entry_bytes_remaining = 0;
}
+ /* XXX TODO: If the full mode is 0160200, then this is a Solaris
+ * ACL description for the following entry. Read this body
+ * and parse it as a Solaris-style ACL, then read the next
+ * header. XXX */
+
/* Compare name to "TRAILER!!!" to test for end-of-archive. */
if (namelength == 11 && strcmp((const char *)h, "TRAILER!!!") == 0) {
/* TODO: Store file location of start of block. */
@@ -284,7 +284,7 @@ archive_read_format_cpio_read_data(struct archive_read *a,
cpio = (struct cpio *)(a->format->data);
if (cpio->entry_bytes_remaining > 0) {
- bytes_read = (a->decompressor->read_ahead)(a, buff, 1);
+ *buff = __archive_read_ahead(a, 1, &bytes_read);
if (bytes_read <= 0)
return (ARCHIVE_FATAL);
if (bytes_read > cpio->entry_bytes_remaining)
@@ -293,16 +293,16 @@ archive_read_format_cpio_read_data(struct archive_read *a,
*offset = cpio->entry_offset;
cpio->entry_offset += bytes_read;
cpio->entry_bytes_remaining -= bytes_read;
- (a->decompressor->consume)(a, bytes_read);
+ __archive_read_consume(a, bytes_read);
return (ARCHIVE_OK);
} else {
while (cpio->entry_padding > 0) {
- bytes_read = (a->decompressor->read_ahead)(a, buff, 1);
+ *buff = __archive_read_ahead(a, 1, &bytes_read);
if (bytes_read <= 0)
return (ARCHIVE_FATAL);
if (bytes_read > cpio->entry_padding)
bytes_read = cpio->entry_padding;
- (a->decompressor->consume)(a, bytes_read);
+ __archive_read_consume(a, bytes_read);
cpio->entry_padding -= bytes_read;
}
*buff = NULL;
@@ -336,11 +336,12 @@ find_newc_header(struct archive_read *a)
{
const void *h;
const char *p, *q;
- size_t skip, bytes, skipped = 0;
+ size_t skip, skipped = 0;
+ ssize_t bytes;
for (;;) {
- bytes = (a->decompressor->read_ahead)(a, &h, 2048);
- if (bytes < sizeof(struct cpio_newc_header))
+ h = __archive_read_ahead(a, sizeof(struct cpio_newc_header), &bytes);
+ if (h == NULL)
return (ARCHIVE_FATAL);
p = h;
q = p + bytes;
@@ -355,14 +356,14 @@ find_newc_header(struct archive_read *a)
* Scan ahead until we find something that looks
* like an odc header.
*/
- while (p + sizeof(struct cpio_newc_header) < q) {
+ while (p + sizeof(struct cpio_newc_header) <= q) {
switch (p[5]) {
case '1':
case '2':
if (memcmp("07070", p, 5) == 0
&& is_hex(p, sizeof(struct cpio_newc_header))) {
skip = p - (const char *)h;
- (a->decompressor->consume)(a, skip);
+ __archive_read_consume(a, skip);
skipped += skip;
if (skipped > 0) {
archive_set_error(&a->archive,
@@ -385,7 +386,7 @@ find_newc_header(struct archive_read *a)
}
}
skip = p - (const char *)h;
- (a->decompressor->consume)(a, skip);
+ __archive_read_consume(a, skip);
skipped += skip;
}
}
@@ -396,7 +397,6 @@ header_newc(struct archive_read *a, struct cpio *cpio,
{
const void *h;
const struct cpio_newc_header *header;
- size_t bytes;
int r;
r = find_newc_header(a);
@@ -404,10 +404,10 @@ header_newc(struct archive_read *a, struct cpio *cpio,
return (r);
/* Read fixed-size portion of header. */
- bytes = (a->decompressor->read_ahead)(a, &h, sizeof(struct cpio_newc_header));
- if (bytes < sizeof(struct cpio_newc_header))
+ h = __archive_read_ahead(a, sizeof(struct cpio_newc_header), NULL);
+ if (h == NULL)
return (ARCHIVE_FATAL);
- (a->decompressor->consume)(a, sizeof(struct cpio_newc_header));
+ __archive_read_consume(a, sizeof(struct cpio_newc_header));
/* Parse out hex fields. */
header = (const struct cpio_newc_header *)h;
@@ -471,11 +471,12 @@ find_odc_header(struct archive_read *a)
{
const void *h;
const char *p, *q;
- size_t skip, bytes, skipped = 0;
+ size_t skip, skipped = 0;
+ ssize_t bytes;
for (;;) {
- bytes = (a->decompressor->read_ahead)(a, &h, 512);
- if (bytes < sizeof(struct cpio_odc_header))
+ h = __archive_read_ahead(a, sizeof(struct cpio_odc_header), &bytes);
+ if (h == NULL)
return (ARCHIVE_FATAL);
p = h;
q = p + bytes;
@@ -489,13 +490,13 @@ find_odc_header(struct archive_read *a)
* Scan ahead until we find something that looks
* like an odc header.
*/
- while (p + sizeof(struct cpio_odc_header) < q) {
+ while (p + sizeof(struct cpio_odc_header) <= q) {
switch (p[5]) {
case '7':
if (memcmp("070707", p, 6) == 0
&& is_octal(p, sizeof(struct cpio_odc_header))) {
skip = p - (const char *)h;
- (a->decompressor->consume)(a, skip);
+ __archive_read_consume(a, skip);
skipped += skip;
if (skipped > 0) {
archive_set_error(&a->archive,
@@ -518,7 +519,7 @@ find_odc_header(struct archive_read *a)
}
}
skip = p - (const char *)h;
- (a->decompressor->consume)(a, skip);
+ __archive_read_consume(a, skip);
skipped += skip;
}
}
@@ -530,7 +531,6 @@ header_odc(struct archive_read *a, struct cpio *cpio,
const void *h;
int r;
const struct cpio_odc_header *header;
- size_t bytes;
a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
a->archive.archive_format_name = "POSIX octet-oriented cpio";
@@ -541,10 +541,10 @@ header_odc(struct archive_read *a, struct cpio *cpio,
return (r);
/* Read fixed-size portion of header. */
- bytes = (a->decompressor->read_ahead)(a, &h, sizeof(struct cpio_odc_header));
- if (bytes < sizeof(struct cpio_odc_header))
+ h = __archive_read_ahead(a, sizeof(struct cpio_odc_header), NULL);
+ if (h == NULL)
return (ARCHIVE_FATAL);
- (a->decompressor->consume)(a, sizeof(struct cpio_odc_header));
+ __archive_read_consume(a, sizeof(struct cpio_odc_header));
/* Parse out octal fields. */
header = (const struct cpio_odc_header *)h;
@@ -578,16 +578,15 @@ header_bin_le(struct archive_read *a, struct cpio *cpio,
{
const void *h;
const struct cpio_bin_header *header;
- size_t bytes;
a->archive.archive_format = ARCHIVE_FORMAT_CPIO_BIN_LE;
a->archive.archive_format_name = "cpio (little-endian binary)";
/* Read fixed-size portion of header. */
- bytes = (a->decompressor->read_ahead)(a, &h, sizeof(struct cpio_bin_header));
- if (bytes < sizeof(struct cpio_bin_header))
+ h = __archive_read_ahead(a, sizeof(struct cpio_bin_header), NULL);
+ if (h == NULL)
return (ARCHIVE_FATAL);
- (a->decompressor->consume)(a, sizeof(struct cpio_bin_header));
+ __archive_read_consume(a, sizeof(struct cpio_bin_header));
/* Parse out binary fields. */
header = (const struct cpio_bin_header *)h;
@@ -615,17 +614,15 @@ header_bin_be(struct archive_read *a, struct cpio *cpio,
{
const void *h;
const struct cpio_bin_header *header;
- size_t bytes;
a->archive.archive_format = ARCHIVE_FORMAT_CPIO_BIN_BE;
a->archive.archive_format_name = "cpio (big-endian binary)";
/* Read fixed-size portion of header. */
- bytes = (a->decompressor->read_ahead)(a, &h,
- sizeof(struct cpio_bin_header));
- if (bytes < sizeof(struct cpio_bin_header))
+ h = __archive_read_ahead(a, sizeof(struct cpio_bin_header), NULL);
+ if (h == NULL)
return (ARCHIVE_FATAL);
- (a->decompressor->consume)(a, sizeof(struct cpio_bin_header));
+ __archive_read_consume(a, sizeof(struct cpio_bin_header));
/* Parse out binary fields. */
header = (const struct cpio_bin_header *)h;
@@ -677,7 +674,7 @@ le4(const unsigned char *p)
static int
be4(const unsigned char *p)
{
- return (p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24));
+ return ((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + (p[3]));
}
/*
@@ -730,48 +727,51 @@ atol16(const char *p, unsigned char_cnt)
static void
record_hardlink(struct cpio *cpio, struct archive_entry *entry)
{
- struct links_entry *le;
+ struct links_entry *le;
dev_t dev;
- ino_t ino;
+ int64_t ino;
+
+ if (archive_entry_nlink(entry) <= 1)
+ return;
dev = archive_entry_dev(entry);
- ino = archive_entry_ino(entry);
-
- /*
- * First look in the list of multiply-linked files. If we've
- * already dumped it, convert this entry to a hard link entry.
- */
- for (le = cpio->links_head; le; le = le->next) {
- if (le->dev == dev && le->ino == ino) {
- archive_entry_copy_hardlink(entry, le->name);
-
- if (--le->links <= 0) {
- if (le->previous != NULL)
- le->previous->next = le->next;
- if (le->next != NULL)
- le->next->previous = le->previous;
- if (cpio->links_head == le)
- cpio->links_head = le->next;
+ ino = archive_entry_ino64(entry);
+
+ /*
+ * First look in the list of multiply-linked files. If we've
+ * already dumped it, convert this entry to a hard link entry.
+ */
+ for (le = cpio->links_head; le; le = le->next) {
+ if (le->dev == dev && le->ino == ino) {
+ archive_entry_copy_hardlink(entry, le->name);
+
+ if (--le->links <= 0) {
+ if (le->previous != NULL)
+ le->previous->next = le->next;
+ if (le->next != NULL)
+ le->next->previous = le->previous;
+ if (cpio->links_head == le)
+ cpio->links_head = le->next;
free(le->name);
- free(le);
- }
+ free(le);
+ }
- return;
- }
- }
+ return;
+ }
+ }
- le = (struct links_entry *)malloc(sizeof(struct links_entry));
+ le = (struct links_entry *)malloc(sizeof(struct links_entry));
if (le == NULL)
__archive_errx(1, "Out of memory adding file to list");
- if (cpio->links_head != NULL)
- cpio->links_head->previous = le;
- le->next = cpio->links_head;
- le->previous = NULL;
- cpio->links_head = le;
- le->dev = dev;
- le->ino = ino;
- le->links = archive_entry_nlink(entry) - 1;
- le->name = strdup(archive_entry_pathname(entry));
+ if (cpio->links_head != NULL)
+ cpio->links_head->previous = le;
+ le->next = cpio->links_head;
+ le->previous = NULL;
+ cpio->links_head = le;
+ le->dev = dev;
+ le->ino = ino;
+ le->links = archive_entry_nlink(entry) - 1;
+ le->name = strdup(archive_entry_pathname(entry));
if (le->name == NULL)
__archive_errx(1, "Out of memory adding file to list");
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_empty.c b/archivers/libarchive/files/libarchive/archive_read_support_format_empty.c
index 837fdef997c..518fdcb4913 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_empty.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_empty.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_empty.c,v 1.3 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_empty.c 191524 2009-04-26 18:24:14Z kientzle $");
#include "archive.h"
#include "archive_entry.h"
@@ -44,7 +44,9 @@ archive_read_support_format_empty(struct archive *_a)
r = __archive_read_register_format(a,
NULL,
+ NULL,
archive_read_format_empty_bid,
+ NULL,
archive_read_format_empty_read_header,
archive_read_format_empty_read_data,
NULL,
@@ -57,11 +59,10 @@ archive_read_support_format_empty(struct archive *_a)
static int
archive_read_format_empty_bid(struct archive_read *a)
{
- int bytes_read;
- const void *h;
+ ssize_t avail;
- bytes_read = (a->decompressor->read_ahead)(a, &h, 1);
- if (bytes_read > 0)
+ (void)__archive_read_ahead(a, 1, &avail);
+ if (avail != 0)
return (-1);
return (1);
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c b/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c
index 481220dd47b..0c640c88e86 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c
@@ -1,5 +1,7 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Andreas Henriksson <andreas@fatal.se>
+ * Copyright (c) 2009 Michihiro NAKAJIMA
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,7 +26,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_iso9660.c,v 1.26 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_iso9660.c 201246 2009-12-30 05:30:35Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -38,8 +40,12 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_iso9660.c,v 1
#include <string.h>
#endif
#include <time.h>
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#endif
#include "archive.h"
+#include "archive_endian.h"
#include "archive_entry.h"
#include "archive_private.h"
#include "archive_read_private.h"
@@ -72,6 +78,8 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_iso9660.c,v 1
* the file body. This strategy allows us to read most compliant
* CDs with a single pass through the data, as required by libarchive.
*/
+#define LOGICAL_BLOCK_SIZE 2048
+#define SYSTEM_AREA_BLOCK 16
/* Structure of on-disk primary volume descriptor. */
#define PVD_type_offset 0
@@ -138,6 +146,46 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_iso9660.c,v 1
#define PVD_reserved4_size 1
#define PVD_application_data_offset (PVD_reserved4_offset + PVD_reserved4_size)
#define PVD_application_data_size 512
+#define PVD_reserved5_offset (PVD_application_data_offset + PVD_application_data_size)
+#define PVD_reserved5_size (2048 - PVD_reserved5_offset)
+
+/* TODO: It would make future maintenance easier to just hardcode the
+ * above values. In particular, ECMA119 states the offsets as part of
+ * the standard. That would eliminate the need for the following check.*/
+#if PVD_reserved5_offset != 1395
+#error PVD offset and size definitions are wrong.
+#endif
+
+
+/* Structure of optional on-disk supplementary volume descriptor. */
+#define SVD_type_offset 0
+#define SVD_type_size 1
+#define SVD_id_offset (SVD_type_offset + SVD_type_size)
+#define SVD_id_size 5
+#define SVD_version_offset (SVD_id_offset + SVD_id_size)
+#define SVD_version_size 1
+/* ... */
+#define SVD_reserved1_offset 72
+#define SVD_reserved1_size 8
+#define SVD_volume_space_size_offset 80
+#define SVD_volume_space_size_size 8
+#define SVD_escape_sequences_offset (SVD_volume_space_size_offset + SVD_volume_space_size_size)
+#define SVD_escape_sequences_size 32
+/* ... */
+#define SVD_logical_block_size_offset 128
+#define SVD_logical_block_size_size 4
+#define SVD_type_L_path_table_offset 140
+#define SVD_type_M_path_table_offset 148
+/* ... */
+#define SVD_root_directory_record_offset 156
+#define SVD_root_directory_record_size 34
+#define SVD_file_structure_version_offset 881
+#define SVD_reserved2_offset 882
+#define SVD_reserved2_size 1
+#define SVD_reserved3_offset 1395
+#define SVD_reserved3_size 653
+/* ... */
+/* FIXME: validate correctness of last SVD entry offset. */
/* Structure of an on-disk directory record. */
/* Note: ISO9660 stores each multi-byte integer twice, once in
@@ -166,57 +214,149 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_iso9660.c,v 1
#define DR_name_len_size 1
#define DR_name_offset 33
-/*
- * Our private data.
- */
+#ifdef HAVE_ZLIB_H
+static const unsigned char zisofs_magic[8] = {
+ 0x37, 0xE4, 0x53, 0x96, 0xC9, 0xDB, 0xD6, 0x07
+};
+
+struct zisofs {
+ /* Set 1 if this file compressed by paged zlib */
+ int pz;
+ int pz_log2_bs; /* Log2 of block size */
+ uint64_t pz_uncompressed_size;
+
+ int initialized;
+ unsigned char *uncompressed_buffer;
+ size_t uncompressed_buffer_size;
+
+ uint32_t pz_offset;
+ unsigned char header[16];
+ size_t header_avail;
+ int header_passed;
+ unsigned char *block_pointers;
+ size_t block_pointers_alloc;
+ size_t block_pointers_size;
+ size_t block_pointers_avail;
+ size_t block_off;
+ uint32_t block_avail;
+
+ z_stream stream;
+ int stream_valid;
+};
+#else
+struct zisofs {
+ /* Set 1 if this file compressed by paged zlib */
+ int pz;
+};
+#endif
+
+struct content {
+ uint64_t offset;/* Offset on disk. */
+ uint64_t size; /* File size in bytes. */
+ struct content *next;
+};
/* In-memory storage for a directory record. */
struct file_info {
+ struct file_info *use_next;
struct file_info *parent;
- int refcount;
- uint64_t offset; /* Offset on disk. */
- uint64_t size; /* File size in bytes. */
- uint64_t ce_offset; /* Offset of CE */
- uint64_t ce_size; /* Size of CE */
- time_t mtime; /* File last modified time. */
- time_t atime; /* File last accessed time. */
- time_t ctime; /* File creation time. */
- uint64_t rdev; /* Device number */
+ struct file_info *next;
+ int subdirs;
+ uint64_t key; /* Heap Key. */
+ uint64_t offset; /* Offset on disk. */
+ uint64_t size; /* File size in bytes. */
+ uint32_t ce_offset; /* Offset of CE. */
+ uint32_t ce_size; /* Size of CE. */
+ char re; /* Having RRIP "RE" extension. */
+ uint64_t cl_offset; /* Having RRIP "CL" extension. */
+ int birthtime_is_set;
+ time_t birthtime; /* File created time. */
+ time_t mtime; /* File last modified time. */
+ time_t atime; /* File last accessed time. */
+ time_t ctime; /* File attribute change time. */
+ uint64_t rdev; /* Device number. */
mode_t mode;
uid_t uid;
gid_t gid;
- ino_t inode;
+ int64_t number;
int nlinks;
- char *name; /* Null-terminated filename. */
+ struct archive_string name; /* Pathname */
+ char name_continues; /* Non-zero if name continues */
struct archive_string symlink;
+ char symlink_continues; /* Non-zero if link continues */
+ /* Set 1 if this file compressed by paged zlib(zisofs) */
+ int pz;
+ int pz_log2_bs; /* Log2 of block size */
+ uint64_t pz_uncompressed_size;
+ /* Set 1 if this file is multi extent. */
+ int multi_extent;
+ struct {
+ struct content *first;
+ struct content **last;
+ } contents;
+ char exposed;
};
+struct heap_queue {
+ struct file_info **files;
+ int allocated;
+ int used;
+};
struct iso9660 {
int magic;
#define ISO9660_MAGIC 0x96609660
+
+ int opt_support_joliet;
+ int opt_support_rockridge;
+
struct archive_string pathname;
- char seenRockridge; /* Set true if RR extensions are used. */
- unsigned char suspOffset;
+ char seenRockridge; /* Set true if RR extensions are used. */
+ char seenSUSP; /* Set true if SUSP is beging used. */
+ char seenJoliet;
- uint64_t previous_offset;
- uint64_t previous_size;
+ unsigned char suspOffset;
+ struct file_info *rr_moved;
+ struct heap_queue re_dirs;
+ struct heap_queue cl_files;
+ struct read_ce_queue {
+ struct read_ce_req {
+ uint64_t offset;/* Offset of CE on disk. */
+ struct file_info *file;
+ } *reqs;
+ int cnt;
+ int allocated;
+ } read_ce_req;
+
+ int64_t previous_number;
struct archive_string previous_pathname;
- /* TODO: Make this a heap for fast inserts and deletions. */
- struct file_info **pending_files;
- int pending_files_allocated;
- int pending_files_used;
+ struct file_info *use_files;
+ struct heap_queue pending_files;
+ struct {
+ struct file_info *first;
+ struct file_info **last;
+ } cache_files;
uint64_t current_position;
ssize_t logical_block_size;
+ uint64_t volume_size; /* Total size of volume in bytes. */
+ int32_t volume_block;/* Total size of volume in logical blocks. */
+
+ struct vd {
+ int location; /* Location of Extent. */
+ uint32_t size;
+ } primary, joliet;
off_t entry_sparse_offset;
int64_t entry_bytes_remaining;
+ struct zisofs entry_zisofs;
+ struct content *entry_content;
};
-static void add_entry(struct iso9660 *iso9660, struct file_info *file);
static int archive_read_format_iso9660_bid(struct archive_read *);
+static int archive_read_format_iso9660_options(struct archive_read *,
+ const char *, const char *);
static int archive_read_format_iso9660_cleanup(struct archive_read *);
static int archive_read_format_iso9660_read_data(struct archive_read *,
const void **, size_t *, off_t *);
@@ -224,22 +364,55 @@ static int archive_read_format_iso9660_read_data_skip(struct archive_read *);
static int archive_read_format_iso9660_read_header(struct archive_read *,
struct archive_entry *);
static const char *build_pathname(struct archive_string *, struct file_info *);
+#if DEBUG
static void dump_isodirrec(FILE *, const unsigned char *isodirrec);
+#endif
static time_t time_from_tm(struct tm *);
static time_t isodate17(const unsigned char *);
static time_t isodate7(const unsigned char *);
+static int isBootRecord(struct iso9660 *, const unsigned char *);
+static int isVolumePartition(struct iso9660 *, const unsigned char *);
+static int isVDSetTerminator(struct iso9660 *, const unsigned char *);
+static int isJolietSVD(struct iso9660 *, const unsigned char *);
+static int isSVD(struct iso9660 *, const unsigned char *);
+static int isEVD(struct iso9660 *, const unsigned char *);
static int isPVD(struct iso9660 *, const unsigned char *);
-static struct file_info *next_entry(struct iso9660 *);
+static struct file_info *next_cache_entry(struct iso9660 *iso9660);
static int next_entry_seek(struct archive_read *a, struct iso9660 *iso9660,
struct file_info **pfile);
static struct file_info *
- parse_file_info(struct iso9660 *iso9660,
+ parse_file_info(struct archive_read *a,
struct file_info *parent, const unsigned char *isodirrec);
-static void parse_rockridge(struct iso9660 *iso9660,
+static int parse_rockridge(struct archive_read *a,
struct file_info *file, const unsigned char *start,
const unsigned char *end);
-static void release_file(struct iso9660 *, struct file_info *);
+static int register_CE(struct archive_read *a, int32_t location,
+ struct file_info *file);
+static int read_CE(struct archive_read *a, struct iso9660 *iso9660);
+static void parse_rockridge_NM1(struct file_info *,
+ const unsigned char *, int);
+static void parse_rockridge_SL1(struct file_info *,
+ const unsigned char *, int);
+static void parse_rockridge_TF1(struct file_info *,
+ const unsigned char *, int);
+static void parse_rockridge_ZF1(struct file_info *,
+ const unsigned char *, int);
+static void register_file(struct iso9660 *, struct file_info *);
+static void release_files(struct iso9660 *);
static unsigned toi(const void *p, int n);
+static inline void cache_add_entry(struct iso9660 *iso9660,
+ struct file_info *file);
+static inline void cache_add_to_next_of_parent(struct iso9660 *iso9660,
+ struct file_info *file);
+static inline struct file_info *cache_get_entry(struct iso9660 *iso9660);
+static void heap_add_entry(struct heap_queue *heap,
+ struct file_info *file, uint64_t key);
+static struct file_info *heap_get_entry(struct heap_queue *heap);
+
+#define add_entry(iso9660, file) \
+ heap_add_entry(&((iso9660)->pending_files), file, file->offset)
+#define next_entry(iso9660) \
+ heap_get_entry(&((iso9660)->pending_files))
int
archive_read_support_format_iso9660(struct archive *_a)
@@ -255,10 +428,18 @@ archive_read_support_format_iso9660(struct archive *_a)
}
memset(iso9660, 0, sizeof(*iso9660));
iso9660->magic = ISO9660_MAGIC;
+ iso9660->cache_files.first = NULL;
+ iso9660->cache_files.last = &(iso9660->cache_files.first);
+ /* Enable to support Joliet extensions by default. */
+ iso9660->opt_support_joliet = 1;
+ /* Enable to support Rock Ridge extensions by default. */
+ iso9660->opt_support_rockridge = 1;
r = __archive_read_register_format(a,
iso9660,
+ "iso9660",
archive_read_format_iso9660_bid,
+ archive_read_format_iso9660_options,
archive_read_format_iso9660_read_header,
archive_read_format_iso9660_read_data,
archive_read_format_iso9660_read_data_skip,
@@ -279,7 +460,7 @@ archive_read_format_iso9660_bid(struct archive_read *a)
ssize_t bytes_read;
const void *h;
const unsigned char *p;
- int bid;
+ int seenTerminator;
iso9660 = (struct iso9660 *)(a->format->data);
@@ -288,54 +469,647 @@ archive_read_format_iso9660_bid(struct archive_read *a)
* 8 sectors of the volume descriptor table. Of course,
* if the I/O layer gives us more, we'll take it.
*/
- bytes_read = (a->decompressor->read_ahead)(a, &h, 32768 + 8*2048);
- if (bytes_read < 32768 + 8*2048)
+#define RESERVED_AREA (SYSTEM_AREA_BLOCK * LOGICAL_BLOCK_SIZE)
+ h = __archive_read_ahead(a,
+ RESERVED_AREA + 8 * LOGICAL_BLOCK_SIZE,
+ &bytes_read);
+ if (h == NULL)
return (-1);
p = (const unsigned char *)h;
/* Skip the reserved area. */
- bytes_read -= 32768;
- p += 32768;
-
- /* Check each volume descriptor to locate the PVD. */
- for (; bytes_read > 2048; bytes_read -= 2048, p += 2048) {
- bid = isPVD(iso9660, p);
- if (bid > 0)
- return (bid);
- if (*p == '\177') /* End-of-volume-descriptor marker. */
+ bytes_read -= RESERVED_AREA;
+ p += RESERVED_AREA;
+
+ /* Check each volume descriptor. */
+ seenTerminator = 0;
+ for (; bytes_read > LOGICAL_BLOCK_SIZE;
+ bytes_read -= LOGICAL_BLOCK_SIZE, p += LOGICAL_BLOCK_SIZE) {
+ /* Do not handle undefined Volume Descriptor Type. */
+ if (p[0] >= 4 && p[0] <= 254)
+ return (0);
+ /* Standard Identifier must be "CD001" */
+ if (memcmp(p + 1, "CD001", 5) != 0)
+ return (0);
+ if (!iso9660->primary.location) {
+ if (isPVD(iso9660, p))
+ continue;
+ }
+ if (!iso9660->joliet.location) {
+ if (isJolietSVD(iso9660, p))
+ continue;
+ }
+ if (isBootRecord(iso9660, p))
+ continue;
+ if (isEVD(iso9660, p))
+ continue;
+ if (isSVD(iso9660, p))
+ continue;
+ if (isVolumePartition(iso9660, p))
+ continue;
+ if (isVDSetTerminator(iso9660, p)) {
+ seenTerminator = 1;
break;
+ }
+ return (0);
}
+ /*
+ * ISO 9660 format must have Primary Volume Descriptor and
+ * Volume Descriptor Set Terminator.
+ */
+ if (seenTerminator && iso9660->primary.location > 16)
+ return (48);
/* We didn't find a valid PVD; return a bid of zero. */
return (0);
}
static int
+archive_read_format_iso9660_options(struct archive_read *a,
+ const char *key, const char *val)
+{
+ struct iso9660 *iso9660;
+
+ iso9660 = (struct iso9660 *)(a->format->data);
+
+ if (strcmp(key, "joliet") == 0) {
+ if (val == NULL || strcmp(val, "off") == 0 ||
+ strcmp(val, "ignore") == 0 ||
+ strcmp(val, "disable") == 0 ||
+ strcmp(val, "0") == 0)
+ iso9660->opt_support_joliet = 0;
+ else
+ iso9660->opt_support_joliet = 1;
+ return (ARCHIVE_OK);
+ }
+ if (strcmp(key, "rockridge") == 0 ||
+ strcmp(key, "Rockridge") == 0) {
+ iso9660->opt_support_rockridge = val != NULL;
+ return (ARCHIVE_OK);
+ }
+
+ /* Note: The "warn" return is just to inform the options
+ * supervisor that we didn't handle it. It will generate
+ * a suitable error if noone used this option. */
+ return (ARCHIVE_WARN);
+}
+
+static int
+isBootRecord(struct iso9660 *iso9660, const unsigned char *h)
+{
+ (void)iso9660; /* UNUSED */
+
+ /* Type of the Volume Descriptor Boot Record must be 0. */
+ if (h[0] != 0)
+ return (0);
+
+ /* Volume Descriptor Version must be 1. */
+ if (h[6] != 1)
+ return (0);
+
+ return (1);
+}
+
+static int
+isVolumePartition(struct iso9660 *iso9660, const unsigned char *h)
+{
+ int32_t location;
+
+ /* Type of the Volume Partition Descriptor must be 3. */
+ if (h[0] != 3)
+ return (0);
+
+ /* Volume Descriptor Version must be 1. */
+ if (h[6] != 1)
+ return (0);
+ /* Unused Field */
+ if (h[7] != 0)
+ return (0);
+
+ location = archive_le32dec(h + 72);
+ if (location <= SYSTEM_AREA_BLOCK ||
+ location >= iso9660->volume_block)
+ return (0);
+ if ((uint32_t)location != archive_be32dec(h + 76))
+ return (0);
+
+ return (1);
+}
+
+static int
+isVDSetTerminator(struct iso9660 *iso9660, const unsigned char *h)
+{
+ int i;
+
+ (void)iso9660; /* UNUSED */
+
+ /* Type of the Volume Descriptor Set Terminator must be 255. */
+ if (h[0] != 255)
+ return (0);
+
+ /* Volume Descriptor Version must be 1. */
+ if (h[6] != 1)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 7; i < 2048; ++i)
+ if (h[i] != 0)
+ return (0);
+
+ return (1);
+}
+
+static int
+isJolietSVD(struct iso9660 *iso9660, const unsigned char *h)
+{
+ const unsigned char *p;
+ ssize_t logical_block_size;
+ int32_t volume_block;
+
+ /* Check if current sector is a kind of Supplementary Volume
+ * Descriptor. */
+ if (!isSVD(iso9660, h))
+ return (0);
+
+ /* FIXME: do more validations according to joliet spec. */
+
+ /* check if this SVD contains joliet extension! */
+ p = h + SVD_escape_sequences_offset;
+ /* N.B. Joliet spec says p[1] == '\\', but.... */
+ if (p[0] == '%' && p[1] == '/') {
+ int level = 0;
+
+ if (p[2] == '@')
+ level = 1;
+ else if (p[2] == 'C')
+ level = 2;
+ else if (p[2] == 'E')
+ level = 3;
+ else /* not joliet */
+ return (0);
+
+ iso9660->seenJoliet = level;
+
+ } else /* not joliet */
+ return (0);
+
+ logical_block_size =
+ archive_le16dec(h + SVD_logical_block_size_offset);
+ volume_block = archive_le32dec(h + SVD_volume_space_size_offset);
+
+ iso9660->logical_block_size = logical_block_size;
+ iso9660->volume_block = volume_block;
+ iso9660->volume_size = logical_block_size * (uint64_t)volume_block;
+ /* Read Root Directory Record in Volume Descriptor. */
+ p = h + SVD_root_directory_record_offset;
+ iso9660->joliet.location = archive_le32dec(p + DR_extent_offset);
+ iso9660->joliet.size = archive_le32dec(p + DR_size_offset);
+
+ return (48);
+}
+
+static int
+isSVD(struct iso9660 *iso9660, const unsigned char *h)
+{
+ const unsigned char *p;
+ ssize_t logical_block_size;
+ int32_t volume_block;
+ int32_t location;
+ int i;
+
+ (void)iso9660; /* UNUSED */
+
+ /* Type 2 means it's a SVD. */
+ if (h[SVD_type_offset] != 2)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < SVD_reserved1_size; ++i)
+ if (h[SVD_reserved1_offset + i] != 0)
+ return (0);
+ for (i = 0; i < SVD_reserved2_size; ++i)
+ if (h[SVD_reserved2_offset + i] != 0)
+ return (0);
+ for (i = 0; i < SVD_reserved3_size; ++i)
+ if (h[SVD_reserved3_offset + i] != 0)
+ return (0);
+
+ /* File structure version must be 1 for ISO9660/ECMA119. */
+ if (h[SVD_file_structure_version_offset] != 1)
+ return (0);
+
+ logical_block_size =
+ archive_le16dec(h + SVD_logical_block_size_offset);
+ if (logical_block_size <= 0)
+ return (0);
+
+ volume_block = archive_le32dec(h + SVD_volume_space_size_offset);
+ if (volume_block <= SYSTEM_AREA_BLOCK+4)
+ return (0);
+
+ /* Location of Occurrence of Type L Path Table must be
+ * available location,
+ * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
+ location = archive_le32dec(h+SVD_type_L_path_table_offset);
+ if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
+ return (0);
+
+ /* Location of Occurrence of Type M Path Table must be
+ * available location,
+ * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
+ location = archive_be32dec(h+SVD_type_M_path_table_offset);
+ if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
+ return (0);
+
+ /* Read Root Directory Record in Volume Descriptor. */
+ p = h + SVD_root_directory_record_offset;
+ if (p[DR_length_offset] != 34)
+ return (0);
+
+ return (48);
+}
+
+static int
+isEVD(struct iso9660 *iso9660, const unsigned char *h)
+{
+ const unsigned char *p;
+ ssize_t logical_block_size;
+ int32_t volume_block;
+ int32_t location;
+ int i;
+
+ (void)iso9660; /* UNUSED */
+
+ /* Type of the Enhanced Volume Descriptor must be 2. */
+ if (h[PVD_type_offset] != 2)
+ return (0);
+
+ /* EVD version must be 2. */
+ if (h[PVD_version_offset] != 2)
+ return (0);
+
+ /* Reserved field must be 0. */
+ if (h[PVD_reserved1_offset] != 0)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved2_size; ++i)
+ if (h[PVD_reserved2_offset + i] != 0)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved3_size; ++i)
+ if (h[PVD_reserved3_offset + i] != 0)
+ return (0);
+
+ /* Logical block size must be > 0. */
+ /* I've looked at Ecma 119 and can't find any stronger
+ * restriction on this field. */
+ logical_block_size =
+ archive_le16dec(h + PVD_logical_block_size_offset);
+ if (logical_block_size <= 0)
+ return (0);
+
+ volume_block =
+ archive_le32dec(h + PVD_volume_space_size_offset);
+ if (volume_block <= SYSTEM_AREA_BLOCK+4)
+ return (0);
+
+ /* File structure version must be 2 for ISO9660:1999. */
+ if (h[PVD_file_structure_version_offset] != 2)
+ return (0);
+
+ /* Location of Occurrence of Type L Path Table must be
+ * available location,
+ * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
+ location = archive_le32dec(h+PVD_type_1_path_table_offset);
+ if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
+ return (0);
+
+ /* Location of Occurrence of Type M Path Table must be
+ * available location,
+ * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
+ location = archive_be32dec(h+PVD_type_m_path_table_offset);
+ if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved4_size; ++i)
+ if (h[PVD_reserved4_offset + i] != 0)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved5_size; ++i)
+ if (h[PVD_reserved5_offset + i] != 0)
+ return (0);
+
+ /* Read Root Directory Record in Volume Descriptor. */
+ p = h + PVD_root_directory_record_offset;
+ if (p[DR_length_offset] != 34)
+ return (0);
+
+ return (48);
+}
+
+static int
isPVD(struct iso9660 *iso9660, const unsigned char *h)
{
- struct file_info *file;
+ const unsigned char *p;
+ ssize_t logical_block_size;
+ int32_t volume_block;
+ int32_t location;
+ int i;
+
+ /* Type of the Primary Volume Descriptor must be 1. */
+ if (h[PVD_type_offset] != 1)
+ return (0);
+
+ /* PVD version must be 1. */
+ if (h[PVD_version_offset] != 1)
+ return (0);
+
+ /* Reserved field must be 0. */
+ if (h[PVD_reserved1_offset] != 0)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved2_size; ++i)
+ if (h[PVD_reserved2_offset + i] != 0)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved3_size; ++i)
+ if (h[PVD_reserved3_offset + i] != 0)
+ return (0);
+
+ /* Logical block size must be > 0. */
+ /* I've looked at Ecma 119 and can't find any stronger
+ * restriction on this field. */
+ logical_block_size =
+ archive_le16dec(h + PVD_logical_block_size_offset);
+ if (logical_block_size <= 0)
+ return (0);
+
+ volume_block = archive_le32dec(h + PVD_volume_space_size_offset);
+ if (volume_block <= SYSTEM_AREA_BLOCK+4)
+ return (0);
- if (h[0] != 1)
+ /* File structure version must be 1 for ISO9660/ECMA119. */
+ if (h[PVD_file_structure_version_offset] != 1)
return (0);
- if (memcmp(h+1, "CD001", 5) != 0)
+
+ /* Location of Occurrence of Type L Path Table must be
+ * available location,
+ * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
+ location = archive_le32dec(h+PVD_type_1_path_table_offset);
+ if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
+ return (0);
+
+ /* Location of Occurrence of Type M Path Table must be
+ * available location,
+ * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
+ location = archive_be32dec(h+PVD_type_m_path_table_offset);
+ if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
return (0);
- iso9660->logical_block_size = toi(h + PVD_logical_block_size_offset, 2);
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved4_size; ++i)
+ if (h[PVD_reserved4_offset + i] != 0)
+ return (0);
+
+ /* Reserved field must be 0. */
+ for (i = 0; i < PVD_reserved5_size; ++i)
+ if (h[PVD_reserved5_offset + i] != 0)
+ return (0);
+
+ /* XXX TODO: Check other values for sanity; reject more
+ * malformed PVDs. XXX */
+
+ /* Read Root Directory Record in Volume Descriptor. */
+ p = h + PVD_root_directory_record_offset;
+ if (p[DR_length_offset] != 34)
+ return (0);
+
+ iso9660->logical_block_size = logical_block_size;
+ iso9660->volume_block = volume_block;
+ iso9660->volume_size = logical_block_size * (uint64_t)volume_block;
+ iso9660->primary.location = archive_le32dec(p + DR_extent_offset);
+ iso9660->primary.size = archive_le32dec(p + DR_size_offset);
- /* Store the root directory in the pending list. */
- file = parse_file_info(iso9660, NULL, h + PVD_root_directory_record_offset);
- add_entry(iso9660, file);
return (48);
}
static int
+read_children(struct archive_read *a, struct file_info *parent)
+{
+ struct iso9660 *iso9660;
+ const unsigned char *b, *p;
+ struct file_info *multi;
+ size_t step;
+
+ iso9660 = (struct iso9660 *)(a->format->data);
+ if (iso9660->current_position > parent->offset) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Ignoring out-of-order directory (%s) %jd > %jd",
+ parent->name.s,
+ iso9660->current_position,
+ parent->offset);
+ return (ARCHIVE_WARN);
+ }
+ if (parent->offset + parent->size > iso9660->volume_size) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Directory is beyond end-of-media: %s",
+ parent->name);
+ return (ARCHIVE_WARN);
+ }
+ if (iso9660->current_position < parent->offset) {
+ int64_t skipsize;
+
+ skipsize = parent->offset - iso9660->current_position;
+ skipsize = __archive_read_skip(a, skipsize);
+ if (skipsize < 0)
+ return ((int)skipsize);
+ iso9660->current_position = parent->offset;
+ }
+
+ step = ((parent->size + iso9660->logical_block_size -1) /
+ iso9660->logical_block_size) * iso9660->logical_block_size;
+ b = __archive_read_ahead(a, step, NULL);
+ if (b == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Failed to read full block when scanning "
+ "ISO9660 directory list");
+ return (ARCHIVE_FATAL);
+ }
+ __archive_read_consume(a, step);
+ iso9660->current_position += step;
+ multi = NULL;
+ while (step) {
+ p = b;
+ b += iso9660->logical_block_size;
+ step -= iso9660->logical_block_size;
+ for (; *p != 0 && p < b && p + *p <= b; p += *p) {
+ struct file_info *child;
+
+ /* N.B.: these special directory identifiers
+ * are 8 bit "values" even on a
+ * Joliet CD with UCS-2 (16bit) encoding.
+ */
+
+ /* Skip '.' entry. */
+ if (*(p + DR_name_len_offset) == 1
+ && *(p + DR_name_offset) == '\0')
+ continue;
+ /* Skip '..' entry. */
+ if (*(p + DR_name_len_offset) == 1
+ && *(p + DR_name_offset) == '\001')
+ continue;
+ child = parse_file_info(a, parent, p);
+ if (child == NULL)
+ return (ARCHIVE_FATAL);
+ if (child->cl_offset)
+ heap_add_entry(&(iso9660->cl_files),
+ child, child->cl_offset);
+ else {
+ if (child->multi_extent || multi != NULL) {
+ struct content *con;
+
+ if (multi == NULL) {
+ multi = child;
+ multi->contents.first = NULL;
+ multi->contents.last =
+ &(multi->contents.first);
+ }
+ con = malloc(sizeof(struct content));
+ if (con == NULL) {
+ archive_set_error(
+ &a->archive, ENOMEM,
+ "No memory for "
+ "multi extent");
+ return (ARCHIVE_FATAL);
+ }
+ con->offset = child->offset;
+ con->size = child->size;
+ con->next = NULL;
+ *multi->contents.last = con;
+ multi->contents.last = &(con->next);
+ if (multi == child)
+ add_entry(iso9660, child);
+ else {
+ multi->size += child->size;
+ if (!child->multi_extent)
+ multi = NULL;
+ }
+ } else
+ add_entry(iso9660, child);
+ }
+ }
+ }
+
+ /* Read data which recorded by RRIP "CE" extension. */
+ if (read_CE(a, iso9660) != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+
+ return (ARCHIVE_OK);
+}
+
+static int
+relocate_dir(struct iso9660 *iso9660, struct file_info *file)
+{
+ struct file_info *re;
+
+ re = heap_get_entry(&(iso9660->re_dirs));
+ while (re != NULL && re->offset < file->cl_offset) {
+ /* This case is wrong pattern.
+ * But dont't reject this directory entry to be robust. */
+ cache_add_entry(iso9660, re);
+ re = heap_get_entry(&(iso9660->re_dirs));
+ }
+ if (re == NULL)
+ /* This case is wrong pattern. */
+ return (0);
+ if (re->offset == file->cl_offset) {
+ re->parent->subdirs--;
+ re->parent = file->parent;
+ re->parent->subdirs++;
+ cache_add_to_next_of_parent(iso9660, re);
+ return (1);
+ } else
+ /* This case is wrong pattern. */
+ heap_add_entry(&(iso9660->re_dirs), re, re->offset);
+ return (0);
+}
+
+static int
+read_entries(struct archive_read *a)
+{
+ struct iso9660 *iso9660;
+ struct file_info *file;
+ int r;
+
+ iso9660 = (struct iso9660 *)(a->format->data);
+
+ while ((file = next_entry(iso9660)) != NULL &&
+ (file->mode & AE_IFMT) == AE_IFDIR) {
+ r = read_children(a, file);
+ if (r != ARCHIVE_OK)
+ return (r);
+
+ if (iso9660->seenRockridge &&
+ file->parent != NULL &&
+ file->parent->parent == NULL &&
+ iso9660->rr_moved == NULL &&
+ (strcmp(file->name.s, "rr_moved") == 0 ||
+ strcmp(file->name.s, ".rr_moved") == 0)) {
+ iso9660->rr_moved = file;
+ } else if (file->re)
+ heap_add_entry(&(iso9660->re_dirs), file,
+ file->offset);
+ else
+ cache_add_entry(iso9660, file);
+ }
+ if (file != NULL)
+ add_entry(iso9660, file);
+
+ if (iso9660->rr_moved != NULL) {
+ /*
+ * Relocate directory which rr_moved has.
+ */
+ while ((file = heap_get_entry(&(iso9660->cl_files))) != NULL)
+ relocate_dir(iso9660, file);
+
+ /* If rr_moved directory still has children,
+ * Add rr_moved into pending_files to show
+ */
+ if (iso9660->rr_moved->subdirs) {
+ cache_add_entry(iso9660, iso9660->rr_moved);
+ /* If entries which have "RE" extension are still
+ * remaining(this case is unlikely except ISO image
+ * is broken), the entries won't be exposed. */
+ while ((file = heap_get_entry(&(iso9660->re_dirs))) != NULL)
+ cache_add_entry(iso9660, file);
+ } else
+ iso9660->rr_moved->parent->subdirs--;
+ } else {
+ /*
+ * In case ISO image is broken. If the name of rr_moved
+ * directory has been changed by damage, subdirectories
+ * of rr_moved entry won't be exposed.
+ */
+ while ((file = heap_get_entry(&(iso9660->re_dirs))) != NULL)
+ cache_add_entry(iso9660, file);
+ }
+
+ return (ARCHIVE_OK);
+}
+
+static int
archive_read_format_iso9660_read_header(struct archive_read *a,
struct archive_entry *entry)
{
struct iso9660 *iso9660;
struct file_info *file;
- ssize_t bytes_read;
- int r;
+ int r, rd_r;
iso9660 = (struct iso9660 *)(a->format->data);
@@ -344,6 +1118,93 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
a->archive.archive_format_name = "ISO9660";
}
+ if (iso9660->current_position == 0) {
+ int64_t skipsize;
+ struct vd *vd;
+ const void *block;
+ char seenJoliet;
+
+ vd = &(iso9660->primary);
+ if (!iso9660->opt_support_joliet)
+ iso9660->seenJoliet = 0;
+ if (iso9660->seenJoliet &&
+ vd->location > iso9660->joliet.location)
+ /* This condition is unlikely; by way of caution. */
+ vd = &(iso9660->joliet);
+
+ skipsize = LOGICAL_BLOCK_SIZE * vd->location;
+ skipsize = __archive_read_skip(a, skipsize);
+ if (skipsize < 0)
+ return ((int)skipsize);
+ iso9660->current_position = skipsize;
+
+ block = __archive_read_ahead(a, vd->size, NULL);
+ if (block == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to read full block when scanning "
+ "ISO9660 directory list");
+ return (ARCHIVE_FATAL);
+ }
+
+ /*
+ * While reading Root Directory, flag seenJoliet
+ * must be zero to avoid converting special name
+ * 0x00(Current Directory) and next byte to UCS2.
+ */
+ seenJoliet = iso9660->seenJoliet;/* Save flag. */
+ iso9660->seenJoliet = 0;
+ file = parse_file_info(a, NULL, block);
+ if (file == NULL)
+ return (ARCHIVE_FATAL);
+ iso9660->seenJoliet = seenJoliet;
+ if (vd == &(iso9660->primary) && iso9660->seenRockridge
+ && iso9660->seenJoliet)
+ /*
+ * If iso image has RockRidge and Joliet,
+ * we use RockRidge Extensions.
+ */
+ iso9660->seenJoliet = 0;
+ if (vd == &(iso9660->primary) && !iso9660->seenRockridge
+ && iso9660->seenJoliet) {
+ /* Switch reading data from primary to joliet. */
+ vd = &(iso9660->joliet);
+ skipsize = LOGICAL_BLOCK_SIZE * vd->location;
+ skipsize -= iso9660->current_position;
+ skipsize = __archive_read_skip(a, skipsize);
+ if (skipsize < 0)
+ return ((int)skipsize);
+ iso9660->current_position += skipsize;
+
+ block = __archive_read_ahead(a, vd->size, NULL);
+ if (block == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to read full block when scanning "
+ "ISO9660 directory list");
+ return (ARCHIVE_FATAL);
+ }
+ seenJoliet = iso9660->seenJoliet;/* Save flag. */
+ iso9660->seenJoliet = 0;
+ file = parse_file_info(a, NULL, block);
+ if (file == NULL)
+ return (ARCHIVE_FATAL);
+ iso9660->seenJoliet = seenJoliet;
+ }
+ /* Store the root directory in the pending list. */
+ add_entry(iso9660, file);
+ if (iso9660->seenRockridge) {
+ a->archive.archive_format =
+ ARCHIVE_FORMAT_ISO9660_ROCKRIDGE;
+ a->archive.archive_format_name =
+ "ISO9660 with Rockridge extensions";
+ }
+ rd_r = read_entries(a);
+ if (rd_r == ARCHIVE_FATAL)
+ return (ARCHIVE_FATAL);
+ } else
+ rd_r = ARCHIVE_OK;
+
/* Get the next entry that appears after the current offset. */
r = next_entry_seek(a, iso9660, &file);
if (r != ARCHIVE_OK)
@@ -352,12 +1213,23 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
iso9660->entry_bytes_remaining = file->size;
iso9660->entry_sparse_offset = 0; /* Offset for sparse-file-aware clients. */
+ if (file->offset + file->size > iso9660->volume_size) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "File is beyond end-of-media: %s", file->name);
+ iso9660->entry_bytes_remaining = 0;
+ iso9660->entry_sparse_offset = 0;
+ return (ARCHIVE_WARN);
+ }
+
/* Set up the entry structure with information about this entry. */
archive_entry_set_mode(entry, file->mode);
archive_entry_set_uid(entry, file->uid);
archive_entry_set_gid(entry, file->gid);
archive_entry_set_nlink(entry, file->nlinks);
- archive_entry_set_ino(entry, file->inode);
+ if (file->birthtime_is_set)
+ archive_entry_set_birthtime(entry, file->birthtime, 0);
+ else
+ archive_entry_unset_birthtime(entry);
archive_entry_set_mtime(entry, file->mtime, 0);
archive_entry_set_ctime(entry, file->ctime, 0);
archive_entry_set_atime(entry, file->atime, 0);
@@ -370,81 +1242,85 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
if (file->symlink.s != NULL)
archive_entry_copy_symlink(entry, file->symlink.s);
- /* If this entry points to the same data as the previous
- * entry, convert this into a hardlink to that entry.
- * But don't bother for zero-length files. */
- if (file->offset == iso9660->previous_offset
- && file->size == iso9660->previous_size
- && file->size > 0) {
+ /* Note: If the input isn't seekable, we can't rewind to
+ * return the same body again, so if the next entry refers to
+ * the same data, we have to return it as a hardlink to the
+ * original entry. */
+ if (file->number != -1 &&
+ file->number == iso9660->previous_number) {
archive_entry_set_hardlink(entry,
iso9660->previous_pathname.s);
+ archive_entry_unset_size(entry);
iso9660->entry_bytes_remaining = 0;
iso9660->entry_sparse_offset = 0;
- release_file(iso9660, file);
return (ARCHIVE_OK);
}
- /* If the offset is before our current position, we can't
- * seek backwards to extract it, so issue a warning. */
- if (file->offset < iso9660->current_position) {
+ /* Except for the hardlink case above, if the offset of the
+ * next entry is before our current position, we can't seek
+ * backwards to extract it, so issue a warning. Note that
+ * this can only happen if this entry was added to the heap
+ * after we passed this offset, that is, only if the directory
+ * mentioning this entry is later than the body of the entry.
+ * Such layouts are very unusual; most ISO9660 writers lay out
+ * and record all directory information first, then store
+ * all file bodies. */
+ /* TODO: Someday, libarchive's I/O core will support optional
+ * seeking. When that day comes, this code should attempt to
+ * seek and only return the error if the seek fails. That
+ * will give us support for whacky ISO images that require
+ * seeking while retaining the ability to read almost all ISO
+ * images in a streaming fashion. */
+ if ((file->mode & AE_IFMT) != AE_IFDIR &&
+ file->offset < iso9660->current_position) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Ignoring out-of-order file");
+ "Ignoring out-of-order file @%x (%s) %jd < %jd",
+ file,
+ iso9660->pathname.s,
+ file->offset, iso9660->current_position);
iso9660->entry_bytes_remaining = 0;
iso9660->entry_sparse_offset = 0;
- release_file(iso9660, file);
return (ARCHIVE_WARN);
}
- iso9660->previous_size = file->size;
- iso9660->previous_offset = file->offset;
+ /* Initialize zisofs variables. */
+ iso9660->entry_zisofs.pz = file->pz;
+ if (file->pz) {
+#ifdef HAVE_ZLIB_H
+ struct zisofs *zisofs;
+
+ zisofs = &iso9660->entry_zisofs;
+ zisofs->initialized = 0;
+ zisofs->pz_log2_bs = file->pz_log2_bs;
+ zisofs->pz_uncompressed_size = file->pz_uncompressed_size;
+ zisofs->pz_offset = 0;
+ zisofs->header_avail = 0;
+ zisofs->header_passed = 0;
+ zisofs->block_pointers_avail = 0;
+#endif
+ archive_entry_set_size(entry, file->pz_uncompressed_size);
+ }
+
+ iso9660->previous_number = file->number;
archive_strcpy(&iso9660->previous_pathname, iso9660->pathname.s);
- /* If this is a directory, read in all of the entries right now. */
+ /* Reset entry_bytes_remaining if the file is multi extent. */
+ iso9660->entry_content = file->contents.first;
+ if (iso9660->entry_content != NULL)
+ iso9660->entry_bytes_remaining = iso9660->entry_content->size;
+
if (archive_entry_filetype(entry) == AE_IFDIR) {
- while (iso9660->entry_bytes_remaining > 0) {
- const void *block;
- const unsigned char *p;
- ssize_t step = iso9660->logical_block_size;
- if (step > iso9660->entry_bytes_remaining)
- step = iso9660->entry_bytes_remaining;
- bytes_read = (a->decompressor->read_ahead)(a, &block, step);
- if (bytes_read < step) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Failed to read full block when scanning ISO9660 directory list");
- release_file(iso9660, file);
- return (ARCHIVE_FATAL);
- }
- if (bytes_read > step)
- bytes_read = step;
- (a->decompressor->consume)(a, bytes_read);
- iso9660->current_position += bytes_read;
- iso9660->entry_bytes_remaining -= bytes_read;
- for (p = (const unsigned char *)block;
- *p != 0 && p < (const unsigned char *)block + bytes_read;
- p += *p) {
- struct file_info *child;
-
- /* Skip '.' entry. */
- if (*(p + DR_name_len_offset) == 1
- && *(p + DR_name_offset) == '\0')
- continue;
- /* Skip '..' entry. */
- if (*(p + DR_name_len_offset) == 1
- && *(p + DR_name_offset) == '\001')
- continue;
- child = parse_file_info(iso9660, file, p);
- add_entry(iso9660, child);
- if (iso9660->seenRockridge) {
- a->archive.archive_format =
- ARCHIVE_FORMAT_ISO9660_ROCKRIDGE;
- a->archive.archive_format_name =
- "ISO9660 with Rockridge extensions";
- }
- }
- }
+ /* Overwrite nlinks by proper link number which is
+ * calculated from number of sub directories. */
+ archive_entry_set_nlink(entry, 2 + file->subdirs);
+ /* Directory data has been read completely. */
+ iso9660->entry_bytes_remaining = 0;
+ iso9660->entry_sparse_offset = 0;
+ file->exposed = 1;
}
- release_file(iso9660, file);
+ if (rd_r != ARCHIVE_OK)
+ return (rd_r);
return (ARCHIVE_OK);
}
@@ -457,6 +1333,241 @@ archive_read_format_iso9660_read_data_skip(struct archive_read *a)
return (ARCHIVE_OK);
}
+#ifdef HAVE_ZLIB_H
+
+static int
+zisofs_read_data(struct archive_read *a,
+ const void **buff, size_t *size, off_t *offset)
+{
+ struct iso9660 *iso9660;
+ struct zisofs *zisofs;
+ const unsigned char *p;
+ size_t avail;
+ ssize_t bytes_read;
+ size_t uncompressed_size;
+ int r;
+
+ iso9660 = (struct iso9660 *)(a->format->data);
+ zisofs = &iso9660->entry_zisofs;
+
+ p = __archive_read_ahead(a, 1, &bytes_read);
+ if (bytes_read <= 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated zisofs file body");
+ return (ARCHIVE_FATAL);
+ }
+ if (bytes_read > iso9660->entry_bytes_remaining)
+ bytes_read = iso9660->entry_bytes_remaining;
+ avail = bytes_read;
+ uncompressed_size = 0;
+
+ if (!zisofs->initialized) {
+ size_t ceil, xsize;
+
+ /* Allocate block pointers buffer. */
+ ceil = (zisofs->pz_uncompressed_size +
+ (1LL << zisofs->pz_log2_bs) - 1)
+ >> zisofs->pz_log2_bs;
+ xsize = (ceil + 1) * 4;
+ if (zisofs->block_pointers_alloc < xsize) {
+ size_t alloc;
+
+ if (zisofs->block_pointers != NULL)
+ free(zisofs->block_pointers);
+ alloc = ((xsize >> 10) + 1) << 10;
+ zisofs->block_pointers = malloc(alloc);
+ if (zisofs->block_pointers == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory for zisofs decompression");
+ return (ARCHIVE_FATAL);
+ }
+ zisofs->block_pointers_alloc = alloc;
+ }
+ zisofs->block_pointers_size = xsize;
+
+ /* Allocate uncompressed data buffer. */
+ xsize = 1UL << zisofs->pz_log2_bs;
+ if (zisofs->uncompressed_buffer_size < xsize) {
+ if (zisofs->uncompressed_buffer != NULL)
+ free(zisofs->uncompressed_buffer);
+ zisofs->uncompressed_buffer = malloc(xsize);
+ if (zisofs->uncompressed_buffer == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory for zisofs decompression");
+ return (ARCHIVE_FATAL);
+ }
+ }
+ zisofs->uncompressed_buffer_size = xsize;
+
+ /*
+ * Read the file header, and check the magic code of zisofs.
+ */
+ if (zisofs->header_avail < sizeof(zisofs->header)) {
+ xsize = sizeof(zisofs->header) - zisofs->header_avail;
+ if (avail < xsize)
+ xsize = avail;
+ memcpy(zisofs->header + zisofs->header_avail, p, xsize);
+ zisofs->header_avail += xsize;
+ avail -= xsize;
+ p += xsize;
+ }
+ if (!zisofs->header_passed &&
+ zisofs->header_avail == sizeof(zisofs->header)) {
+ int err = 0;
+
+ if (memcmp(zisofs->header, zisofs_magic,
+ sizeof(zisofs_magic)) != 0)
+ err = 1;
+ if (archive_le32dec(zisofs->header + 8)
+ != zisofs->pz_uncompressed_size)
+ err = 1;
+ if (zisofs->header[12] != 4)
+ err = 1;
+ if (zisofs->header[13] != zisofs->pz_log2_bs)
+ err = 1;
+ if (err) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Illegal zisofs file body");
+ return (ARCHIVE_FATAL);
+ }
+ zisofs->header_passed = 1;
+ }
+ /*
+ * Read block pointers.
+ */
+ if (zisofs->header_passed &&
+ zisofs->block_pointers_avail < zisofs->block_pointers_size) {
+ xsize = zisofs->block_pointers_size
+ - zisofs->block_pointers_avail;
+ if (avail < xsize)
+ xsize = avail;
+ memcpy(zisofs->block_pointers
+ + zisofs->block_pointers_avail, p, xsize);
+ zisofs->block_pointers_avail += xsize;
+ avail -= xsize;
+ p += xsize;
+ if (zisofs->block_pointers_avail
+ == zisofs->block_pointers_size) {
+ /* We've got all block pointers and initialize
+ * related variables. */
+ zisofs->block_off = 0;
+ zisofs->block_avail = 0;
+ /* Complete a initialization */
+ zisofs->initialized = 1;
+ }
+ }
+
+ if (!zisofs->initialized)
+ goto next_data; /* We need more datas. */
+ }
+
+ /*
+ * Get block offsets from block pointers.
+ */
+ if (zisofs->block_avail == 0) {
+ uint32_t bst, bed;
+
+ if (zisofs->block_off + 4 >= zisofs->block_pointers_size) {
+ /* There isn't a pair of offsets. */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Illegal zisofs block pointers");
+ return (ARCHIVE_FATAL);
+ }
+ bst = archive_le32dec(zisofs->block_pointers + zisofs->block_off);
+ if (bst != zisofs->pz_offset + (bytes_read - avail)) {
+ /* TODO: Should we seek offset of current file by bst ? */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Illegal zisofs block pointers(cannot seek)");
+ return (ARCHIVE_FATAL);
+ }
+ bed = archive_le32dec(
+ zisofs->block_pointers + zisofs->block_off + 4);
+ if (bed < bst) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Illegal zisofs block pointers");
+ return (ARCHIVE_FATAL);
+ }
+ zisofs->block_avail = bed - bst;
+ zisofs->block_off += 4;
+
+ /* Initialize compression library for new block. */
+ if (zisofs->stream_valid)
+ r = inflateReset(&zisofs->stream);
+ else
+ r = inflateInit(&zisofs->stream);
+ if (r != Z_OK) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Can't initialize zisofs decompression.");
+ return (ARCHIVE_FATAL);
+ }
+ zisofs->stream_valid = 1;
+ zisofs->stream.total_in = 0;
+ zisofs->stream.total_out = 0;
+ }
+
+ /*
+ * Make uncompressed datas.
+ */
+ if (zisofs->block_avail == 0) {
+ memset(zisofs->uncompressed_buffer, 0,
+ zisofs->uncompressed_buffer_size);
+ uncompressed_size = zisofs->uncompressed_buffer_size;
+ } else {
+ zisofs->stream.next_in = (Bytef *)(uintptr_t)(const void *)p;
+ if (avail > zisofs->block_avail)
+ zisofs->stream.avail_in = zisofs->block_avail;
+ else
+ zisofs->stream.avail_in = avail;
+ zisofs->stream.next_out = zisofs->uncompressed_buffer;
+ zisofs->stream.avail_out = zisofs->uncompressed_buffer_size;
+
+ r = inflate(&zisofs->stream, 0);
+ switch (r) {
+ case Z_OK: /* Decompressor made some progress.*/
+ case Z_STREAM_END: /* Found end of stream. */
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "zisofs decompression failed (%d)", r);
+ return (ARCHIVE_FATAL);
+ }
+ uncompressed_size =
+ zisofs->uncompressed_buffer_size - zisofs->stream.avail_out;
+ avail -= zisofs->stream.next_in - p;
+ zisofs->block_avail -= zisofs->stream.next_in - p;
+ }
+next_data:
+ bytes_read -= avail;
+ *buff = zisofs->uncompressed_buffer;
+ *size = uncompressed_size;
+ *offset = iso9660->entry_sparse_offset;
+ iso9660->entry_sparse_offset += uncompressed_size;
+ iso9660->entry_bytes_remaining -= bytes_read;
+ iso9660->current_position += bytes_read;
+ zisofs->pz_offset += bytes_read;
+ __archive_read_consume(a, bytes_read);
+
+ return (ARCHIVE_OK);
+}
+
+#else /* HAVE_ZLIB_H */
+
+static int
+zisofs_read_data(struct archive_read *a,
+ const void **buff, size_t *size, off_t *offset)
+{
+
+ (void)buff;/* UNUSED */
+ (void)size;/* UNUSED */
+ (void)offset;/* UNUSED */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "zisofs is not supported on this platform.");
+ return (ARCHIVE_FAILED);
+}
+
+#endif /* HAVE_ZLIB_H */
+
static int
archive_read_format_iso9660_read_data(struct archive_read *a,
const void **buff, size_t *size, off_t *offset)
@@ -466,17 +1577,47 @@ archive_read_format_iso9660_read_data(struct archive_read *a,
iso9660 = (struct iso9660 *)(a->format->data);
if (iso9660->entry_bytes_remaining <= 0) {
- *buff = NULL;
- *size = 0;
- *offset = iso9660->entry_sparse_offset;
- return (ARCHIVE_EOF);
+ if (iso9660->entry_content != NULL)
+ iso9660->entry_content = iso9660->entry_content->next;
+ if (iso9660->entry_content == NULL) {
+ *buff = NULL;
+ *size = 0;
+ *offset = iso9660->entry_sparse_offset;
+ return (ARCHIVE_EOF);
+ }
+ /* Seek forward to the start of the entry. */
+ if (iso9660->current_position < iso9660->entry_content->offset) {
+ int64_t step;
+
+ step = iso9660->entry_content->offset -
+ iso9660->current_position;
+ step = __archive_read_skip(a, step);
+ if (step < 0)
+ return ((int)step);
+ iso9660->current_position =
+ iso9660->entry_content->offset;
+ }
+ if (iso9660->entry_content->offset < iso9660->current_position) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Ignoring out-of-order file (%s) %jd < %jd",
+ iso9660->pathname.s,
+ iso9660->entry_content->offset,
+ iso9660->current_position);
+ *buff = NULL;
+ *size = 0;
+ *offset = iso9660->entry_sparse_offset;
+ return (ARCHIVE_WARN);
+ }
+ iso9660->entry_bytes_remaining = iso9660->entry_content->size;
}
+ if (iso9660->entry_zisofs.pz)
+ return (zisofs_read_data(a, buff, size, offset));
- bytes_read = (a->decompressor->read_ahead)(a, buff, 1);
+ *buff = __archive_read_ahead(a, 1, &bytes_read);
if (bytes_read == 0)
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Truncated input file");
- if (bytes_read <= 0)
+ if (*buff == NULL)
return (ARCHIVE_FATAL);
if (bytes_read > iso9660->entry_bytes_remaining)
bytes_read = iso9660->entry_bytes_remaining;
@@ -485,7 +1626,7 @@ archive_read_format_iso9660_read_data(struct archive_read *a,
iso9660->entry_sparse_offset += bytes_read;
iso9660->entry_bytes_remaining -= bytes_read;
iso9660->current_position += bytes_read;
- (a->decompressor->consume)(a, bytes_read);
+ __archive_read_consume(a, bytes_read);
return (ARCHIVE_OK);
}
@@ -493,18 +1634,33 @@ static int
archive_read_format_iso9660_cleanup(struct archive_read *a)
{
struct iso9660 *iso9660;
- struct file_info *file;
+ int r = ARCHIVE_OK;
iso9660 = (struct iso9660 *)(a->format->data);
- while ((file = next_entry(iso9660)) != NULL)
- release_file(iso9660, file);
+ release_files(iso9660);
+ free(iso9660->read_ce_req.reqs);
archive_string_free(&iso9660->pathname);
archive_string_free(&iso9660->previous_pathname);
- if (iso9660->pending_files)
- free(iso9660->pending_files);
+ if (iso9660->pending_files.files)
+ free(iso9660->pending_files.files);
+ if (iso9660->re_dirs.files)
+ free(iso9660->re_dirs.files);
+ if (iso9660->cl_files.files)
+ free(iso9660->cl_files.files);
+#ifdef HAVE_ZLIB_H
+ free(iso9660->entry_zisofs.uncompressed_buffer);
+ free(iso9660->entry_zisofs.block_pointers);
+ if (iso9660->entry_zisofs.stream_valid) {
+ if (inflateEnd(&iso9660->entry_zisofs.stream) != Z_OK) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Failed to clean up zlib decompressor");
+ r = ARCHIVE_FATAL;
+ }
+ }
+#endif
free(iso9660);
(a->format->data) = NULL;
- return (ARCHIVE_OK);
+ return (r);
}
/*
@@ -512,55 +1668,202 @@ archive_read_format_iso9660_cleanup(struct archive_read *a)
* of any extensions, and stores the result in memory.
*/
static struct file_info *
-parse_file_info(struct iso9660 *iso9660, struct file_info *parent,
+parse_file_info(struct archive_read *a, struct file_info *parent,
const unsigned char *isodirrec)
{
+ struct iso9660 *iso9660;
struct file_info *file;
size_t name_len;
+ const unsigned char *rr_start, *rr_end;
+ const unsigned char *p;
+ size_t dr_len;
+ int32_t location;
int flags;
- /* TODO: Sanity check that name_len doesn't exceed length, etc. */
+ iso9660 = (struct iso9660 *)(a->format->data);
+
+ dr_len = (size_t)isodirrec[DR_length_offset];
+ name_len = (size_t)isodirrec[DR_name_len_offset];
+ location = archive_le32dec(isodirrec + DR_extent_offset);
+ /* Sanity check that dr_len needs at least 34. */
+ if (dr_len < 34) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Invalid length of directory record");
+ return (NULL);
+ }
+ /* Sanity check that name_len doesn't exceed dr_len. */
+ if (dr_len - 33 < name_len || name_len == 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Invalid length of file identifier");
+ return (NULL);
+ }
+ /* Sanity check that location doesn't exceed volume block.
+ * Don't check lower limit of location; it's possibility
+ * the location has negative value when file type is symbolic
+ * link or file size is zero. As far as I know latest mkisofs
+ * do that.
+ */
+ if (location >= iso9660->volume_block) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Invalid location of extent of file");
+ return (NULL);
+ }
/* Create a new file entry and copy data from the ISO dir record. */
file = (struct file_info *)malloc(sizeof(*file));
- if (file == NULL)
+ if (file == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory for file entry");
return (NULL);
+ }
memset(file, 0, sizeof(*file));
file->parent = parent;
- if (parent != NULL)
- parent->refcount++;
- file->offset = toi(isodirrec + DR_extent_offset, DR_extent_size)
- * iso9660->logical_block_size;
+ file->offset = iso9660->logical_block_size * (uint64_t)location;
file->size = toi(isodirrec + DR_size_offset, DR_size_size);
file->mtime = isodate7(isodirrec + DR_date_offset);
file->ctime = file->atime = file->mtime;
- name_len = (size_t)*(const unsigned char *)(isodirrec + DR_name_len_offset);
- file->name = (char *)malloc(name_len + 1);
- if (file->name == NULL) {
- free(file);
- return (NULL);
+
+ p = isodirrec + DR_name_offset;
+ /* Rockridge extensions (if any) follow name. Compute this
+ * before fidgeting the name_len below. */
+ rr_start = p + name_len + (name_len & 1 ? 0 : 1);
+ rr_end = isodirrec + dr_len;
+
+ if (iso9660->seenJoliet) {
+ /* Joliet names are max 64 chars (128 bytes) according to spec,
+ * but genisoimage/mkisofs allows recording longer Joliet
+ * names which are 103 UCS2 characters(206 bytes) by their
+ * option '-joliet-long'.
+ */
+ wchar_t wbuff[103+1], *wp;
+ const unsigned char *c;
+
+ if (name_len > 206)
+ name_len = 206;
+ /* convert BE UTF-16 to wchar_t */
+ for (c = p, wp = wbuff;
+ c < (p + name_len) &&
+ wp < (wbuff + sizeof(wbuff)/sizeof(*wbuff) - 1);
+ c += 2) {
+ *wp++ = (((255 & (int)c[0]) << 8) | (255 & (int)c[1]));
+ }
+ *wp = L'\0';
+
+#if 0 /* untested code, is it at all useful on Joliet? */
+ /* trim trailing first version and dot from filename.
+ *
+ * Remember we where in UTF-16BE land!
+ * SEPARATOR 1 (.) and SEPARATOR 2 (;) are both
+ * 16 bits big endian characters on Joliet.
+ *
+ * TODO: sanitize filename?
+ * Joliet allows any UCS-2 char except:
+ * *, /, :, ;, ? and \.
+ */
+ /* Chop off trailing ';1' from files. */
+ if (*(wp-2) == ';' && *(wp-1) == '1') {
+ wp-=2;
+ *wp = L'\0';
+ }
+
+ /* Chop off trailing '.' from filenames. */
+ if (*(wp-1) == '.')
+ *(--wp) = L'\0';
+#endif
+
+ /* store the result in the file name field. */
+ archive_strappend_w_utf8(&file->name, wbuff);
+ } else {
+ /* Chop off trailing ';1' from files. */
+ if (name_len > 2 && p[name_len - 2] == ';' &&
+ p[name_len - 1] == '1')
+ name_len -= 2;
+ /* Chop off trailing '.' from filenames. */
+ if (name_len > 1 && p[name_len - 1] == '.')
+ --name_len;
+
+ archive_strncpy(&file->name, (const char *)p, name_len);
}
- memcpy(file->name, isodirrec + DR_name_offset, name_len);
- file->name[name_len] = '\0';
- flags = *(isodirrec + DR_flags_offset);
+
+ flags = isodirrec[DR_flags_offset];
if (flags & 0x02)
file->mode = AE_IFDIR | 0700;
else
file->mode = AE_IFREG | 0400;
+ if (flags & 0x80)
+ file->multi_extent = 1;
+ else
+ file->multi_extent = 0;
+ /*
+ * Use location for file number.
+ * File number is treated as inode number to find out harlink
+ * target. If Rockridge extensions is being used, file number
+ * will be overwritten by FILE SERIAL NUMBER of RRIP "PX"
+ * extension.
+ * NOTE: Old mkisofs did not record that FILE SERIAL NUMBER
+ * in ISO images.
+ */
+ if (file->size == 0 && location >= 0)
+ /* If file->size is zero, its location points wrong place.
+ * Dot not use it for file number.
+ * When location has negative value, it can be used
+ * for file number.
+ */
+ file->number = -1;
+ else
+ file->number = (int64_t)(uint32_t)location;
/* Rockridge extensions overwrite information from above. */
- {
- const unsigned char *rr_start, *rr_end;
- rr_end = (const unsigned char *)isodirrec
- + *(isodirrec + DR_length_offset);
- rr_start = (const unsigned char *)(isodirrec + DR_name_offset
- + name_len);
- if ((name_len & 1) == 0)
- rr_start++;
- rr_start += iso9660->suspOffset;
- parse_rockridge(iso9660, file, rr_start, rr_end);
+ if (iso9660->opt_support_rockridge) {
+ if (parent == NULL && rr_end - rr_start >= 7) {
+ p = rr_start;
+ if (p[0] == 'S' && p[1] == 'P'
+ && p[2] == 7 && p[3] == 1
+ && p[4] == 0xBE && p[5] == 0xEF) {
+ /*
+ * SP extension stores the suspOffset
+ * (Number of bytes to skip between
+ * filename and SUSP records.)
+ * It is mandatory by the SUSP standard
+ * (IEEE 1281).
+ *
+ * It allows SUSP to coexist with
+ * non-SUSP uses of the System
+ * Use Area by placing non-SUSP data
+ * before SUSP data.
+ *
+ * SP extension must be in the root
+ * directory entry, disable all SUSP
+ * processing if not found.
+ */
+ iso9660->suspOffset = p[6];
+ iso9660->seenSUSP = 1;
+ rr_start += 7;
+ }
+ }
+ if (iso9660->seenSUSP) {
+ int r;
+
+ file->name_continues = 0;
+ file->symlink_continues = 0;
+ rr_start += iso9660->suspOffset;
+ r = parse_rockridge(a, file, rr_start, rr_end);
+ if (r != ARCHIVE_OK) {
+ free(file);
+ return (NULL);
+ }
+ } else
+ /* If there isn't SUSP, disable parsing
+ * rock ridge extensions. */
+ iso9660->opt_support_rockridge = 0;
}
+ file->nlinks = 1;/* Reset nlink. we'll calculate it later. */
+ /* Tell file's parent how many children that parent has. */
+ if (parent != NULL && (flags & 0x02) && file->cl_offset == 0)
+ parent->subdirs++;
+
+#if DEBUG
/* DEBUGGING: Warn about attributes I don't yet fully support. */
if ((flags & ~0x02) != 0) {
fprintf(stderr, "\n ** Unrecognized flag: ");
@@ -583,46 +1886,23 @@ parse_file_info(struct iso9660 *iso9660, struct file_info *parent,
dump_isodirrec(stderr, isodirrec);
fprintf(stderr, "\n");
}
-
+#endif
+ register_file(iso9660, file);
return (file);
}
-static void
-add_entry(struct iso9660 *iso9660, struct file_info *file)
-{
- /* Expand our pending files list as necessary. */
- if (iso9660->pending_files_used >= iso9660->pending_files_allocated) {
- struct file_info **new_pending_files;
- int new_size = iso9660->pending_files_allocated * 2;
-
- if (iso9660->pending_files_allocated < 1024)
- new_size = 1024;
- /* Overflow might keep us from growing the list. */
- if (new_size <= iso9660->pending_files_allocated)
- __archive_errx(1, "Out of memory");
- new_pending_files = (struct file_info **)malloc(new_size * sizeof(new_pending_files[0]));
- if (new_pending_files == NULL)
- __archive_errx(1, "Out of memory");
- memcpy(new_pending_files, iso9660->pending_files,
- iso9660->pending_files_allocated * sizeof(new_pending_files[0]));
- if (iso9660->pending_files != NULL)
- free(iso9660->pending_files);
- iso9660->pending_files = new_pending_files;
- iso9660->pending_files_allocated = new_size;
- }
-
- iso9660->pending_files[iso9660->pending_files_used++] = file;
-}
-
-static void
-parse_rockridge(struct iso9660 *iso9660, struct file_info *file,
+static int
+parse_rockridge(struct archive_read *a, struct file_info *file,
const unsigned char *p, const unsigned char *end)
{
- (void)iso9660; /* UNUSED */
+ struct iso9660 *iso9660;
+
+ iso9660 = (struct iso9660 *)(a->format->data);
- while (p + 4 < end /* Enough space for another entry. */
+ while (p + 4 <= end /* Enough space for another entry. */
&& p[0] >= 'A' && p[0] <= 'Z' /* Sanity-check 1st char of name. */
&& p[1] >= 'A' && p[1] <= 'Z' /* Sanity-check 2nd char of name. */
+ && p[2] >= 4 /* Sanity-check length. */
&& p + p[2] <= end) { /* Sanity-check length. */
const unsigned char *data = p + 4;
int data_length = p[2] - 4;
@@ -635,61 +1915,64 @@ parse_rockridge(struct iso9660 *iso9660, struct file_info *file,
*/
switch(p[0]) {
case 'C':
- if (p[0] == 'C' && p[1] == 'E' && version == 1) {
- /*
- * CE extension comprises:
- * 8 byte sector containing extension
- * 8 byte offset w/in above sector
- * 8 byte length of continuation
- */
- file->ce_offset = toi(data, 4)
- * iso9660->logical_block_size
- + toi(data + 8, 4);
- file->ce_size = toi(data + 16, 4);
+ if (p[0] == 'C' && p[1] == 'E') {
+ if (version == 1 && data_length == 24) {
+ /*
+ * CE extension comprises:
+ * 8 byte sector containing extension
+ * 8 byte offset w/in above sector
+ * 8 byte length of continuation
+ */
+ int32_t location =
+ archive_le32dec(data);
+ file->ce_offset =
+ archive_le32dec(data+8);
+ file->ce_size =
+ archive_le32dec(data+16);
+ if (register_CE(a, location, file)
+ != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ }
+ break;
+ }
+ if (p[0] == 'C' && p[1] == 'L') {
+ if (version == 1 && data_length == 8) {
+ file->cl_offset = (uint64_t)
+ iso9660->logical_block_size *
+ (uint64_t)archive_le32dec(data);
+ iso9660->seenRockridge = 1;
+ }
break;
}
/* FALLTHROUGH */
case 'N':
- if (p[0] == 'N' && p[1] == 'M' && version == 1
- && *data == 0) {
- /* NM extension with flag byte == 0 */
- /*
- * NM extension comprises:
- * one byte flag
- * rest is long name
- */
- /* TODO: Obey flags. */
- char *old_name = file->name;
-
- data++; /* Skip flag byte. */
- data_length--;
- file->name = (char *)malloc(data_length + 1);
- if (file->name != NULL) {
- free(old_name);
- memcpy(file->name, data, data_length);
- file->name[data_length] = '\0';
- } else
- file->name = old_name;
+ if (p[0] == 'N' && p[1] == 'M') {
+ if (version == 1) {
+ parse_rockridge_NM1(file,
+ data, data_length);
+ iso9660->seenRockridge = 1;
+ }
break;
}
/* FALLTHROUGH */
case 'P':
- if (p[0] == 'P' && p[1] == 'D' && version == 1) {
+ if (p[0] == 'P' && p[1] == 'D') {
/*
* PD extension is padding;
* contents are always ignored.
*/
break;
}
- if (p[0] == 'P' && p[1] == 'N' && version == 1) {
- if (data_length == 16) {
+ if (p[0] == 'P' && p[1] == 'N') {
+ if (version == 1 && data_length == 16) {
file->rdev = toi(data,4);
file->rdev <<= 32;
file->rdev |= toi(data + 8, 4);
+ iso9660->seenRockridge = 1;
}
break;
}
- if (p[0] == 'P' && p[1] == 'X' && version == 1) {
+ if (p[0] == 'P' && p[1] == 'X') {
/*
* PX extension comprises:
* 8 bytes for mode,
@@ -698,99 +1981,52 @@ parse_rockridge(struct iso9660 *iso9660, struct file_info *file,
* 8 bytes for gid,
* 8 bytes for inode.
*/
- if (data_length == 32) {
- file->mode = toi(data, 4);
- file->nlinks = toi(data + 8, 4);
- file->uid = toi(data + 16, 4);
- file->gid = toi(data + 24, 4);
- file->inode = toi(data + 32, 4);
+ if (version == 1) {
+ if (data_length >= 8)
+ file->mode
+ = toi(data, 4);
+ if (data_length >= 16)
+ file->nlinks
+ = toi(data + 8, 4);
+ if (data_length >= 24)
+ file->uid
+ = toi(data + 16, 4);
+ if (data_length >= 32)
+ file->gid
+ = toi(data + 24, 4);
+ if (data_length >= 40)
+ file->number
+ = toi(data + 32, 4);
+ iso9660->seenRockridge = 1;
}
break;
}
/* FALLTHROUGH */
case 'R':
- if (p[0] == 'R' && p[1] == 'R' && version == 1) {
+ if (p[0] == 'R' && p[1] == 'E' && version == 1) {
+ file->re = 1;
iso9660->seenRockridge = 1;
+ break;
+ }
+ if (p[0] == 'R' && p[1] == 'R' && version == 1) {
/*
* RR extension comprises:
* one byte flag value
+ * This extension is obsolete,
+ * so contents are always ignored.
*/
- /* TODO: Handle RR extension. */
break;
}
/* FALLTHROUGH */
case 'S':
- if (p[0] == 'S' && p[1] == 'L' && version == 1
- && *data == 0) {
- int cont = 1;
- /* SL extension with flags == 0 */
- /* TODO: handle non-zero flag values. */
- data++; /* Skip flag byte. */
- data_length--;
- while (data_length > 0) {
- unsigned char flag = *data++;
- unsigned char nlen = *data++;
- data_length -= 2;
-
- if (cont == 0)
- archive_strcat(&file->symlink, "/");
- cont = 0;
-
- switch(flag) {
- case 0x01: /* Continue */
- archive_strncat(&file->symlink,
- (const char *)data, nlen);
- cont = 1;
- break;
- case 0x02: /* Current */
- archive_strcat(&file->symlink, ".");
- break;
- case 0x04: /* Parent */
- archive_strcat(&file->symlink, "..");
- break;
- case 0x08: /* Root */
- case 0x10: /* Volume root */
- archive_string_empty(&file->symlink);
- break;
- case 0x20: /* Hostname */
- archive_strcat(&file->symlink, "hostname");
- break;
- case 0:
- archive_strncat(&file->symlink,
- (const char *)data, nlen);
- break;
- default:
- /* TODO: issue a warning ? */
- break;
- }
- data += nlen;
- data_length -= nlen;
+ if (p[0] == 'S' && p[1] == 'L') {
+ if (version == 1) {
+ parse_rockridge_SL1(file,
+ data, data_length);
+ iso9660->seenRockridge = 1;
}
break;
}
- if (p[0] == 'S' && p[1] == 'P'
- && version == 1 && data_length == 7
- && data[0] == (unsigned char)'\xbe'
- && data[1] == (unsigned char)'\xef') {
- /*
- * SP extension stores the suspOffset
- * (Number of bytes to skip between
- * filename and SUSP records.)
- * It is mandatory by the SUSP standard
- * (IEEE 1281).
- *
- * It allows SUSP to coexist with
- * non-SUSP uses of the System
- * Use Area by placing non-SUSP data
- * before SUSP data.
- *
- * TODO: Add a check for 'SP' in
- * first directory entry, disable all SUSP
- * processing if not found.
- */
- iso9660->suspOffset = data[2];
- break;
- }
if (p[0] == 'S' && p[1] == 'T'
&& data_length == 0 && version == 1) {
/*
@@ -802,92 +2038,436 @@ parse_rockridge(struct iso9660 *iso9660, struct file_info *file,
* Use Area by placing non-SUSP data
* after SUSP data.
*/
- return;
+ iso9660->seenSUSP = 0;
+ iso9660->seenRockridge = 0;
+ return (ARCHIVE_OK);
}
case 'T':
- if (p[0] == 'T' && p[1] == 'F' && version == 1) {
- char flag = data[0];
- /*
- * TF extension comprises:
- * one byte flag
- * create time (optional)
- * modify time (optional)
- * access time (optional)
- * attribute time (optional)
- * Time format and presence of fields
- * is controlled by flag bits.
- */
- data++;
- if (flag & 0x80) {
- /* Use 17-byte time format. */
- if (flag & 1) /* Create time. */
- data += 17;
- if (flag & 2) { /* Modify time. */
- file->mtime = isodate17(data);
- data += 17;
- }
- if (flag & 4) { /* Access time. */
- file->atime = isodate17(data);
- data += 17;
- }
- if (flag & 8) { /* Attribute time. */
- file->ctime = isodate17(data);
- data += 17;
- }
- } else {
- /* Use 7-byte time format. */
- if (flag & 1) /* Create time. */
- data += 7;
- if (flag & 2) { /* Modify time. */
- file->mtime = isodate7(data);
- data += 7;
- }
- if (flag & 4) { /* Access time. */
- file->atime = isodate7(data);
- data += 7;
- }
- if (flag & 8) { /* Attribute time. */
- file->ctime = isodate7(data);
- data += 7;
- }
+ if (p[0] == 'T' && p[1] == 'F') {
+ if (version == 1) {
+ parse_rockridge_TF1(file,
+ data, data_length);
+ iso9660->seenRockridge = 1;
}
break;
}
/* FALLTHROUGH */
+ case 'Z':
+ if (p[0] == 'Z' && p[1] == 'F') {
+ if (version == 1)
+ parse_rockridge_ZF1(file,
+ data, data_length);
+ break;
+ }
+ /* FALLTHROUGH */
default:
/* The FALLTHROUGHs above leave us here for
* any unsupported extension. */
- {
- const unsigned char *t;
- fprintf(stderr, "\nUnsupported RRIP extension for %s\n", file->name);
- fprintf(stderr, " %c%c(%d):", p[0], p[1], data_length);
- for (t = data; t < data + data_length && t < data + 16; t++)
- fprintf(stderr, " %02x", *t);
- fprintf(stderr, "\n");
- }
+ break;
}
p += p[2];
}
+ return (ARCHIVE_OK);
+}
+
+static int
+register_CE(struct archive_read *a, int32_t location,
+ struct file_info *file)
+{
+ struct iso9660 *iso9660;
+ struct read_ce_queue *heap;
+ struct read_ce_req *p;
+ uint64_t offset, parent_offset;
+ int hole, parent;
+
+ iso9660 = (struct iso9660 *)(a->format->data);
+ offset = ((uint64_t)location) * (uint64_t)iso9660->logical_block_size;
+ if (((file->mode & AE_IFMT) == AE_IFREG &&
+ offset >= file->offset) ||
+ offset < iso9660->current_position) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Invalid location in SUSP \"CE\" extension");
+ return (ARCHIVE_FATAL);
+ }
+
+ /* Expand our CE list as necessary. */
+ heap = &(iso9660->read_ce_req);
+ if (heap->cnt >= heap->allocated) {
+ int new_size;
+
+ if (heap->allocated < 16)
+ new_size = 16;
+ else
+ new_size = heap->allocated * 2;
+ /* Overflow might keep us from growing the list. */
+ if (new_size <= heap->allocated)
+ __archive_errx(1, "Out of memory");
+ p = malloc(new_size * sizeof(p[0]));
+ if (p == NULL)
+ __archive_errx(1, "Out of memory");
+ if (heap->reqs != NULL) {
+ memcpy(p, heap->reqs, heap->cnt * sizeof(*p));
+ free(heap->reqs);
+ }
+ heap->reqs = p;
+ heap->allocated = new_size;
+ }
+
+ /*
+ * Start with hole at end, walk it up tree to find insertion point.
+ */
+ hole = heap->cnt++;
+ while (hole > 0) {
+ parent = (hole - 1)/2;
+ parent_offset = heap->reqs[parent].offset;
+ if (offset >= parent_offset) {
+ heap->reqs[hole].offset = offset;
+ heap->reqs[hole].file = file;
+ return (ARCHIVE_OK);
+ }
+ // Move parent into hole <==> move hole up tree.
+ heap->reqs[hole] = heap->reqs[parent];
+ hole = parent;
+ }
+ heap->reqs[0].offset = offset;
+ heap->reqs[0].file = file;
+ return (ARCHIVE_OK);
+}
+
+static void
+next_CE(struct read_ce_queue *heap)
+{
+ uint64_t a_offset, b_offset, c_offset;
+ int a, b, c;
+ struct read_ce_req tmp;
+
+ if (heap->cnt < 1)
+ return;
+
+ /*
+ * Move the last item in the heap to the root of the tree
+ */
+ heap->reqs[0] = heap->reqs[--(heap->cnt)];
+
+ /*
+ * Rebalance the heap.
+ */
+ a = 0; // Starting element and its offset
+ a_offset = heap->reqs[a].offset;
+ for (;;) {
+ b = a + a + 1; // First child
+ if (b >= heap->cnt)
+ return;
+ b_offset = heap->reqs[b].offset;
+ c = b + 1; // Use second child if it is smaller.
+ if (c < heap->cnt) {
+ c_offset = heap->reqs[c].offset;
+ if (c_offset < b_offset) {
+ b = c;
+ b_offset = c_offset;
+ }
+ }
+ if (a_offset <= b_offset)
+ return;
+ tmp = heap->reqs[a];
+ heap->reqs[a] = heap->reqs[b];
+ heap->reqs[b] = tmp;
+ a = b;
+ }
+}
+
+
+static int
+read_CE(struct archive_read *a, struct iso9660 *iso9660)
+{
+ struct read_ce_queue *heap;
+ const unsigned char *b, *p, *end;
+ struct file_info *file;
+ size_t step;
+ int r;
+
+ /* Read data which RRIP "CE" extension points. */
+ heap = &(iso9660->read_ce_req);
+ step = iso9660->logical_block_size;
+ while (heap->cnt &&
+ heap->reqs[0].offset == iso9660->current_position) {
+ b = __archive_read_ahead(a, step, NULL);
+ if (b == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to read full block when scanning "
+ "ISO9660 directory list");
+ return (ARCHIVE_FATAL);
+ }
+ do {
+ file = heap->reqs[0].file;
+ p = b + file->ce_offset;
+ end = p + file->ce_size;
+ next_CE(heap);
+ r = parse_rockridge(a, file, p, end);
+ if (r != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ } while (heap->cnt &&
+ heap->reqs[0].offset == iso9660->current_position);
+ /* NOTE: Do not move this consume's code to fron of
+ * do-while loop. Registration of nested CE extension
+ * might cause error because of current position. */
+ __archive_read_consume(a, step);
+ iso9660->current_position += step;
+ }
+ return (ARCHIVE_OK);
}
static void
-release_file(struct iso9660 *iso9660, struct file_info *file)
+parse_rockridge_NM1(struct file_info *file,
+ const unsigned char *data, int data_length)
{
- struct file_info *parent;
+ if (!file->name_continues)
+ archive_string_empty(&file->name);
+ file->name_continues = 0;
+ if (data_length < 1)
+ return;
+ /*
+ * NM version 1 extension comprises:
+ * 1 byte flag, value is one of:
+ * = 0: remainder is name
+ * = 1: remainder is name, next NM entry continues name
+ * = 2: "."
+ * = 4: ".."
+ * = 32: Implementation specific
+ * All other values are reserved.
+ */
+ switch(data[0]) {
+ case 0:
+ if (data_length < 2)
+ return;
+ archive_strncat(&file->name, (const char *)data + 1, data_length - 1);
+ break;
+ case 1:
+ if (data_length < 2)
+ return;
+ archive_strncat(&file->name, (const char *)data + 1, data_length - 1);
+ file->name_continues = 1;
+ break;
+ case 2:
+ archive_strcat(&file->name, ".");
+ break;
+ case 4:
+ archive_strcat(&file->name, "..");
+ break;
+ default:
+ return;
+ }
+
+}
- if (file->refcount == 0) {
- parent = file->parent;
- if (file->name)
- free(file->name);
+static void
+parse_rockridge_TF1(struct file_info *file, const unsigned char *data,
+ int data_length)
+{
+ char flag;
+ /*
+ * TF extension comprises:
+ * one byte flag
+ * create time (optional)
+ * modify time (optional)
+ * access time (optional)
+ * attribute time (optional)
+ * Time format and presence of fields
+ * is controlled by flag bits.
+ */
+ if (data_length < 1)
+ return;
+ flag = data[0];
+ ++data;
+ --data_length;
+ if (flag & 0x80) {
+ /* Use 17-byte time format. */
+ if ((flag & 1) && data_length >= 17) {
+ /* Create time. */
+ file->birthtime_is_set = 1;
+ file->birthtime = isodate17(data);
+ data += 17;
+ data_length -= 17;
+ }
+ if ((flag & 2) && data_length >= 17) {
+ /* Modify time. */
+ file->mtime = isodate17(data);
+ data += 17;
+ data_length -= 17;
+ }
+ if ((flag & 4) && data_length >= 17) {
+ /* Access time. */
+ file->atime = isodate17(data);
+ data += 17;
+ data_length -= 17;
+ }
+ if ((flag & 8) && data_length >= 17) {
+ /* Attribute change time. */
+ file->ctime = isodate17(data);
+ }
+ } else {
+ /* Use 7-byte time format. */
+ if ((flag & 1) && data_length >= 7) {
+ /* Create time. */
+ file->birthtime_is_set = 1;
+ file->birthtime = isodate7(data);
+ data += 7;
+ data_length -= 7;
+ }
+ if ((flag & 2) && data_length >= 7) {
+ /* Modify time. */
+ file->mtime = isodate7(data);
+ data += 7;
+ data_length -= 7;
+ }
+ if ((flag & 4) && data_length >= 7) {
+ /* Access time. */
+ file->atime = isodate7(data);
+ data += 7;
+ data_length -= 7;
+ }
+ if ((flag & 8) && data_length >= 7) {
+ /* Attribute change time. */
+ file->ctime = isodate7(data);
+ }
+ }
+}
+
+static void
+parse_rockridge_SL1(struct file_info *file, const unsigned char *data,
+ int data_length)
+{
+ const char *separator = "";
+
+ if (!file->symlink_continues || file->symlink.length < 1)
+ archive_string_empty(&file->symlink);
+ else if (!file->symlink_continues &&
+ file->symlink.s[file->symlink.length - 1] != '/')
+ separator = "/";
+ file->symlink_continues = 0;
+
+ /*
+ * Defined flag values:
+ * 0: This is the last SL record for this symbolic link
+ * 1: this symbolic link field continues in next SL entry
+ * All other values are reserved.
+ */
+ if (data_length < 1)
+ return;
+ switch(*data) {
+ case 0:
+ break;
+ case 1:
+ file->symlink_continues = 1;
+ break;
+ default:
+ return;
+ }
+ ++data; /* Skip flag byte. */
+ --data_length;
+
+ /*
+ * SL extension body stores "components".
+ * Basically, this is a complicated way of storing
+ * a POSIX path. It also interferes with using
+ * symlinks for storing non-path data. <sigh>
+ *
+ * Each component is 2 bytes (flag and length)
+ * possibly followed by name data.
+ */
+ while (data_length >= 2) {
+ unsigned char flag = *data++;
+ unsigned char nlen = *data++;
+ data_length -= 2;
+
+ archive_strcat(&file->symlink, separator);
+ separator = "/";
+
+ switch(flag) {
+ case 0: /* Usual case, this is text. */
+ if (data_length < nlen)
+ return;
+ archive_strncat(&file->symlink,
+ (const char *)data, nlen);
+ break;
+ case 0x01: /* Text continues in next component. */
+ if (data_length < nlen)
+ return;
+ archive_strncat(&file->symlink,
+ (const char *)data, nlen);
+ separator = "";
+ break;
+ case 0x02: /* Current dir. */
+ archive_strcat(&file->symlink, ".");
+ break;
+ case 0x04: /* Parent dir. */
+ archive_strcat(&file->symlink, "..");
+ break;
+ case 0x08: /* Root of filesystem. */
+ archive_strcat(&file->symlink, "/");
+ separator = "";
+ break;
+ case 0x10: /* Undefined (historically "volume root" */
+ archive_string_empty(&file->symlink);
+ archive_strcat(&file->symlink, "ROOT");
+ break;
+ case 0x20: /* Undefined (historically "hostname") */
+ archive_strcat(&file->symlink, "hostname");
+ break;
+ default:
+ /* TODO: issue a warning ? */
+ return;
+ }
+ data += nlen;
+ data_length -= nlen;
+ }
+}
+
+static void
+parse_rockridge_ZF1(struct file_info *file, const unsigned char *data,
+ int data_length)
+{
+
+ if (data[0] == 0x70 && data[1] == 0x7a && data_length == 12) {
+ /* paged zlib */
+ file->pz = 1;
+ file->pz_log2_bs = data[3];
+ file->pz_uncompressed_size = archive_le32dec(&data[4]);
+ }
+}
+
+static void
+register_file(struct iso9660 *iso9660, struct file_info *file)
+{
+
+ file->use_next = iso9660->use_files;
+ iso9660->use_files = file;
+}
+
+static void
+release_files(struct iso9660 *iso9660)
+{
+ struct content *con, *connext;
+ struct file_info *file;
+
+ file = iso9660->use_files;
+ while (file != NULL) {
+ struct file_info *next = file->use_next;
+
+ archive_string_free(&file->name);
archive_string_free(&file->symlink);
- free(file);
- if (parent != NULL) {
- parent->refcount--;
- release_file(iso9660, parent);
+ con = file->contents.first;
+ while (con != NULL) {
+ connext = con->next;
+ free(con);
+ con = connext;
}
+ free(file);
+ file = next;
}
}
@@ -896,102 +2476,242 @@ next_entry_seek(struct archive_read *a, struct iso9660 *iso9660,
struct file_info **pfile)
{
struct file_info *file;
- uint64_t offset;
- *pfile = NULL;
- for (;;) {
- *pfile = file = next_entry(iso9660);
- if (file == NULL)
- return (ARCHIVE_EOF);
+ *pfile = file = next_cache_entry(iso9660);
+ if (file == NULL)
+ return (ARCHIVE_EOF);
- /* CE area precedes actual file data? Ignore it. */
- if (file->ce_offset > file->offset) {
-fprintf(stderr, " *** Discarding CE data.\n");
- file->ce_offset = 0;
- file->ce_size = 0;
- }
+ /* Don't waste time seeking for zero-length bodies. */
+ if (file->size == 0)
+ file->offset = iso9660->current_position;
+
+ /* Seek forward to the start of the entry. */
+ if (iso9660->current_position < file->offset) {
+ int64_t step;
+
+ step = file->offset - iso9660->current_position;
+ step = __archive_read_skip(a, step);
+ if (step < 0)
+ return ((int)step);
+ iso9660->current_position = file->offset;
+ }
+
+ /* We found body of file; handle it now. */
+ return (ARCHIVE_OK);
+}
- /* Don't waste time seeking for zero-length bodies. */
- if (file->size == 0) {
- file->offset = iso9660->current_position;
+static struct file_info *
+next_cache_entry(struct iso9660 *iso9660)
+{
+ struct file_info *file;
+ struct {
+ struct file_info *first;
+ struct file_info **last;
+ } empty_files;
+ int64_t number;
+ int count;
+
+ file = cache_get_entry(iso9660);
+ if (file != NULL) {
+ while (file->parent != NULL && !file->parent->exposed) {
+ /* If file's parent is not exposed, it's moved
+ * to next entry of its parent. */
+ cache_add_to_next_of_parent(iso9660, file);
+ file = cache_get_entry(iso9660);
}
+ return (file);
+ }
- /* If CE exists, find and read it now. */
- if (file->ce_offset > 0)
- offset = file->ce_offset;
- else
- offset = file->offset;
+ file = next_entry(iso9660);
+ if (file == NULL)
+ return (NULL);
- /* Seek forward to the start of the entry. */
- if (iso9660->current_position < offset) {
- off_t step = offset - iso9660->current_position;
- off_t bytes_read;
- bytes_read = (a->decompressor->skip)(a, step);
- if (bytes_read < 0)
- return (bytes_read);
- iso9660->current_position = offset;
+ if ((file->mode & AE_IFMT) != AE_IFREG || file->number == -1)
+ return (file);
+
+ count = 0;
+ number = file->number;
+ iso9660->cache_files.first = NULL;
+ iso9660->cache_files.last = &(iso9660->cache_files.first);
+ empty_files.first = NULL;
+ empty_files.last = &empty_files.first;
+ /* Collect files which has the same file serial number.
+ * Peek pending_files so that file which number is different
+ * is not put bak. */
+ while (iso9660->pending_files.used > 0 &&
+ (iso9660->pending_files.files[0]->number == -1 ||
+ iso9660->pending_files.files[0]->number == number)) {
+ if (file->number == -1) {
+ /* This file has the same offset
+ * but it's wrong offset which empty files
+ * and symlink files have.
+ * NOTE: This wrong offse was recorded by
+ * old mkisofs utility. If ISO images is
+ * created by latest mkisofs, this does not
+ * happen.
+ */
+ file->next = NULL;
+ *empty_files.last = file;
+ empty_files.last = &(file->next);
+ } else {
+ count++;
+ cache_add_entry(iso9660, file);
}
+ file = next_entry(iso9660);
+ }
- /* We found body of file; handle it now. */
- if (offset == file->offset)
- return (ARCHIVE_OK);
+ if (count == 0)
+ return (file);
+ if (file->number == -1) {
+ file->next = NULL;
+ *empty_files.last = file;
+ empty_files.last = &(file->next);
+ } else {
+ count++;
+ cache_add_entry(iso9660, file);
+ }
+
+ if (count > 1) {
+ /* The count is the same as number of hardlink,
+ * so much so that each nlinks of files in cache_file
+ * is overwritten by value of the count.
+ */
+ for (file = iso9660->cache_files.first;
+ file != NULL; file = file->next)
+ file->nlinks = count;
+ }
+ /* If there are empty files, that files are added
+ * to the tail of the cache_files. */
+ if (empty_files.first != NULL) {
+ *iso9660->cache_files.last = empty_files.first;
+ iso9660->cache_files.last = empty_files.last;
+ }
+ return (cache_get_entry(iso9660));
+}
+
+static inline void
+cache_add_entry(struct iso9660 *iso9660, struct file_info *file)
+{
+ file->next = NULL;
+ *iso9660->cache_files.last = file;
+ iso9660->cache_files.last = &(file->next);
+}
+
+static inline void
+cache_add_to_next_of_parent(struct iso9660 *iso9660, struct file_info *file)
+{
+ file->next = file->parent->next;
+ file->parent->next = file;
+ if (iso9660->cache_files.last == &(file->parent->next))
+ iso9660->cache_files.last = &(file->next);
+}
+
+static inline struct file_info *
+cache_get_entry(struct iso9660 *iso9660)
+{
+ struct file_info *file;
+
+ if ((file = iso9660->cache_files.first) != NULL) {
+ iso9660->cache_files.first = file->next;
+ if (iso9660->cache_files.first == NULL)
+ iso9660->cache_files.last = &(iso9660->cache_files.first);
+ }
+ return (file);
+}
+
+static void
+heap_add_entry(struct heap_queue *heap, struct file_info *file, uint64_t key)
+{
+ uint64_t file_key, parent_key;
+ int hole, parent;
+
+ /* Expand our pending files list as necessary. */
+ if (heap->used >= heap->allocated) {
+ struct file_info **new_pending_files;
+ int new_size = heap->allocated * 2;
+
+ if (heap->allocated < 1024)
+ new_size = 1024;
+ /* Overflow might keep us from growing the list. */
+ if (new_size <= heap->allocated)
+ __archive_errx(1, "Out of memory");
+ new_pending_files = (struct file_info **)
+ malloc(new_size * sizeof(new_pending_files[0]));
+ if (new_pending_files == NULL)
+ __archive_errx(1, "Out of memory");
+ memcpy(new_pending_files, heap->files,
+ heap->allocated * sizeof(new_pending_files[0]));
+ if (heap->files != NULL)
+ free(heap->files);
+ heap->files = new_pending_files;
+ heap->allocated = new_size;
+ }
+
+ file_key = file->key = key;
- /* Found CE? Process it and push the file back onto list. */
- if (offset == file->ce_offset) {
- const void *p;
- ssize_t size = file->ce_size;
- ssize_t bytes_read;
- const unsigned char *rr_start;
-
- file->ce_offset = 0;
- file->ce_size = 0;
- bytes_read = (a->decompressor->read_ahead)(a, &p, size);
- if (bytes_read > size)
- bytes_read = size;
- rr_start = (const unsigned char *)p;
- parse_rockridge(iso9660, file, rr_start,
- rr_start + bytes_read);
- (a->decompressor->consume)(a, bytes_read);
- iso9660->current_position += bytes_read;
- add_entry(iso9660, file);
+ /*
+ * Start with hole at end, walk it up tree to find insertion point.
+ */
+ hole = heap->used++;
+ while (hole > 0) {
+ parent = (hole - 1)/2;
+ parent_key = heap->files[parent]->key;
+ if (file_key >= parent_key) {
+ heap->files[hole] = file;
+ return;
}
+ // Move parent into hole <==> move hole up tree.
+ heap->files[hole] = heap->files[parent];
+ hole = parent;
}
+ heap->files[0] = file;
}
static struct file_info *
-next_entry(struct iso9660 *iso9660)
+heap_get_entry(struct heap_queue *heap)
{
- int least_index;
- uint64_t least_end_offset;
- int i;
- struct file_info *r;
+ uint64_t a_key, b_key, c_key;
+ int a, b, c;
+ struct file_info *r, *tmp;
- if (iso9660->pending_files_used < 1)
+ if (heap->used < 1)
return (NULL);
- /* Assume the first file in the list is the earliest on disk. */
- least_index = 0;
- least_end_offset = iso9660->pending_files[0]->offset
- + iso9660->pending_files[0]->size;
-
- /* Now, try to find an earlier one. */
- for (i = 0; i < iso9660->pending_files_used; i++) {
- /* Use the position of the file *end* as our comparison. */
- uint64_t end_offset = iso9660->pending_files[i]->offset
- + iso9660->pending_files[i]->size;
- if (iso9660->pending_files[i]->ce_offset > 0
- && iso9660->pending_files[i]->ce_offset < iso9660->pending_files[i]->offset)
- end_offset = iso9660->pending_files[i]->ce_offset
- + iso9660->pending_files[i]->ce_size;
- if (least_end_offset > end_offset) {
- least_index = i;
- least_end_offset = end_offset;
+ /*
+ * The first file in the list is the earliest; we'll return this.
+ */
+ r = heap->files[0];
+
+ /*
+ * Move the last item in the heap to the root of the tree
+ */
+ heap->files[0] = heap->files[--(heap->used)];
+
+ /*
+ * Rebalance the heap.
+ */
+ a = 0; // Starting element and its heap key
+ a_key = heap->files[a]->key;
+ for (;;) {
+ b = a + a + 1; // First child
+ if (b >= heap->used)
+ return (r);
+ b_key = heap->files[b]->key;
+ c = b + 1; // Use second child if it is smaller.
+ if (c < heap->used) {
+ c_key = heap->files[c]->key;
+ if (c_key < b_key) {
+ b = c;
+ b_key = c_key;
+ }
}
+ if (a_key <= b_key)
+ return (r);
+ tmp = heap->files[a];
+ heap->files[a] = heap->files[b];
+ heap->files[b] = tmp;
+ a = b;
}
- r = iso9660->pending_files[least_index];
- iso9660->pending_files[least_index]
- = iso9660->pending_files[--iso9660->pending_files_used];
- return (r);
}
static unsigned int
@@ -1071,17 +2791,18 @@ time_from_tm(struct tm *t)
static const char *
build_pathname(struct archive_string *as, struct file_info *file)
{
- if (file->parent != NULL && file->parent->name[0] != '\0') {
+ if (file->parent != NULL && archive_strlen(&file->parent->name) > 0) {
build_pathname(as, file->parent);
archive_strcat(as, "/");
}
- if (file->name[0] == '\0')
+ if (archive_strlen(&file->name) == 0)
archive_strcat(as, ".");
else
- archive_strcat(as, file->name);
+ archive_string_concat(as, &file->name);
return (as->s);
}
+#if DEBUG
static void
dump_isodirrec(FILE *out, const unsigned char *isodirrec)
{
@@ -1106,3 +2827,4 @@ dump_isodirrec(FILE *out, const unsigned char *isodirrec)
fprintf(out, " `%.*s'",
toi(isodirrec + DR_name_len_offset, DR_name_len_size), isodirrec + DR_name_offset);
}
+#endif
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c b/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c
index 33597e0de6b..f83ebe53339 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.9 2008/06/21 19:06:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_mtree.c 201165 2009-12-29 05:52:13Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -148,8 +148,8 @@ archive_read_support_format_mtree(struct archive *_a)
memset(mtree, 0, sizeof(*mtree));
mtree->fd = -1;
- r = __archive_read_register_format(a, mtree,
- mtree_bid, read_header, read_data, skip, cleanup);
+ r = __archive_read_register_format(a, mtree, "mtree",
+ mtree_bid, NULL, read_header, read_data, skip, cleanup);
if (r != ARCHIVE_OK)
free(mtree);
@@ -187,32 +187,17 @@ cleanup(struct archive_read *a)
static int
mtree_bid(struct archive_read *a)
{
- struct mtree *mtree;
- ssize_t bytes_read;
- const void *h;
const char *signature = "#mtree";
const char *p;
- int bid;
-
- mtree = (struct mtree *)(a->format->data);
/* Now let's look at the actual header and see if it matches. */
- bytes_read = (a->decompressor->read_ahead)(a, &h, strlen(signature));
-
- if (bytes_read <= 0)
- return (bytes_read);
-
- p = h;
- bid = 0;
- while (bytes_read > 0 && *signature != '\0') {
- if (*p != *signature)
- return (bid = 0);
- bid += 8;
- p++;
- signature++;
- bytes_read--;
- }
- return (bid);
+ p = __archive_read_ahead(a, strlen(signature), NULL);
+ if (p == NULL)
+ return (-1);
+
+ if (strncmp(p, signature, strlen(signature)) == 0)
+ return (8 * (int)strlen(signature));
+ return (0);
}
/*
@@ -408,21 +393,23 @@ read_mtree(struct archive_read *a, struct mtree *mtree)
struct mtree_entry *last_entry;
int r;
- mtree->archive_format = ARCHIVE_FORMAT_MTREE_V1;
+ mtree->archive_format = ARCHIVE_FORMAT_MTREE;
mtree->archive_format_name = "mtree";
global = NULL;
last_entry = NULL;
- r = ARCHIVE_OK;
for (counter = 1; ; ++counter) {
len = readline(a, mtree, &p, 256);
if (len == 0) {
mtree->this_entry = mtree->entries;
+ free_options(global);
return (ARCHIVE_OK);
}
- if (len < 0)
+ if (len < 0) {
+ free_options(global);
return (len);
+ }
/* Leading whitespace is never significant, ignore it. */
while (*p == ' ' || *p == '\t') {
++p;
@@ -447,13 +434,16 @@ read_mtree(struct archive_read *a, struct mtree *mtree)
} else
break;
- if (r != ARCHIVE_OK)
+ if (r != ARCHIVE_OK) {
+ free_options(global);
return r;
+ }
}
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Can't parse line %ju", counter);
- return ARCHIVE_FATAL;
+ free_options(global);
+ return (ARCHIVE_FATAL);
}
/*
@@ -597,8 +587,7 @@ parse_file(struct archive_read *a, struct archive_entry *entry,
if (archive_entry_filetype(entry) == AE_IFREG ||
archive_entry_filetype(entry) == AE_IFDIR) {
- mtree->fd = open(path,
- O_RDONLY | O_BINARY);
+ mtree->fd = open(path, O_RDONLY | O_BINARY);
if (mtree->fd == -1 &&
(errno != ENOENT ||
archive_strlen(&mtree->contents_name) > 0)) {
@@ -687,6 +676,15 @@ parse_file(struct archive_read *a, struct archive_entry *entry,
#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
archive_entry_set_mtime(entry, st->st_mtime,
st->st_mtim.tv_nsec);
+#elif HAVE_STRUCT_STAT_ST_MTIME_N
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_mtime_n);
+#elif HAVE_STRUCT_STAT_ST_UMTIME
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_umtime*1000);
+#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_mtime_usec*1000);
#else
archive_entry_set_mtime(entry, st->st_mtime, 0);
#endif
@@ -897,8 +895,17 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
break;
}
if (strcmp(key, "time") == 0) {
+ time_t m;
+ long ns;
+
*parsed_kws |= MTREE_HAS_MTIME;
- archive_entry_set_mtime(entry, mtree_atol10(&val), 0);
+ m = (time_t)mtree_atol10(&val);
+ if (*val == '.') {
+ ++val;
+ ns = (long)mtree_atol10(&val);
+ } else
+ ns = 0;
+ archive_entry_set_mtime(entry, m, ns);
break;
}
if (strcmp(key, "type") == 0) {
@@ -981,8 +988,8 @@ read_data(struct archive_read *a, const void **buff, size_t *size, off_t *offset
if (mtree->buff == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory");
+ return (ARCHIVE_FATAL);
}
- return (ARCHIVE_FATAL);
}
*buff = mtree->buff;
@@ -1029,11 +1036,7 @@ parse_escapes(char *src, struct mtree_entry *mentry)
char *dest = src;
char c;
- /*
- * The current directory is somewhat special, it should be archived
- * only once as it will confuse extraction otherwise.
- */
- if (strcmp(src, ".") == 0)
+ if (mentry != NULL && strcmp(src, ".") == 0)
mentry->full = 1;
while (*src != '\0') {
@@ -1152,7 +1155,7 @@ mtree_atol10(char **p)
digit = **p - '0';
while (digit >= 0 && digit < base) {
if (l > limit || (l == limit && digit > last_digit_limit)) {
- l = UINT64_MAX; /* Truncate on overflow. */
+ l = INT64_MAX; /* Truncate on overflow. */
break;
}
l = (l * base) + digit;
@@ -1193,7 +1196,7 @@ mtree_atol16(char **p)
digit = -1;
while (digit >= 0 && digit < base) {
if (l > limit || (l == limit && digit > last_digit_limit)) {
- l = UINT64_MAX; /* Truncate on overflow. */
+ l = INT64_MAX; /* Truncate on overflow. */
break;
}
l = (l * base) + digit;
@@ -1231,6 +1234,7 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi
{
ssize_t bytes_read;
ssize_t total_size = 0;
+ ssize_t find_off = 0;
const void *t;
const char *s;
void *p;
@@ -1239,8 +1243,8 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi
/* Accumulate line in a line buffer. */
for (;;) {
/* Read some more. */
- bytes_read = (a->decompressor->read_ahead)(a, &t, 1);
- if (bytes_read == 0)
+ t = __archive_read_ahead(a, 1, &bytes_read);
+ if (t == NULL)
return (0);
if (bytes_read < 0)
return (ARCHIVE_FATAL);
@@ -1263,14 +1267,12 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi
return (ARCHIVE_FATAL);
}
memcpy(mtree->line.s + total_size, t, bytes_read);
- (a->decompressor->consume)(a, bytes_read);
+ __archive_read_consume(a, bytes_read);
total_size += bytes_read;
/* Null terminate. */
mtree->line.s[total_size] = '\0';
/* If we found an unescaped '\n', clean up and return. */
- if (p == NULL)
- continue;
- for (u = mtree->line.s; *u; ++u) {
+ for (u = mtree->line.s + find_off; *u; ++u) {
if (u[0] == '\n') {
*start = mtree->line.s;
return total_size;
@@ -1291,8 +1293,12 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi
memmove(u, u + 1,
total_size - (u - mtree->line.s) + 1);
--total_size;
- continue;
+ ++u;
+ break;
}
+ if (u[1] == '\0')
+ break;
}
+ find_off = u - mtree->line.s;
}
}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_raw.c b/archivers/libarchive/files/libarchive/archive_read_support_format_raw.c
new file mode 100644
index 00000000000..7a8481bf221
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_raw.c
@@ -0,0 +1,185 @@
+/*-
+ * Copyright (c) 2003-2009 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 "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_raw.c 201107 2009-12-28 03:25:33Z kientzle $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+struct raw_info {
+ int64_t offset; /* Current position in the file. */
+ int end_of_file;
+};
+
+static int archive_read_format_raw_bid(struct archive_read *);
+static int archive_read_format_raw_cleanup(struct archive_read *);
+static int archive_read_format_raw_read_data(struct archive_read *,
+ const void **, size_t *, off_t *);
+static int archive_read_format_raw_read_data_skip(struct archive_read *);
+static int archive_read_format_raw_read_header(struct archive_read *,
+ struct archive_entry *);
+
+int
+archive_read_support_format_raw(struct archive *_a)
+{
+ struct raw_info *info;
+ struct archive_read *a = (struct archive_read *)_a;
+ int r;
+
+ info = (struct raw_info *)calloc(1, sizeof(*info));
+ if (info == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate raw_info data");
+ return (ARCHIVE_FATAL);
+ }
+
+ r = __archive_read_register_format(a,
+ info,
+ "raw",
+ archive_read_format_raw_bid,
+ NULL,
+ archive_read_format_raw_read_header,
+ archive_read_format_raw_read_data,
+ archive_read_format_raw_read_data_skip,
+ archive_read_format_raw_cleanup);
+ if (r != ARCHIVE_OK)
+ free(info);
+ return (r);
+}
+
+/*
+ * Bid 1 if this is a non-empty file. Anyone who can really support
+ * this should outbid us, so it should generally be safe to use "raw"
+ * in conjunction with other formats. But, this could really confuse
+ * folks if there are bid errors or minor file damage, so we don't
+ * include "raw" as part of support_format_all().
+ */
+static int
+archive_read_format_raw_bid(struct archive_read *a)
+{
+
+ if (__archive_read_ahead(a, 1, NULL) == NULL)
+ return (-1);
+ return (1);
+}
+
+/*
+ * Mock up a fake header.
+ */
+static int
+archive_read_format_raw_read_header(struct archive_read *a,
+ struct archive_entry *entry)
+{
+ struct raw_info *info;
+
+ info = (struct raw_info *)(a->format->data);
+ if (info->end_of_file)
+ return (ARCHIVE_EOF);
+
+ a->archive.archive_format = ARCHIVE_FORMAT_RAW;
+ a->archive.archive_format_name = "Raw data";
+ archive_entry_set_pathname(entry, "data");
+ /* XXX should we set mode to mimic a regular file? XXX */
+ /* I'm deliberately leaving most fields unset here. */
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_read_format_raw_read_data(struct archive_read *a,
+ const void **buff, size_t *size, off_t *offset)
+{
+ struct raw_info *info;
+ ssize_t avail;
+
+ info = (struct raw_info *)(a->format->data);
+ if (info->end_of_file)
+ return (ARCHIVE_EOF);
+
+ /* Get whatever bytes are immediately available. */
+ *buff = __archive_read_ahead(a, 1, &avail);
+ if (avail > 0) {
+ /* Consume and return the bytes we just read */
+ __archive_read_consume(a, avail);
+ *size = avail;
+ *offset = info->offset;
+ info->offset += *size;
+ return (ARCHIVE_OK);
+ } else if (0 == avail) {
+ /* Record and return end-of-file. */
+ info->end_of_file = 1;
+ *size = 0;
+ *offset = info->offset;
+ return (ARCHIVE_EOF);
+ } else {
+ /* Record and return an error. */
+ *size = 0;
+ *offset = info->offset;
+ return (avail);
+ }
+}
+
+static int
+archive_read_format_raw_read_data_skip(struct archive_read *a)
+{
+ struct raw_info *info;
+ off_t bytes_skipped;
+ int64_t request = 1024 * 1024 * 1024UL; /* Skip 1 GB at a time. */
+
+ info = (struct raw_info *)(a->format->data);
+ if (info->end_of_file)
+ return (ARCHIVE_EOF);
+ info->end_of_file = 1;
+
+ for (;;) {
+ bytes_skipped = __archive_read_skip_lenient(a, request);
+ if (bytes_skipped < 0)
+ return (ARCHIVE_FATAL);
+ if (bytes_skipped < request)
+ return (ARCHIVE_OK);
+ /* We skipped all the bytes we asked for. There might
+ * be more, so try again. */
+ }
+}
+
+static int
+archive_read_format_raw_cleanup(struct archive_read *a)
+{
+ struct raw_info *info;
+
+ info = (struct raw_info *)(a->format->data);
+ free(info);
+ a->format->data = NULL;
+ return (ARCHIVE_OK);
+}
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
index 0c2f0077c1e..dae13dc6e00 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_tar.c,v 1.69 2008/05/27 04:46:12 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_tar.c 201161 2009-12-29 05:44:39Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -159,10 +159,10 @@ struct tar {
wchar_t *pax_entry;
size_t pax_entry_length;
int header_recursion_depth;
- off_t entry_bytes_remaining;
- off_t entry_offset;
- off_t entry_padding;
- off_t realsize;
+ int64_t entry_bytes_remaining;
+ int64_t entry_offset;
+ int64_t entry_padding;
+ int64_t realsize;
struct sparse_block *sparse_list;
struct sparse_block *sparse_last;
int64_t sparse_offset;
@@ -253,8 +253,9 @@ archive_read_support_format_tar(struct archive *_a)
}
memset(tar, 0, sizeof(*tar));
- r = __archive_read_register_format(a, tar,
+ r = __archive_read_register_format(a, tar, "tar",
archive_read_format_tar_bid,
+ NULL,
archive_read_format_tar_read_header,
archive_read_format_tar_read_data,
archive_read_format_tar_skip,
@@ -294,21 +295,15 @@ static int
archive_read_format_tar_bid(struct archive_read *a)
{
int bid;
- ssize_t bytes_read;
const void *h;
const struct archive_entry_header_ustar *header;
bid = 0;
/* Now let's look at the actual header and see if it matches. */
- if (a->decompressor->read_ahead != NULL)
- bytes_read = (a->decompressor->read_ahead)(a, &h, 512);
- else
- bytes_read = 0; /* Empty file. */
- if (bytes_read < 0)
- return (ARCHIVE_FATAL);
- if (bytes_read < 512)
- return (0);
+ h = __archive_read_ahead(a, 512, NULL);
+ if (h == NULL)
+ return (-1);
/* If it's an end-of-archive mark, we can handle it. */
if ((*(const char *)h) == 0
@@ -479,7 +474,7 @@ archive_read_format_tar_read_data(struct archive_read *a,
/* If we're at end of file, return EOF. */
if (tar->sparse_list == NULL || tar->entry_bytes_remaining == 0) {
- if ((a->decompressor->skip)(a, tar->entry_padding) < 0)
+ if (__archive_read_skip(a, tar->entry_padding) < 0)
return (ARCHIVE_FATAL);
tar->entry_padding = 0;
*buff = NULL;
@@ -488,14 +483,14 @@ archive_read_format_tar_read_data(struct archive_read *a,
return (ARCHIVE_EOF);
}
- bytes_read = (a->decompressor->read_ahead)(a, buff, 1);
- if (bytes_read == 0) {
+ *buff = __archive_read_ahead(a, 1, &bytes_read);
+ if (bytes_read < 0)
+ return (ARCHIVE_FATAL);
+ if (*buff == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Truncated tar archive");
return (ARCHIVE_FATAL);
}
- if (bytes_read < 0)
- return (ARCHIVE_FATAL);
if (bytes_read > tar->entry_bytes_remaining)
bytes_read = tar->entry_bytes_remaining;
/* Don't read more than is available in the
@@ -507,14 +502,14 @@ archive_read_format_tar_read_data(struct archive_read *a,
tar->sparse_list->remaining -= bytes_read;
tar->sparse_list->offset += bytes_read;
tar->entry_bytes_remaining -= bytes_read;
- (a->decompressor->consume)(a, bytes_read);
+ __archive_read_consume(a, bytes_read);
return (ARCHIVE_OK);
}
static int
archive_read_format_tar_skip(struct archive_read *a)
{
- off_t bytes_skipped;
+ int64_t bytes_skipped;
struct tar* tar;
tar = (struct tar *)(a->format->data);
@@ -524,8 +519,8 @@ archive_read_format_tar_skip(struct archive_read *a)
* length requested or fail, so we can rely upon the entire entry
* plus padding being skipped.
*/
- bytes_skipped = (a->decompressor->skip)(a, tar->entry_bytes_remaining +
- tar->entry_padding);
+ bytes_skipped = __archive_read_skip(a,
+ tar->entry_bytes_remaining + tar->entry_padding);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
@@ -552,31 +547,35 @@ tar_read_header(struct archive_read *a, struct tar *tar,
const struct archive_entry_header_ustar *header;
/* Read 512-byte header record */
- bytes = (a->decompressor->read_ahead)(a, &h, 512);
+ h = __archive_read_ahead(a, 512, &bytes);
if (bytes < 0)
return (bytes);
- if (bytes == 0) {
- /*
- * An archive that just ends without a proper
- * end-of-archive marker. Yes, there are tar programs
- * that do this; hold our nose and accept it.
- */
- return (ARCHIVE_EOF);
- }
- if (bytes < 512) {
+ if (bytes < 512) { /* Short read or EOF. */
+ /* Try requesting just one byte and see what happens. */
+ (void)__archive_read_ahead(a, 1, &bytes);
+ if (bytes == 0) {
+ /*
+ * The archive ends at a 512-byte boundary but
+ * without a proper end-of-archive marker.
+ * Yes, there are tar writers that do this;
+ * hold our nose and accept it.
+ */
+ return (ARCHIVE_EOF);
+ }
+ /* Archive ends with a partial block; this is bad. */
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated tar archive");
return (ARCHIVE_FATAL);
}
- (a->decompressor->consume)(a, 512);
+ __archive_read_consume(a, 512);
/* Check for end-of-archive mark. */
if (((*(const char *)h)==0) && archive_block_is_null((const unsigned char *)h)) {
/* Try to consume a second all-null record, as well. */
- bytes = (a->decompressor->read_ahead)(a, &h, 512);
- if (bytes > 0)
- (a->decompressor->consume)(a, bytes);
+ h = __archive_read_ahead(a, 512, NULL);
+ if (h != NULL)
+ __archive_read_consume(a, 512);
archive_set_error(&a->archive, 0, NULL);
if (a->archive.archive_format_name == NULL) {
a->archive.archive_format = ARCHIVE_FORMAT_TAR;
@@ -733,6 +732,7 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
const struct archive_entry_header_ustar *header;
size_t size;
int err;
+ int64_t type;
char *acl, *p;
wchar_t *wp;
@@ -745,24 +745,57 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
err = read_body_to_string(a, tar, &(tar->acl_text), h);
if (err != ARCHIVE_OK)
return (err);
+ /* Recursively read next header */
err = tar_read_header(a, tar, entry);
if ((err != ARCHIVE_OK) && (err != ARCHIVE_WARN))
return (err);
- /* Skip leading octal number. */
- /* XXX TODO: Parse the octal number and sanity-check it. */
+ /* TODO: Examine the first characters to see if this
+ * is an AIX ACL descriptor. We'll likely never support
+ * them, but it would be polite to recognize and warn when
+ * we do see them. */
+
+ /* Leading octal number indicates ACL type and number of entries. */
p = acl = tar->acl_text.s;
- while (*p != '\0' && p < acl + size)
+ type = 0;
+ while (*p != '\0' && p < acl + size) {
+ if (*p < '0' || *p > '7') {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Malformed Solaris ACL attribute (invalid digit)");
+ return(ARCHIVE_WARN);
+ }
+ type <<= 3;
+ type += *p - '0';
+ if (type > 077777777) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Malformed Solaris ACL attribute (count too large)");
+ return (ARCHIVE_WARN);
+ }
p++;
+ }
+ switch ((int)type & ~0777777) {
+ case 01000000:
+ /* POSIX.1e ACL */
+ break;
+ case 03000000:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Solaris NFSv4 ACLs not supported");
+ return (ARCHIVE_WARN);
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Malformed Solaris ACL attribute (unsupported type %o)",
+ (int)type);
+ return (ARCHIVE_WARN);
+ }
p++;
if (p >= acl + size) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Malformed Solaris ACL attribute");
+ "Malformed Solaris ACL attribute (body overflow)");
return(ARCHIVE_WARN);
}
- /* Skip leading octal number. */
+ /* ACL text is null-terminated; find the end. */
size -= (p - acl);
acl = p;
@@ -772,6 +805,9 @@ header_Solaris_ACL(struct archive_read *a, struct tar *tar,
wp = utf8_decode(tar, acl, p - acl);
err = __archive_entry_acl_parse_w(entry, wp,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
+ if (err != ARCHIVE_OK)
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Malformed Solaris ACL attribute (unparsable)");
return (err);
}
@@ -837,10 +873,8 @@ read_body_to_string(struct archive_read *a, struct tar *tar,
struct archive_string *as, const void *h)
{
off_t size, padded_size;
- ssize_t bytes_read, bytes_to_copy;
const struct archive_entry_header_ustar *header;
const void *src;
- char *dest;
(void)tar; /* UNUSED */
header = (const struct archive_entry_header_ustar *)h;
@@ -858,27 +892,14 @@ read_body_to_string(struct archive_read *a, struct tar *tar,
return (ARCHIVE_FATAL);
}
- /* Read the body into the string. */
+ /* Read the body into the string. */
padded_size = (size + 511) & ~ 511;
- dest = as->s;
- while (padded_size > 0) {
- bytes_read = (a->decompressor->read_ahead)(a, &src, padded_size);
- if (bytes_read == 0)
- return (ARCHIVE_EOF);
- if (bytes_read < 0)
- return (ARCHIVE_FATAL);
- if (bytes_read > padded_size)
- bytes_read = padded_size;
- (a->decompressor->consume)(a, bytes_read);
- bytes_to_copy = bytes_read;
- if ((off_t)bytes_to_copy > size)
- bytes_to_copy = (ssize_t)size;
- memcpy(dest, src, bytes_to_copy);
- dest += bytes_to_copy;
- size -= bytes_to_copy;
- padded_size -= bytes_read;
- }
- *dest = '\0';
+ src = __archive_read_ahead(a, padded_size, NULL);
+ if (src == NULL)
+ return (ARCHIVE_FATAL);
+ memcpy(as->s, src, size);
+ __archive_read_consume(a, padded_size);
+ as->s[size] = '\0';
return (ARCHIVE_OK);
}
@@ -1175,7 +1196,7 @@ pax_header(struct archive_read *a, struct tar *tar,
struct archive_entry *entry, char *attr)
{
size_t attr_length, l, line_length;
- char *line, *p;
+ char *p;
char *key, *value;
int err, err2;
@@ -1191,7 +1212,7 @@ pax_header(struct archive_read *a, struct tar *tar,
/* Parse decimal length field at start of line. */
line_length = 0;
l = attr_length;
- line = p = attr; /* Record start of line. */
+ p = attr; /* Record start of line. */
while (l>0) {
if (*p == ' ') {
p++;
@@ -1451,6 +1472,10 @@ pax_attribute(struct tar *tar, struct archive_entry *entry,
if (strcmp(key, "LIBARCHIVE.xxxxxxx")==0)
archive_entry_set_xxxxxx(entry, value);
*/
+ if (strcmp(key, "LIBARCHIVE.creationtime")==0) {
+ pax_time(value, &s, &n);
+ archive_entry_set_birthtime(entry, s, n);
+ }
if (strncmp(key, "LIBARCHIVE.xattr.", 17)==0)
pax_attribute_xattr(entry, key, value);
break;
@@ -1605,7 +1630,7 @@ pax_time(const char *p, int64_t *ps, long *pn)
digit = *p - '0';
if (s > limit ||
(s == limit && digit > last_digit_limit)) {
- s = UINT64_MAX;
+ s = INT64_MAX;
break;
}
s = (s * 10) + digit;
@@ -1762,7 +1787,7 @@ gnu_sparse_old_read(struct archive_read *a, struct tar *tar,
return (ARCHIVE_OK);
do {
- bytes_read = (a->decompressor->read_ahead)(a, &data, 512);
+ data = __archive_read_ahead(a, 512, &bytes_read);
if (bytes_read < 0)
return (ARCHIVE_FATAL);
if (bytes_read < 512) {
@@ -1771,7 +1796,7 @@ gnu_sparse_old_read(struct archive_read *a, struct tar *tar,
"detected while reading sparse file data");
return (ARCHIVE_FATAL);
}
- (a->decompressor->consume)(a, 512);
+ __archive_read_consume(a, 512);
ext = (const struct extended *)data;
gnu_sparse_old_parse(tar, ext->sparse, 21);
} while (ext->isextended[0] != 0);
@@ -1904,7 +1929,7 @@ gnu_sparse_10_atol(struct archive_read *a, struct tar *tar,
return (ARCHIVE_WARN);
digit = *p - '0';
if (l > limit || (l == limit && digit > last_digit_limit))
- l = UINT64_MAX; /* Truncate on overflow. */
+ l = INT64_MAX; /* Truncate on overflow. */
else
l = (l * base) + digit;
p++;
@@ -1949,7 +1974,7 @@ gnu_sparse_10_read(struct archive_read *a, struct tar *tar)
/* Skip rest of block... */
bytes_read = tar->entry_bytes_remaining - remaining;
to_skip = 0x1ff & -bytes_read;
- if (to_skip != (a->decompressor->skip)(a, to_skip))
+ if (to_skip != __archive_read_skip(a, to_skip))
return (ARCHIVE_FATAL);
return (bytes_read + to_skip);
}
@@ -2010,7 +2035,7 @@ tar_atol8(const char *p, unsigned char_cnt)
digit = *p - '0';
while (digit >= 0 && digit < base && char_cnt-- > 0) {
if (l>limit || (l == limit && digit > last_digit_limit)) {
- l = UINT64_MAX; /* Truncate on overflow. */
+ l = INT64_MAX; /* Truncate on overflow. */
break;
}
l = (l * base) + digit;
@@ -2046,7 +2071,7 @@ tar_atol10(const char *p, unsigned char_cnt)
digit = *p - '0';
while (digit >= 0 && digit < base && char_cnt-- > 0) {
if (l > limit || (l == limit && digit > last_digit_limit)) {
- l = UINT64_MAX; /* Truncate on overflow. */
+ l = INT64_MAX; /* Truncate on overflow. */
break;
}
l = (l * base) + digit;
@@ -2104,7 +2129,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
const char *s;
void *p;
- bytes_read = (a->decompressor->read_ahead)(a, &t, 1);
+ t = __archive_read_ahead(a, 1, &bytes_read);
if (bytes_read <= 0)
return (ARCHIVE_FATAL);
s = t; /* Start of line? */
@@ -2118,7 +2143,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
"Line too long");
return (ARCHIVE_FATAL);
}
- (a->decompressor->consume)(a, bytes_read);
+ __archive_read_consume(a, bytes_read);
*start = s;
return (bytes_read);
}
@@ -2136,7 +2161,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
return (ARCHIVE_FATAL);
}
memcpy(tar->line.s + total_size, t, bytes_read);
- (a->decompressor->consume)(a, bytes_read);
+ __archive_read_consume(a, bytes_read);
total_size += bytes_read;
/* If we found '\n', clean up and return. */
if (p != NULL) {
@@ -2144,7 +2169,7 @@ readline(struct archive_read *a, struct tar *tar, const char **start,
return (total_size);
}
/* Read some more. */
- bytes_read = (a->decompressor->read_ahead)(a, &t, 1);
+ t = __archive_read_ahead(a, 1, &bytes_read);
if (bytes_read <= 0)
return (ARCHIVE_FATAL);
s = t; /* Start of line? */
@@ -2161,11 +2186,10 @@ utf8_decode(struct tar *tar, const char *src, size_t length)
{
wchar_t *dest;
ssize_t n;
- int err;
/* Ensure pax_entry buffer is big enough. */
if (tar->pax_entry_length <= length) {
- wchar_t *old_entry = tar->pax_entry;
+ wchar_t *old_entry;
if (tar->pax_entry_length <= 0)
tar->pax_entry_length = 1024;
@@ -2183,7 +2207,6 @@ utf8_decode(struct tar *tar, const char *src, size_t length)
}
dest = tar->pax_entry;
- err = 0;
while (length > 0) {
n = UTF8_mbrtowc(dest, src, length);
if (n < 0)
@@ -2194,7 +2217,7 @@ utf8_decode(struct tar *tar, const char *src, size_t length)
src += n;
length -= n;
}
- *dest++ = L'\0';
+ *dest = L'\0';
return (tar->pax_entry);
}
@@ -2295,7 +2318,7 @@ base64_decode(const char *s, size_t len, size_t *out_len)
/* If the decode table is not yet initialized, prepare it. */
if (decode_table[digits[1]] != 1) {
- size_t i;
+ unsigned i;
memset(decode_table, 0xff, sizeof(decode_table));
for (i = 0; i < sizeof(digits); i++)
decode_table[digits[i]] = i;
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_xar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_xar.c
new file mode 100644
index 00000000000..b914975423d
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_xar.c
@@ -0,0 +1,3150 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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 "archive_platform.h"
+__FBSDID("$FreeBSD$");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#if HAVE_LIBXML_XMLREADER_H
+#include <libxml/xmlreader.h>
+#elif HAVE_BSDXML_H
+#include <bsdxml.h>
+#elif HAVE_EXPAT_H
+#include <expat.h>
+#endif
+#ifdef HAVE_BZLIB_H
+#include <bzlib.h>
+#endif
+#if HAVE_LZMA_H
+#include <lzma.h>
+#elif HAVE_LZMADEC_H
+#include <lzmadec.h>
+#endif
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_entry.h"
+#include "archive_hash.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+#if (!defined(HAVE_LIBXML_XMLREADER_H) && \
+ !defined(HAVE_BSDXML_H) && !defined(HAVE_EXPAT_H)) ||\
+ !defined(HAVE_ZLIB_H) || \
+ !defined(ARCHIVE_HAS_MD5) || !defined(ARCHIVE_HAS_SHA1)
+/*
+ * xar needs several external libraries.
+ * o libxml2 or expat --- XML parser
+ * o openssl or MD5/SHA1 hash function
+ * o zlib
+ * o bzlib2 (option)
+ * o liblzma (option)
+ */
+int
+archive_read_support_format_xar(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Xar not supported on this platform");
+ return (ARCHIVE_WARN);
+}
+
+#else /* Support xar format */
+
+//#define DEBUG 1
+//#define DEBUG_PRINT_TOC 1
+#if DEBUG_PRINT_TOC
+#define PRINT_TOC(d, outbytes) do { \
+ unsigned char *x = (unsigned char *)(uintptr_t)d; \
+ unsigned char c = x[outbytes-1]; \
+ x[outbytes - 1] = 0; \
+ fprintf(stderr, "%s", x); \
+ fprintf(stderr, "%c", c); \
+ x[outbytes - 1] = c; \
+} while (0)
+#else
+#define PRINT_TOC(d, outbytes)
+#endif
+
+#define HEADER_MAGIC 0x78617221
+#define HEADER_SIZE 28
+#define HEADER_VERSION 1
+#define CKSUM_NONE 0
+#define CKSUM_SHA1 1
+#define CKSUM_MD5 2
+
+#define MD5_SIZE 16
+#define SHA1_SIZE 20
+#define MAX_SUM_SIZE 20
+
+enum enctype {
+ NONE,
+ GZIP,
+ BZIP2,
+ LZMA,
+ XZ,
+};
+
+struct chksumval {
+ int alg;
+ size_t len;
+ unsigned char val[MAX_SUM_SIZE];
+};
+
+struct chksumwork {
+ int alg;
+#ifdef ARCHIVE_HAS_MD5
+ archive_md5_ctx md5ctx;
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+ archive_sha1_ctx sha1ctx;
+#endif
+};
+
+struct xattr {
+ struct xattr *next;
+ struct archive_string name;
+ uint64_t id;
+ uint64_t length;
+ uint64_t offset;
+ uint64_t size;
+ enum enctype encoding;
+ struct chksumval a_sum;
+ struct chksumval e_sum;
+ struct archive_string fstype;
+};
+
+struct xar_file {
+ struct xar_file *next;
+ struct xar_file *hdnext;
+ struct xar_file *parent;
+ int subdirs;
+
+ unsigned int has;
+#define HAS_DATA 0x00001
+#define HAS_PATHNAME 0x00002
+#define HAS_SYMLINK 0x00004
+#define HAS_TIME 0x00008
+#define HAS_UID 0x00010
+#define HAS_GID 0x00020
+#define HAS_MODE 0x00040
+#define HAS_TYPE 0x00080
+#define HAS_DEV 0x00100
+#define HAS_DEVMAJOR 0x00200
+#define HAS_DEVMINOR 0x00400
+#define HAS_INO 0x00800
+#define HAS_FFLAGS 0x01000
+#define HAS_XATTR 0x02000
+#define HAS_ACL 0x04000
+
+ uint64_t id;
+ uint64_t length;
+ uint64_t offset;
+ uint64_t size;
+ enum enctype encoding;
+ struct chksumval a_sum;
+ struct chksumval e_sum;
+ struct archive_string pathname;
+ struct archive_string symlink;
+ time_t ctime;
+ time_t mtime;
+ time_t atime;
+ struct archive_string uname;
+ uid_t uid;
+ struct archive_string gname;
+ gid_t gid;
+ mode_t mode;
+ dev_t dev;
+ dev_t devmajor;
+ dev_t devminor;
+ int64_t ino64;
+ struct archive_string fflags_text;
+ unsigned int link;
+ unsigned int nlink;
+ struct archive_string hardlink;
+ struct xattr *xattr_list;
+};
+
+struct hdlink {
+ struct hdlink *next;
+
+ unsigned int id;
+ int cnt;
+ struct xar_file *files;
+};
+
+struct heap_queue {
+ struct xar_file **files;
+ int allocated;
+ int used;
+};
+
+enum xmlstatus {
+ INIT,
+ XAR,
+ TOC,
+ TOC_CREATION_TIME,
+ TOC_CHECKSUM,
+ TOC_CHECKSUM_OFFSET,
+ TOC_CHECKSUM_SIZE,
+ TOC_FILE,
+ FILE_DATA,
+ FILE_DATA_LENGTH,
+ FILE_DATA_OFFSET,
+ FILE_DATA_SIZE,
+ FILE_DATA_ENCODING,
+ FILE_DATA_A_CHECKSUM,
+ FILE_DATA_E_CHECKSUM,
+ FILE_DATA_CONTENT,
+ FILE_EA,
+ FILE_EA_LENGTH,
+ FILE_EA_OFFSET,
+ FILE_EA_SIZE,
+ FILE_EA_ENCODING,
+ FILE_EA_A_CHECKSUM,
+ FILE_EA_E_CHECKSUM,
+ FILE_EA_NAME,
+ FILE_EA_FSTYPE,
+ FILE_CTIME,
+ FILE_MTIME,
+ FILE_ATIME,
+ FILE_GROUP,
+ FILE_GID,
+ FILE_USER,
+ FILE_UID,
+ FILE_MODE,
+ FILE_DEVICE,
+ FILE_DEVICE_MAJOR,
+ FILE_DEVICE_MINOR,
+ FILE_DEVICENO,
+ FILE_INODE,
+ FILE_LINK,
+ FILE_TYPE,
+ FILE_NAME,
+ FILE_ACL,
+ FILE_ACL_DEFAULT,
+ FILE_ACL_ACCESS,
+ FILE_ACL_APPLEEXTENDED,
+ /* BSD file flags. */
+ FILE_FLAGS,
+ FILE_FLAGS_USER_NODUMP,
+ FILE_FLAGS_USER_IMMUTABLE,
+ FILE_FLAGS_USER_APPEND,
+ FILE_FLAGS_USER_OPAQUE,
+ FILE_FLAGS_USER_NOUNLINK,
+ FILE_FLAGS_SYS_ARCHIVED,
+ FILE_FLAGS_SYS_IMMUTABLE,
+ FILE_FLAGS_SYS_APPEND,
+ FILE_FLAGS_SYS_NOUNLINK,
+ FILE_FLAGS_SYS_SNAPSHOT,
+ /* Linux file flags. */
+ FILE_EXT2,
+ FILE_EXT2_SecureDeletion,
+ FILE_EXT2_Undelete,
+ FILE_EXT2_Compress,
+ FILE_EXT2_Synchronous,
+ FILE_EXT2_Immutable,
+ FILE_EXT2_AppendOnly,
+ FILE_EXT2_NoDump,
+ FILE_EXT2_NoAtime,
+ FILE_EXT2_CompDirty,
+ FILE_EXT2_CompBlock,
+ FILE_EXT2_NoCompBlock,
+ FILE_EXT2_CompError,
+ FILE_EXT2_BTree,
+ FILE_EXT2_HashIndexed,
+ FILE_EXT2_iMagic,
+ FILE_EXT2_Journaled,
+ FILE_EXT2_NoTail,
+ FILE_EXT2_DirSync,
+ FILE_EXT2_TopDir,
+ FILE_EXT2_Reserved,
+ UNKNOWN,
+};
+
+struct unknown_tag {
+ struct unknown_tag *next;
+ struct archive_string name;
+};
+
+struct xar {
+ uint64_t offset; /* Current position in the file. */
+ int64_t total;
+ uint64_t h_base;
+ int end_of_file;
+ unsigned char buff[1024*32];
+
+ enum xmlstatus xmlsts;
+ enum xmlstatus xmlsts_unknown;
+ struct unknown_tag *unknowntags;
+ int base64text;
+
+ /*
+ * TOC
+ */
+ uint64_t toc_remaining;
+ uint64_t toc_total;
+ uint64_t toc_chksum_offset;
+ uint64_t toc_chksum_size;
+
+ /*
+ * For Decoding data.
+ */
+ enum enctype rd_encoding;
+ z_stream stream;
+ int stream_valid;
+#ifdef HAVE_BZLIB_H
+ bz_stream bzstream;
+ int bzstream_valid;
+#endif
+#if HAVE_LZMA_H && HAVE_LIBLZMA
+ lzma_stream lzstream;
+ int lzstream_valid;
+#elif HAVE_LZMADEC_H && HAVE_LIBLZMADEC
+ lzmadec_stream lzstream;
+ int lzstream_valid;
+#endif
+ /*
+ * For Checksum data.
+ */
+ struct chksumwork a_sumwrk;
+ struct chksumwork e_sumwrk;
+
+ struct xar_file *file; /* current reading file. */
+ struct xattr *xattr; /* current reading extended attribute. */
+ struct heap_queue file_queue;
+ struct xar_file *hdlink_orgs;
+ struct hdlink *hdlink_list;
+
+ int entry_init;
+ uint64_t entry_total;
+ uint64_t entry_remaining;
+ uint64_t entry_size;
+ enum enctype entry_encoding;
+ struct chksumval entry_a_sum;
+ struct chksumval entry_e_sum;
+};
+
+struct xmlattr {
+ struct xmlattr *next;
+ char *name;
+ char *value;
+};
+
+struct xmlattr_list {
+ struct xmlattr *first;
+ struct xmlattr **last;
+};
+
+static int xar_bid(struct archive_read *);
+static int xar_read_header(struct archive_read *,
+ struct archive_entry *);
+static int xar_read_data(struct archive_read *,
+ const void **, size_t *, off_t *);
+static int xar_read_data_skip(struct archive_read *);
+static int xar_cleanup(struct archive_read *);
+static int move_reading_point(struct archive_read *, uint64_t);
+static int rd_contents_init(struct archive_read *,
+ enum enctype, int, int);
+static int rd_contents(struct archive_read *, const void **,
+ size_t *, size_t *, uint64_t);
+static uint64_t atol10(const char *, size_t);
+static int64_t atol8(const char *, size_t);
+static size_t atohex(unsigned char *, size_t, const char *, size_t);
+static time_t parse_time(const char *p, size_t n);
+static void heap_add_entry(struct heap_queue *, struct xar_file *);
+static struct xar_file *heap_get_entry(struct heap_queue *);
+static void add_link(struct xar *, struct xar_file *);
+static void checksum_init(struct archive_read *, int, int);
+static void checksum_update(struct archive_read *, const void *,
+ size_t, const void *, size_t);
+static int checksum_final(struct archive_read *, const void *,
+ size_t, const void *, size_t);
+static int decompression_init(struct archive_read *, enum enctype);
+static int decompress(struct archive_read *, const void **,
+ size_t *, const void *, size_t *);
+static int decompression_cleanup(struct archive_read *);
+static void xmlattr_cleanup(struct xmlattr_list *);
+static void file_new(struct xar *, struct xmlattr_list *);
+static void file_free(struct xar_file *);
+static void xattr_new(struct xar *, struct xmlattr_list *);
+static void xattr_free(struct xattr *);
+static int getencoding(struct xmlattr_list *);
+static int getsumalgorithm(struct xmlattr_list *);
+static void unknowntag_start(struct xar *, const char *);
+static void unknowntag_end(struct xar *, const char *);
+static void xml_start(void *, const char *, struct xmlattr_list *);
+static void xml_end(void *, const char *);
+static void xml_data(void *, const char *, int);
+static int xml_parse_file_flags(struct xar *, const char *);
+static int xml_parse_file_ext2(struct xar *, const char *);
+#if defined(HAVE_LIBXML_XMLREADER_H)
+static int xml2_xmlattr_setup(struct xmlattr_list *, xmlTextReaderPtr);
+static int xml2_read_cb(void *, char *, int);
+static int xml2_close_cb(void *);
+static void xml2_error_hdr(void *, const char *, xmlParserSeverities,
+ xmlTextReaderLocatorPtr);
+static int xml2_read_toc(struct archive_read *);
+#elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H)
+static void expat_xmlattr_setup(struct xmlattr_list *, const XML_Char **);
+static void expat_start_cb(void *, const XML_Char *, const XML_Char **);
+static void expat_end_cb(void *, const XML_Char *);
+static void expat_data_cb(void *, const XML_Char *, int);
+static int expat_read_toc(struct archive_read *);
+#endif
+
+int
+archive_read_support_format_xar(struct archive *_a)
+{
+ struct xar *xar;
+ struct archive_read *a = (struct archive_read *)_a;
+ int r;
+
+ xar = (struct xar *)calloc(1, sizeof(*xar));
+ if (xar == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate xar data");
+ return (ARCHIVE_FATAL);
+ }
+
+ r = __archive_read_register_format(a,
+ xar,
+ "xar",
+ xar_bid,
+ NULL,
+ xar_read_header,
+ xar_read_data,
+ xar_read_data_skip,
+ xar_cleanup);
+ if (r != ARCHIVE_OK)
+ free(xar);
+ return (r);
+}
+
+static int
+xar_bid(struct archive_read *a)
+{
+ const unsigned char *b;
+ int bid;
+
+ b = __archive_read_ahead(a, HEADER_SIZE, NULL);
+ if (b == NULL)
+ return (-1);
+
+ bid = 0;
+ /*
+ * Verify magic code
+ */
+ if (archive_be32dec(b) != HEADER_MAGIC)
+ return (0);
+ bid += 32;
+ /*
+ * Verify header size
+ */
+ if (archive_be16dec(b+4) != HEADER_SIZE)
+ return (0);
+ bid += 16;
+ /*
+ * Verify header version
+ */
+ if (archive_be16dec(b+6) != HEADER_VERSION)
+ return (0);
+ bid += 16;
+ /*
+ * Verify type of checksum
+ */
+ switch (archive_be32dec(b+24)) {
+ case CKSUM_NONE:
+ case CKSUM_SHA1:
+ case CKSUM_MD5:
+ bid += 32;
+ break;
+ default:
+ return (0);
+ }
+
+ return (bid);
+}
+
+static int
+read_toc(struct archive_read *a)
+{
+ struct xar *xar;
+ struct xar_file *file;
+ const unsigned char *b;
+ uint64_t toc_compressed_size;
+ uint64_t toc_uncompressed_size;
+ uint32_t toc_chksum_alg;
+ ssize_t bytes;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+
+ /*
+ * Read xar header.
+ */
+ b = __archive_read_ahead(a, HEADER_SIZE, &bytes);
+ if (bytes < 0)
+ return ((int)bytes);
+ if (bytes < HEADER_SIZE) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated archive header");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (archive_be32dec(b) != HEADER_MAGIC) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Invalid header magic");
+ return (ARCHIVE_FATAL);
+ }
+ if (archive_be16dec(b+6) != HEADER_VERSION) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Unsupported header version(%d)",
+ archive_be16dec(b+6));
+ return (ARCHIVE_FATAL);
+ }
+ toc_compressed_size = archive_be64dec(b+8);
+ xar->toc_remaining = toc_compressed_size;
+ toc_uncompressed_size = archive_be64dec(b+16);
+ toc_chksum_alg = archive_be32dec(b+24);
+ __archive_read_consume(a, HEADER_SIZE);
+ xar->offset += HEADER_SIZE;
+ xar->toc_total = 0;
+
+ /*
+ * Read TOC(Table of Contents).
+ */
+ /* Initialize reading contents. */
+ r = move_reading_point(a, HEADER_SIZE);
+ if (r != ARCHIVE_OK)
+ return (r);
+ r = rd_contents_init(a, GZIP, toc_chksum_alg, CKSUM_NONE);
+ if (r != ARCHIVE_OK)
+ return (r);
+
+#ifdef HAVE_LIBXML_XMLREADER_H
+ r = xml2_read_toc(a);
+#elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H)
+ r = expat_read_toc(a);
+#endif
+ if (r != ARCHIVE_OK)
+ return (r);
+
+ /* Set 'The HEAP' base. */
+ xar->h_base = xar->offset;
+ if (xar->toc_total != toc_uncompressed_size) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "TOC uncompressed size error");
+ return (ARCHIVE_FATAL);
+ }
+
+ /*
+ * Checksum TOC
+ */
+ if (toc_chksum_alg != CKSUM_NONE) {
+ r = move_reading_point(a, xar->toc_chksum_offset);
+ if (r != ARCHIVE_OK)
+ return (r);
+ b = __archive_read_ahead(a, xar->toc_chksum_size, &bytes);
+ if (bytes < 0)
+ return ((int)bytes);
+ if ((uint64_t)bytes < xar->toc_chksum_size) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated archive file");
+ return (ARCHIVE_FATAL);
+ }
+ r = checksum_final(a, b, xar->toc_chksum_size, NULL, 0);
+ __archive_read_consume(a, xar->toc_chksum_size);
+ xar->offset += xar->toc_chksum_size;
+ if (r != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ }
+
+ /*
+ * Connect hardlinked files.
+ */
+ for (file = xar->hdlink_orgs; file != NULL; file = file->hdnext) {
+ struct hdlink **hdlink;
+
+ for (hdlink = &(xar->hdlink_list); *hdlink != NULL;
+ hdlink = &((*hdlink)->next)) {
+ if ((*hdlink)->id == file->id) {
+ struct hdlink *hltmp;
+ struct xar_file *f2;
+ int nlink = (*hdlink)->cnt + 1;
+
+ file->nlink = nlink;
+ for (f2 = (*hdlink)->files; f2 != NULL;
+ f2 = f2->hdnext) {
+ f2->nlink = nlink;
+ archive_string_copy(
+ &(f2->hardlink), &(file->pathname));
+ }
+ /* Remove resolved files from hdlist_list. */
+ hltmp = *hdlink;
+ *hdlink = hltmp->next;
+ free(hltmp);
+ break;
+ }
+ }
+ }
+ a->archive.archive_format = ARCHIVE_FORMAT_XAR;
+ a->archive.archive_format_name = "xar";
+
+ return (ARCHIVE_OK);
+}
+
+static int
+xar_read_header(struct archive_read *a, struct archive_entry *entry)
+{
+ struct xar *xar;
+ struct xar_file *file;
+ struct xattr *xattr;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+
+ if (xar->offset == 0) {
+ /* Read TOC. */
+ r = read_toc(a);
+ if (r != ARCHIVE_OK)
+ return (r);
+ }
+
+ for (;;) {
+ file = xar->file = heap_get_entry(&(xar->file_queue));
+ if (file == NULL) {
+ xar->end_of_file = 1;
+ return (ARCHIVE_EOF);
+ }
+ if ((file->mode & AE_IFMT) != AE_IFDIR)
+ break;
+ if (file->has != (HAS_PATHNAME | HAS_TYPE))
+ break;
+ /*
+ * If a file type is a directory and it does not have
+ * any metadata, do not export.
+ */
+ file_free(file);
+ }
+ archive_entry_set_atime(entry, file->atime, 0);
+ archive_entry_set_ctime(entry, file->ctime, 0);
+ archive_entry_set_mtime(entry, file->mtime, 0);
+ archive_entry_set_gid(entry, file->gid);
+ if (file->gname.length > 0)
+ archive_entry_update_gname_utf8(entry, file->gname.s);
+ archive_entry_set_uid(entry, file->uid);
+ if (file->uname.length > 0)
+ archive_entry_update_uname_utf8(entry, file->uname.s);
+ archive_entry_set_mode(entry, file->mode);
+ archive_entry_update_pathname_utf8(entry, file->pathname.s);
+ if (file->symlink.length > 0)
+ archive_entry_update_symlink_utf8(entry, file->symlink.s);
+ /* Set proper nlink. */
+ if ((file->mode & AE_IFMT) == AE_IFDIR)
+ archive_entry_set_nlink(entry, file->subdirs + 2);
+ else
+ archive_entry_set_nlink(entry, file->nlink);
+ archive_entry_set_size(entry, file->size);
+ if (archive_strlen(&(file->hardlink)) > 0)
+ archive_entry_update_hardlink_utf8(entry,
+ file->hardlink.s);
+ archive_entry_set_ino64(entry, file->ino64);
+ if (file->has & HAS_DEV)
+ archive_entry_set_dev(entry, file->dev);
+ if (file->has & HAS_DEVMAJOR)
+ archive_entry_set_devmajor(entry, file->devmajor);
+ if (file->has & HAS_DEVMINOR)
+ archive_entry_set_devminor(entry, file->devminor);
+ if (archive_strlen(&(file->fflags_text)) > 0)
+ archive_entry_copy_fflags_text(entry, file->fflags_text.s);
+
+ xar->entry_init = 1;
+ xar->entry_total = 0;
+ xar->entry_remaining = file->length;
+ xar->entry_size = file->size;
+ xar->entry_encoding = file->encoding;
+ xar->entry_a_sum = file->a_sum;
+ xar->entry_e_sum = file->e_sum;
+ /*
+ * Read extended attributes.
+ */
+ r = ARCHIVE_OK;
+ xattr = file->xattr_list;
+ while (xattr != NULL) {
+ const void *d;
+ size_t outbytes, used;
+
+ r = move_reading_point(a, xattr->offset);
+ if (r != ARCHIVE_OK)
+ break;
+ r = rd_contents_init(a, xattr->encoding,
+ xattr->a_sum.alg, xattr->e_sum.alg);
+ if (r != ARCHIVE_OK)
+ break;
+ d = NULL;
+ r = rd_contents(a, &d, &outbytes, &used, xattr->length);
+ if (r != ARCHIVE_OK)
+ break;
+ if (outbytes != xattr->size) {
+ archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
+ "Decompressed size error");
+ r = ARCHIVE_FATAL;
+ break;
+ }
+ r = checksum_final(a,
+ xattr->a_sum.val, xattr->a_sum.len,
+ xattr->e_sum.val, xattr->e_sum.len);
+ if (r != ARCHIVE_OK)
+ break;
+ archive_entry_xattr_add_entry(entry,
+ xattr->name.s, d, outbytes);
+ xattr = xattr->next;
+ }
+ if (r != ARCHIVE_OK) {
+ file_free(file);
+ return (r);
+ }
+
+ if (xar->entry_remaining > 0)
+ /* Move reading point to the beginning of current
+ * file contents. */
+ r = move_reading_point(a, file->offset);
+ else
+ r = ARCHIVE_OK;
+
+ file_free(file);
+ return (r);
+}
+
+static int
+xar_read_data(struct archive_read *a,
+ const void **buff, size_t *size, off_t *offset)
+{
+ struct xar *xar;
+ size_t used;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+ if (xar->end_of_file || xar->entry_remaining <= 0) {
+ r = ARCHIVE_EOF;
+ goto abort_read_data;
+ }
+
+ if (xar->entry_init) {
+ r = rd_contents_init(a, xar->entry_encoding,
+ xar->entry_a_sum.alg, xar->entry_e_sum.alg);
+ if (r != ARCHIVE_OK) {
+ xar->entry_remaining = 0;
+ return (r);
+ }
+ xar->entry_init = 0;
+ }
+
+ *buff = NULL;
+ r = rd_contents(a, buff, size, &used, xar->entry_remaining);
+ if (r != ARCHIVE_OK)
+ goto abort_read_data;
+
+ *offset = xar->entry_total;
+ xar->entry_total += *size;
+ xar->total += *size;
+ xar->offset += used;
+ xar->entry_remaining -= used;
+ __archive_read_consume(a, used);
+
+ if (xar->entry_remaining == 0) {
+ if (xar->entry_total != xar->entry_size) {
+ archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
+ "Decompressed size error");
+ r = ARCHIVE_FATAL;
+ goto abort_read_data;
+ }
+ r = checksum_final(a,
+ xar->entry_a_sum.val, xar->entry_a_sum.len,
+ xar->entry_e_sum.val, xar->entry_e_sum.len);
+ if (r != ARCHIVE_OK)
+ goto abort_read_data;
+ }
+
+ return (ARCHIVE_OK);
+abort_read_data:
+ *buff = NULL;
+ *size = 0;
+ *offset = xar->total;
+ return (r);
+}
+
+static int
+xar_read_data_skip(struct archive_read *a)
+{
+ struct xar *xar;
+ int64_t bytes_skipped;
+
+ xar = (struct xar *)(a->format->data);
+ if (xar->end_of_file)
+ return (ARCHIVE_EOF);
+ bytes_skipped = __archive_read_skip(a, xar->entry_remaining);
+ if (bytes_skipped < 0)
+ return (ARCHIVE_FATAL);
+ xar->offset += bytes_skipped;
+ return (ARCHIVE_OK);
+}
+
+static int
+xar_cleanup(struct archive_read *a)
+{
+ struct xar *xar;
+ struct hdlink *hdlink;
+ int i;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+ r = decompression_cleanup(a);
+ hdlink = xar->hdlink_list;
+ while (hdlink != NULL) {
+ struct hdlink *next = hdlink->next;
+
+ free(hdlink);
+ hdlink = next;
+ }
+ for (i = 0; i < xar->file_queue.used; i++)
+ file_free(xar->file_queue.files[i]);
+ while (xar->unknowntags != NULL) {
+ struct unknown_tag *tag;
+
+ tag = xar->unknowntags;
+ xar->unknowntags = tag->next;
+ archive_string_free(&(tag->name));
+ free(tag);
+ }
+ free(xar);
+ a->format->data = NULL;
+ return (r);
+}
+
+static int
+move_reading_point(struct archive_read *a, uint64_t offset)
+{
+ struct xar *xar;
+
+ xar = (struct xar *)(a->format->data);
+ if (xar->offset - xar->h_base != offset) {
+ /* Seek forward to the start of file contents. */
+ int64_t step;
+
+ step = offset - (xar->offset - xar->h_base);
+ if (step > 0) {
+ step = __archive_read_skip(a, step);
+ if (step < 0)
+ return ((int)step);
+ xar->offset += step;
+ } else {
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Cannot seek.");
+ return (ARCHIVE_FAILED);
+ }
+ }
+ return (ARCHIVE_OK);
+}
+
+static int
+rd_contents_init(struct archive_read *a, enum enctype encoding,
+ int a_sum_alg, int e_sum_alg)
+{
+ int r;
+
+ /* Init decompress library. */
+ if ((r = decompression_init(a, encoding)) != ARCHIVE_OK)
+ return (r);
+ /* Init checksum library. */
+ checksum_init(a, a_sum_alg, e_sum_alg);
+ return (ARCHIVE_OK);
+}
+
+static int
+rd_contents(struct archive_read *a, const void **buff, size_t *size,
+ size_t *used, uint64_t remaining)
+{
+ const unsigned char *b;
+ ssize_t bytes;
+
+ /* Get whatever bytes are immediately available. */
+ b = __archive_read_ahead(a, 1, &bytes);
+ if (bytes < 0)
+ return ((int)bytes);
+ if (bytes == 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Truncated archive file");
+ return (ARCHIVE_FATAL);
+ }
+ if ((uint64_t)bytes > remaining)
+ bytes = (ssize_t)remaining;
+
+ /*
+ * Decompress contents of file.
+ */
+ *used = bytes;
+ if (decompress(a, buff, size, b, used) != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+
+ /*
+ * Update checksum of a compressed data and a extracted data.
+ */
+ checksum_update(a, b, *used, *buff, *size);
+
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Note that this implementation does not (and should not!) obey
+ * locale settings; you cannot simply substitute strtol here, since
+ * it does obey locale.
+ */
+
+static uint64_t
+atol10(const char *p, size_t char_cnt)
+{
+ uint64_t l;
+ int digit;
+
+ l = 0;
+ digit = *p - '0';
+ while (digit >= 0 && digit < 10 && char_cnt-- > 0) {
+ l = (l * 10) + digit;
+ digit = *++p - '0';
+ }
+ return (l);
+}
+
+static int64_t
+atol8(const char *p, size_t char_cnt)
+{
+ int64_t l;
+ int digit;
+
+ l = 0;
+ while (char_cnt-- > 0) {
+ if (*p >= '0' && *p <= '7')
+ digit = *p - '0';
+ else
+ break;
+ p++;
+ l <<= 3;
+ l |= digit;
+ }
+ return (l);
+}
+
+static size_t
+atohex(unsigned char *b, size_t bsize, const char *p, size_t psize)
+{
+ size_t fbsize = bsize;
+
+ while (bsize && psize > 1) {
+ unsigned char x;
+
+ if (p[0] >= 'a' && p[0] <= 'z')
+ x = (p[0] - 'a' + 0x0a) << 4;
+ else if (p[0] >= 'A' && p[0] <= 'Z')
+ x = (p[0] - 'A' + 0x0a) << 4;
+ else if (p[0] >= '0' && p[0] <= '9')
+ x = (p[0] - '0') << 4;
+ else
+ return (-1);
+ if (p[1] >= 'a' && p[1] <= 'z')
+ x |= p[1] - 'a' + 0x0a;
+ else if (p[1] >= 'A' && p[1] <= 'Z')
+ x |= p[1] - 'A' + 0x0a;
+ else if (p[1] >= '0' && p[1] <= '9')
+ x |= p[1] - '0';
+ else
+ return (-1);
+
+ *b++ = x;
+ bsize--;
+ p += 2;
+ psize -= 2;
+ }
+ return (fbsize - bsize);
+}
+
+static time_t
+time_from_tm(struct tm *t)
+{
+#if HAVE_TIMEGM
+ /* Use platform timegm() if available. */
+ return (timegm(t));
+#else
+ /* Else use direct calculation using POSIX assumptions. */
+ /* First, fix up tm_yday based on the year/month/day. */
+ mktime(t);
+ /* Then we can compute timegm() from first principles. */
+ return (t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600
+ + t->tm_yday * 86400 + (t->tm_year - 70) * 31536000
+ + ((t->tm_year - 69) / 4) * 86400 -
+ ((t->tm_year - 1) / 100) * 86400
+ + ((t->tm_year + 299) / 400) * 86400);
+#endif
+}
+
+static time_t
+parse_time(const char *p, size_t n)
+{
+ struct tm tm;
+ time_t t = 0;
+ int64_t data;
+
+ memset(&tm, 0, sizeof(tm));
+ if (n != 20)
+ return (t);
+ data = atol10(p, 4);
+ if (data < 1900)
+ return (t);
+ tm.tm_year = (int)data - 1900;
+ p += 4;
+ if (*p++ != '-')
+ return (t);
+ data = atol10(p, 2);
+ if (data < 1 || data > 12)
+ return (t);
+ tm.tm_mon = (int)data -1;
+ p += 2;
+ if (*p++ != '-')
+ return (t);
+ data = atol10(p, 2);
+ if (data < 1 || data > 31)
+ return (t);
+ tm.tm_mday = (int)data;
+ p += 2;
+ if (*p++ != 'T')
+ return (t);
+ data = atol10(p, 2);
+ if (data < 0 || data > 23)
+ return (t);
+ tm.tm_hour = (int)data;
+ p += 2;
+ if (*p++ != ':')
+ return (t);
+ data = atol10(p, 2);
+ if (data < 0 || data > 59)
+ return (t);
+ tm.tm_min = (int)data;
+ p += 2;
+ if (*p++ != ':')
+ return (t);
+ data = atol10(p, 2);
+ if (data < 0 || data > 60)
+ return (t);
+ tm.tm_sec = (int)data;
+#if 0
+ p += 2;
+ if (*p != 'Z')
+ return (t);
+#endif
+
+ t = time_from_tm(&tm);
+
+ return (t);
+}
+
+static void
+heap_add_entry(struct heap_queue *heap, struct xar_file *file)
+{
+ uint64_t file_id, parent_id;
+ int hole, parent;
+
+ /* Expand our pending files list as necessary. */
+ if (heap->used >= heap->allocated) {
+ struct xar_file **new_pending_files;
+ int new_size = heap->allocated * 2;
+
+ if (heap->allocated < 1024)
+ new_size = 1024;
+ /* Overflow might keep us from growing the list. */
+ if (new_size <= heap->allocated)
+ __archive_errx(1, "Out of memory");
+ new_pending_files = (struct xar_file **)
+ malloc(new_size * sizeof(new_pending_files[0]));
+ if (new_pending_files == NULL)
+ __archive_errx(1, "Out of memory");
+ memcpy(new_pending_files, heap->files,
+ heap->allocated * sizeof(new_pending_files[0]));
+ if (heap->files != NULL)
+ free(heap->files);
+ heap->files = new_pending_files;
+ heap->allocated = new_size;
+ }
+
+ file_id = file->id;
+
+ /*
+ * Start with hole at end, walk it up tree to find insertion point.
+ */
+ hole = heap->used++;
+ while (hole > 0) {
+ parent = (hole - 1)/2;
+ parent_id = heap->files[parent]->id;
+ if (file_id >= parent_id) {
+ heap->files[hole] = file;
+ return;
+ }
+ // Move parent into hole <==> move hole up tree.
+ heap->files[hole] = heap->files[parent];
+ hole = parent;
+ }
+ heap->files[0] = file;
+}
+
+static struct xar_file *
+heap_get_entry(struct heap_queue *heap)
+{
+ uint64_t a_id, b_id, c_id;
+ int a, b, c;
+ struct xar_file *r, *tmp;
+
+ if (heap->used < 1)
+ return (NULL);
+
+ /*
+ * The first file in the list is the earliest; we'll return this.
+ */
+ r = heap->files[0];
+
+ /*
+ * Move the last item in the heap to the root of the tree
+ */
+ heap->files[0] = heap->files[--(heap->used)];
+
+ /*
+ * Rebalance the heap.
+ */
+ a = 0; // Starting element and its heap key
+ a_id = heap->files[a]->id;
+ for (;;) {
+ b = a + a + 1; // First child
+ if (b >= heap->used)
+ return (r);
+ b_id = heap->files[b]->id;
+ c = b + 1; // Use second child if it is smaller.
+ if (c < heap->used) {
+ c_id = heap->files[c]->id;
+ if (c_id < b_id) {
+ b = c;
+ b_id = c_id;
+ }
+ }
+ if (a_id <= b_id)
+ return (r);
+ tmp = heap->files[a];
+ heap->files[a] = heap->files[b];
+ heap->files[b] = tmp;
+ a = b;
+ }
+}
+
+static void
+add_link(struct xar *xar, struct xar_file *file)
+{
+ struct hdlink *hdlink;
+
+ for (hdlink = xar->hdlink_list; hdlink != NULL; hdlink = hdlink->next) {
+ if (hdlink->id == file->link) {
+ file->hdnext = hdlink->files;
+ hdlink->cnt++;
+ hdlink->files = file;
+ return;
+ }
+ }
+ hdlink = malloc(sizeof(*hdlink));
+ if (hdlink == NULL)
+ __archive_errx(1, "No memory for add_link()");
+ file->hdnext = NULL;
+ hdlink->id = file->link;
+ hdlink->cnt = 1;
+ hdlink->files = file;
+ hdlink->next = xar->hdlink_list;
+ xar->hdlink_list = hdlink;
+}
+
+static void
+_checksum_init(struct chksumwork *sumwrk, int sum_alg)
+{
+ sumwrk->alg = sum_alg;
+ switch (sum_alg) {
+ case CKSUM_NONE:
+ break;
+ case CKSUM_SHA1:
+ archive_sha1_init(&(sumwrk->sha1ctx));
+ break;
+ case CKSUM_MD5:
+ archive_md5_init(&(sumwrk->md5ctx));
+ break;
+ }
+}
+
+static void
+_checksum_update(struct chksumwork *sumwrk, const void *buff, size_t size)
+{
+
+ switch (sumwrk->alg) {
+ case CKSUM_NONE:
+ break;
+ case CKSUM_SHA1:
+ archive_sha1_update(&(sumwrk->sha1ctx), buff, size);
+ break;
+ case CKSUM_MD5:
+ archive_md5_update(&(sumwrk->md5ctx), buff, size);
+ break;
+ }
+}
+
+static int
+_checksum_final(struct chksumwork *sumwrk, const void *val, size_t len)
+{
+ unsigned char sum[MAX_SUM_SIZE];
+ int r = ARCHIVE_OK;
+
+ switch (sumwrk->alg) {
+ case CKSUM_NONE:
+ break;
+ case CKSUM_SHA1:
+ archive_sha1_final(&(sumwrk->sha1ctx), sum);
+ if (len != SHA1_SIZE ||
+ memcmp(val, sum, SHA1_SIZE) != 0)
+ r = ARCHIVE_FAILED;
+ break;
+ case CKSUM_MD5:
+ archive_md5_final(&(sumwrk->md5ctx), sum);
+ if (len != MD5_SIZE ||
+ memcmp(val, sum, MD5_SIZE) != 0)
+ r = ARCHIVE_FAILED;
+ break;
+ }
+ return (r);
+}
+
+static void
+checksum_init(struct archive_read *a, int a_sum_alg, int e_sum_alg)
+{
+ struct xar *xar;
+
+ xar = (struct xar *)(a->format->data);
+ _checksum_init(&(xar->a_sumwrk), a_sum_alg);
+ _checksum_init(&(xar->e_sumwrk), e_sum_alg);
+}
+
+static void
+checksum_update(struct archive_read *a, const void *abuff, size_t asize,
+ const void *ebuff, size_t esize)
+{
+ struct xar *xar;
+
+ xar = (struct xar *)(a->format->data);
+ _checksum_update(&(xar->a_sumwrk), abuff, asize);
+ _checksum_update(&(xar->e_sumwrk), ebuff, esize);
+}
+
+static int
+checksum_final(struct archive_read *a, const void *a_sum_val,
+ size_t a_sum_len, const void *e_sum_val, size_t e_sum_len)
+{
+ struct xar *xar;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+ r = _checksum_final(&(xar->a_sumwrk), a_sum_val, a_sum_len);
+ if (r == ARCHIVE_OK)
+ r = _checksum_final(&(xar->e_sumwrk), e_sum_val, e_sum_len);
+ if (r != ARCHIVE_OK)
+ archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
+ "Sumcheck error");
+ return (r);
+}
+
+static int
+decompression_init(struct archive_read *a, enum enctype encoding)
+{
+ struct xar *xar;
+ const char *detail;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+ xar->rd_encoding = encoding;
+ switch (encoding) {
+ case NONE:
+ break;
+ case GZIP:
+ if (xar->stream_valid)
+ r = inflateReset(&(xar->stream));
+ else
+ r = inflateInit(&(xar->stream));
+ if (r != Z_OK) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Couldn't initialize zlib stream.");
+ return (ARCHIVE_FATAL);
+ }
+ xar->stream_valid = 1;
+ xar->stream.total_in = 0;
+ xar->stream.total_out = 0;
+ break;
+#ifdef HAVE_BZLIB_H
+ case BZIP2:
+ if (xar->bzstream_valid) {
+ BZ2_bzDecompressEnd(&(xar->bzstream));
+ xar->bzstream_valid = 0;
+ }
+ r = BZ2_bzDecompressInit(&(xar->bzstream), 0, 0);
+ if (r == BZ_MEM_ERROR)
+ r = BZ2_bzDecompressInit(&(xar->bzstream), 0, 1);
+ if (r != BZ_OK) {
+ int err = ARCHIVE_ERRNO_MISC;
+ detail = NULL;
+ switch (r) {
+ case BZ_PARAM_ERROR:
+ detail = "invalid setup parameter";
+ break;
+ case BZ_MEM_ERROR:
+ err = ENOMEM;
+ detail = "out of memory";
+ break;
+ case BZ_CONFIG_ERROR:
+ detail = "mis-compiled library";
+ break;
+ }
+ archive_set_error(&a->archive, err,
+ "Internal error initializing decompressor: %s",
+ detail == NULL ? "??" : detail);
+ xar->bzstream_valid = 0;
+ return (ARCHIVE_FATAL);
+ }
+ xar->bzstream_valid = 1;
+ xar->bzstream.total_in_lo32 = 0;
+ xar->bzstream.total_in_hi32 = 0;
+ xar->bzstream.total_out_lo32 = 0;
+ xar->bzstream.total_out_hi32 = 0;
+ break;
+#endif
+#if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA)
+ case XZ:
+ case LZMA:
+ if (xar->lzstream_valid) {
+ lzma_end(&(xar->lzstream));
+ xar->lzstream_valid = 0;
+ }
+ if (xar->entry_encoding == XZ)
+ r = lzma_stream_decoder(&(xar->lzstream),
+ (1U << 30),/* memlimit */
+ LZMA_CONCATENATED);
+ else
+ r = lzma_alone_decoder(&(xar->lzstream),
+ (1U << 30));/* memlimit */
+ if (r != LZMA_OK) {
+ switch (r) {
+ case LZMA_MEM_ERROR:
+ archive_set_error(&a->archive,
+ ENOMEM,
+ "Internal error initializing "
+ "compression library: "
+ "Cannot allocate memory");
+ break;
+ case LZMA_OPTIONS_ERROR:
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Internal error initializing "
+ "compression library: "
+ "Invalid or unsupported options");
+ break;
+ default:
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Internal error initializing "
+ "lzma library");
+ break;
+ }
+ return (ARCHIVE_FATAL);
+ }
+ xar->lzstream_valid = 1;
+ xar->lzstream.total_in = 0;
+ xar->lzstream.total_out = 0;
+ break;
+#elif defined(HAVE_LZMADEC_H) && defined(HAVE_LIBLZMADEC)
+ case LZMA:
+ if (xar->lzstream_valid)
+ lzmadec_end(&(xar->lzstream));
+ r = lzmadec_init(&(xar->lzstream));
+ if (r != LZMADEC_OK) {
+ switch (r) {
+ case LZMADEC_HEADER_ERROR:
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Internal error initializing "
+ "compression library: "
+ "invalid header");
+ break;
+ case LZMADEC_MEM_ERROR:
+ archive_set_error(&a->archive,
+ ENOMEM,
+ "Internal error initializing "
+ "compression library: "
+ "out of memory");
+ break;
+ }
+ return (ARCHIVE_FATAL);
+ }
+ xar->lzstream_valid = 1;
+ xar->lzstream.total_in = 0;
+ xar->lzstream.total_out = 0;
+ break;
+#endif
+ /*
+ * Unsupported compression.
+ */
+ default:
+#ifndef HAVE_BZLIB_H
+ case BZIP2:
+#endif
+#if !defined(HAVE_LZMA_H) || !defined(HAVE_LIBLZMA)
+#if !defined(HAVE_LZMADEC_H) || !defined(HAVE_LIBLZMADEC)
+ case LZMA:
+#endif
+ case XZ:
+#endif
+ switch (xar->entry_encoding) {
+ case BZIP2: detail = "bzip2"; break;
+ case LZMA: detail = "lzma"; break;
+ case XZ: detail = "xz"; break;
+ default: detail = "??"; break;
+ }
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "%s compression not supported on this platform",
+ detail);
+ return (ARCHIVE_FAILED);
+ }
+ return (ARCHIVE_OK);
+}
+
+static int
+decompress(struct archive_read *a, const void **buff, size_t *outbytes,
+ const void *b, size_t *used)
+{
+ struct xar *xar;
+ void *outbuff;
+ size_t avail_in, avail_out;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+ avail_in = *used;
+ outbuff = (void *)(uintptr_t)*buff;
+ if (outbuff == NULL) {
+ outbuff = xar->buff;
+ *buff = outbuff;
+ avail_out = sizeof(xar->buff);
+ } else
+ avail_out = *outbytes;
+ switch (xar->rd_encoding) {
+ case GZIP:
+ xar->stream.next_in = (Bytef *)(uintptr_t)b;
+ xar->stream.avail_in = avail_in;
+ xar->stream.next_out = (unsigned char *)outbuff;
+ xar->stream.avail_out = avail_out;
+ r = inflate(&(xar->stream), 0);
+ switch (r) {
+ case Z_OK: /* Decompressor made some progress.*/
+ case Z_STREAM_END: /* Found end of stream. */
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "File decompression failed (%d)", r);
+ return (ARCHIVE_FATAL);
+ }
+ *used = avail_in - xar->stream.avail_in;
+ *outbytes = avail_out - xar->stream.avail_out;
+ break;
+#ifdef HAVE_BZLIB_H
+ case BZIP2:
+ xar->bzstream.next_in = (char *)(uintptr_t)b;
+ xar->bzstream.avail_in = avail_in;
+ xar->bzstream.next_out = (char *)outbuff;
+ xar->bzstream.avail_out = avail_out;
+ r = BZ2_bzDecompress(&(xar->bzstream));
+ switch (r) {
+ case BZ_STREAM_END: /* Found end of stream. */
+ switch (BZ2_bzDecompressEnd(&(xar->bzstream))) {
+ case BZ_OK:
+ break;
+ default:
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up decompressor");
+ return (ARCHIVE_FATAL);
+ }
+ xar->bzstream_valid = 0;
+ /* FALLTHROUGH */
+ case BZ_OK: /* Decompressor made some progress. */
+ break;
+ default:
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "bzip decompression failed");
+ return (ARCHIVE_FATAL);
+ }
+ *used = avail_in - xar->bzstream.avail_in;
+ *outbytes = avail_out - xar->bzstream.avail_out;
+ break;
+#endif
+#if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA)
+ case LZMA:
+ case XZ:
+ xar->lzstream.next_in = b;
+ xar->lzstream.avail_in = avail_in;
+ xar->lzstream.next_out = (unsigned char *)outbuff;
+ xar->lzstream.avail_out = avail_out;
+ r = lzma_code(&(xar->lzstream), LZMA_RUN);
+ switch (r) {
+ case LZMA_STREAM_END: /* Found end of stream. */
+ lzma_end(&(xar->lzstream));
+ xar->lzstream_valid = 0;
+ /* FALLTHROUGH */
+ case LZMA_OK: /* Decompressor made some progress. */
+ break;
+ default:
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "%s decompression failed(%d)",
+ (xar->entry_encoding == XZ)?"xz":"lzma",
+ r);
+ return (ARCHIVE_FATAL);
+ }
+ *used = avail_in - xar->lzstream.avail_in;
+ *outbytes = avail_out - xar->lzstream.avail_out;
+ break;
+#elif defined(HAVE_LZMADEC_H) && defined(HAVE_LIBLZMADEC)
+ case LZMA:
+ xar->lzstream.next_in = (unsigned char *)(uintptr_t)b;
+ xar->lzstream.avail_in = avail_in;
+ xar->lzstream.next_out = (unsigned char *)outbuff;
+ xar->lzstream.avail_out = avail_out;
+ r = lzmadec_decode(&(xar->lzstream), 0);
+ switch (r) {
+ case LZMADEC_STREAM_END: /* Found end of stream. */
+ switch (lzmadec_end(&(xar->lzstream))) {
+ case LZMADEC_OK:
+ break;
+ default:
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up lzmadec decompressor");
+ return (ARCHIVE_FATAL);
+ }
+ xar->lzstream_valid = 0;
+ /* FALLTHROUGH */
+ case LZMADEC_OK: /* Decompressor made some progress. */
+ break;
+ default:
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "lzmadec decompression failed(%d)",
+ r);
+ return (ARCHIVE_FATAL);
+ }
+ *used = avail_in - xar->lzstream.avail_in;
+ *outbytes = avail_out - xar->lzstream.avail_out;
+ break;
+#endif
+#ifndef HAVE_BZLIB_H
+ case BZIP2:
+#endif
+#if !defined(HAVE_LZMA_H) || !defined(HAVE_LIBLZMA)
+#if !defined(HAVE_LZMADEC_H) || !defined(HAVE_LIBLZMADEC)
+ case LZMA:
+#endif
+ case XZ:
+#endif
+ case NONE:
+ default:
+ if (outbuff == xar->buff) {
+ *buff = b;
+ *used = avail_in;
+ *outbytes = avail_in;
+ } else {
+ if (avail_out > avail_in)
+ avail_out = avail_in;
+ memcpy(outbuff, b, avail_out);
+ *used = avail_out;
+ *outbytes = avail_out;
+ }
+ break;
+ }
+ return (ARCHIVE_OK);
+}
+
+static int
+decompression_cleanup(struct archive_read *a)
+{
+ struct xar *xar;
+ int r;
+
+ xar = (struct xar *)(a->format->data);
+ r = ARCHIVE_OK;
+ if (xar->stream_valid) {
+ if (inflateEnd(&(xar->stream)) != Z_OK) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up zlib decompressor");
+ r = ARCHIVE_FATAL;
+ }
+ }
+#ifdef HAVE_BZLIB_H
+ if (xar->bzstream_valid) {
+ if (BZ2_bzDecompressEnd(&(xar->bzstream)) != BZ_OK) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up bzip2 decompressor");
+ r = ARCHIVE_FATAL;
+ }
+ }
+#endif
+#if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA)
+ if (xar->lzstream_valid)
+ lzma_end(&(xar->lzstream));
+#elif defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA)
+ if (xar->lzstream_valid) {
+ if (lzmadec_end(&(xar->lzstream)) != LZMADEC_OK) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "Failed to clean up lzmadec decompressor");
+ r = ARCHIVE_FATAL;
+ }
+ }
+#endif
+ return (r);
+}
+
+static void
+xmlattr_cleanup(struct xmlattr_list *list)
+{
+ struct xmlattr *attr, *next;
+
+ attr = list->first;
+ while (attr != NULL) {
+ next = attr->next;
+ free(attr->name);
+ free(attr->value);
+ free(attr);
+ attr = next;
+ }
+ list->first = NULL;
+ list->last = &(list->first);
+}
+
+static void
+file_new(struct xar *xar, struct xmlattr_list *list)
+{
+ struct xar_file *file;
+ struct xmlattr *attr;
+
+ file = calloc(1, sizeof(*file));
+ if (file == NULL)
+ __archive_errx(1, "Out of memory");
+ file->parent = xar->file;
+ file->mode = 0777 | AE_IFREG;
+ file->atime = time(NULL);
+ file->mtime = time(NULL);
+ xar->file = file;
+ xar->xattr = NULL;
+ for (attr = list->first; attr != NULL; attr = attr->next) {
+ if (strcmp(attr->name, "id") == 0)
+ file->id = atol10(attr->value, strlen(attr->value));
+ }
+ file->nlink = 1;
+ heap_add_entry(&(xar->file_queue), file);
+}
+
+static void
+file_free(struct xar_file *file)
+{
+ struct xattr *xattr;
+
+ archive_string_free(&(file->pathname));
+ archive_string_free(&(file->symlink));
+ archive_string_free(&(file->uname));
+ archive_string_free(&(file->gname));
+ archive_string_free(&(file->hardlink));
+ xattr = file->xattr_list;
+ while (xattr != NULL) {
+ struct xattr *next;
+
+ next = xattr->next;
+ xattr_free(xattr);
+ xattr = next;
+ }
+
+ free(file);
+}
+
+static void
+xattr_new(struct xar *xar, struct xmlattr_list *list)
+{
+ struct xattr *xattr, **nx;
+ struct xmlattr *attr;
+
+ xattr = calloc(1, sizeof(*xattr));
+ if (xattr == NULL)
+ __archive_errx(1, "Out of memory");
+ xar->xattr = xattr;
+ for (attr = list->first; attr != NULL; attr = attr->next) {
+ if (strcmp(attr->name, "id") == 0)
+ xattr->id = atol10(attr->value, strlen(attr->value));
+ }
+ /* Chain to xattr list. */
+ for (nx = &(xar->file->xattr_list);
+ *nx != NULL; nx = &((*nx)->next)) {
+ if (xattr->id < (*nx)->id)
+ break;
+ }
+ xattr->next = *nx;
+ *nx = xattr;
+}
+
+static void
+xattr_free(struct xattr *xattr)
+{
+ archive_string_free(&(xattr->name));
+ free(xattr);
+}
+
+static int
+getencoding(struct xmlattr_list *list)
+{
+ struct xmlattr *attr;
+ enum enctype encoding = NONE;
+
+ for (attr = list->first; attr != NULL; attr = attr->next) {
+ if (strcmp(attr->name, "style") == 0) {
+ if (strcmp(attr->value, "application/octet-stream") == 0)
+ encoding = NONE;
+ else if (strcmp(attr->value, "application/x-gzip") == 0)
+ encoding = GZIP;
+ else if (strcmp(attr->value, "application/x-bzip2") == 0)
+ encoding = BZIP2;
+ else if (strcmp(attr->value, "application/x-lzma") == 0)
+ encoding = LZMA;
+ else if (strcmp(attr->value, "application/x-xz") == 0)
+ encoding = XZ;
+ }
+ }
+ return (encoding);
+}
+
+static int
+getsumalgorithm(struct xmlattr_list *list)
+{
+ struct xmlattr *attr;
+ int alg = CKSUM_NONE;
+
+ for (attr = list->first; attr != NULL; attr = attr->next) {
+ if (strcmp(attr->name, "style") == 0) {
+ const char *v = attr->value;
+ if ((v[0] == 'S' || v[0] == 's') &&
+ (v[1] == 'H' || v[1] == 'h') &&
+ (v[2] == 'A' || v[2] == 'a') &&
+ v[3] == '1' && v[4] == '\0')
+ alg = CKSUM_SHA1;
+ if ((v[0] == 'M' || v[0] == 'm') &&
+ (v[1] == 'D' || v[1] == 'd') &&
+ v[2] == '5' && v[3] == '\0')
+ alg = CKSUM_MD5;
+ }
+ }
+ return (alg);
+}
+
+static void
+unknowntag_start(struct xar *xar, const char *name)
+{
+ struct unknown_tag *tag;
+
+#if DEBUG
+ fprintf(stderr, "unknowntag_start:%s\n", name);
+#endif
+ tag = malloc(sizeof(*tag));
+ if (tag == NULL)
+ __archive_errx(1, "Out of memory");
+ tag->next = xar->unknowntags;
+ archive_string_init(&(tag->name));
+ archive_strcpy(&(tag->name), name);
+ if (xar->unknowntags == NULL) {
+ xar->xmlsts_unknown = xar->xmlsts;
+ xar->xmlsts = UNKNOWN;
+ }
+ xar->unknowntags = tag;
+}
+
+static void
+unknowntag_end(struct xar *xar, const char *name)
+{
+ struct unknown_tag *tag;
+
+#if DEBUG
+ fprintf(stderr, "unknowntag_end:%s\n", name);
+#endif
+ tag = xar->unknowntags;
+ if (tag == NULL || name == NULL)
+ return;
+ if (strcmp(tag->name.s, name) == 0) {
+ xar->unknowntags = tag->next;
+ archive_string_free(&(tag->name));
+ free(tag);
+ if (xar->unknowntags == NULL)
+ xar->xmlsts = xar->xmlsts_unknown;
+ }
+}
+
+static void
+xml_start(void *userData, const char *name, struct xmlattr_list *list)
+{
+ struct archive_read *a;
+ struct xar *xar;
+ struct xmlattr *attr;
+
+ a = (struct archive_read *)userData;
+ xar = (struct xar *)(a->format->data);
+
+#if DEBUG
+ fprintf(stderr, "xml_sta:[%s]\n", name);
+ for (attr = list->first; attr != NULL; attr = attr->next)
+ fprintf(stderr, " attr:\"%s\"=\"%s\"\n",
+ attr->name, attr->value);
+#endif
+ xar->base64text = 0;
+ switch (xar->xmlsts) {
+ case INIT:
+ if (strcmp(name, "xar") == 0)
+ xar->xmlsts = XAR;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case XAR:
+ if (strcmp(name, "toc") == 0)
+ xar->xmlsts = TOC;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case TOC:
+ if (strcmp(name, "creation-time") == 0)
+ xar->xmlsts = TOC_CREATION_TIME;
+ else if (strcmp(name, "checksum") == 0)
+ xar->xmlsts = TOC_CHECKSUM;
+ else if (strcmp(name, "file") == 0) {
+ file_new(xar, list);
+ xar->xmlsts = TOC_FILE;
+ }
+ else
+ unknowntag_start(xar, name);
+ break;
+ case TOC_CHECKSUM:
+ if (strcmp(name, "offset") == 0)
+ xar->xmlsts = TOC_CHECKSUM_OFFSET;
+ else if (strcmp(name, "size") == 0)
+ xar->xmlsts = TOC_CHECKSUM_SIZE;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case TOC_FILE:
+ if (strcmp(name, "file") == 0) {
+ file_new(xar, list);
+ }
+ else if (strcmp(name, "data") == 0)
+ xar->xmlsts = FILE_DATA;
+ else if (strcmp(name, "ea") == 0) {
+ xattr_new(xar, list);
+ xar->xmlsts = FILE_EA;
+ }
+ else if (strcmp(name, "ctime") == 0)
+ xar->xmlsts = FILE_CTIME;
+ else if (strcmp(name, "mtime") == 0)
+ xar->xmlsts = FILE_MTIME;
+ else if (strcmp(name, "atime") == 0)
+ xar->xmlsts = FILE_ATIME;
+ else if (strcmp(name, "group") == 0)
+ xar->xmlsts = FILE_GROUP;
+ else if (strcmp(name, "gid") == 0)
+ xar->xmlsts = FILE_GID;
+ else if (strcmp(name, "user") == 0)
+ xar->xmlsts = FILE_USER;
+ else if (strcmp(name, "uid") == 0)
+ xar->xmlsts = FILE_UID;
+ else if (strcmp(name, "mode") == 0)
+ xar->xmlsts = FILE_MODE;
+ else if (strcmp(name, "device") == 0)
+ xar->xmlsts = FILE_DEVICE;
+ else if (strcmp(name, "deviceno") == 0)
+ xar->xmlsts = FILE_DEVICENO;
+ else if (strcmp(name, "inode") == 0)
+ xar->xmlsts = FILE_INODE;
+ else if (strcmp(name, "link") == 0)
+ xar->xmlsts = FILE_LINK;
+ else if (strcmp(name, "type") == 0) {
+ xar->xmlsts = FILE_TYPE;
+ for (attr = list->first; attr != NULL;
+ attr = attr->next) {
+ if (strcmp(attr->name, "link") != 0)
+ continue;
+ if (strcmp(attr->value, "original") == 0) {
+ xar->file->hdnext = xar->hdlink_orgs;
+ xar->hdlink_orgs = xar->file;
+ } else {
+ xar->file->link = atol10(attr->value,
+ strlen(attr->value));
+ if (xar->file->link > 0)
+ add_link(xar, xar->file);
+ }
+ }
+ }
+ else if (strcmp(name, "name") == 0) {
+ xar->xmlsts = FILE_NAME;
+ for (attr = list->first; attr != NULL;
+ attr = attr->next) {
+ if (strcmp(attr->name, "enctype") == 0 &&
+ strcmp(attr->value, "base64") == 0)
+ xar->base64text = 1;
+ }
+ }
+ else if (strcmp(name, "acl") == 0)
+ xar->xmlsts = FILE_ACL;
+ else if (strcmp(name, "flags") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ else if (strcmp(name, "ext2") == 0)
+ xar->xmlsts = FILE_EXT2;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case FILE_DATA:
+ if (strcmp(name, "length") == 0)
+ xar->xmlsts = FILE_DATA_LENGTH;
+ else if (strcmp(name, "offset") == 0)
+ xar->xmlsts = FILE_DATA_OFFSET;
+ else if (strcmp(name, "size") == 0)
+ xar->xmlsts = FILE_DATA_SIZE;
+ else if (strcmp(name, "encoding") == 0) {
+ xar->xmlsts = FILE_DATA_ENCODING;
+ xar->file->encoding = getencoding(list);
+ }
+ else if (strcmp(name, "archived-checksum") == 0) {
+ xar->xmlsts = FILE_DATA_A_CHECKSUM;
+ xar->file->a_sum.alg = getsumalgorithm(list);
+ }
+ else if (strcmp(name, "extracted-checksum") == 0) {
+ xar->xmlsts = FILE_DATA_E_CHECKSUM;
+ xar->file->e_sum.alg = getsumalgorithm(list);
+ }
+ else if (strcmp(name, "content") == 0)
+ xar->xmlsts = FILE_DATA_CONTENT;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case FILE_DEVICE:
+ if (strcmp(name, "major") == 0)
+ xar->xmlsts = FILE_DEVICE_MAJOR;
+ else if (strcmp(name, "minor") == 0)
+ xar->xmlsts = FILE_DEVICE_MINOR;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case FILE_DATA_CONTENT:
+ unknowntag_start(xar, name);
+ break;
+ case FILE_EA:
+ if (strcmp(name, "length") == 0)
+ xar->xmlsts = FILE_EA_LENGTH;
+ else if (strcmp(name, "offset") == 0)
+ xar->xmlsts = FILE_EA_OFFSET;
+ else if (strcmp(name, "size") == 0)
+ xar->xmlsts = FILE_EA_SIZE;
+ else if (strcmp(name, "encoding") == 0) {
+ xar->xmlsts = FILE_EA_ENCODING;
+ xar->xattr->encoding = getencoding(list);
+ } else if (strcmp(name, "archived-checksum") == 0)
+ xar->xmlsts = FILE_EA_A_CHECKSUM;
+ else if (strcmp(name, "extracted-checksum") == 0)
+ xar->xmlsts = FILE_EA_E_CHECKSUM;
+ else if (strcmp(name, "name") == 0)
+ xar->xmlsts = FILE_EA_NAME;
+ else if (strcmp(name, "fstype") == 0)
+ xar->xmlsts = FILE_EA_FSTYPE;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case FILE_ACL:
+ if (strcmp(name, "appleextended") == 0)
+ xar->xmlsts = FILE_ACL_APPLEEXTENDED;
+ if (strcmp(name, "default") == 0)
+ xar->xmlsts = FILE_ACL_DEFAULT;
+ else if (strcmp(name, "access") == 0)
+ xar->xmlsts = FILE_ACL_ACCESS;
+ else
+ unknowntag_start(xar, name);
+ break;
+ case FILE_FLAGS:
+ if (!xml_parse_file_flags(xar, name))
+ unknowntag_start(xar, name);
+ break;
+ case FILE_EXT2:
+ if (!xml_parse_file_ext2(xar, name))
+ unknowntag_start(xar, name);
+ break;
+ case TOC_CREATION_TIME:
+ case TOC_CHECKSUM_OFFSET:
+ case TOC_CHECKSUM_SIZE:
+ case FILE_DATA_LENGTH:
+ case FILE_DATA_OFFSET:
+ case FILE_DATA_SIZE:
+ case FILE_DATA_ENCODING:
+ case FILE_DATA_A_CHECKSUM:
+ case FILE_DATA_E_CHECKSUM:
+ case FILE_EA_LENGTH:
+ case FILE_EA_OFFSET:
+ case FILE_EA_SIZE:
+ case FILE_EA_ENCODING:
+ case FILE_EA_A_CHECKSUM:
+ case FILE_EA_E_CHECKSUM:
+ case FILE_EA_NAME:
+ case FILE_EA_FSTYPE:
+ case FILE_CTIME:
+ case FILE_MTIME:
+ case FILE_ATIME:
+ case FILE_GROUP:
+ case FILE_GID:
+ case FILE_USER:
+ case FILE_UID:
+ case FILE_INODE:
+ case FILE_DEVICE_MAJOR:
+ case FILE_DEVICE_MINOR:
+ case FILE_DEVICENO:
+ case FILE_MODE:
+ case FILE_TYPE:
+ case FILE_LINK:
+ case FILE_NAME:
+ case FILE_ACL_DEFAULT:
+ case FILE_ACL_ACCESS:
+ case FILE_ACL_APPLEEXTENDED:
+ case FILE_FLAGS_USER_NODUMP:
+ case FILE_FLAGS_USER_IMMUTABLE:
+ case FILE_FLAGS_USER_APPEND:
+ case FILE_FLAGS_USER_OPAQUE:
+ case FILE_FLAGS_USER_NOUNLINK:
+ case FILE_FLAGS_SYS_ARCHIVED:
+ case FILE_FLAGS_SYS_IMMUTABLE:
+ case FILE_FLAGS_SYS_APPEND:
+ case FILE_FLAGS_SYS_NOUNLINK:
+ case FILE_FLAGS_SYS_SNAPSHOT:
+ case FILE_EXT2_SecureDeletion:
+ case FILE_EXT2_Undelete:
+ case FILE_EXT2_Compress:
+ case FILE_EXT2_Synchronous:
+ case FILE_EXT2_Immutable:
+ case FILE_EXT2_AppendOnly:
+ case FILE_EXT2_NoDump:
+ case FILE_EXT2_NoAtime:
+ case FILE_EXT2_CompDirty:
+ case FILE_EXT2_CompBlock:
+ case FILE_EXT2_NoCompBlock:
+ case FILE_EXT2_CompError:
+ case FILE_EXT2_BTree:
+ case FILE_EXT2_HashIndexed:
+ case FILE_EXT2_iMagic:
+ case FILE_EXT2_Journaled:
+ case FILE_EXT2_NoTail:
+ case FILE_EXT2_DirSync:
+ case FILE_EXT2_TopDir:
+ case FILE_EXT2_Reserved:
+ case UNKNOWN:
+ unknowntag_start(xar, name);
+ break;
+ }
+}
+
+static void
+xml_end(void *userData, const char *name)
+{
+ struct archive_read *a;
+ struct xar *xar;
+
+ a = (struct archive_read *)userData;
+ xar = (struct xar *)(a->format->data);
+
+#if DEBUG
+ fprintf(stderr, "xml_end:[%s]\n", name);
+#endif
+ switch (xar->xmlsts) {
+ case INIT:
+ break;
+ case XAR:
+ if (strcmp(name, "xar") == 0)
+ xar->xmlsts = INIT;
+ break;
+ case TOC:
+ if (strcmp(name, "toc") == 0)
+ xar->xmlsts = XAR;
+ break;
+ case TOC_CREATION_TIME:
+ if (strcmp(name, "creation-time") == 0)
+ xar->xmlsts = TOC;
+ break;
+ case TOC_CHECKSUM:
+ if (strcmp(name, "checksum") == 0)
+ xar->xmlsts = TOC;
+ break;
+ case TOC_CHECKSUM_OFFSET:
+ if (strcmp(name, "offset") == 0)
+ xar->xmlsts = TOC_CHECKSUM;
+ break;
+ case TOC_CHECKSUM_SIZE:
+ if (strcmp(name, "size") == 0)
+ xar->xmlsts = TOC_CHECKSUM;
+ break;
+ case TOC_FILE:
+ if (strcmp(name, "file") == 0) {
+ if (xar->file->parent != NULL &&
+ ((xar->file->mode & AE_IFMT) == AE_IFDIR))
+ xar->file->parent->subdirs++;
+ xar->file = xar->file->parent;
+ if (xar->file == NULL)
+ xar->xmlsts = TOC;
+ }
+ break;
+ case FILE_DATA:
+ if (strcmp(name, "data") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_DATA_LENGTH:
+ if (strcmp(name, "length") == 0)
+ xar->xmlsts = FILE_DATA;
+ break;
+ case FILE_DATA_OFFSET:
+ if (strcmp(name, "offset") == 0)
+ xar->xmlsts = FILE_DATA;
+ break;
+ case FILE_DATA_SIZE:
+ if (strcmp(name, "size") == 0)
+ xar->xmlsts = FILE_DATA;
+ break;
+ case FILE_DATA_ENCODING:
+ if (strcmp(name, "encoding") == 0)
+ xar->xmlsts = FILE_DATA;
+ break;
+ case FILE_DATA_A_CHECKSUM:
+ if (strcmp(name, "archived-checksum") == 0)
+ xar->xmlsts = FILE_DATA;
+ break;
+ case FILE_DATA_E_CHECKSUM:
+ if (strcmp(name, "extracted-checksum") == 0)
+ xar->xmlsts = FILE_DATA;
+ break;
+ case FILE_DATA_CONTENT:
+ if (strcmp(name, "content") == 0)
+ xar->xmlsts = FILE_DATA;
+ break;
+ case FILE_EA:
+ if (strcmp(name, "ea") == 0) {
+ xar->xmlsts = TOC_FILE;
+ xar->xattr = NULL;
+ }
+ break;
+ case FILE_EA_LENGTH:
+ if (strcmp(name, "length") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_EA_OFFSET:
+ if (strcmp(name, "offset") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_EA_SIZE:
+ if (strcmp(name, "size") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_EA_ENCODING:
+ if (strcmp(name, "encoding") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_EA_A_CHECKSUM:
+ if (strcmp(name, "archived-checksum") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_EA_E_CHECKSUM:
+ if (strcmp(name, "extracted-checksum") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_EA_NAME:
+ if (strcmp(name, "name") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_EA_FSTYPE:
+ if (strcmp(name, "fstype") == 0)
+ xar->xmlsts = FILE_EA;
+ break;
+ case FILE_CTIME:
+ if (strcmp(name, "ctime") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_MTIME:
+ if (strcmp(name, "mtime") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_ATIME:
+ if (strcmp(name, "atime") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_GROUP:
+ if (strcmp(name, "group") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_GID:
+ if (strcmp(name, "gid") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_USER:
+ if (strcmp(name, "user") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_UID:
+ if (strcmp(name, "uid") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_MODE:
+ if (strcmp(name, "mode") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_DEVICE:
+ if (strcmp(name, "device") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_DEVICE_MAJOR:
+ if (strcmp(name, "major") == 0)
+ xar->xmlsts = FILE_DEVICE;
+ break;
+ case FILE_DEVICE_MINOR:
+ if (strcmp(name, "minor") == 0)
+ xar->xmlsts = FILE_DEVICE;
+ break;
+ case FILE_DEVICENO:
+ if (strcmp(name, "deviceno") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_INODE:
+ if (strcmp(name, "inode") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_LINK:
+ if (strcmp(name, "link") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_TYPE:
+ if (strcmp(name, "type") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_NAME:
+ if (strcmp(name, "name") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_ACL:
+ if (strcmp(name, "acl") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_ACL_DEFAULT:
+ if (strcmp(name, "default") == 0)
+ xar->xmlsts = FILE_ACL;
+ break;
+ case FILE_ACL_ACCESS:
+ if (strcmp(name, "access") == 0)
+ xar->xmlsts = FILE_ACL;
+ break;
+ case FILE_ACL_APPLEEXTENDED:
+ if (strcmp(name, "appleextended") == 0)
+ xar->xmlsts = FILE_ACL;
+ break;
+ case FILE_FLAGS:
+ if (strcmp(name, "flags") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_FLAGS_USER_NODUMP:
+ if (strcmp(name, "UserNoDump") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_USER_IMMUTABLE:
+ if (strcmp(name, "UserImmutable") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_USER_APPEND:
+ if (strcmp(name, "UserAppend") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_USER_OPAQUE:
+ if (strcmp(name, "UserOpaque") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_USER_NOUNLINK:
+ if (strcmp(name, "UserNoUnlink") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_SYS_ARCHIVED:
+ if (strcmp(name, "SystemArchived") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_SYS_IMMUTABLE:
+ if (strcmp(name, "SystemImmutable") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_SYS_APPEND:
+ if (strcmp(name, "SystemAppend") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_SYS_NOUNLINK:
+ if (strcmp(name, "SystemNoUnlink") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_FLAGS_SYS_SNAPSHOT:
+ if (strcmp(name, "SystemSnapshot") == 0)
+ xar->xmlsts = FILE_FLAGS;
+ break;
+ case FILE_EXT2:
+ if (strcmp(name, "ext2") == 0)
+ xar->xmlsts = TOC_FILE;
+ break;
+ case FILE_EXT2_SecureDeletion:
+ if (strcmp(name, "SecureDeletion") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_Undelete:
+ if (strcmp(name, "Undelete") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_Compress:
+ if (strcmp(name, "Compress") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_Synchronous:
+ if (strcmp(name, "Synchronous") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_Immutable:
+ if (strcmp(name, "Immutable") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_AppendOnly:
+ if (strcmp(name, "AppendOnly") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_NoDump:
+ if (strcmp(name, "NoDump") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_NoAtime:
+ if (strcmp(name, "NoAtime") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_CompDirty:
+ if (strcmp(name, "CompDirty") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_CompBlock:
+ if (strcmp(name, "CompBlock") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_NoCompBlock:
+ if (strcmp(name, "NoCompBlock") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_CompError:
+ if (strcmp(name, "CompError") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_BTree:
+ if (strcmp(name, "BTree") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_HashIndexed:
+ if (strcmp(name, "HashIndexed") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_iMagic:
+ if (strcmp(name, "iMagic") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_Journaled:
+ if (strcmp(name, "Journaled") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_NoTail:
+ if (strcmp(name, "NoTail") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_DirSync:
+ if (strcmp(name, "DirSync") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_TopDir:
+ if (strcmp(name, "TopDir") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case FILE_EXT2_Reserved:
+ if (strcmp(name, "Reserved") == 0)
+ xar->xmlsts = FILE_EXT2;
+ break;
+ case UNKNOWN:
+ unknowntag_end(xar, name);
+ break;
+ }
+}
+
+static const int base64[256] = {
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 00 - 0F */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 10 - 1F */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, 62, -1, -1, -1, 63, /* 20 - 2F */
+ 52, 53, 54, 55, 56, 57, 58, 59,
+ 60, 61, -1, -1, -1, -1, -1, -1, /* 30 - 3F */
+ -1, 0, 1, 2, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, /* 40 - 4F */
+ 15, 16, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, -1, -1, -1, -1, -1, /* 50 - 5F */
+ -1, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, /* 60 - 6F */
+ 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, -1, -1, -1, -1, -1, /* 70 - 7F */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 80 - 8F */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* 90 - 9F */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* A0 - AF */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* B0 - BF */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* C0 - CF */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* D0 - DF */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* E0 - EF */
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, /* F0 - FF */
+};
+
+static void
+strappend_base64(struct archive_string *as, const char *s, size_t l)
+{
+ unsigned char buff[256];
+ unsigned char *out;
+ const unsigned char *b;
+ size_t len;
+
+ len = 0;
+ out = buff;
+ b = (const unsigned char *)s;
+ while (l > 0) {
+ int n = 0;
+
+ if (l > 0) {
+ if (base64[b[0]] < 0 || base64[b[1]] < 0)
+ break;
+ n = base64[*b++] << 18;
+ n |= base64[*b++] << 12;
+ *out++ = n >> 16;
+ len++;
+ l -= 2;
+ }
+ if (l > 0) {
+ if (base64[*b] < 0)
+ break;
+ n |= base64[*b++] << 6;
+ *out++ = (n >> 8) & 0xFF;
+ len++;
+ --l;
+ }
+ if (l > 0) {
+ if (base64[*b] < 0)
+ break;
+ n |= base64[*b++];
+ *out++ = n & 0xFF;
+ len++;
+ --l;
+ }
+ if (len+3 >= sizeof(buff)) {
+ archive_strncat(as, (const char *)buff, len);
+ len = 0;
+ out = buff;
+ }
+ }
+ if (len > 0)
+ archive_strncat(as, (const char *)buff, len);
+}
+
+static void
+xml_data(void *userData, const char *s, int len)
+{
+ struct archive_read *a;
+ struct xar *xar;
+
+ a = (struct archive_read *)userData;
+ xar = (struct xar *)(a->format->data);
+
+#if DEBUG
+ {
+ char buff[1024];
+ if (len > sizeof(buff)-1)
+ len = sizeof(buff)-1;
+ memcpy(buff, s, len);
+ buff[len] = 0;
+ fprintf(stderr, "\tlen=%d:\"%s\"\n", len, buff);
+ }
+#endif
+ switch (xar->xmlsts) {
+ case TOC_CHECKSUM_OFFSET:
+ xar->toc_chksum_offset = atol10(s, len);
+ break;
+ case TOC_CHECKSUM_SIZE:
+ xar->toc_chksum_size = atol10(s, len);
+ break;
+ default:
+ break;
+ }
+ if (xar->file == NULL)
+ return;
+
+ switch (xar->xmlsts) {
+ case FILE_NAME:
+ if (xar->file->parent != NULL) {
+ archive_string_concat(&(xar->file->pathname),
+ &(xar->file->parent->pathname));
+ archive_strappend_char(&(xar->file->pathname), '/');
+ }
+ xar->file->has |= HAS_PATHNAME;
+ if (xar->base64text)
+ strappend_base64(&(xar->file->pathname), s, len);
+ else
+ archive_strncat(&(xar->file->pathname), s, len);
+ break;
+ case FILE_LINK:
+ xar->file->has |= HAS_SYMLINK;
+ archive_strncpy(&(xar->file->symlink), s, len);
+ break;
+ case FILE_TYPE:
+ if (strncmp("file", s, len) == 0 ||
+ strncmp("hardlink", s, len) == 0)
+ xar->file->mode =
+ (xar->file->mode & ~AE_IFMT) | AE_IFREG;
+ if (strncmp("directory", s, len) == 0)
+ xar->file->mode =
+ (xar->file->mode & ~AE_IFMT) | AE_IFDIR;
+ if (strncmp("symlink", s, len) == 0)
+ xar->file->mode =
+ (xar->file->mode & ~AE_IFMT) | AE_IFLNK;
+ if (strncmp("character special", s, len) == 0)
+ xar->file->mode =
+ (xar->file->mode & ~AE_IFMT) | AE_IFCHR;
+ if (strncmp("block special", s, len) == 0)
+ xar->file->mode =
+ (xar->file->mode & ~AE_IFMT) | AE_IFBLK;
+ if (strncmp("socket", s, len) == 0)
+ xar->file->mode =
+ (xar->file->mode & ~AE_IFMT) | AE_IFSOCK;
+ if (strncmp("fifo", s, len) == 0)
+ xar->file->mode =
+ (xar->file->mode & ~AE_IFMT) | AE_IFIFO;
+ xar->file->has |= HAS_TYPE;
+ break;
+ case FILE_INODE:
+ xar->file->has |= HAS_INO;
+ xar->file->ino64 = atol10(s, len);
+ break;
+ case FILE_DEVICE_MAJOR:
+ xar->file->has |= HAS_DEVMAJOR;
+ xar->file->devmajor = (dev_t)atol10(s, len);
+ break;
+ case FILE_DEVICE_MINOR:
+ xar->file->has |= HAS_DEVMINOR;
+ xar->file->devminor = (dev_t)atol10(s, len);
+ break;
+ case FILE_DEVICENO:
+ xar->file->has |= HAS_DEV;
+ xar->file->dev = (dev_t)atol10(s, len);
+ break;
+ case FILE_MODE:
+ xar->file->has |= HAS_MODE;
+ xar->file->mode =
+ (xar->file->mode & AE_IFMT) |
+ (atol8(s, len) & ~AE_IFMT);
+ break;
+ case FILE_GROUP:
+ xar->file->has |= HAS_GID;
+ archive_strncpy(&(xar->file->gname), s, len);
+ break;
+ case FILE_GID:
+ xar->file->has |= HAS_GID;
+ xar->file->gid = atol10(s, len);
+ break;
+ case FILE_USER:
+ xar->file->has |= HAS_UID;
+ archive_strncpy(&(xar->file->uname), s, len);
+ break;
+ case FILE_UID:
+ xar->file->has |= HAS_UID;
+ xar->file->uid = atol10(s, len);
+ break;
+ case FILE_CTIME:
+ xar->file->has |= HAS_TIME;
+ xar->file->ctime = parse_time(s, len);
+ break;
+ case FILE_MTIME:
+ xar->file->has |= HAS_TIME;
+ xar->file->mtime = parse_time(s, len);
+ break;
+ case FILE_ATIME:
+ xar->file->has |= HAS_TIME;
+ xar->file->atime = parse_time(s, len);
+ break;
+ case FILE_DATA_LENGTH:
+ xar->file->has |= HAS_DATA;
+ xar->file->length = atol10(s, len);
+ break;
+ case FILE_DATA_OFFSET:
+ xar->file->has |= HAS_DATA;
+ xar->file->offset = atol10(s, len);
+ break;
+ case FILE_DATA_SIZE:
+ xar->file->has |= HAS_DATA;
+ xar->file->size = atol10(s, len);
+ break;
+ case FILE_DATA_A_CHECKSUM:
+ xar->file->a_sum.len = atohex(xar->file->a_sum.val,
+ sizeof(xar->file->a_sum.val), s, len);
+ break;
+ case FILE_DATA_E_CHECKSUM:
+ xar->file->e_sum.len = atohex(xar->file->e_sum.val,
+ sizeof(xar->file->e_sum.val), s, len);
+ break;
+ case FILE_EA_LENGTH:
+ xar->file->has |= HAS_XATTR;
+ xar->xattr->length = atol10(s, len);
+ break;
+ case FILE_EA_OFFSET:
+ xar->file->has |= HAS_XATTR;
+ xar->xattr->offset = atol10(s, len);
+ break;
+ case FILE_EA_SIZE:
+ xar->file->has |= HAS_XATTR;
+ xar->xattr->size = atol10(s, len);
+ break;
+ case FILE_EA_A_CHECKSUM:
+ xar->file->has |= HAS_XATTR;
+ xar->xattr->a_sum.len = atohex(xar->xattr->a_sum.val,
+ sizeof(xar->xattr->a_sum.val), s, len);
+ break;
+ case FILE_EA_E_CHECKSUM:
+ xar->file->has |= HAS_XATTR;
+ xar->xattr->e_sum.len = atohex(xar->xattr->e_sum.val,
+ sizeof(xar->xattr->e_sum.val), s, len);
+ break;
+ case FILE_EA_NAME:
+ xar->file->has |= HAS_XATTR;
+ archive_strncpy(&(xar->xattr->name), s, len);
+ break;
+ case FILE_EA_FSTYPE:
+ xar->file->has |= HAS_XATTR;
+ archive_strncpy(&(xar->xattr->fstype), s, len);
+ break;
+ break;
+ case FILE_ACL_DEFAULT:
+ case FILE_ACL_ACCESS:
+ case FILE_ACL_APPLEEXTENDED:
+ xar->file->has |= HAS_ACL;
+ /* TODO */
+ break;
+ case INIT:
+ case XAR:
+ case TOC:
+ case TOC_CREATION_TIME:
+ case TOC_CHECKSUM:
+ case TOC_CHECKSUM_OFFSET:
+ case TOC_CHECKSUM_SIZE:
+ case TOC_FILE:
+ case FILE_DATA:
+ case FILE_DATA_ENCODING:
+ case FILE_DATA_CONTENT:
+ case FILE_DEVICE:
+ case FILE_EA:
+ case FILE_EA_ENCODING:
+ case FILE_ACL:
+ case FILE_FLAGS:
+ case FILE_FLAGS_USER_NODUMP:
+ case FILE_FLAGS_USER_IMMUTABLE:
+ case FILE_FLAGS_USER_APPEND:
+ case FILE_FLAGS_USER_OPAQUE:
+ case FILE_FLAGS_USER_NOUNLINK:
+ case FILE_FLAGS_SYS_ARCHIVED:
+ case FILE_FLAGS_SYS_IMMUTABLE:
+ case FILE_FLAGS_SYS_APPEND:
+ case FILE_FLAGS_SYS_NOUNLINK:
+ case FILE_FLAGS_SYS_SNAPSHOT:
+ case FILE_EXT2:
+ case FILE_EXT2_SecureDeletion:
+ case FILE_EXT2_Undelete:
+ case FILE_EXT2_Compress:
+ case FILE_EXT2_Synchronous:
+ case FILE_EXT2_Immutable:
+ case FILE_EXT2_AppendOnly:
+ case FILE_EXT2_NoDump:
+ case FILE_EXT2_NoAtime:
+ case FILE_EXT2_CompDirty:
+ case FILE_EXT2_CompBlock:
+ case FILE_EXT2_NoCompBlock:
+ case FILE_EXT2_CompError:
+ case FILE_EXT2_BTree:
+ case FILE_EXT2_HashIndexed:
+ case FILE_EXT2_iMagic:
+ case FILE_EXT2_Journaled:
+ case FILE_EXT2_NoTail:
+ case FILE_EXT2_DirSync:
+ case FILE_EXT2_TopDir:
+ case FILE_EXT2_Reserved:
+ case UNKNOWN:
+ break;
+ }
+}
+
+/*
+ * BSD file flags.
+ */
+static int
+xml_parse_file_flags(struct xar *xar, const char *name)
+{
+ const char *flag = NULL;
+
+ if (strcmp(name, "UserNoDump") == 0) {
+ xar->xmlsts = FILE_FLAGS_USER_NODUMP;
+ flag = "nodump";
+ }
+ else if (strcmp(name, "UserImmutable") == 0) {
+ xar->xmlsts = FILE_FLAGS_USER_IMMUTABLE;
+ flag = "uimmutable";
+ }
+ else if (strcmp(name, "UserAppend") == 0) {
+ xar->xmlsts = FILE_FLAGS_USER_APPEND;
+ flag = "uappend";
+ }
+ else if (strcmp(name, "UserOpaque") == 0) {
+ xar->xmlsts = FILE_FLAGS_USER_OPAQUE;
+ flag = "opaque";
+ }
+ else if (strcmp(name, "UserNoUnlink") == 0) {
+ xar->xmlsts = FILE_FLAGS_USER_NOUNLINK;
+ flag = "nouunlink";
+ }
+ else if (strcmp(name, "SystemArchived") == 0) {
+ xar->xmlsts = FILE_FLAGS_SYS_ARCHIVED;
+ flag = "archived";
+ }
+ else if (strcmp(name, "SystemImmutable") == 0) {
+ xar->xmlsts = FILE_FLAGS_SYS_IMMUTABLE;
+ flag = "simmutable";
+ }
+ else if (strcmp(name, "SystemAppend") == 0) {
+ xar->xmlsts = FILE_FLAGS_SYS_APPEND;
+ flag = "sappend";
+ }
+ else if (strcmp(name, "SystemNoUnlink") == 0) {
+ xar->xmlsts = FILE_FLAGS_SYS_NOUNLINK;
+ flag = "nosunlink";
+ }
+ else if (strcmp(name, "SystemSnapshot") == 0) {
+ xar->xmlsts = FILE_FLAGS_SYS_SNAPSHOT;
+ flag = "snapshot";
+ }
+
+ if (flag == NULL)
+ return (0);
+ xar->file->has |= HAS_FFLAGS;
+ if (archive_strlen(&(xar->file->fflags_text)) > 0)
+ archive_strappend_char(&(xar->file->fflags_text), ',');
+ archive_strcat(&(xar->file->fflags_text), flag);
+ return (1);
+}
+
+/*
+ * Linux file flags.
+ */
+static int
+xml_parse_file_ext2(struct xar *xar, const char *name)
+{
+ const char *flag = NULL;
+
+ if (strcmp(name, "SecureDeletion") == 0) {
+ xar->xmlsts = FILE_EXT2_SecureDeletion;
+ flag = "securedeletion";
+ }
+ else if (strcmp(name, "Undelete") == 0) {
+ xar->xmlsts = FILE_EXT2_Undelete;
+ flag = "nouunlink";
+ }
+ else if (strcmp(name, "Compress") == 0) {
+ xar->xmlsts = FILE_EXT2_Compress;
+ flag = "compress";
+ }
+ else if (strcmp(name, "Synchronous") == 0) {
+ xar->xmlsts = FILE_EXT2_Synchronous;
+ flag = "sync";
+ }
+ else if (strcmp(name, "Immutable") == 0) {
+ xar->xmlsts = FILE_EXT2_Immutable;
+ flag = "simmutable";
+ }
+ else if (strcmp(name, "AppendOnly") == 0) {
+ xar->xmlsts = FILE_EXT2_AppendOnly;
+ flag = "sappend";
+ }
+ else if (strcmp(name, "NoDump") == 0) {
+ xar->xmlsts = FILE_EXT2_NoDump;
+ flag = "nodump";
+ }
+ else if (strcmp(name, "NoAtime") == 0) {
+ xar->xmlsts = FILE_EXT2_NoAtime;
+ flag = "noatime";
+ }
+ else if (strcmp(name, "CompDirty") == 0) {
+ xar->xmlsts = FILE_EXT2_CompDirty;
+ flag = "compdirty";
+ }
+ else if (strcmp(name, "CompBlock") == 0) {
+ xar->xmlsts = FILE_EXT2_CompBlock;
+ flag = "comprblk";
+ }
+ else if (strcmp(name, "NoCompBlock") == 0) {
+ xar->xmlsts = FILE_EXT2_NoCompBlock;
+ flag = "nocomprblk";
+ }
+ else if (strcmp(name, "CompError") == 0) {
+ xar->xmlsts = FILE_EXT2_CompError;
+ flag = "comperr";
+ }
+ else if (strcmp(name, "BTree") == 0) {
+ xar->xmlsts = FILE_EXT2_BTree;
+ flag = "btree";
+ }
+ else if (strcmp(name, "HashIndexed") == 0) {
+ xar->xmlsts = FILE_EXT2_HashIndexed;
+ flag = "hashidx";
+ }
+ else if (strcmp(name, "iMagic") == 0) {
+ xar->xmlsts = FILE_EXT2_iMagic;
+ flag = "imagic";
+ }
+ else if (strcmp(name, "Journaled") == 0) {
+ xar->xmlsts = FILE_EXT2_Journaled;
+ flag = "journal";
+ }
+ else if (strcmp(name, "NoTail") == 0) {
+ xar->xmlsts = FILE_EXT2_NoTail;
+ flag = "notail";
+ }
+ else if (strcmp(name, "DirSync") == 0) {
+ xar->xmlsts = FILE_EXT2_DirSync;
+ flag = "dirsync";
+ }
+ else if (strcmp(name, "TopDir") == 0) {
+ xar->xmlsts = FILE_EXT2_TopDir;
+ flag = "topdir";
+ }
+ else if (strcmp(name, "Reserved") == 0) {
+ xar->xmlsts = FILE_EXT2_Reserved;
+ flag = "reserved";
+ }
+
+ if (flag == NULL)
+ return (0);
+ if (archive_strlen(&(xar->file->fflags_text)) > 0)
+ archive_strappend_char(&(xar->file->fflags_text), ',');
+ archive_strcat(&(xar->file->fflags_text), flag);
+ return (1);
+}
+
+#ifdef HAVE_LIBXML_XMLREADER_H
+
+static int
+xml2_xmlattr_setup(struct xmlattr_list *list, xmlTextReaderPtr reader)
+{
+ struct xmlattr *attr;
+ int r;
+
+ list->first = NULL;
+ list->last = &(list->first);
+ r = xmlTextReaderMoveToFirstAttribute(reader);
+ while (r == 1) {
+ attr = malloc(sizeof*(attr));
+ if (attr == NULL)
+ __archive_errx(1, "Out of memory");
+ attr->name = strdup(
+ (const char *)xmlTextReaderConstLocalName(reader));
+ if (attr->name == NULL)
+ __archive_errx(1, "Out of memory");
+ attr->value = strdup(
+ (const char *)xmlTextReaderConstValue(reader));
+ if (attr->value == NULL)
+ __archive_errx(1, "Out of memory");
+ attr->next = NULL;
+ *list->last = attr;
+ list->last = &(attr->next);
+ r = xmlTextReaderMoveToNextAttribute(reader);
+ }
+ return (r);
+}
+
+static int
+xml2_read_cb(void *context, char *buffer, int len)
+{
+ struct archive_read *a;
+ struct xar *xar;
+ const void *d;
+ size_t outbytes;
+ size_t used;
+ int r;
+
+ a = (struct archive_read *)context;
+ xar = (struct xar *)(a->format->data);
+
+ if (xar->toc_remaining <= 0)
+ return (0);
+ d = buffer;
+ outbytes = len;
+ r = rd_contents(a, &d, &outbytes, &used, xar->toc_remaining);
+ if (r != ARCHIVE_OK)
+ return (r);
+ __archive_read_consume(a, used);
+ xar->toc_remaining -= used;
+ xar->offset += used;
+ xar->toc_total += outbytes;
+ PRINT_TOC(buffer, len);
+
+ return ((int)outbytes);
+}
+
+static int
+xml2_close_cb(void *context)
+{
+
+ (void)context; /* UNUSED */
+ return (0);
+}
+
+static void
+xml2_error_hdr(void *arg, const char *msg, xmlParserSeverities severity,
+ xmlTextReaderLocatorPtr locator)
+{
+ struct archive_read *a;
+
+ (void)locator; /* UNUSED */
+ a = (struct archive_read *)arg;
+ switch (severity) {
+ case XML_PARSER_SEVERITY_VALIDITY_WARNING:
+ case XML_PARSER_SEVERITY_WARNING:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "XML Parsing error: %s", msg);
+ break;
+ case XML_PARSER_SEVERITY_VALIDITY_ERROR:
+ case XML_PARSER_SEVERITY_ERROR:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "XML Parsing error: %s", msg);
+ break;
+ }
+}
+
+static int
+xml2_read_toc(struct archive_read *a)
+{
+ xmlTextReaderPtr reader;
+ struct xmlattr_list list;
+ int r;
+
+ reader = xmlReaderForIO(xml2_read_cb, xml2_close_cb, a, NULL, NULL, 0);
+ if (reader == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Couldn't allocate memory for xml parser");
+ return (ARCHIVE_FATAL);
+ }
+ xmlTextReaderSetErrorHandler(reader, xml2_error_hdr, a);
+
+ while ((r = xmlTextReaderRead(reader)) == 1) {
+ const char *name, *value;
+ int type, empty;
+
+ type = xmlTextReaderNodeType(reader);
+ name = (const char *)xmlTextReaderConstLocalName(reader);
+ switch (type) {
+ case XML_READER_TYPE_ELEMENT:
+ empty = xmlTextReaderIsEmptyElement(reader);
+ r = xml2_xmlattr_setup(&list, reader);
+ if (r == 0) {
+ xml_start(a, name, &list);
+ xmlattr_cleanup(&list);
+ if (empty)
+ xml_end(a, name);
+ }
+ break;
+ case XML_READER_TYPE_END_ELEMENT:
+ xml_end(a, name);
+ break;
+ case XML_READER_TYPE_TEXT:
+ value = (const char *)xmlTextReaderConstValue(reader);
+ xml_data(a, value, strlen(value));
+ break;
+ case XML_READER_TYPE_SIGNIFICANT_WHITESPACE:
+ default:
+ break;
+ }
+ if (r < 0)
+ break;
+ }
+ xmlFreeTextReader(reader);
+ xmlCleanupParser();
+
+ return ((r == 0)?ARCHIVE_OK:ARCHIVE_FATAL);
+}
+
+#elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H)
+
+static void
+expat_xmlattr_setup(struct xmlattr_list *list, const XML_Char **atts)
+{
+ struct xmlattr *attr;
+
+ list->first = NULL;
+ list->last = &(list->first);
+ if (atts == NULL)
+ return;
+ while (atts[0] != NULL && atts[1] != NULL) {
+ attr = malloc(sizeof*(attr));
+ if (attr == NULL)
+ __archive_errx(1, "Out of memory");
+ attr->name = strdup(atts[0]);
+ if (attr->name == NULL)
+ __archive_errx(1, "Out of memory");
+ attr->value = strdup(atts[1]);
+ if (attr->value == NULL)
+ __archive_errx(1, "Out of memory");
+ attr->next = NULL;
+ *list->last = attr;
+ list->last = &(attr->next);
+ atts += 2;
+ }
+}
+
+static void
+expat_start_cb(void *userData, const XML_Char *name, const XML_Char **atts)
+{
+ struct xmlattr_list list;
+
+ expat_xmlattr_setup(&list, atts);
+ xml_start(userData, (const char *)name, &list);
+ xmlattr_cleanup(&list);
+}
+
+static void
+expat_end_cb(void *userData, const XML_Char *name)
+{
+ xml_end(userData, (const char *)name);
+}
+
+static void
+expat_data_cb(void *userData, const XML_Char *s, int len)
+{
+ xml_data(userData, s, len);
+}
+
+static int
+expat_read_toc(struct archive_read *a)
+{
+ struct xar *xar;
+ XML_Parser parser;
+
+ xar = (struct xar *)(a->format->data);
+
+ /* Initialize XML Parser library. */
+ parser = XML_ParserCreate(NULL);
+ if (parser == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Couldn't allocate memory for xml parser");
+ return (ARCHIVE_FATAL);
+ }
+ XML_SetUserData(parser, a);
+ XML_SetElementHandler(parser, expat_start_cb, expat_end_cb);
+ XML_SetCharacterDataHandler(parser, expat_data_cb);
+ xar->xmlsts = INIT;
+
+ while (xar->toc_remaining) {
+ enum XML_Status xr;
+ const void *d;
+ size_t outbytes;
+ size_t used;
+ int r;
+
+ d = NULL;
+ r = rd_contents(a, &d, &outbytes, &used, xar->toc_remaining);
+ if (r != ARCHIVE_OK)
+ return (r);
+ __archive_read_consume(a, used);
+ xar->toc_remaining -= used;
+ xar->offset += used;
+ xar->toc_total += outbytes;
+ PRINT_TOC(d, outbytes);
+
+ xr = XML_Parse(parser, d, outbytes, xar->toc_remaining == 0);
+ if (xr == XML_STATUS_ERROR) {
+ XML_ParserFree(parser);
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "XML Parsing failed");
+ return (ARCHIVE_FATAL);
+ }
+ }
+ XML_ParserFree(parser);
+ return (ARCHIVE_OK);
+}
+#endif /* defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H) */
+
+#endif /* Support xar format */
diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
index f04f69bb205..5a85e71125a 100644
--- a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
+++ b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.24 2008/06/15 05:15:53 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102 2009-12-28 03:11:36Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -44,6 +44,10 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.24
#include "archive_read_private.h"
#include "archive_endian.h"
+#ifndef HAVE_ZLIB_H
+#include "archive_crc32.h"
+#endif
+
struct zip {
/* entry_bytes_remaining is the number of bytes we expect. */
int64_t entry_bytes_remaining;
@@ -53,6 +57,9 @@ struct zip {
int64_t entry_compressed_bytes_read;
int64_t entry_uncompressed_bytes_read;
+ /* Running CRC32 of the decompressed data */
+ unsigned long entry_crc32;
+
unsigned version;
unsigned system;
unsigned flags;
@@ -68,9 +75,8 @@ struct zip {
/* Flags to mark progress of decompression. */
char decompress_init;
char end_of_entry;
- char end_of_entry_cleanup;
- long crc32;
+ unsigned long crc32;
ssize_t filename_length;
ssize_t extra_length;
int64_t uncompressed_size;
@@ -147,7 +153,9 @@ archive_read_support_format_zip(struct archive *_a)
r = __archive_read_register_format(a,
zip,
+ "zip",
archive_read_format_zip_bid,
+ NULL,
archive_read_format_zip_read_header,
archive_read_format_zip_read_data,
archive_read_format_zip_read_data_skip,
@@ -164,9 +172,9 @@ archive_read_format_zip_bid(struct archive_read *a)
{
const char *p;
const void *buff;
- size_t bytes_avail;
+ ssize_t bytes_avail, offset;
- if ((p = __archive_read_ahead(a, 4)) == NULL)
+ if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
return (-1);
/*
@@ -186,42 +194,37 @@ archive_read_format_zip_bid(struct archive_read *a)
/*
* Attempt to handle self-extracting archives
* by noting a PE header and searching forward
- * up to 64k for a 'PK\003\004' marker.
+ * up to 128k for a 'PK\003\004' marker.
*/
if (p[0] == 'M' && p[1] == 'Z') {
/*
- * TODO: Additional checks that this really is a PE
- * file before we invoke the 128k lookahead below.
- * No point in allocating a bigger lookahead buffer
- * if we don't need to.
- */
- /*
- * TODO: Of course, the compression layer lookahead
- * buffers aren't dynamically sized yet; they should be.
+ * TODO: Optimize by initializing 'offset' to an
+ * estimate of the likely start of the archive data
+ * based on values in the PE header. Note that we
+ * don't need to be exact, but we mustn't skip too
+ * far. The search below will compensate if we
+ * undershoot.
*/
- bytes_avail = (a->decompressor->read_ahead)(a, &buff, 128*1024);
- p = (const char *)buff;
-
- /*
- * TODO: Optimize by jumping forward based on values
- * in the PE header. Note that we don't need to be
- * exact, but we mustn't skip too far. The search
- * below will compensate if we undershoot. Skipping
- * will also reduce the chance of false positives
- * (which is not really all that high to begin with,
- * so maybe skipping isn't really necessary).
- */
-
- while (p < bytes_avail + (const char *)buff) {
- if (p[0] == 'P' && p[1] == 'K' /* "PK" signature */
- && p[2] == 3 && p[3] == 4 /* File entry */
- && p[8] == 8 /* compression == deflate */
- && p[9] == 0 /* High byte of compression */
- )
- {
- return (30);
+ offset = 0;
+ while (offset < 124000) {
+ /* Get 4k of data beyond where we stopped. */
+ buff = __archive_read_ahead(a, offset + 4096,
+ &bytes_avail);
+ if (bytes_avail < offset + 1)
+ break;
+ p = (const char *)buff + offset;
+ while (p + 9 < (const char *)buff + bytes_avail) {
+ if (p[0] == 'P' && p[1] == 'K' /* signature */
+ && p[2] == 3 && p[3] == 4 /* File entry */
+ && p[8] == 8 /* compression == deflate */
+ && p[9] == 0 /* High byte of compression */
+ )
+ {
+ return (30);
+ }
+ ++p;
}
- ++p;
+ offset = p - (const char *)buff;
}
}
@@ -238,7 +241,8 @@ skip_sfx(struct archive_read *a)
{
const void *h;
const char *p, *q;
- size_t skip, bytes;
+ size_t skip;
+ ssize_t bytes;
/*
* TODO: We should be able to skip forward by a bunch
@@ -248,7 +252,7 @@ skip_sfx(struct archive_read *a)
* reduce the chance of a false positive.
*/
for (;;) {
- bytes = (a->decompressor->read_ahead)(a, &h, 4096);
+ h = __archive_read_ahead(a, 4, &bytes);
if (bytes < 4)
return (ARCHIVE_FATAL);
p = h;
@@ -264,7 +268,7 @@ skip_sfx(struct archive_read *a)
/* TODO: Additional verification here. */
if (memcmp("PK\003\004", p, 4) == 0) {
skip = p - (const char *)h;
- (a->decompressor->consume)(a, skip);
+ __archive_read_consume(a, skip);
return (ARCHIVE_OK);
}
p += 4;
@@ -276,7 +280,7 @@ skip_sfx(struct archive_read *a)
}
}
skip = p - (const char *)h;
- (a->decompressor->consume)(a, skip);
+ __archive_read_consume(a, skip);
}
}
@@ -296,10 +300,10 @@ archive_read_format_zip_read_header(struct archive_read *a,
zip = (struct zip *)(a->format->data);
zip->decompress_init = 0;
zip->end_of_entry = 0;
- zip->end_of_entry_cleanup = 0;
zip->entry_uncompressed_bytes_read = 0;
zip->entry_compressed_bytes_read = 0;
- if ((h = __archive_read_ahead(a, 4)) == NULL)
+ zip->entry_crc32 = crc32(0, NULL, 0);
+ if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
return (ARCHIVE_FATAL);
signature = (const char *)h;
@@ -308,7 +312,7 @@ archive_read_format_zip_read_header(struct archive_read *a,
r = skip_sfx(a);
if (r < ARCHIVE_WARN)
return (r);
- if ((h = __archive_read_ahead(a, 4)) == NULL)
+ if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
return (ARCHIVE_FATAL);
signature = (const char *)h;
}
@@ -325,8 +329,8 @@ archive_read_format_zip_read_header(struct archive_read *a,
* skip the PK00; the first real file header should follow.
*/
if (signature[2] == '0' && signature[3] == '0') {
- (a->decompressor->consume)(a, 4);
- if ((h = __archive_read_ahead(a, 4)) == NULL)
+ __archive_read_consume(a, 4);
+ if ((h = __archive_read_ahead(a, 4, NULL)) == NULL)
return (ARCHIVE_FATAL);
signature = (const char *)h;
if (signature[0] != 'P' || signature[1] != 'K') {
@@ -370,14 +374,14 @@ archive_read_format_zip_read_header(struct archive_read *a,
return (ARCHIVE_FATAL);
}
-int
+static int
zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
struct zip *zip)
{
const struct zip_file_header *p;
const void *h;
- if ((p = __archive_read_ahead(a, sizeof *p)) == NULL) {
+ if ((p = __archive_read_ahead(a, sizeof *p, NULL)) == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated ZIP file header");
return (ARCHIVE_FATAL);
@@ -404,11 +408,11 @@ zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
zip->uncompressed_size = archive_le32dec(p->uncompressed_size);
zip->compressed_size = archive_le32dec(p->compressed_size);
- (a->decompressor->consume)(a, sizeof(struct zip_file_header));
+ __archive_read_consume(a, sizeof(struct zip_file_header));
/* Read the filename. */
- if ((h = __archive_read_ahead(a, zip->filename_length)) == NULL) {
+ if ((h = __archive_read_ahead(a, zip->filename_length, NULL)) == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated ZIP file header");
return (ARCHIVE_FATAL);
@@ -416,7 +420,7 @@ zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
if (archive_string_ensure(&zip->pathname, zip->filename_length) == NULL)
__archive_errx(1, "Out of memory");
archive_strncpy(&zip->pathname, h, zip->filename_length);
- (a->decompressor->consume)(a, zip->filename_length);
+ __archive_read_consume(a, zip->filename_length);
archive_entry_set_pathname(entry, zip->pathname.s);
if (zip->pathname.s[archive_strlen(&zip->pathname) - 1] == '/')
@@ -425,13 +429,13 @@ zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
zip->mode = AE_IFREG | 0777;
/* Read the extra data. */
- if ((h = __archive_read_ahead(a, zip->extra_length)) == NULL) {
+ if ((h = __archive_read_ahead(a, zip->extra_length, NULL)) == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated ZIP file header");
return (ARCHIVE_FATAL);
}
process_extra(h, zip);
- (a->decompressor->consume)(a, zip->extra_length);
+ __archive_read_consume(a, zip->extra_length);
/* Populate some additional entry fields: */
archive_entry_set_mode(entry, zip->mode);
@@ -440,7 +444,9 @@ zip_read_file_header(struct archive_read *a, struct archive_entry *entry,
archive_entry_set_mtime(entry, zip->mtime, 0);
archive_entry_set_ctime(entry, zip->ctime, 0);
archive_entry_set_atime(entry, zip->atime, 0);
- archive_entry_set_size(entry, zip->uncompressed_size);
+ /* Set the size only if it's meaningful. */
+ if (0 == (zip->flags & ZIP_LENGTH_AT_END))
+ archive_entry_set_size(entry, zip->uncompressed_size);
zip->entry_bytes_remaining = zip->compressed_size;
zip->entry_offset = 0;
@@ -494,46 +500,6 @@ archive_read_format_zip_read_data(struct archive_read *a,
* ARCHIVE_EOF this time.
*/
if (zip->end_of_entry) {
- if (!zip->end_of_entry_cleanup) {
- if (zip->flags & ZIP_LENGTH_AT_END) {
- const char *p;
-
- if ((p = __archive_read_ahead(a, 16)) == NULL) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Truncated ZIP end-of-file record");
- return (ARCHIVE_FATAL);
- }
- zip->crc32 = archive_le32dec(p + 4);
- zip->compressed_size = archive_le32dec(p + 8);
- zip->uncompressed_size = archive_le32dec(p + 12);
- (a->decompressor->consume)(a, 16);
- }
-
- /* Check file size, CRC against these values. */
- if (zip->compressed_size != zip->entry_compressed_bytes_read) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "ZIP compressed data is wrong size");
- return (ARCHIVE_WARN);
- }
- /* Size field only stores the lower 32 bits of the actual size. */
- if ((zip->uncompressed_size & UINT32_MAX)
- != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "ZIP uncompressed data is wrong size");
- return (ARCHIVE_WARN);
- }
-/* TODO: Compute CRC. */
-/*
- if (zip->crc32 != zip->entry_crc32_calculated) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "ZIP data CRC error");
- return (ARCHIVE_WARN);
- }
-*/
- /* End-of-entry cleanup done. */
- zip->end_of_entry_cleanup = 1;
- }
*offset = zip->entry_uncompressed_bytes_read;
*size = 0;
*buff = NULL;
@@ -570,7 +536,53 @@ archive_read_format_zip_read_data(struct archive_read *a,
}
break;
}
- return (r);
+ if (r != ARCHIVE_OK)
+ return (r);
+ /* Update checksum */
+ if (*size)
+ zip->entry_crc32 = crc32(zip->entry_crc32, *buff, *size);
+ /* If we hit the end, swallow any end-of-data marker. */
+ if (zip->end_of_entry) {
+ if (zip->flags & ZIP_LENGTH_AT_END) {
+ const char *p;
+
+ if ((p = __archive_read_ahead(a, 16, NULL)) == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated ZIP end-of-file record");
+ return (ARCHIVE_FATAL);
+ }
+ zip->crc32 = archive_le32dec(p + 4);
+ zip->compressed_size = archive_le32dec(p + 8);
+ zip->uncompressed_size = archive_le32dec(p + 12);
+ __archive_read_consume(a, 16);
+ }
+ /* Check file size, CRC against these values. */
+ if (zip->compressed_size != zip->entry_compressed_bytes_read) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "ZIP compressed data is wrong size");
+ return (ARCHIVE_WARN);
+ }
+ /* Size field only stores the lower 32 bits of the actual size. */
+ if ((zip->uncompressed_size & UINT32_MAX)
+ != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "ZIP uncompressed data is wrong size");
+ return (ARCHIVE_WARN);
+ }
+ /* Check computed CRC against header */
+ if (zip->crc32 != zip->entry_crc32) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "ZIP bad CRC: 0x%lx should be 0x%lx",
+ zip->entry_crc32, zip->crc32);
+ return (ARCHIVE_WARN);
+ }
+ }
+
+ /* Return EOF immediately if this is a non-regular file. */
+ if (AE_IFREG != (zip->mode & AE_IFMT))
+ return (ARCHIVE_EOF);
+ return (ARCHIVE_OK);
}
/*
@@ -608,7 +620,7 @@ zip_read_data_none(struct archive_read *a, const void **buff,
* available bytes; asking for more than that forces the
* decompressor to combine reads by copying data.
*/
- bytes_avail = (a->decompressor->read_ahead)(a, buff, 1);
+ *buff = __archive_read_ahead(a, 1, &bytes_avail);
if (bytes_avail <= 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated ZIP file data");
@@ -616,7 +628,7 @@ zip_read_data_none(struct archive_read *a, const void **buff,
}
if (bytes_avail > zip->entry_bytes_remaining)
bytes_avail = zip->entry_bytes_remaining;
- (a->decompressor->consume)(a, bytes_avail);
+ __archive_read_consume(a, bytes_avail);
*size = bytes_avail;
*offset = zip->entry_offset;
zip->entry_offset += *size;
@@ -674,7 +686,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
* available bytes; asking for more than that forces the
* decompressor to combine reads by copying data.
*/
- bytes_avail = (a->decompressor->read_ahead)(a, &compressed_buff, 1);
+ compressed_buff = __archive_read_ahead(a, 1, &bytes_avail);
if (bytes_avail <= 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated ZIP file body");
@@ -713,7 +725,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
/* Consume as much as the compressor actually used. */
bytes_avail = zip->stream.total_in;
- (a->decompressor->consume)(a, bytes_avail);
+ __archive_read_consume(a, bytes_avail);
zip->entry_bytes_remaining -= bytes_avail;
zip->entry_compressed_bytes_read += bytes_avail;
@@ -748,7 +760,7 @@ archive_read_format_zip_read_data_skip(struct archive_read *a)
zip = (struct zip *)(a->format->data);
/* If we've already read to end of data, we're done. */
- if (zip->end_of_entry_cleanup)
+ if (zip->end_of_entry)
return (ARCHIVE_OK);
/*
@@ -770,12 +782,12 @@ archive_read_format_zip_read_data_skip(struct archive_read *a)
* If the length is at the beginning, we can skip the
* compressed data much more quickly.
*/
- bytes_skipped = (a->decompressor->skip)(a, zip->entry_bytes_remaining);
+ bytes_skipped = __archive_read_skip(a, zip->entry_bytes_remaining);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
/* This entry is finished and done. */
- zip->end_of_entry_cleanup = zip->end_of_entry = 1;
+ zip->end_of_entry = 1;
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_string.c b/archivers/libarchive/files/libarchive/archive_string.c
index 21fe5711516..4e57d62e138 100644
--- a/archivers/libarchive/files/libarchive/archive_string.c
+++ b/archivers/libarchive/files/libarchive/archive_string.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.16 2008/06/15 11:28:56 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_string.c 201095 2009-12-28 02:33:22Z kientzle $");
/*
* Basic resizable string support, to simplify manipulating arbitrary-sized
@@ -40,6 +40,9 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.16 2008/06/15 11:28:
#ifdef HAVE_WCHAR_H
#include <wchar.h>
#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <windows.h>
+#endif
#include "archive_private.h"
#include "archive_string.h"
@@ -70,6 +73,18 @@ __archive_string_copy(struct archive_string *dest, struct archive_string *src)
}
void
+__archive_string_concat(struct archive_string *dest, struct archive_string *src)
+{
+ if (src->length > 0) {
+ if (__archive_string_ensure(dest, dest->length + src->length + 1) == NULL)
+ __archive_errx(1, "Out of memory");
+ memcpy(dest->s + dest->length, src->s, src->length);
+ dest->length += src->length;
+ dest->s[dest->length] = 0;
+ }
+}
+
+void
__archive_string_free(struct archive_string *as)
{
as->length = 0;
@@ -100,11 +115,11 @@ __archive_string_ensure(struct archive_string *as, size_t s)
as->buffer_length = 32;
else if (as->buffer_length < 8192)
/* Buffers under 8k are doubled for speed. */
- as->buffer_length *= 2;
+ as->buffer_length += as->buffer_length;
else {
/* Buffers 8k and over grow by at least 25% each time. */
size_t old_length = as->buffer_length;
- as->buffer_length = (as->buffer_length * 5) / 4;
+ as->buffer_length += as->buffer_length / 4;
/* Be safe: If size wraps, release buffer and return NULL. */
if (as->buffer_length < old_length) {
free(as->s);
@@ -127,10 +142,12 @@ __archive_string_ensure(struct archive_string *as, size_t s)
}
struct archive_string *
-__archive_strncat(struct archive_string *as, const char *p, size_t n)
+__archive_strncat(struct archive_string *as, const void *_p, size_t n)
{
size_t s;
- const char *pp;
+ const char *p, *pp;
+
+ p = (const char *)_p;
/* Like strlen(p), except won't examine positions beyond p[n]. */
s = 0;
@@ -148,70 +165,18 @@ __archive_strappend_char(struct archive_string *as, char c)
return (__archive_string_append(as, &c, 1));
}
-struct archive_string *
-__archive_strappend_int(struct archive_string *as, int d, int base)
-{
- static const char *digits = "0123456789abcdef";
-
- if (d < 0) {
- __archive_strappend_char(as, '-');
- d = -d;
- }
- if (d >= base)
- __archive_strappend_int(as, d/base, base);
- __archive_strappend_char(as, digits[d % base]);
- return (as);
-}
-
/*
- * Home-grown wctomb for UTF-8.
+ * Translates a wide character string into UTF-8 and appends
+ * to the archive_string. Note: returns NULL if conversion fails,
+ * but still leaves a best-effort conversion in the argument as.
*/
-static int
-my_wctomb_utf8(char *p, wchar_t wc)
-{
- if (p == NULL)
- /* UTF-8 doesn't use shift states. */
- return (0);
- if (wc <= 0x7f) {
- p[0] = (char)wc;
- return (1);
- }
- if (wc <= 0x7ff) {
- p[0] = 0xc0 | ((wc >> 6) & 0x1f);
- p[1] = 0x80 | (wc & 0x3f);
- return (2);
- }
- if (wc <= 0xffff) {
- p[0] = 0xe0 | ((wc >> 12) & 0x0f);
- p[1] = 0x80 | ((wc >> 6) & 0x3f);
- p[2] = 0x80 | (wc & 0x3f);
- return (3);
- }
- if (wc <= 0x1fffff) {
- p[0] = 0xf0 | ((wc >> 18) & 0x07);
- p[1] = 0x80 | ((wc >> 12) & 0x3f);
- p[2] = 0x80 | ((wc >> 6) & 0x3f);
- p[3] = 0x80 | (wc & 0x3f);
- return (4);
- }
- /* Unicode has no codes larger than 0x1fffff. */
- /*
- * Awkward point: UTF-8 <-> wchar_t conversions
- * can actually fail.
- */
- return (-1);
-}
-
-static int
-my_wcstombs(struct archive_string *as, const wchar_t *w,
- int (*func)(char *, wchar_t))
+struct archive_string *
+__archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w)
{
- int n;
char *p;
+ unsigned wc;
char buff[256];
-
- /* Clear the shift state before starting. */
- (*func)(NULL, L'\0');
+ struct archive_string *return_val = as;
/*
* Convert one wide char at a time into 'buff', whenever that
@@ -226,67 +191,50 @@ my_wcstombs(struct archive_string *as, const wchar_t *w,
archive_strcat(as, buff);
p = buff;
}
- n = (*func)(p, *w++);
- if (n == -1)
- return (-1);
- p += n;
+ wc = *w++;
+ /* If this is a surrogate pair, assemble the full code point.*/
+ /* Note: wc must not be wchar_t here, because the full code
+ * point can be more than 16 bits! */
+ if (wc >= 0xD800 && wc <= 0xDBff
+ && *w >= 0xDC00 && *w <= 0xDFFF) {
+ wc -= 0xD800;
+ wc *= 0x400;
+ wc += (*w - 0xDC00);
+ wc += 0x10000;
+ ++w;
+ }
+ /* Translate code point to UTF8 */
+ if (wc <= 0x7f) {
+ *p++ = (char)wc;
+ } else if (wc <= 0x7ff) {
+ *p++ = 0xc0 | ((wc >> 6) & 0x1f);
+ *p++ = 0x80 | (wc & 0x3f);
+ } else if (wc <= 0xffff) {
+ *p++ = 0xe0 | ((wc >> 12) & 0x0f);
+ *p++ = 0x80 | ((wc >> 6) & 0x3f);
+ *p++ = 0x80 | (wc & 0x3f);
+ } else if (wc <= 0x1fffff) {
+ *p++ = 0xf0 | ((wc >> 18) & 0x07);
+ *p++ = 0x80 | ((wc >> 12) & 0x3f);
+ *p++ = 0x80 | ((wc >> 6) & 0x3f);
+ *p++ = 0x80 | (wc & 0x3f);
+ } else {
+ /* Unicode has no codes larger than 0x1fffff. */
+ /* TODO: use \uXXXX escape here instead of ? */
+ *p++ = '?';
+ return_val = NULL;
+ }
}
*p = '\0';
archive_strcat(as, buff);
- return (0);
+ return (return_val);
}
-/*
- * Translates a wide character string into UTF-8 and appends
- * to the archive_string. Note: returns NULL if conversion fails.
- */
-struct archive_string *
-__archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w)
-{
- if (my_wcstombs(as, w, my_wctomb_utf8))
- return (NULL);
- return (as);
-}
-
-/*
- * Translates a wide character string into current locale character set
- * and appends to the archive_string. Note: returns NULL if conversion
- * fails.
- */
-struct archive_string *
-__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w)
-{
-#if HAVE_WCTOMB
- if (my_wcstombs(as, w, wctomb))
- return (NULL);
-#else
- /* TODO: Can we do better than this? Are there platforms
- * that have locale support but don't have wctomb()? */
- if (my_wcstombs(as, w, my_wctomb_utf8))
- return (NULL);
-#endif
- return (as);
-}
-
-
-/*
- * Home-grown mbtowc for UTF-8. Some systems lack UTF-8
- * (or even lack mbtowc()) and we need UTF-8 support for pax
- * format. So please don't replace this with a call to the
- * standard mbtowc() function!
- */
static int
-my_mbtowc_utf8(wchar_t *pwc, const char *s, size_t n)
+utf8_to_unicode(int *pwc, const char *s, size_t n)
{
int ch;
- /* Standard behavior: a NULL value for 's' just resets shift state. */
- if (s == NULL)
- return (0);
- /* If length argument is zero, don't look at the first character. */
- if (n <= 0)
- return (-1);
-
/*
* Decode 1-4 bytes depending on the value of the first byte.
*/
@@ -332,34 +280,174 @@ my_mbtowc_utf8(wchar_t *pwc, const char *s, size_t n)
}
/*
- * Return a wide-character string by converting this archive_string
- * from UTF-8.
+ * Return a wide-character Unicode string by converting this archive_string
+ * from UTF-8. We assume that systems with 16-bit wchar_t always use
+ * UTF16 and systems with 32-bit wchar_t can accept UCS4.
*/
wchar_t *
__archive_string_utf8_w(struct archive_string *as)
{
wchar_t *ws, *dest;
+ int wc, wc2;/* Must be large enough for a 21-bit Unicode code point. */
const char *src;
int n;
- int err;
ws = (wchar_t *)malloc((as->length + 1) * sizeof(wchar_t));
if (ws == NULL)
__archive_errx(1, "Out of memory");
- err = 0;
dest = ws;
src = as->s;
while (*src != '\0') {
- n = my_mbtowc_utf8(dest, src, 8);
+ n = utf8_to_unicode(&wc, src, 8);
if (n == 0)
break;
if (n < 0) {
free(ws);
return (NULL);
}
- dest++;
src += n;
+ if (wc >= 0xDC00 && wc <= 0xDBFF) {
+ /* This is a leading surrogate; some idiot
+ * has translated UTF16 to UTF8 without combining
+ * surrogates; rebuild the full code point before
+ * continuing. */
+ n = utf8_to_unicode(&wc2, src, 8);
+ if (n < 0) {
+ free(ws);
+ return (NULL);
+ }
+ if (n == 0) /* Ignore the leading surrogate */
+ break;
+ if (wc2 < 0xDC00 || wc2 > 0xDFFF) {
+ /* If the second character isn't a
+ * trailing surrogate, then someone
+ * has really screwed up and this is
+ * invalid. */
+ free(ws);
+ return (NULL);
+ } else {
+ src += n;
+ wc -= 0xD800;
+ wc *= 0x400;
+ wc += wc2 - 0xDC00;
+ wc += 0x10000;
+ }
+ }
+ if ((sizeof(wchar_t) < 4) && (wc > 0xffff)) {
+ /* We have a code point that won't fit into a
+ * wchar_t; convert it to a surrogate pair. */
+ wc -= 0x10000;
+ *dest++ = ((wc >> 10) & 0x3ff) + 0xD800;
+ *dest++ = (wc & 0x3ff) + 0xDC00;
+ } else
+ *dest++ = wc;
}
- *dest++ = L'\0';
+ *dest = L'\0';
return (ws);
}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+/*
+ * Translates a wide character string into current locale character set
+ * and appends to the archive_string. Note: returns NULL if conversion
+ * fails.
+ *
+ * Win32 builds use WideCharToMultiByte from the Windows API.
+ * (Maybe Cygwin should too? WideCharToMultiByte will know a
+ * lot more about local character encodings than the wcrtomb()
+ * wrapper is going to know.)
+ */
+struct archive_string *
+__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w)
+{
+ char *p;
+ int l, wl;
+ BOOL useDefaultChar = FALSE;
+
+ wl = (int)wcslen(w);
+ l = wl * 4 + 4;
+ p = malloc(l);
+ if (p == NULL)
+ __archive_errx(1, "Out of memory");
+ /* To check a useDefaultChar is to simulate error handling of
+ * the my_wcstombs() which is running on non Windows system with
+ * wctomb().
+ * And to set NULL for last argument is necessary when a codepage
+ * is not CP_ACP(current locale).
+ */
+ l = WideCharToMultiByte(CP_ACP, 0, w, wl, p, l, NULL, &useDefaultChar);
+ if (l == 0) {
+ free(p);
+ return (NULL);
+ }
+ __archive_string_append(as, p, l);
+ free(p);
+ return (as);
+}
+
+#else
+
+/*
+ * Translates a wide character string into current locale character set
+ * and appends to the archive_string. Note: returns NULL if conversion
+ * fails.
+ *
+ * Non-Windows uses ISO C wcrtomb() or wctomb() to perform the conversion
+ * one character at a time. If a non-Windows platform doesn't have
+ * either of these, fall back to the built-in UTF8 conversion.
+ */
+struct archive_string *
+__archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w)
+{
+#if !defined(HAVE_WCTOMB) && !defined(HAVE_WCRTOMB)
+ /* If there's no built-in locale support, fall back to UTF8 always. */
+ return __archive_strappend_w_utf8(as, w);
+#else
+ /* We cannot use the standard wcstombs() here because it
+ * cannot tell us how big the output buffer should be. So
+ * I've built a loop around wcrtomb() or wctomb() that
+ * converts a character at a time and resizes the string as
+ * needed. We prefer wcrtomb() when it's available because
+ * it's thread-safe. */
+ int n;
+ char *p;
+ char buff[256];
+#if HAVE_WCRTOMB
+ mbstate_t shift_state;
+
+ memset(&shift_state, 0, sizeof(shift_state));
+#else
+ /* Clear the shift state before starting. */
+ wctomb(NULL, L'\0');
+#endif
+
+ /*
+ * Convert one wide char at a time into 'buff', whenever that
+ * fills, append it to the string.
+ */
+ p = buff;
+ while (*w != L'\0') {
+ /* Flush the buffer when we have <=16 bytes free. */
+ /* (No encoding has a single character >16 bytes.) */
+ if ((size_t)(p - buff) >= (size_t)(sizeof(buff) - MB_CUR_MAX)) {
+ *p = '\0';
+ archive_strcat(as, buff);
+ p = buff;
+ }
+#if HAVE_WCRTOMB
+ n = wcrtomb(p, *w++, &shift_state);
+#else
+ n = wctomb(p, *w++);
+#endif
+ if (n == -1)
+ return (NULL);
+ p += n;
+ }
+ *p = '\0';
+ archive_strcat(as, buff);
+ return (as);
+#endif
+}
+
+#endif /* _WIN32 && ! __CYGWIN__ */
diff --git a/archivers/libarchive/files/libarchive/archive_string.h b/archivers/libarchive/files/libarchive/archive_string.h
index e59c33af198..25d7a8b1e61 100644
--- a/archivers/libarchive/files/libarchive/archive_string.h
+++ b/archivers/libarchive/files/libarchive/archive_string.h
@@ -22,10 +22,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_string.h,v 1.12 2008/06/15 05:11:08 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_string.h 201092 2009-12-28 02:26:06Z kientzle $
*
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
#ifndef ARCHIVE_STRING_H_INCLUDED
#define ARCHIVE_STRING_H_INCLUDED
@@ -66,11 +70,6 @@ struct archive_string *
__archive_strappend_char(struct archive_string *, char);
#define archive_strappend_char __archive_strappend_char
-/* Append an integer in the specified base (2 <= base <= 16). */
-struct archive_string *
-__archive_strappend_int(struct archive_string *as, int d, int base);
-#define archive_strappend_int __archive_strappend_int
-
/* Convert a wide-char string to UTF-8 and append the result. */
struct archive_string *
__archive_strappend_w_utf8(struct archive_string *, const wchar_t *);
@@ -92,14 +91,24 @@ __archive_string_copy(struct archive_string *dest, struct archive_string *src);
#define archive_string_copy(dest, src) \
__archive_string_copy(dest, src)
+/* Concatenate one archive_string to another */
+void
+__archive_string_concat(struct archive_string *dest, struct archive_string *src);
+#define archive_string_concat(dest, src) \
+ __archive_string_concat(dest, src)
+
/* Ensure that the underlying buffer is at least as large as the request. */
struct archive_string *
__archive_string_ensure(struct archive_string *, size_t);
#define archive_string_ensure __archive_string_ensure
/* Append C string, which may lack trailing \0. */
+/* The source is declared void * here because this gets used with
+ * "signed char *", "unsigned char *" and "char *" arguments.
+ * Declaring it "char *" as with some of the other functions just
+ * leads to a lot of extra casts. */
struct archive_string *
-__archive_strncat(struct archive_string *, const char *, size_t);
+__archive_strncat(struct archive_string *, const void *, size_t);
#define archive_strncat __archive_strncat
/* Append a C string to an archive_string, resizing as necessary. */
diff --git a/archivers/libarchive/files/libarchive/archive_string_sprintf.c b/archivers/libarchive/files/libarchive/archive_string_sprintf.c
index 6f77a36a1b8..6d3d8edded8 100644
--- a/archivers/libarchive/files/libarchive/archive_string_sprintf.c
+++ b/archivers/libarchive/files/libarchive/archive_string_sprintf.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.10 2008/03/14 22:00:09 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_string_sprintf.c 189435 2009-03-06 05:14:55Z kientzle $");
/*
* The use of printf()-family functions can be troublesome
@@ -32,7 +32,7 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.10 2008/03/1
* implementing this function in terms of vsnprintf() requires
* two calls (one to determine the size, another to format the
* result), which in turn requires duplicating the argument list
- * using va_copy, which isn't yet universally available.
+ * using va_copy, which isn't yet universally available. <sigh>
*
* So, I've implemented a bare minimum of printf()-like capability
* here. This is only used to format error messages, so doesn't
@@ -44,6 +44,30 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_string_sprintf.c,v 1.10 2008/03/1
#include "archive_string.h"
#include "archive_private.h"
+/*
+ * Utility functions to format signed/unsigned integers and append
+ * them to an archive_string.
+ */
+static void
+append_uint(struct archive_string *as, uintmax_t d, unsigned base)
+{
+ static const char *digits = "0123456789abcdef";
+ if (d >= base)
+ append_uint(as, d/base, base);
+ archive_strappend_char(as, digits[d % base]);
+}
+
+static void
+append_int(struct archive_string *as, intmax_t d, unsigned base)
+{
+ if (d < 0) {
+ archive_strappend_char(as, '-');
+ d = -d;
+ }
+ append_uint(as, d, base);
+}
+
+
void
__archive_string_sprintf(struct archive_string *as, const char *fmt, ...)
{
@@ -75,7 +99,6 @@ __archive_string_vsprintf(struct archive_string *as, const char *fmt,
return;
}
- long_flag = '\0';
for (p = fmt; *p != '\0'; p++) {
const char *saved_p = p;
@@ -86,6 +109,7 @@ __archive_string_vsprintf(struct archive_string *as, const char *fmt,
p++;
+ long_flag = '\0';
switch(*p) {
case 'j':
long_flag = 'j';
@@ -111,7 +135,7 @@ __archive_string_vsprintf(struct archive_string *as, const char *fmt,
case 'l': s = va_arg(ap, long); break;
default: s = va_arg(ap, int); break;
}
- archive_strappend_int(as, s, 10);
+ append_int(as, s, 10);
break;
case 's':
p2 = va_arg(ap, char *);
@@ -126,9 +150,9 @@ __archive_string_vsprintf(struct archive_string *as, const char *fmt,
}
/* Format it in the correct base. */
switch (*p) {
- case 'o': archive_strappend_int(as, u, 8); break;
- case 'u': archive_strappend_int(as, u, 10); break;
- default: archive_strappend_int(as, u, 16); break;
+ case 'o': append_uint(as, u, 8); break;
+ case 'u': append_uint(as, u, 10); break;
+ default: append_uint(as, u, 16); break;
}
break;
default:
diff --git a/archivers/libarchive/files/libarchive/archive_util.3 b/archivers/libarchive/files/libarchive/archive_util.3
index b315c55e515..98609e565a7 100644
--- a/archivers/libarchive/files/libarchive/archive_util.3
+++ b/archivers/libarchive/files/libarchive/archive_util.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_util.3,v 1.8 2008/03/10 14:44:40 jkoshy Exp $
+.\" $FreeBSD: head/lib/libarchive/archive_util.3 201098 2009-12-28 02:58:14Z kientzle $
.\"
.Dd January 8, 2005
.Dt archive_util 3
@@ -34,6 +34,7 @@
.Nm archive_copy_error ,
.Nm archive_errno ,
.Nm archive_error_string ,
+.Nm archive_file_count ,
.Nm archive_format ,
.Nm archive_format_name ,
.Nm archive_set_error
@@ -53,6 +54,8 @@
.Ft const char *
.Fn archive_error_string "struct archive *"
.Ft int
+.Fn archive_file_count "struct archive *"
+.Ft int
.Fn archive_format "struct archive *"
.Ft const char *
.Fn archive_format_name "struct archive *"
@@ -92,6 +95,12 @@ obtained from passing the result of
.Fn archive_errno
to
.Xr strerror 3 .
+.It Fn archive_file_count
+Returns a count of the number of files processed by this archive object.
+The count is incremented by calls to
+.Xr archive_write_header
+or
+.Xr archive_read_next_header .
.It Fn archive_format
Returns a numeric code indicating the format of the current
archive entry.
diff --git a/archivers/libarchive/files/libarchive/archive_util.c b/archivers/libarchive/files/libarchive/archive_util.c
index 7fb46967715..c945d5fa71a 100644
--- a/archivers/libarchive/files/libarchive/archive_util.c
+++ b/archivers/libarchive/files/libarchive/archive_util.c
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
* Copyright (c) 2003-2007 Tim Kientzle
* All rights reserved.
*
@@ -24,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.18 2008/05/26 17:00:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:14Z kientzle $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -99,6 +100,11 @@ archive_error_string(struct archive *a)
return ("(Empty error message)");
}
+int
+archive_file_count(struct archive *a)
+{
+ return (a->file_count);
+}
int
archive_format(struct archive *a)
@@ -155,10 +161,6 @@ void
archive_set_error(struct archive *a, int error_number, const char *fmt, ...)
{
va_list ap;
-#ifdef HAVE_STRERROR_R
- char errbuff[512];
-#endif
- char *errp;
a->archive_error_number = error_number;
if (fmt == NULL) {
@@ -168,23 +170,8 @@ archive_set_error(struct archive *a, int error_number, const char *fmt, ...)
va_start(ap, fmt);
archive_string_vsprintf(&(a->error_string), fmt, ap);
- if (error_number > 0) {
- archive_strcat(&(a->error_string), ": ");
-#ifdef HAVE_STRERROR_R
-#ifdef STRERROR_R_CHAR_P
- errp = strerror_r(error_number, errbuff, sizeof(errbuff));
-#else
- strerror_r(error_number, errbuff, sizeof(errbuff));
- errp = errbuff;
-#endif
-#else
- /* Note: this is not threadsafe! */
- errp = strerror(error_number);
-#endif
- archive_strcat(&(a->error_string), errp);
- }
- a->error = a->error_string.s;
va_end(ap);
+ a->error = a->error_string.s;
}
void
@@ -200,8 +187,205 @@ void
__archive_errx(int retvalue, const char *msg)
{
static const char *msg1 = "Fatal Internal Error in libarchive: ";
- write(2, msg1, strlen(msg1));
- write(2, msg, strlen(msg));
- write(2, "\n", 1);
+ size_t s;
+
+ s = write(2, msg1, strlen(msg1));
+ (void)s; /* UNUSED */
+ s = write(2, msg, strlen(msg));
+ (void)s; /* UNUSED */
+ s = write(2, "\n", 1);
+ (void)s; /* UNUSED */
exit(retvalue);
}
+
+/*
+ * Parse option strings
+ * Detail of option format.
+ * - The option can accept:
+ * "opt-name", "!opt-name", "opt-name=value".
+ *
+ * - The option entries are separated by comma.
+ * e.g "compression=9,opt=XXX,opt-b=ZZZ"
+ *
+ * - The name of option string consist of '-' and alphabet
+ * but character '-' cannot be used for the first character.
+ * (Regular expression is [a-z][-a-z]+)
+ *
+ * - For a specfic format/filter, using the format name with ':'.
+ * e.g "zip:compression=9"
+ * (This "compression=9" option entry is for "zip" format only)
+ *
+ * If another entries follow it, those are not for
+ * the specfic format/filter.
+ * e.g handle "zip:compression=9,opt=XXX,opt-b=ZZZ"
+ * "zip" format/filter handler will get "compression=9"
+ * all format/filter handler will get "opt=XXX"
+ * all format/filter handler will get "opt-b=ZZZ"
+ *
+ * - Whitespace and tab are bypassed.
+ *
+ */
+int
+__archive_parse_options(const char *p, const char *fn, int keysize, char *key,
+ int valsize, char *val)
+{
+ const char *p_org;
+ int apply;
+ int kidx, vidx;
+ int negative;
+ enum {
+ /* Requested for initialization. */
+ INIT,
+ /* Finding format/filter-name and option-name. */
+ F_BOTH,
+ /* Finding option-name only.
+ * (already detected format/filter-name) */
+ F_NAME,
+ /* Getting option-value. */
+ G_VALUE,
+ } state;
+
+ p_org = p;
+ state = INIT;
+ kidx = vidx = negative = 0;
+ apply = 1;
+ while (*p) {
+ switch (state) {
+ case INIT:
+ kidx = vidx = 0;
+ negative = 0;
+ apply = 1;
+ state = F_BOTH;
+ break;
+ case F_BOTH:
+ case F_NAME:
+ if ((*p >= 'a' && *p <= 'z') ||
+ (*p >= '0' && *p <= '9') || *p == '-') {
+ if (kidx == 0 && !(*p >= 'a' && *p <= 'z'))
+ /* Illegal sequence. */
+ return (-1);
+ if (kidx >= keysize -1)
+ /* Too many characters. */
+ return (-1);
+ key[kidx++] = *p++;
+ } else if (*p == '!') {
+ if (kidx != 0)
+ /* Illegal sequence. */
+ return (-1);
+ negative = 1;
+ ++p;
+ } else if (*p == ',') {
+ if (kidx == 0)
+ /* Illegal sequence. */
+ return (-1);
+ if (!negative)
+ val[vidx++] = '1';
+ /* We have got boolean option data. */
+ ++p;
+ if (apply)
+ goto complete;
+ else
+ /* This option does not apply to the
+ * format which the fn variable
+ * indicate. */
+ state = INIT;
+ } else if (*p == ':') {
+ /* obuf data is format name */
+ if (state == F_NAME)
+ /* We already found it. */
+ return (-1);
+ if (kidx == 0)
+ /* Illegal sequence. */
+ return (-1);
+ if (negative)
+ /* We cannot accept "!format-name:". */
+ return (-1);
+ key[kidx] = '\0';
+ if (strcmp(fn, key) != 0)
+ /* This option does not apply to the
+ * format which the fn variable
+ * indicate. */
+ apply = 0;
+ kidx = 0;
+ ++p;
+ state = F_NAME;
+ } else if (*p == '=') {
+ if (kidx == 0)
+ /* Illegal sequence. */
+ return (-1);
+ if (negative)
+ /* We cannot accept "!opt-name=value". */
+ return (-1);
+ ++p;
+ state = G_VALUE;
+ } else if (*p == ' ') {
+ /* Pass the space character */
+ ++p;
+ } else {
+ /* Illegal character. */
+ return (-1);
+ }
+ break;
+ case G_VALUE:
+ if (*p == ',') {
+ if (vidx == 0)
+ /* Illegal sequence. */
+ return (-1);
+ /* We have got option data. */
+ ++p;
+ if (apply)
+ goto complete;
+ else
+ /* This option does not apply to the
+ * format which the fn variable
+ * indicate. */
+ state = INIT;
+ } else if (*p == ' ') {
+ /* Pass the space character */
+ ++p;
+ } else {
+ if (vidx >= valsize -1)
+ /* Too many characters. */
+ return (-1);
+ val[vidx++] = *p++;
+ }
+ break;
+ }
+ }
+
+ switch (state) {
+ case F_BOTH:
+ case F_NAME:
+ if (kidx != 0) {
+ if (!negative)
+ val[vidx++] = '1';
+ /* We have got boolean option. */
+ if (apply)
+ /* This option apply to the format which the
+ * fn variable indicate. */
+ goto complete;
+ }
+ break;
+ case G_VALUE:
+ if (vidx == 0)
+ /* Illegal sequence. */
+ return (-1);
+ /* We have got option value. */
+ if (apply)
+ /* This option apply to the format which the fn
+ * variable indicate. */
+ goto complete;
+ break;
+ case INIT:/* nothing */
+ break;
+ }
+
+ /* End of Option string. */
+ return (0);
+
+complete:
+ key[kidx] = '\0';
+ val[vidx] = '\0';
+ /* Return a size which we've consumed for detecting option */
+ return ((int)(p - p_org));
+}
diff --git a/archivers/libarchive/files/libarchive/archive_virtual.c b/archivers/libarchive/files/libarchive/archive_virtual.c
index a431058c671..a5c0b39b9cc 100644
--- a/archivers/libarchive/files/libarchive/archive_virtual.c
+++ b/archivers/libarchive/files/libarchive/archive_virtual.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_virtual.c,v 1.1 2007/03/03 07:37:36 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_virtual.c 201098 2009-12-28 02:58:14Z kientzle $");
#include "archive.h"
#include "archive_entry.h"
@@ -33,27 +33,40 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_virtual.c,v 1.1 2007/03/03 07:37:
int
archive_write_close(struct archive *a)
{
- return ((a->vtable->archive_write_close)(a));
+ return ((a->vtable->archive_close)(a));
+}
+
+int
+archive_read_close(struct archive *a)
+{
+ return ((a->vtable->archive_close)(a));
}
#if ARCHIVE_API_VERSION > 1
int
archive_write_finish(struct archive *a)
{
- return ((a->vtable->archive_write_finish)(a));
+ return ((a->vtable->archive_finish)(a));
}
#else
/* Temporarily allow library to compile with either 1.x or 2.0 API. */
void
archive_write_finish(struct archive *a)
{
- (void)(a->vtable->archive_write_finish)(a);
+ (void)(a->vtable->archive_finish)(a);
}
#endif
int
+archive_read_finish(struct archive *a)
+{
+ return ((a->vtable->archive_finish)(a));
+}
+
+int
archive_write_header(struct archive *a, struct archive_entry *entry)
{
+ ++a->file_count;
return ((a->vtable->archive_write_header)(a, entry));
}
diff --git a/archivers/libarchive/files/libarchive/archive_windows.c b/archivers/libarchive/files/libarchive/archive_windows.c
index 1f4d273dabb..03a459e7c49 100644
--- a/archivers/libarchive/files/libarchive/archive_windows.c
+++ b/archivers/libarchive/files/libarchive/archive_windows.c
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
* Copyright (c) 2003-2007 Kees Zeelenberg
* All rights reserved.
*
@@ -43,146 +44,1237 @@
* considering alternative APIs.
*/
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include "archive_platform.h"
+#include "archive_private.h"
+#include <ctype.h>
#include <errno.h>
#include <stddef.h>
+#ifdef HAVE_SYS_UTIME_H
#include <sys/utime.h>
+#endif
#include <sys/stat.h>
#include <process.h>
#include <stdlib.h>
+#include <wchar.h>
#include <windows.h>
-#include "archive_platform.h"
-/* Make a link to FROM called TO. */
-int link (from, to)
- const char *from;
- const char *to;
+#define EPOC_TIME ARCHIVE_LITERAL_ULL(116444736000000000)
+
+#if defined(_MSC_VER) && _MSC_VER < 1300
+/* VS 6 does not provide SetFilePointerEx, so define it here. */
+static BOOL SetFilePointerEx(HANDLE hFile,
+ LARGE_INTEGER liDistanceToMove,
+ PLARGE_INTEGER lpNewFilePointer,
+ DWORD dwMoveMethod)
+{
+ LARGE_INTEGER li;
+ li.QuadPart = liDistanceToMove.QuadPart;
+ li.LowPart = SetFilePointer(
+ hFile, li.LowPart, &li.HighPart, dwMoveMethod);
+ if(lpNewFilePointer) {
+ lpNewFilePointer->QuadPart = li.QuadPart;
+ }
+ return li.LowPart != -1 || GetLastError() == NO_ERROR;
+}
+#endif
+
+struct ustat {
+ int64_t st_atime;
+ uint32_t st_atime_nsec;
+ int64_t st_ctime;
+ uint32_t st_ctime_nsec;
+ int64_t st_mtime;
+ uint32_t st_mtime_nsec;
+ gid_t st_gid;
+ /* 64bits ino */
+ int64_t st_ino;
+ mode_t st_mode;
+ uint32_t st_nlink;
+ uint64_t st_size;
+ uid_t st_uid;
+ dev_t st_dev;
+ dev_t st_rdev;
+};
+
+/* Local replacement for undocumented Windows CRT function. */
+static void la_dosmaperr(unsigned long e);
+
+/* Transform 64-bits ino into 32-bits by hashing.
+ * You do not forget that really unique number size is 64-bits.
+ */
+#define INOSIZE (8*sizeof(ino_t)) /* 32 */
+static __inline ino_t
+getino(struct ustat *ub)
+{
+ ULARGE_INTEGER ino64;
+ ino64.QuadPart = ub->st_ino;
+ /* I don't know this hashing is correct way */
+ return (ino64.LowPart ^ (ino64.LowPart >> INOSIZE));
+}
+
+/*
+ * Prepend "\\?\" to the path name and convert it to unicode to permit
+ * an extended-length path for a maximum total path length of 32767
+ * characters.
+ * see also http://msdn.microsoft.com/en-us/library/aa365247.aspx
+ */
+static wchar_t *
+permissive_name(const char *name)
{
- int res;
+ wchar_t *wn, *wnp;
+ wchar_t *ws, *wsp;
+ DWORD l, len, slen;
+ int unc;
+
+ len = (DWORD)strlen(name);
+ wn = malloc((len + 1) * sizeof(wchar_t));
+ if (wn == NULL)
+ return (NULL);
+ l = MultiByteToWideChar(CP_ACP, 0, name, (int)len, wn, (int)len);
+ if (l == 0) {
+ free(wn);
+ return (NULL);
+ }
+ wn[l] = L'\0';
+
+ /* Get a full path names */
+ l = GetFullPathNameW(wn, 0, NULL, NULL);
+ if (l == 0) {
+ free(wn);
+ return (NULL);
+ }
+ wnp = malloc(l * sizeof(wchar_t));
+ if (wnp == NULL) {
+ free(wn);
+ return (NULL);
+ }
+ len = GetFullPathNameW(wn, l, wnp, NULL);
+ free(wn);
+ wn = wnp;
+
+ if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
+ wnp[2] == L'?' && wnp[3] == L'\\')
+ /* We have already permissive names. */
+ return (wn);
+
+ if (wnp[0] == L'\\' && wnp[1] == L'\\' &&
+ wnp[2] == L'.' && wnp[3] == L'\\') {
+ /* Device names */
+ if (((wnp[4] >= L'a' && wnp[4] <= L'z') ||
+ (wnp[4] >= L'A' && wnp[4] <= L'Z')) &&
+ wnp[5] == L':' && wnp[6] == L'\\')
+ wnp[2] = L'?';/* Not device names. */
+ return (wn);
+ }
+
+ unc = 0;
+ if (wnp[0] == L'\\' && wnp[1] == L'\\' && wnp[2] != L'\\') {
+ wchar_t *p = &wnp[2];
+
+ /* Skip server-name letters. */
+ while (*p != L'\\' && *p != L'\0')
+ ++p;
+ if (*p == L'\\') {
+ wchar_t *rp = ++p;
+ /* Skip share-name letters. */
+ while (*p != L'\\' && *p != L'\0')
+ ++p;
+ if (*p == L'\\' && p != rp) {
+ /* Now, match patterns such as
+ * "\\server-name\share-name\" */
+ wnp += 2;
+ len -= 2;
+ unc = 1;
+ }
+ }
+ }
+
+ slen = 4 + (unc * 4) + len + 1;
+ ws = wsp = malloc(slen * sizeof(wchar_t));
+ if (ws == NULL) {
+ free(wn);
+ return (NULL);
+ }
+ /* prepend "\\?\" */
+ wcsncpy(wsp, L"\\\\?\\", 4);
+ wsp += 4;
+ slen -= 4;
+ if (unc) {
+ /* append "UNC\" ---> "\\?\UNC\" */
+ wcsncpy(wsp, L"UNC\\", 4);
+ wsp += 4;
+ slen -= 4;
+ }
+ wcsncpy(wsp, wnp, slen);
+ wsp[slen - 1] = L'\0'; /* Ensure null termination. */
+ free(wn);
+ return (ws);
+}
- if (from == NULL || to == NULL) {
+static HANDLE
+la_CreateFile(const char *path, DWORD dwDesiredAccess, DWORD dwShareMode,
+ LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition,
+ DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
+{
+ wchar_t *wpath;
+ HANDLE handle;
+
+ handle = CreateFileA(path, dwDesiredAccess, dwShareMode,
+ lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
+ hTemplateFile);
+ if (handle != INVALID_HANDLE_VALUE)
+ return (handle);
+ if (GetLastError() != ERROR_PATH_NOT_FOUND)
+ return (handle);
+ wpath = permissive_name(path);
+ if (wpath == NULL)
+ return (handle);
+ handle = CreateFileW(wpath, dwDesiredAccess, dwShareMode,
+ lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes,
+ hTemplateFile);
+ free(wpath);
+ return (handle);
+}
+
+static void *
+la_GetFunctionKernel32(const char *name)
+{
+ static HINSTANCE lib;
+ static int set;
+ if (!set) {
+ set = 1;
+ lib = LoadLibrary("kernel32.dll");
+ }
+ if (lib == NULL) {
+ fprintf(stderr, "Can't load kernel32.dll?!\n");
+ exit(1);
+ }
+ return (void *)GetProcAddress(lib, name);
+}
+
+static int
+la_CreateHardLinkW(wchar_t *linkname, wchar_t *target)
+{
+ static BOOLEAN (WINAPI *f)(LPWSTR, LPWSTR, LPSECURITY_ATTRIBUTES);
+ static int set;
+ if (!set) {
+ set = 1;
+ f = la_GetFunctionKernel32("CreateHardLinkW");
+ }
+ return f == NULL ? 0 : (*f)(linkname, target, NULL);
+}
+
+
+/* Make a link to src called dst. */
+static int
+__link(const char *src, const char *dst)
+{
+ wchar_t *wsrc, *wdst;
+ int res, retval;
+ DWORD attr;
+
+ if (src == NULL || dst == NULL) {
set_errno (EINVAL);
return -1;
}
- if (!_access (from, F_OK))
- res = CopyFile (from, to, FALSE);
- else {
- /* from doesn not exist; try to prepend it with the dirname of to */
- char *fullfrompath, *slash, *todir;
- todir = strdup (to);
- if (!todir)
- return -1;
- slash = strrchr(todir, '/');
- if (slash)
- *slash = '\0';
- fullfrompath = malloc (strlen (from) + strlen (todir) + 2);
- if (!fullfrompath)
- return -1;
- strcpy (fullfrompath, todir);
- strcat (fullfrompath, "/");
- strcat (fullfrompath, from);
- if (todir)
- free (todir);
- if (_access (fullfrompath, R_OK))
- return -1;
- res = CopyFile (fullfrompath, to, FALSE);
- if (fullfrompath)
- free (fullfrompath);
+ wsrc = permissive_name(src);
+ wdst = permissive_name(dst);
+ if (wsrc == NULL || wdst == NULL) {
+ free(wsrc);
+ free(wdst);
+ set_errno (EINVAL);
+ return -1;
}
+ if ((attr = GetFileAttributesW(wsrc)) != (DWORD)-1) {
+ res = la_CreateHardLinkW(wdst, wsrc);
+ } else {
+ /* wsrc does not exist; try src prepend it with the dirname of wdst */
+ wchar_t *wnewsrc, *slash;
+ int i, n, slen, wlen;
+
+ if (strlen(src) >= 3 && isalpha((unsigned char)src[0]) &&
+ src[1] == ':' && src[2] == '\\') {
+ /* Original src name is already full-path */
+ retval = -1;
+ goto exit;
+ }
+ if (src[0] == '\\') {
+ /* Original src name is almost full-path
+ * (maybe src name is without drive) */
+ retval = -1;
+ goto exit;
+ }
+
+ wnewsrc = malloc ((wcslen(wsrc) + wcslen(wdst) + 1) * sizeof(wchar_t));
+ if (wnewsrc == NULL) {
+ errno = ENOMEM;
+ retval = -1;
+ goto exit;
+ }
+ /* Copying a dirname of wdst */
+ wcscpy(wnewsrc, wdst);
+ slash = wcsrchr(wnewsrc, L'\\');
+ if (slash != NULL)
+ *++slash = L'\0';
+ else
+ wcscat(wnewsrc, L"\\");
+ /* Converting multi-byte src to wide-char src */
+ wlen = (int)wcslen(wsrc);
+ slen = (int)strlen(src);
+ n = MultiByteToWideChar(CP_ACP, 0, src, slen, wsrc, wlen);
+ if (n == 0) {
+ free (wnewsrc);
+ retval = -1;
+ goto exit;
+ }
+ for (i = 0; i < n; i++)
+ if (wsrc[i] == L'/')
+ wsrc[i] = L'\\';
+ wcsncat(wnewsrc, wsrc, n);
+ /* Check again */
+ attr = GetFileAttributesW(wnewsrc);
+ if (attr == (DWORD)-1 || (attr & FILE_ATTRIBUTE_DIRECTORY) != 0) {
+ if (attr == (DWORD)-1)
+ la_dosmaperr(GetLastError());
+ else
+ errno = EPERM;
+ free (wnewsrc);
+ retval = -1;
+ goto exit;
+ }
+ res = la_CreateHardLinkW(wdst, wnewsrc);
+ free (wnewsrc);
+ }
if (res == 0) {
- set_errno (EINVAL);
- return -1;
+ la_dosmaperr(GetLastError());
+ retval = -1;
+ } else
+ retval = 0;
+exit:
+ free(wsrc);
+ free(wdst);
+ return (retval);
+}
+
+/* Make a hard link to src called dst. */
+int
+__la_link(const char *src, const char *dst)
+{
+ return __link(src, dst);
+}
+
+int
+__la_ftruncate(int fd, off_t length)
+{
+ LARGE_INTEGER distance;
+ HANDLE handle;
+
+ if (fd < 0) {
+ errno = EBADF;
+ return (-1);
+ }
+ handle = (HANDLE)_get_osfhandle(fd);
+ if (GetFileType(handle) != FILE_TYPE_DISK) {
+ errno = EBADF;
+ return (-1);
+ }
+ distance.QuadPart = length;
+ if (!SetFilePointerEx(handle, distance, NULL, FILE_BEGIN)) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ if (!SetEndOfFile(handle)) {
+ la_dosmaperr(GetLastError());
+ return (-1);
}
- return 0;
+ return (0);
}
-/* Make a symbolic link to FROM called TO. */
-int symlink (from, to)
- const char *from;
- const char *to;
+#define WINTIME(sec, usec) ((Int32x32To64(sec, 10000000) + EPOC_TIME) + (usec * 10))
+static int
+__hutimes(HANDLE handle, const struct __timeval *times)
{
- return link (from, to);
+ ULARGE_INTEGER wintm;
+ FILETIME fatime, fmtime;
+
+ wintm.QuadPart = WINTIME(times[0].tv_sec, times[0].tv_usec);
+ fatime.dwLowDateTime = wintm.LowPart;
+ fatime.dwHighDateTime = wintm.HighPart;
+ wintm.QuadPart = WINTIME(times[1].tv_sec, times[1].tv_usec);
+ fmtime.dwLowDateTime = wintm.LowPart;
+ fmtime.dwHighDateTime = wintm.HighPart;
+ if (SetFileTime(handle, NULL, &fatime, &fmtime) == 0) {
+ errno = EINVAL;
+ return (-1);
+ }
+ return (0);
}
-static int get_dev_ino (HANDLE hFile, dev_t *dev, ino_t *ino)
+int
+__la_futimes(int fd, const struct __timeval *times)
{
-/* dev_t: short (2 bytes); ino_t: unsigned int (4 bytes) */
-#define LODWORD(l) ((DWORD)((DWORDLONG)(l)))
-#define HIDWORD(l) ((DWORD)(((DWORDLONG)(l)>>32)&0xFFFFFFFF))
-#define MAKEDWORDLONG(a,b) ((DWORDLONG)(((DWORD)(a))|(((DWORDLONG)((DWORD)(b)))<<32)))
-#define INOSIZE (8*sizeof(ino_t)) /* 32 */
-//#define DEVSIZE (8*sizeof(dev_t)) /* 16 */
-#define SEQNUMSIZE (16)
-
- BY_HANDLE_FILE_INFORMATION FileInformation;
- uint64_t ino64, FileReferenceNumber ;
- ino_t resino;
- dev_t resdev;
- DWORD VolumeSerialNumber;
+ return (__hutimes((HANDLE)_get_osfhandle(fd), times));
+}
+
+int
+__la_utimes(const char *name, const struct __timeval *times)
+{
+ int ret;
+ HANDLE handle;
+
+ handle = la_CreateFile(name, GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ if (handle == INVALID_HANDLE_VALUE) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ ret = __hutimes(handle, times);
+ CloseHandle(handle);
+ return (ret);
+}
+
+int
+__la_chdir(const char *path)
+{
+ wchar_t *ws;
+ int r;
+
+ r = SetCurrentDirectoryA(path);
+ if (r == 0) {
+ if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ } else
+ return (0);
+ ws = permissive_name(path);
+ if (ws == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ r = SetCurrentDirectoryW(ws);
+ free(ws);
+ if (r == 0) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ return (0);
+}
+
+int
+__la_chmod(const char *path, mode_t mode)
+{
+ wchar_t *ws;
+ DWORD attr;
+ BOOL r;
+
+ ws = NULL;
+ attr = GetFileAttributesA(path);
+ if (attr == (DWORD)-1) {
+ if (GetLastError() != ERROR_FILE_NOT_FOUND) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ ws = permissive_name(path);
+ if (ws == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ attr = GetFileAttributesW(ws);
+ if (attr == (DWORD)-1) {
+ free(ws);
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ }
+ if (mode & _S_IWRITE)
+ attr &= ~FILE_ATTRIBUTE_READONLY;
+ else
+ attr |= FILE_ATTRIBUTE_READONLY;
+ if (ws == NULL)
+ r = SetFileAttributesA(path, attr);
+ else {
+ r = SetFileAttributesW(ws, attr);
+ free(ws);
+ }
+ if (r == 0) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ return (0);
+}
+
+/*
+ * This fcntl is limited implemention.
+ */
+int
+__la_fcntl(int fd, int cmd, int val)
+{
+ HANDLE handle;
+
+ handle = (HANDLE)_get_osfhandle(fd);
+ if (GetFileType(handle) == FILE_TYPE_PIPE) {
+ if (cmd == F_SETFL && val == 0) {
+ DWORD mode = PIPE_WAIT;
+ if (SetNamedPipeHandleState(
+ handle, &mode, NULL, NULL) != 0)
+ return (0);
+ }
+ }
+ errno = EINVAL;
+ return (-1);
+}
+
+__int64
+__la_lseek(int fd, __int64 offset, int whence)
+{
+ LARGE_INTEGER distance;
+ LARGE_INTEGER newpointer;
+ HANDLE handle;
+
+ if (fd < 0) {
+ errno = EBADF;
+ return (-1);
+ }
+ handle = (HANDLE)_get_osfhandle(fd);
+ if (GetFileType(handle) != FILE_TYPE_DISK) {
+ errno = EBADF;
+ return (-1);
+ }
+ distance.QuadPart = offset;
+ if (!SetFilePointerEx(handle, distance, &newpointer, whence)) {
+ DWORD lasterr;
+
+ lasterr = GetLastError();
+ if (lasterr == ERROR_BROKEN_PIPE)
+ return (0);
+ if (lasterr == ERROR_ACCESS_DENIED)
+ errno = EBADF;
+ else
+ la_dosmaperr(lasterr);
+ return (-1);
+ }
+ return (newpointer.QuadPart);
+}
+
+int
+__la_mkdir(const char *path, mode_t mode)
+{
+ wchar_t *ws;
+ int r;
+
+ (void)mode;/* UNUSED */
+ r = CreateDirectoryA(path, NULL);
+ if (r == 0) {
+ DWORD lasterr = GetLastError();
+ if (lasterr != ERROR_FILENAME_EXCED_RANGE &&
+ lasterr != ERROR_PATH_NOT_FOUND) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ } else
+ return (0);
+ ws = permissive_name(path);
+ if (ws == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ r = CreateDirectoryW(ws, NULL);
+ free(ws);
+ if (r == 0) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ return (0);
+}
+
+/* Windows' mbstowcs is differrent error handling from other unix mbstowcs.
+ * That one is using MultiByteToWideChar function with MB_PRECOMPOSED and
+ * MB_ERR_INVALID_CHARS flags.
+ * This implements for only to pass libarchive_test.
+ */
+size_t
+__la_mbstowcs(wchar_t *wcstr, const char *mbstr, size_t nwchars)
+{
+
+ return (MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS,
+ mbstr, (int)strlen(mbstr), wcstr,
+ (int)nwchars));
+}
+
+int
+__la_open(const char *path, int flags, ...)
+{
+ va_list ap;
+ wchar_t *ws;
+ int r, pmode;
+ DWORD attr;
+
+ va_start(ap, flags);
+ pmode = va_arg(ap, int);
+ va_end(ap);
+ ws = NULL;
+ if ((flags & ~O_BINARY) == O_RDONLY) {
+ /*
+ * When we open a directory, _open function returns
+ * "Permission denied" error.
+ */
+ attr = GetFileAttributesA(path);
+ if (attr == (DWORD)-1 && GetLastError() == ERROR_PATH_NOT_FOUND) {
+ ws = permissive_name(path);
+ if (ws == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ attr = GetFileAttributesW(ws);
+ }
+ if (attr == (DWORD)-1) {
+ la_dosmaperr(GetLastError());
+ free(ws);
+ return (-1);
+ }
+ if (attr & FILE_ATTRIBUTE_DIRECTORY) {
+ HANDLE handle;
+
+ if (ws != NULL)
+ handle = CreateFileW(ws, 0, 0, NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS |
+ FILE_ATTRIBUTE_READONLY,
+ NULL);
+ else
+ handle = CreateFileA(path, 0, 0, NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS |
+ FILE_ATTRIBUTE_READONLY,
+ NULL);
+ free(ws);
+ if (handle == INVALID_HANDLE_VALUE) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ r = _open_osfhandle((intptr_t)handle, _O_RDONLY);
+ return (r);
+ }
+ }
+ if (ws == NULL) {
+#if defined(__BORLANDC__)
+ /* Borland has no mode argument.
+ TODO: Fix mode of new file. */
+ r = _open(path, flags);
+#else
+ r = _open(path, flags, pmode);
+#endif
+ if (r < 0 && errno == EACCES && (flags & O_CREAT) != 0) {
+ /* simular other POSIX system action to pass a test */
+ attr = GetFileAttributesA(path);
+ if (attr == (DWORD)-1)
+ la_dosmaperr(GetLastError());
+ else if (attr & FILE_ATTRIBUTE_DIRECTORY)
+ errno = EISDIR;
+ else
+ errno = EACCES;
+ return (-1);
+ }
+ if (r >= 0 || errno != ENOENT)
+ return (r);
+ ws = permissive_name(path);
+ if (ws == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ }
+ r = _wopen(ws, flags, pmode);
+ if (r < 0 && errno == EACCES && (flags & O_CREAT) != 0) {
+ /* simular other POSIX system action to pass a test */
+ attr = GetFileAttributesW(ws);
+ if (attr == (DWORD)-1)
+ la_dosmaperr(GetLastError());
+ else if (attr & FILE_ATTRIBUTE_DIRECTORY)
+ errno = EISDIR;
+ else
+ errno = EACCES;
+ }
+ free(ws);
+ return (r);
+}
+
+ssize_t
+__la_read(int fd, void *buf, size_t nbytes)
+{
+ HANDLE handle;
+ DWORD bytes_read, lasterr;
+ int r;
+
+#ifdef _WIN64
+ if (nbytes > UINT32_MAX)
+ nbytes = UINT32_MAX;
+#endif
+ if (fd < 0) {
+ errno = EBADF;
+ return (-1);
+ }
+ handle = (HANDLE)_get_osfhandle(fd);
+ if (GetFileType(handle) == FILE_TYPE_PIPE) {
+ DWORD sta;
+ if (GetNamedPipeHandleState(
+ handle, &sta, NULL, NULL, NULL, NULL, 0) != 0 &&
+ (sta & PIPE_NOWAIT) == 0) {
+ DWORD avail = -1;
+ int cnt = 3;
+
+ while (PeekNamedPipe(
+ handle, NULL, 0, NULL, &avail, NULL) != 0 &&
+ avail == 0 && --cnt)
+ Sleep(100);
+ if (avail == 0)
+ return (0);
+ }
+ }
+ r = ReadFile(handle, buf, (uint32_t)nbytes,
+ &bytes_read, NULL);
+ if (r == 0) {
+ lasterr = GetLastError();
+ if (lasterr == ERROR_NO_DATA) {
+ errno = EAGAIN;
+ return (-1);
+ }
+ if (lasterr == ERROR_BROKEN_PIPE)
+ return (0);
+ if (lasterr == ERROR_ACCESS_DENIED)
+ errno = EBADF;
+ else
+ la_dosmaperr(lasterr);
+ return (-1);
+ }
+ return ((ssize_t)bytes_read);
+}
+
+/* Remove directory */
+int
+__la_rmdir(const char *path)
+{
+ wchar_t *ws;
+ int r;
+
+ r = _rmdir(path);
+ if (r >= 0 || errno != ENOENT)
+ return (r);
+ ws = permissive_name(path);
+ if (ws == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ r = _wrmdir(ws);
+ free(ws);
+ return (r);
+}
+
+/* Convert Windows FILETIME to UTC */
+__inline static void
+fileTimeToUTC(const FILETIME *filetime, time_t *time, long *ns)
+{
+ ULARGE_INTEGER utc;
+
+ utc.HighPart = filetime->dwHighDateTime;
+ utc.LowPart = filetime->dwLowDateTime;
+ if (utc.QuadPart >= EPOC_TIME) {
+ utc.QuadPart -= EPOC_TIME;
+ *time = (time_t)(utc.QuadPart / 10000000); /* milli seconds base */
+ *ns = (long)(utc.QuadPart % 10000000) * 100;/* nano seconds base */
+ } else {
+ *time = 0;
+ *ns = 0;
+ }
+}
+
+/* Stat by handle
+ * Windows' stat() does not accept path which is added "\\?\" especially "?"
+ * character.
+ * It means we cannot access a long name path(which is longer than MAX_PATH).
+ * So I've implemented simular Windows' stat() to access the long name path.
+ * And I've added some feature.
+ * 1. set st_ino by nFileIndexHigh and nFileIndexLow of
+ * BY_HANDLE_FILE_INFORMATION.
+ * 2. set st_nlink by nNumberOfLinks of BY_HANDLE_FILE_INFORMATION.
+ * 3. set st_dev by dwVolumeSerialNumber by BY_HANDLE_FILE_INFORMATION.
+ */
+static int
+__hstat(HANDLE handle, struct ustat *st)
+{
+ BY_HANDLE_FILE_INFORMATION info;
+ ULARGE_INTEGER ino64;
+ DWORD ftype;
+ mode_t mode;
+ time_t time;
+ long ns;
+
+ switch (ftype = GetFileType(handle)) {
+ case FILE_TYPE_UNKNOWN:
+ errno = EBADF;
+ return (-1);
+ case FILE_TYPE_CHAR:
+ case FILE_TYPE_PIPE:
+ if (ftype == FILE_TYPE_CHAR) {
+ st->st_mode = S_IFCHR;
+ st->st_size = 0;
+ } else {
+ DWORD avail;
+
+ st->st_mode = S_IFIFO;
+ if (PeekNamedPipe(handle, NULL, 0, NULL, &avail, NULL))
+ st->st_size = avail;
+ else
+ st->st_size = 0;
+ }
+ st->st_atime = 0;
+ st->st_atime_nsec = 0;
+ st->st_mtime = 0;
+ st->st_mtime_nsec = 0;
+ st->st_ctime = 0;
+ st->st_ctime_nsec = 0;
+ st->st_ino = 0;
+ st->st_nlink = 1;
+ st->st_uid = 0;
+ st->st_gid = 0;
+ st->st_rdev = 0;
+ st->st_dev = 0;
+ return (0);
+ case FILE_TYPE_DISK:
+ break;
+ default:
+ /* This ftype is undocumented type. */
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+
+ ZeroMemory(&info, sizeof(info));
+ if (!GetFileInformationByHandle (handle, &info)) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+
+ mode = S_IRUSR | S_IRGRP | S_IROTH;
+ if ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0)
+ mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+ if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
+ else
+ mode |= S_IFREG;
+ st->st_mode = mode;
- *ino = 0;
- *dev = 0;
- if (hFile == INVALID_HANDLE_VALUE) /* file cannot be opened */
- return 0;
- ZeroMemory (&FileInformation, sizeof(FileInformation));
- if (!GetFileInformationByHandle (hFile, &FileInformation)) /* cannot obtain FileInformation */
- return 0;
- ino64 = (uint64_t) MAKEDWORDLONG (
- FileInformation.nFileIndexLow, FileInformation.nFileIndexHigh);
- FileReferenceNumber = ino64 & ((~(0ULL)) >> SEQNUMSIZE); /* remove sequence number */
- /* transform 64-bits ino into 32-bits by hashing */
- resino = (ino_t) (
- ( (LODWORD(FileReferenceNumber)) ^ ((LODWORD(FileReferenceNumber)) >> INOSIZE) )
-// ^
-// ( (HIDWORD(FileReferenceNumber)) ^ ((HIDWORD(FileReferenceNumber)) >> INOSIZE) )
- );
- *ino = resino;
- VolumeSerialNumber = FileInformation.dwVolumeSerialNumber;
- //resdev = (unsigned short) ( (LOWORD(VolumeSerialNumber)) ^ ((HIWORD(VolumeSerialNumber)) >> DEVSIZE) );
- resdev = (dev_t) VolumeSerialNumber;
- *dev = resdev;
-//printf ("get_dev_ino: dev = %d; ino = %u\n", resdev, resino);
- return 0;
-}
-
-int get_dev_ino_fd (int fd, dev_t *dev, ino_t *ino)
-{
- HANDLE hFile;
- hFile = (HANDLE) _get_osfhandle (fd);
- return get_dev_ino (hFile, dev, ino);
-}
-
-int get_dev_ino_filename (char *path, dev_t *dev, ino_t *ino)
-{
- HANDLE hFile;
- int res;
- if (!path || !*path) /* path = NULL */
- return 0;
- if (_access (path, F_OK)) /* path does not exist */
- return -1;
-/* obtain handle to file "name"; FILE_FLAG_BACKUP_SEMANTICS is used to open directories */
- hFile = CreateFile (path, 0, 0, NULL, OPEN_EXISTING,
+ fileTimeToUTC(&info.ftLastAccessTime, &time, &ns);
+ st->st_atime = time;
+ st->st_atime_nsec = ns;
+ fileTimeToUTC(&info.ftLastWriteTime, &time, &ns);
+ st->st_mtime = time;
+ st->st_mtime_nsec = ns;
+ fileTimeToUTC(&info.ftCreationTime, &time, &ns);
+ st->st_ctime = time;
+ st->st_ctime_nsec = ns;
+ st->st_size =
+ ((int64_t)(info.nFileSizeHigh) * ((int64_t)MAXDWORD + 1))
+ + (int64_t)(info.nFileSizeLow);
+#ifdef SIMULATE_WIN_STAT
+ st->st_ino = 0;
+ st->st_nlink = 1;
+ st->st_dev = 0;
+#else
+ /* Getting FileIndex as i-node. We have to remove a sequence which
+ * is high-16-bits of nFileIndexHigh. */
+ ino64.HighPart = info.nFileIndexHigh & 0x0000FFFFUL;
+ ino64.LowPart = info.nFileIndexLow;
+ st->st_ino = ino64.QuadPart;
+ st->st_nlink = info.nNumberOfLinks;
+ if (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ ++st->st_nlink;/* Add parent directory. */
+ st->st_dev = info.dwVolumeSerialNumber;
+#endif
+ st->st_uid = 0;
+ st->st_gid = 0;
+ st->st_rdev = 0;
+ return (0);
+}
+
+static void
+copy_stat(struct stat *st, struct ustat *us)
+{
+ st->st_atime = us->st_atime;
+ st->st_ctime = us->st_ctime;
+ st->st_mtime = us->st_mtime;
+ st->st_gid = us->st_gid;
+ st->st_ino = getino(us);
+ st->st_mode = us->st_mode;
+ st->st_nlink = us->st_nlink;
+ st->st_size = us->st_size;
+ st->st_uid = us->st_uid;
+ st->st_dev = us->st_dev;
+ st->st_rdev = us->st_rdev;
+}
+
+int
+__la_fstat(int fd, struct stat *st)
+{
+ struct ustat u;
+ int ret;
+
+ if (fd < 0) {
+ errno = EBADF;
+ return (-1);
+ }
+ ret = __hstat((HANDLE)_get_osfhandle(fd), &u);
+ if (ret >= 0) {
+ copy_stat(st, &u);
+ if (u.st_mode & (S_IFCHR | S_IFIFO)) {
+ st->st_dev = fd;
+ st->st_rdev = fd;
+ }
+ }
+ return (ret);
+}
+
+int
+__la_stat(const char *path, struct stat *st)
+{
+ HANDLE handle;
+ struct ustat u;
+ int ret;
+
+ handle = la_CreateFile(path, 0, 0, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS | FILE_ATTRIBUTE_READONLY,
NULL);
- res = get_dev_ino (hFile, dev, ino);
- CloseHandle (hFile);
- return res;
+ if (handle == INVALID_HANDLE_VALUE) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ ret = __hstat(handle, &u);
+ CloseHandle(handle);
+ if (ret >= 0) {
+ char *p;
+
+ copy_stat(st, &u);
+ p = strrchr(path, '.');
+ if (p != NULL && strlen(p) == 4) {
+ char exttype[4];
+
+ ++ p;
+ exttype[0] = toupper(*p++);
+ exttype[1] = toupper(*p++);
+ exttype[2] = toupper(*p++);
+ exttype[3] = '\0';
+ if (!strcmp(exttype, "EXE") || !strcmp(exttype, "CMD") ||
+ !strcmp(exttype, "BAT") || !strcmp(exttype, "COM"))
+ st->st_mode |= S_IXUSR | S_IXGRP | S_IXOTH;
+ }
+ }
+ return (ret);
}
-int fstati64 (int fd, struct _stati64 *st)
+int
+__la_unlink(const char *path)
{
- int res;
- res = _fstati64 (fd, st);
- if (res < 0)
- return -1;
- if (st->st_ino == 0)
- res = get_dev_ino_fd (fd, &st->st_dev, &st->st_ino);
-// printf ("fstat: dev = %u; ino = %u\n", st->st_dev, st->st_ino);
- return res;
+ wchar_t *ws;
+ int r;
+
+ r = _unlink(path);
+ if (r >= 0 || errno != ENOENT)
+ return (r);
+ ws = permissive_name(path);
+ if (ws == NULL) {
+ errno = EINVAL;
+ return (-1);
+ }
+ r = _wunlink(ws);
+ free(ws);
+ return (r);
+}
+
+/*
+ * This waitpid is limited implemention.
+ */
+pid_t
+__la_waitpid(pid_t wpid, int *status, int option)
+{
+ HANDLE child;
+ DWORD cs, ret;
+
+ (void)option;/* UNUSED */
+ child = OpenProcess(PROCESS_QUERY_INFORMATION | SYNCHRONIZE, FALSE, wpid);
+ if (child == NULL) {
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ ret = WaitForSingleObject(child, INFINITE);
+ if (ret == WAIT_FAILED) {
+ CloseHandle(child);
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ if (GetExitCodeProcess(child, &cs) == 0) {
+ CloseHandle(child);
+ la_dosmaperr(GetLastError());
+ return (-1);
+ }
+ if (cs == STILL_ACTIVE)
+ *status = 0x100;
+ else
+ *status = (int)(cs & 0xff);
+ CloseHandle(child);
+ return (wpid);
+}
+
+ssize_t
+__la_write(int fd, const void *buf, size_t nbytes)
+{
+ DWORD bytes_written;
+
+#ifdef _WIN64
+ if (nbytes > UINT32_MAX)
+ nbytes = UINT32_MAX;
+#endif
+ if (fd < 0) {
+ errno = EBADF;
+ return (-1);
+ }
+ if (!WriteFile((HANDLE)_get_osfhandle(fd), buf, (uint32_t)nbytes,
+ &bytes_written, NULL)) {
+ DWORD lasterr;
+
+ lasterr = GetLastError();
+ if (lasterr == ERROR_ACCESS_DENIED)
+ errno = EBADF;
+ else
+ la_dosmaperr(lasterr);
+ return (-1);
+ }
+ return (bytes_written);
}
-#endif /* _WIN32 */
+/*
+ * The following function was modified from PostgreSQL sources and is
+ * subject to the copyright below.
+ */
+/*-------------------------------------------------------------------------
+ *
+ * win32error.c
+ * Map win32 error codes to errno values
+ *
+ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $PostgreSQL: pgsql/src/port/win32error.c,v 1.4 2008/01/01 19:46:00 momjian Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+/*
+PostgreSQL Database Management System
+(formerly known as Postgres, then as Postgres95)
+
+Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose, without fee, and without a written agreement
+is hereby granted, provided that the above copyright notice and this
+paragraph and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
+DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
+PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+*/
+
+static const struct {
+ DWORD winerr;
+ int doserr;
+} doserrors[] =
+{
+ { ERROR_INVALID_FUNCTION, EINVAL },
+ { ERROR_FILE_NOT_FOUND, ENOENT },
+ { ERROR_PATH_NOT_FOUND, ENOENT },
+ { ERROR_TOO_MANY_OPEN_FILES, EMFILE },
+ { ERROR_ACCESS_DENIED, EACCES },
+ { ERROR_INVALID_HANDLE, EBADF },
+ { ERROR_ARENA_TRASHED, ENOMEM },
+ { ERROR_NOT_ENOUGH_MEMORY, ENOMEM },
+ { ERROR_INVALID_BLOCK, ENOMEM },
+ { ERROR_BAD_ENVIRONMENT, E2BIG },
+ { ERROR_BAD_FORMAT, ENOEXEC },
+ { ERROR_INVALID_ACCESS, EINVAL },
+ { ERROR_INVALID_DATA, EINVAL },
+ { ERROR_INVALID_DRIVE, ENOENT },
+ { ERROR_CURRENT_DIRECTORY, EACCES },
+ { ERROR_NOT_SAME_DEVICE, EXDEV },
+ { ERROR_NO_MORE_FILES, ENOENT },
+ { ERROR_LOCK_VIOLATION, EACCES },
+ { ERROR_SHARING_VIOLATION, EACCES },
+ { ERROR_BAD_NETPATH, ENOENT },
+ { ERROR_NETWORK_ACCESS_DENIED, EACCES },
+ { ERROR_BAD_NET_NAME, ENOENT },
+ { ERROR_FILE_EXISTS, EEXIST },
+ { ERROR_CANNOT_MAKE, EACCES },
+ { ERROR_FAIL_I24, EACCES },
+ { ERROR_INVALID_PARAMETER, EINVAL },
+ { ERROR_NO_PROC_SLOTS, EAGAIN },
+ { ERROR_DRIVE_LOCKED, EACCES },
+ { ERROR_BROKEN_PIPE, EPIPE },
+ { ERROR_DISK_FULL, ENOSPC },
+ { ERROR_INVALID_TARGET_HANDLE, EBADF },
+ { ERROR_INVALID_HANDLE, EINVAL },
+ { ERROR_WAIT_NO_CHILDREN, ECHILD },
+ { ERROR_CHILD_NOT_COMPLETE, ECHILD },
+ { ERROR_DIRECT_ACCESS_HANDLE, EBADF },
+ { ERROR_NEGATIVE_SEEK, EINVAL },
+ { ERROR_SEEK_ON_DEVICE, EACCES },
+ { ERROR_DIR_NOT_EMPTY, ENOTEMPTY },
+ { ERROR_NOT_LOCKED, EACCES },
+ { ERROR_BAD_PATHNAME, ENOENT },
+ { ERROR_MAX_THRDS_REACHED, EAGAIN },
+ { ERROR_LOCK_FAILED, EACCES },
+ { ERROR_ALREADY_EXISTS, EEXIST },
+ { ERROR_FILENAME_EXCED_RANGE, ENOENT },
+ { ERROR_NESTING_NOT_ALLOWED, EAGAIN },
+ { ERROR_NOT_ENOUGH_QUOTA, ENOMEM }
+};
+
+static void
+la_dosmaperr(unsigned long e)
+{
+ int i;
+
+ if (e == 0)
+ {
+ errno = 0;
+ return;
+ }
+
+ for (i = 0; i < sizeof(doserrors); i++)
+ {
+ if (doserrors[i].winerr == e)
+ {
+ errno = doserrors[i].doserr;
+ return;
+ }
+ }
+
+ /* fprintf(stderr, "unrecognized win32 error code: %lu", e); */
+ errno = EINVAL;
+ return;
+}
+
+#if !defined(HAVE_OPENSSL_MD5_H) && !defined(HAVE_OPENSSL_SHA_H)
+/*
+ * Message digest functions.
+ */
+static void
+Digest_Init(Digest_CTX *ctx, ALG_ID algId)
+{
+
+ ctx->valid = 0;
+ if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
+ PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
+ if (GetLastError() != (DWORD)NTE_BAD_KEYSET)
+ return;
+ if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
+ PROV_RSA_FULL, CRYPT_NEWKEYSET))
+ return;
+ }
+
+ if (!CryptCreateHash(ctx->cryptProv, algId, 0, 0, &ctx->hash)) {
+ CryptReleaseContext(ctx->cryptProv, 0);
+ return;
+ }
+
+ ctx->valid = 1;
+}
+
+static void
+Digest_Update(Digest_CTX *ctx, const unsigned char *buf, size_t len)
+{
+
+ if (!ctx->valid)
+ return;
+
+ CryptHashData(ctx->hash,
+ (unsigned char *)(uintptr_t)buf,
+ (DWORD)len, 0);
+}
+
+static void
+Digest_Final(unsigned char *buf, int bufsize, Digest_CTX *ctx)
+{
+ DWORD siglen = bufsize;
+
+ if (!ctx->valid)
+ return;
+
+ CryptGetHashParam(ctx->hash, HP_HASHVAL, buf, &siglen, 0);
+ CryptDestroyHash(ctx->hash);
+ CryptReleaseContext(ctx->cryptProv, 0);
+ ctx->valid = 0;
+}
+
+#define DIGEST_INIT(name, algid) \
+void name ## _Init(Digest_CTX *ctx)\
+{\
+ Digest_Init(ctx, algid);\
+}
+
+#define DIGEST_UPDATE(name) \
+void name ## _Update(Digest_CTX *ctx, const unsigned char *buf, size_t len)\
+{\
+ Digest_Update(ctx, buf, len);\
+}
+
+#define DIGEST_FINAL(name, size) \
+void name ## _Final(unsigned char *buf, Digest_CTX *ctx)\
+{\
+ Digest_Final(buf, size, ctx);\
+}
+
+DIGEST_INIT(MD5, CALG_MD5)
+DIGEST_UPDATE(MD5)
+DIGEST_FINAL(MD5, MD5_DIGEST_LENGTH)
+
+DIGEST_INIT(SHA1, CALG_SHA1)
+DIGEST_UPDATE(SHA1)
+DIGEST_FINAL(SHA1, SHA1_DIGEST_LENGTH)
+
+/*
+ * SHA256 nor SHA384 nor SHA512 are not supported on Windows XP and Windows 2000.
+ */
+#ifdef CALG_SHA_256
+DIGEST_INIT(SHA256, CALG_SHA_256)
+DIGEST_UPDATE(SHA256)
+DIGEST_FINAL(SHA256, SHA256_DIGEST_LENGTH)
+#endif
+
+#ifdef CALG_SHA_384
+DIGEST_INIT(SHA384, CALG_SHA_384)
+DIGEST_UPDATE(SHA384)
+DIGEST_FINAL(SHA384, SHA384_DIGEST_LENGTH)
+#endif
+
+#ifdef CALG_SHA_512
+DIGEST_INIT(SHA512, CALG_SHA_512)
+DIGEST_UPDATE(SHA512)
+DIGEST_FINAL(SHA512, SHA384_DIGEST_LENGTH)
+#endif
+
+#endif /* !HAVE_OPENSSL_MD5_H && !HAVE_OPENSSL_SHA_H */
+
+#endif /* _WIN32 && !__CYGWIN__ */
diff --git a/archivers/libarchive/files/libarchive/archive_windows.h b/archivers/libarchive/files/libarchive/archive_windows.h
index 9bc21e4de8f..b68e72e9870 100644
--- a/archivers/libarchive/files/libarchive/archive_windows.h
+++ b/archivers/libarchive/files/libarchive/archive_windows.h
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
* Copyright (c) 2003-2006 Tim Kientzle
* All rights reserved.
*
@@ -26,101 +27,254 @@
* $FreeBSD$
*/
-#ifndef LIBARCHIVE_NONPOSIX_H_INCLUDED
-#define LIBARCHIVE_NONPOSIX_H_INCLUDED
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
+/*
+ * TODO: A lot of stuff in here isn't actually used by libarchive and
+ * can be trimmed out. Note that this file is used by libarchive and
+ * libarchive_test but nowhere else. (But note that it gets compiled
+ * with many different Windows environments, including MinGW, Visual
+ * Studio, and Cygwin. Significant changes should be tested in all three.)
+ */
+
+/*
+ * TODO: Don't use off_t in here. Use __int64 instead. Note that
+ * Visual Studio and the Windows SDK define off_t as 32 bits; Win32's
+ * more modern file handling APIs all use __int64 instead of off_t.
+ */
+
+#ifndef LIBARCHIVE_ARCHIVE_WINDOWS_H_INCLUDED
+#define LIBARCHIVE_ARCHIVE_WINDOWS_H_INCLUDED
/* Start of configuration for native Win32 */
#include <errno.h>
-#define set_errno(val) ((errno)=val)
+#define set_errno(val) ((errno)=val)
#include <io.h>
+#include <stdlib.h> //brings in NULL
+#if defined(HAVE_STDINT_H)
+#include <stdint.h>
+#endif
+#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <process.h>
#include <direct.h>
+#define NOCRYPT
+#include <windows.h>
+//#define EFTYPE 7
+
+#if !defined(STDIN_FILENO)
+#define STDIN_FILENO 0
+#endif
-#define EFTYPE 7
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
+#if !defined(STDOUT_FILENO)
+#define STDOUT_FILENO 1
+#endif
+
+#if !defined(STDERR_FILENO)
+#define STDERR_FILENO 2
+#endif
+
+#if defined(_MSC_VER)
/* TODO: Fix the code, don't suppress the warnings. */
#pragma warning(disable:4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */
-#pragma warning(disable:4146) /* unary minus operator applied to unsigned type, result still unsigned */
-#pragma warning(disable:4996) /* 'function': was declared deprecated */
-#pragma warning(disable:4267) /* Conversion, possible loss of data */
-
-/* Basic definitions for system and integer types. */
-#ifndef _SSIZE_T_
-# define SSIZE_MAX LONG_MAX
-#define _SSIZE_T_
-#endif /* _SSIZE_T_ */
+#endif
+#if defined(__BORLANDC__)
+#pragma warn -8068 /* Constant out of range in comparison. */
+#pragma warn -8072 /* Suspicious pointer arithmetic. */
+#endif
#ifndef NULL
#ifdef __cplusplus
-#define NULL 0
+#define NULL 0
#else
-#define NULL ((void *)0)
+#define NULL ((void *)0)
#endif
#endif
-/* Replacement for major/minor/makedev. */
-#define major(x) ((int)(0x00ff & ((x) >> 8)))
-#define minor(x) ((int)(0xffff00ff & (x)))
-#define makedev(maj,min) ((0xff00 & ((maj)<<8))|(0xffff00ff & (min)))
-
-#define EFTYPE 7
-#ifndef STDERR_FILENO
-#define STDERR_FILENO 2
-#endif /* STDERR_FILENO */
-
/* Alias the Windows _function to the POSIX equivalent. */
-#define chdir _chdir
-#define chmod _chmod
+#define access _access
+#define chdir __la_chdir
+#define chmod __la_chmod
#define close _close
+#define fcntl __la_fcntl
+#ifndef fileno
#define fileno _fileno
-#define fstat _fstat
-#define lseek _lseek
-#define open _open
-#define stat _stat
-#define mkdir(d,m) _mkdir(d)
+#endif
+#define fstat __la_fstat
+#define ftruncate __la_ftruncate
+#define futimes __la_futimes
+#define getcwd _getcwd
+#define link __la_link
+#define lseek __la_lseek
+#define lstat __la_stat
+#define mbstowcs __la_mbstowcs
+#define mkdir(d,m) __la_mkdir(d, m)
#define mktemp _mktemp
-#define read _read
-#define rmdir _rmdir
+#define open __la_open
+#define read __la_read
+#define rmdir __la_rmdir
+#if !defined(__BORLANDC__)
+#define setmode _setmode
+#endif
+#define stat(path,stref) __la_stat(path,stref)
+#if !defined(__BORLANDC__)
#define strdup _strdup
+#endif
#define tzset _tzset
+#if !defined(__BORLANDC__)
#define umask _umask
-#define write _write
+#endif
+#define unlink __la_unlink
+#define utimes __la_utimes
+#define waitpid __la_waitpid
+#define write __la_write
-#define O_RDONLY _O_RDONLY
+#ifndef O_RDONLY
+#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
#define O_TRUNC _O_TRUNC
#define O_CREAT _O_CREAT
#define O_EXCL _O_EXCL
+#define O_BINARY _O_BINARY
+#endif
-#define S_ISUID 0004000
-#define S_ISGID 0002000
-#define S_ISVTX 0001000
+#ifndef _S_IFIFO
+ #define _S_IFIFO 0010000 /* pipe */
+#endif
+#ifndef _S_IFCHR
+ #define _S_IFCHR 0020000 /* character special */
+#endif
+#ifndef _S_IFDIR
+ #define _S_IFDIR 0040000 /* directory */
+#endif
+#ifndef _S_IFBLK
+ #define _S_IFBLK 0060000 /* block special */
+#endif
+#ifndef _S_IFLNK
+ #define _S_IFLNK 0120000 /* symbolic link */
+#endif
+#ifndef _S_IFSOCK
+ #define _S_IFSOCK 0140000 /* socket */
+#endif
+#ifndef _S_IFREG
+ #define _S_IFREG 0100000 /* regular */
+#endif
+#ifndef _S_IFMT
+ #define _S_IFMT 0170000 /* file type mask */
+#endif
-#define S_IFMT 0170000
-#define S_IFDIR _S_IFDIR
-#define S_IFREG _S_IFREG
+#ifndef S_IFIFO
+#define S_IFIFO _S_IFIFO
+#endif
+//#define S_IFCHR _S_IFCHR
+//#define S_IFDIR _S_IFDIR
+#ifndef S_IFBLK
+#define S_IFBLK _S_IFBLK
+#endif
+#ifndef S_IFLNK
+#define S_IFLNK _S_IFLNK
+#endif
+#ifndef S_IFSOCK
+#define S_IFSOCK _S_IFSOCK
+#endif
+//#define S_IFREG _S_IFREG
+//#define S_IFMT _S_IFMT
-#define S_ISDIR(m) (((m) & 0170000) == _S_IFDIR) /* directory */
-#define S_ISCHR(m) (((m) & 0170000) == _S_IFCHR) /* char special */
-#define S_ISREG(m) (((m) & 0170000) == _S_IFREG) /* regular file */
+#ifndef S_ISBLK
+#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) /* block special */
+#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) /* fifo or socket */
+#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) /* char special */
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */
+#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */
+#endif
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* Symbolic link */
+#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* Socket */
-/* Windows doesn't have the following, so they're trivial. */
-#define S_ISBLK(m) (0) /* block special */
-#define S_ISFIFO(m) (0) /* fifo or socket */
-#define S_ISLNK(m) (0) /* Symbolic link */
-#define S_ISSOCK(m) (0) /* Socket */
+#define _S_ISUID 0004000 /* set user id on execution */
+#define _S_ISGID 0002000 /* set group id on execution */
+#define _S_ISVTX 0001000 /* save swapped text even after use */
+#define S_ISUID _S_ISUID
+#define S_ISGID _S_ISGID
+#define S_ISVTX _S_ISVTX
+
+#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
+#define _S_IXUSR _S_IEXEC /* read permission, user */
+#define _S_IWUSR _S_IWRITE /* write permission, user */
+#define _S_IRUSR _S_IREAD /* execute/search permission, user */
+#define _S_IRWXG (_S_IRWXU >> 3)
+#define _S_IXGRP (_S_IXUSR >> 3) /* read permission, group */
+#define _S_IWGRP (_S_IWUSR >> 3) /* write permission, group */
+#define _S_IRGRP (_S_IRUSR >> 3) /* execute/search permission, group */
+#define _S_IRWXO (_S_IRWXG >> 3)
+#define _S_IXOTH (_S_IXGRP >> 3) /* read permission, other */
+#define _S_IWOTH (_S_IWGRP >> 3) /* write permission, other */
+#define _S_IROTH (_S_IRGRP >> 3) /* execute/search permission, other */
+
+#ifndef S_IRWXU
+#define S_IRWXU _S_IRWXU
+#define S_IXUSR _S_IXUSR
+#define S_IWUSR _S_IWUSR
+#define S_IRUSR _S_IRUSR
+#endif
+#define S_IRWXG _S_IRWXG
+#define S_IXGRP _S_IXGRP
+#define S_IWGRP _S_IWGRP
+#define S_IRGRP _S_IRGRP
+#define S_IRWXO _S_IRWXO
+#define S_IXOTH _S_IXOTH
+#define S_IWOTH _S_IWOTH
+#define S_IROTH _S_IROTH
+
+#define F_DUPFD 0 /* Duplicate file descriptor. */
+#define F_GETFD 1 /* Get file descriptor flags. */
+#define F_SETFD 2 /* Set file descriptor flags. */
+#define F_GETFL 3 /* Get file status flags. */
+#define F_SETFL 4 /* Set file status flags. */
+#define F_GETOWN 5 /* Get owner (receiver of SIGIO). */
+#define F_SETOWN 6 /* Set owner (receiver of SIGIO). */
+#define F_GETLK 7 /* Get record locking info. */
+#define F_SETLK 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW 9 /* Set record locking info (blocking). */
+
+/* XXX missing */
+#define F_GETLK64 7 /* Get record locking info. */
+#define F_SETLK64 8 /* Set record locking info (non-blocking). */
+#define F_SETLKW64 9 /* Set record locking info (blocking). */
+
+/* File descriptor flags used with F_GETFD and F_SETFD. */
+#define FD_CLOEXEC 1 /* Close on exec. */
+
+//NOT SURE IF O_NONBLOCK is OK here but at least the 0x0004 flag is not used by anything else...
+#define O_NONBLOCK 0x0004 /* Non-blocking I/O. */
+//#define O_NDELAY O_NONBLOCK
+
+/* Symbolic constants for the access() function */
+#if !defined(F_OK)
+ #define R_OK 4 /* Test for read permission */
+ #define W_OK 2 /* Test for write permission */
+ #define X_OK 1 /* Test for execute permission */
+ #define F_OK 0 /* Test for existence of file */
+#endif
+
+
+#ifdef _LARGEFILE_SOURCE
+# define __USE_LARGEFILE 1 /* declare fseeko and ftello */
+#endif
+
+#if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
+# define __USE_FILE_OFFSET64 1 /* replace 32-bit functions by 64-bit ones */
+#endif
+
+#if __USE_LARGEFILE && __USE_FILE_OFFSET64
/* replace stat and seek by their large-file equivalents */
#undef stat
-#define stat _stati64
-#undef fstat
-#define fstat _fstati64
+#define stat _stati64
#undef lseek
#define lseek _lseeki64
@@ -135,18 +289,134 @@
# define ftello ftello64
# define ftell64 ftello64
#endif /* __MINGW32__ */
+#endif /* LARGE_FILES */
+
+#ifdef USE_WINSOCK_TIMEVAL
+/* Winsock timeval has long size tv_sec. */
+#define __timeval timeval
+#else
+struct _timeval64i32 {
+ time_t tv_sec;
+ long tv_usec;
+};
+#define __timeval _timeval64i32
+#endif
+
+/* Message digest define */
+#if !defined(HAVE_OPENSSL_MD5_H) && !defined(HAVE_OPENSSL_SHA_H)
+# if defined(_MSC_VER) && _MSC_VER < 1300
+# define _WIN32_WINNT 0x0400
+# endif
+#include <wincrypt.h>
+typedef struct {
+ int valid;
+ HCRYPTPROV cryptProv;
+ HCRYPTHASH hash;
+} Digest_CTX;
+#endif
+
+#if !defined(HAVE_OPENSSL_MD5_H) && defined(CALG_MD5)
+#define MD5_DIGEST_LENGTH 16
+#define HAVE_MD5 1
+#define MD5_CTX Digest_CTX
+#endif
+#ifndef HAVE_OPENSSL_SHA_H
+#ifdef CALG_SHA1
+#define SHA1_DIGEST_LENGTH 20
+#define HAVE_SHA1 1
+#define SHA1_CTX Digest_CTX
+#endif
+#ifdef CALG_SHA_256
+#define SHA256_DIGEST_LENGTH 32
+#define HAVE_SHA256 1
+#define SHA256_CTX Digest_CTX
+#endif
+#ifdef CALG_SHA_384
+#define SHA384_DIGEST_LENGTH 48
+#define HAVE_SHA384 1
+#define SHA384_CTX Digest_CTX
+#endif
+#ifdef CALG_SHA_512
+#define SHA512_DIGEST_LENGTH 64
+#define HAVE_SHA512 1
+#define SHA512_CTX Digest_CTX
+#endif
+#endif /* HAVE_OPENSSL_SHA_H */
/* End of Win32 definitions. */
-#ifdef __cplusplus
-extern "C" {
+/* Tell libarchive code that we have simulations for these. */
+#ifndef HAVE_FTRUNCATE
+#define HAVE_FTRUNCATE 1
+#endif
+#ifndef HAVE_FUTIMES
+#define HAVE_FUTIMES 1
+#endif
+#ifndef HAVE_UTIMES
+#define HAVE_UTIMES 1
+#endif
+#ifndef HAVE_LINK
+#define HAVE_LINK 1
#endif
-extern int link (const char *from, const char *to);
-extern int symlink (const char *from, const char *to);
+/* Replacement POSIX function */
+extern int __la_chdir(const char *path);
+extern int __la_chmod(const char *path, mode_t mode);
+extern int __la_fcntl(int fd, int cmd, int val);
+extern int __la_fstat(int fd, struct stat *st);
+extern int __la_ftruncate(int fd, off_t length);
+extern int __la_futimes(int fd, const struct __timeval *times);
+extern int __la_link(const char *src, const char *dst);
+extern __int64 __la_lseek(int fd, __int64 offset, int whence);
+extern size_t __la_mbstowcs(wchar_t *wcstr, const char *mbstr, size_t nwchars);
+extern int __la_mkdir(const char *path, mode_t mode);
+extern int __la_open(const char *path, int flags, ...);
+extern ssize_t __la_read(int fd, void *buf, size_t nbytes);
+extern int __la_rmdir(const char *path);
+extern int __la_stat(const char *path, struct stat *st);
+extern int __la_unlink(const char *path);
+extern int __la_utimes(const char *name, const struct __timeval *times);
+extern pid_t __la_waitpid(pid_t wpid, int *status, int option);
+extern ssize_t __la_write(int fd, const void *buf, size_t nbytes);
-#ifdef __cplusplus
-}
+#define _stat64i32(path, st) __la_stat(path, st)
+#define _stat64(path, st) __la_stat(path, st)
+/* for status returned by la_waitpid */
+#define WIFEXITED(sts) ((sts & 0x100) == 0)
+#define WEXITSTATUS(sts) (sts & 0x0FF)
+
+/* Message digest function */
+#if !defined(HAVE_OPENSSL_MD5_H) && !defined(HAVE_OPENSSL_SHA_H)
+#ifdef MD5_DIGEST_LENGTH
+extern void MD5_Init(Digest_CTX *ctx);
+extern void MD5_Update(Digest_CTX *ctx, const unsigned char *buf,
+ size_t len);
+extern void MD5_Final(unsigned char *buf, Digest_CTX *ctx);
+#endif
+#ifdef SHA1_DIGEST_LENGTH
+extern void SHA1_Init(Digest_CTX *ctx);
+extern void SHA1_Update(Digest_CTX *ctx, const unsigned char *buf,
+ size_t len);
+extern void SHA1_Final(unsigned char *buf, Digest_CTX *ctx);
+#endif
+#ifdef SHA256_DIGEST_LENGTH
+extern void SHA256_Init(Digest_CTX *ctx);
+extern void SHA256_Update(Digest_CTX *ctx, const unsigned char *buf,
+ size_t len);
+extern void SHA256_Final(unsigned char *buf, Digest_CTX *ctx);
+#endif
+#ifdef SHA384_DIGEST_LENGTH
+extern void SHA384_Init(Digest_CTX *ctx);
+extern void SHA384_Update(Digest_CTX *ctx, const unsigned char *buf,
+ size_t len);
+extern void SHA384_Final(unsigned char *buf, Digest_CTX *ctx);
+#endif
+#ifdef SHA512_DIGEST_LENGTH
+extern void SHA512_Init(Digest_CTX *ctx);
+extern void SHA512_Update(Digest_CTX *ctx, const unsigned char *buf,
+ size_t len);
+extern void SHA512_Final(unsigned char *buf, Digest_CTX *ctx);
+#endif
#endif
-#endif /* LIBARCHIVE_NONPOSIX_H_INCLUDED */
+#endif /* LIBARCHIVE_ARCHIVE_WINDOWS_H_INCLUDED */
diff --git a/archivers/libarchive/files/libarchive/archive_write.3 b/archivers/libarchive/files/libarchive/archive_write.3
index 14003f43c36..ffe0c9b45f0 100644
--- a/archivers/libarchive/files/libarchive/archive_write.3
+++ b/archivers/libarchive/files/libarchive/archive_write.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_write.3,v 1.24 2008/05/26 17:00:23 kientzle Exp $
+.\" $FreeBSD: head/lib/libarchive/archive_write.3 201110 2009-12-28 03:31:29Z kientzle $
.\"
.Dd May 11, 2008
.Dt archive_write 3
@@ -43,6 +43,9 @@
.Nm archive_write_set_compression_gzip ,
.Nm archive_write_set_compression_none ,
.Nm archive_write_set_compression_program ,
+.Nm archive_write_set_compressor_options ,
+.Nm archive_write_set_format_options ,
+.Nm archive_write_set_options ,
.Nm archive_write_open ,
.Nm archive_write_open_fd ,
.Nm archive_write_open_FILE ,
@@ -73,10 +76,7 @@
.Ft int
.Fn archive_write_set_compression_none "struct archive *"
.Ft int
-.Fo archive_write_set_compression_program
-.Fa "struct archive *"
-.Fa "const char * cmd"
-.Fc
+.Fn archive_write_set_compression_program "struct archive *" "const char * cmd"
.Ft int
.Fn archive_write_set_format_cpio "struct archive *"
.Ft int
@@ -90,6 +90,12 @@
.Ft int
.Fn archive_write_set_format_ustar "struct archive *"
.Ft int
+.Fn archive_write_set_format_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_write_set_compressor_options "struct archive *" "const char *"
+.Ft int
+.Fn archive_write_set_options "struct archive *" "const char *"
+.Ft int
.Fo archive_write_open
.Fa "struct archive *"
.Fa "void *client_data"
@@ -210,6 +216,68 @@ Note that the compressed output is always properly blocked.
The archive will be fed into the specified compression program.
The output of that program is blocked and written to the client
write callbacks.
+.It Xo
+.Fn archive_write_set_compressor_options ,
+.Fn archive_write_set_format_options ,
+.Fn archive_write_set_options
+.Xc
+Specifies options that will be passed to the currently-enabled
+compressor and/or format writer.
+The argument is a comma-separated list of individual options.
+Individual options have one of the following forms:
+.Bl -tag -compact -width indent
+.It Ar option=value
+The option/value pair will be provided to every module.
+Modules that do not accept an option with this name will ignore it.
+.It Ar option
+The option will be provided to every module with a value of
+.Dq 1 .
+.It Ar !option
+The option will be provided to every module with a NULL value.
+.It Ar module:option=value , Ar module:option , Ar module:!option
+As above, but the corresponding option and value will be provided
+only to modules whose name matches
+.Ar module .
+.El
+The return value will be
+.Cm ARCHIVE_OK
+if any module accepts the option, or
+.Cm ARCHIVE_WARN
+if no module accepted the option, or
+.Cm ARCHIVE_FATAL
+if there was a fatal error while attempting to process the option.
+.Pp
+The currently supported options are:
+.Bl -tag -compact -width indent
+.It Compressor gzip
+.Bl -tag -compact -width indent
+.It Cm compression-level
+The value is interpreted as a decimal integer specifying the
+gzip compression level.
+.El
+.It Compressor xz
+.Bl -tag -compact -width indent
+.It Cm compression-level
+The value is interpreted as a decimal integer specifying the
+compression level.
+.El
+.It Format mtree
+.Bl -tag -compact -width indent
+.It Cm cksum , Cm device , Cm flags , Cm gid , Cm gname , Cm indent , Cm link , Cm md5 , Cm mode , Cm nlink , Cm rmd160 , Cm sha1 , Cm sha256 , Cm sha384 , Cm sha512 , Cm size , Cm time , Cm uid , Cm uname
+Enable a particular keyword in the mtree output.
+Prefix with an exclamation mark to disable the corresponding keyword.
+The default is equivalent to
+.Dq device, flags, gid, gname, link, mode, nlink, size, time, type, uid, uname .
+.It Cm all
+Enables all of the above keywords.
+.It Cm use-set
+Enables generation of
+.Cm /set
+lines that specify default values for the following files and/or directories.
+.It Cm indent
+XXX needs explanation XXX
+.El
+.El
.It Fn archive_write_open
Freeze the settings, open the archive, and prepare for writing entries.
This is the most generic form of this function, which accepts
@@ -342,7 +410,7 @@ to register an error code and message and return
.Fo archive_write_callback
.Fa "struct archive *"
.Fa "void *client_data"
-.Fa "void *buffer"
+.Fa "const void *buffer"
.Fa "size_t length"
.Fc
.El
@@ -385,6 +453,9 @@ and
.Xr close 2
system calls.
.Bd -literal -offset indent
+#ifdef __linux__
+#define _FILE_OFFSET_BITS 64
+#endif
#include <sys/stat.h>
#include <archive.h>
#include <archive_entry.h>
@@ -410,7 +481,7 @@ myopen(struct archive *a, void *client_data)
}
ssize_t
-mywrite(struct archive *a, void *client_data, void *buff, size_t n)
+mywrite(struct archive *a, void *client_data, const void *buff, size_t n)
{
struct mydata *mydata = client_data;
diff --git a/archivers/libarchive/files/libarchive/archive_write.c b/archivers/libarchive/files/libarchive/archive_write.c
index 1a3ddc9a5e6..e0d942b0754 100644
--- a/archivers/libarchive/files/libarchive/archive_write.c
+++ b/archivers/libarchive/files/libarchive/archive_write.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write.c,v 1.27 2008/03/14 23:09:02 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write.c 201099 2009-12-28 03:03:00Z kientzle $");
/*
* This file contains the "essential" portions of the write API, that
@@ -72,8 +72,8 @@ archive_write_vtable(void)
static int inited = 0;
if (!inited) {
- av.archive_write_close = _archive_write_close;
- av.archive_write_finish = _archive_write_finish;
+ av.archive_close = _archive_write_close;
+ av.archive_finish = _archive_write_finish;
av.archive_write_header = _archive_write_header;
av.archive_write_finish_entry = _archive_write_finish_entry;
av.archive_write_data = _archive_write_data;
@@ -125,6 +125,115 @@ archive_write_new(void)
}
/*
+ * Set write options for the format. Returns 0 if successful.
+ */
+int
+archive_write_set_format_options(struct archive *_a, const char *s)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ char key[64], val[64];
+ int len, r, ret = ARCHIVE_OK;
+
+ __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_set_format_options");
+ archive_clear_error(&a->archive);
+
+ if (s == NULL || *s == '\0')
+ return (ARCHIVE_OK);
+ if (a->format_options == NULL)
+ /* This format does not support option. */
+ return (ARCHIVE_OK);
+
+ while ((len = __archive_parse_options(s, a->format_name,
+ sizeof(key), key, sizeof(val), val)) > 0) {
+ if (val[0] == '\0')
+ r = a->format_options(a, key, NULL);
+ else
+ r = a->format_options(a, key, val);
+ if (r == ARCHIVE_FATAL)
+ return (r);
+ if (r < ARCHIVE_OK) { /* This key was not handled. */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Unsupported option ``%s''", key);
+ ret = ARCHIVE_WARN;
+ }
+ s += len;
+ }
+ if (len < 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Malformed options string.");
+ return (ARCHIVE_WARN);
+ }
+ return (ret);
+}
+
+/*
+ * Set write options for the compressor. Returns 0 if successful.
+ */
+int
+archive_write_set_compressor_options(struct archive *_a, const char *s)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ char key[64], val[64];
+ int len, r;
+ int ret = ARCHIVE_OK;
+
+ __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_set_compressor_options");
+ archive_clear_error(&a->archive);
+
+ if (s == NULL || *s == '\0')
+ return (ARCHIVE_OK);
+ if (a->compressor.options == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Unsupported option ``%s''", s);
+ /* This compressor does not support option. */
+ return (ARCHIVE_WARN);
+ }
+
+ while ((len = __archive_parse_options(s, a->archive.compression_name,
+ sizeof(key), key, sizeof(val), val)) > 0) {
+ if (val[0] == '\0')
+ r = a->compressor.options(a, key, NULL);
+ else
+ r = a->compressor.options(a, key, val);
+ if (r == ARCHIVE_FATAL)
+ return (r);
+ if (r < ARCHIVE_OK) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Unsupported option ``%s''", key);
+ ret = ARCHIVE_WARN;
+ }
+ s += len;
+ }
+ if (len < 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Illegal format options.");
+ return (ARCHIVE_WARN);
+ }
+ return (ret);
+}
+
+/*
+ * Set write options for the format and the compressor. Returns 0 if successful.
+ */
+int
+archive_write_set_options(struct archive *_a, const char *s)
+{
+ int r1, r2;
+
+ r1 = archive_write_set_format_options(_a, s);
+ if (r1 < ARCHIVE_WARN)
+ return (r1);
+ r2 = archive_write_set_compressor_options(_a, s);
+ if (r2 < ARCHIVE_WARN)
+ return (r2);
+ if (r1 == ARCHIVE_WARN && r2 == ARCHIVE_WARN)
+ return (ARCHIVE_WARN);
+ return (ARCHIVE_OK);
+}
+
+/*
* Set the block size. Returns 0 if successful.
*/
int
@@ -203,7 +312,6 @@ archive_write_open(struct archive *_a, void *client_data,
struct archive_write *a = (struct archive_write *)_a;
int ret;
- ret = ARCHIVE_OK;
__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_NEW, "archive_write_open");
archive_clear_error(&a->archive);
@@ -314,7 +422,7 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry)
if (a->skip_file_dev != 0 &&
archive_entry_dev(entry) == a->skip_file_dev &&
a->skip_file_ino != 0 &&
- archive_entry_ino(entry) == a->skip_file_ino) {
+ archive_entry_ino64(entry) == a->skip_file_ino) {
archive_set_error(&a->archive, 0,
"Can't add archive to itself");
return (ARCHIVE_FAILED);
diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.3 b/archivers/libarchive/files/libarchive/archive_write_disk.3
index d68a0ffca3d..5ed4a5038f1 100644
--- a/archivers/libarchive/files/libarchive/archive_write_disk.3
+++ b/archivers/libarchive/files/libarchive/archive_write_disk.3
@@ -22,9 +22,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.3 2008/05/26 17:00:23 kientzle Exp $
+.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.4 2008/09/04 05:22:00 kientzle Exp $
.\"
-.Dd March 2, 2007
+.Dd August 5, 2008
.Dt archive_write_disk 3
.Os
.Sh NAME
@@ -169,11 +169,11 @@ The default is to not refuse such paths.
Note that paths ending in
.Pa ..
always cause an error, regardless of this flag.
-.El
.It Cm ARCHIVE_EXTRACT_SPARSE
Scan data for blocks of NUL bytes and try to recreate them with holes.
This results in sparse files, independent of whether the archive format
supports or uses them.
+.El
.It Xo
.Fn archive_write_disk_set_group_lookup ,
.Fn archive_write_disk_set_user_lookup
diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.c b/archivers/libarchive/files/libarchive/archive_write_disk.c
index 238173c42a2..f61ae175925 100644
--- a/archivers/libarchive/files/libarchive/archive_write_disk.c
+++ b/archivers/libarchive/files/libarchive/archive_write_disk.c
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19:05:29 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 05:35:40Z kientzle $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -33,6 +33,12 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19
#ifdef HAVE_SYS_ACL_H
#include <sys/acl.h>
#endif
+#ifdef HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#endif
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
#ifdef HAVE_ATTR_XATTR_H
#include <attr/xattr.h>
#endif
@@ -48,10 +54,6 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19
#ifdef HAVE_SYS_UTIME_H
#include <sys/utime.h>
#endif
-
-#ifdef HAVE_EXT2FS_EXT2_FS_H
-#include <ext2fs/ext2_fs.h> /* for Linux file flags */
-#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -64,6 +66,16 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19
#ifdef HAVE_LINUX_FS_H
#include <linux/fs.h> /* for Linux file flags */
#endif
+/*
+ * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.
+ * As the include guards don't agree, the order of include is important.
+ */
+#ifdef HAVE_LINUX_EXT2_FS_H
+#include <linux/ext2_fs.h> /* for Linux file flags */
+#endif
+#if defined(HAVE_EXT2FS_EXT2_FS_H) && !defined(__CYGWIN__)
+#include <ext2fs/ext2_fs.h> /* Linux file flags, broken on Cygwin */
+#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
@@ -96,10 +108,12 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19
struct fixup_entry {
struct fixup_entry *next;
mode_t mode;
- int64_t mtime;
int64_t atime;
- unsigned long mtime_nanos;
+ int64_t birthtime;
+ int64_t mtime;
unsigned long atime_nanos;
+ unsigned long birthtime_nanos;
+ unsigned long mtime_nanos;
unsigned long fflags_set;
int fixup; /* bitmask of what needs fixing */
char *name;
@@ -140,6 +154,7 @@ struct archive_write_disk {
uid_t user_uid;
dev_t skip_file_dev;
ino_t skip_file_ino;
+ time_t start_time;
gid_t (*lookup_gid)(void *private, const char *gname, gid_t gid);
void (*cleanup_gid)(void *private);
@@ -175,7 +190,9 @@ struct archive_write_disk {
int fd;
/* Current offset for writing data to the file. */
off_t offset;
- /* Maximum size of file. */
+ /* Last offset actually written to disk. */
+ off_t fd_offset;
+ /* Maximum size of file, -1 if unknown. */
off_t filesize;
/* Dir we were in before this restore; only for deep paths. */
int restore_pwd;
@@ -184,8 +201,6 @@ struct archive_write_disk {
/* UID/GID to use in restoring this entry. */
uid_t uid;
gid_t gid;
- /* Last offset written to disk. */
- off_t last_offset;
};
/*
@@ -226,11 +241,13 @@ static int set_fflags_platform(struct archive_write_disk *, int fd,
unsigned long fflags_set, unsigned long fflags_clear);
static int set_ownership(struct archive_write_disk *);
static int set_mode(struct archive_write_disk *, int mode);
-static int set_time(struct archive_write_disk *);
+static int set_time(int, int, const char *, time_t, long, time_t, long);
+static int set_times(struct archive_write_disk *);
static struct fixup_entry *sort_dir_list(struct fixup_entry *p);
static gid_t trivial_lookup_gid(void *, const char *, gid_t);
static uid_t trivial_lookup_uid(void *, const char *, uid_t);
-
+static ssize_t write_data_block(struct archive_write_disk *,
+ const char *, size_t);
static struct archive_vtable *archive_write_disk_vtable(void);
@@ -273,8 +290,8 @@ archive_write_disk_vtable(void)
static int inited = 0;
if (!inited) {
- av.archive_write_close = _archive_write_close;
- av.archive_write_finish = _archive_write_finish;
+ av.archive_close = _archive_write_close;
+ av.archive_finish = _archive_write_finish;
av.archive_write_header = _archive_write_header;
av.archive_write_finish_entry = _archive_write_finish_entry;
av.archive_write_data = _archive_write_data;
@@ -332,11 +349,14 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry)
}
a->entry = archive_entry_clone(entry);
a->fd = -1;
- a->last_offset = 0;
+ a->fd_offset = 0;
a->offset = 0;
a->uid = a->user_uid;
a->mode = archive_entry_mode(a->entry);
- a->filesize = archive_entry_size(a->entry);
+ if (archive_entry_size_is_set(a->entry))
+ a->filesize = archive_entry_size(a->entry);
+ else
+ a->filesize = -1;
archive_strcpy(&(a->_name_data), archive_entry_pathname(a->entry));
a->name = a->_name_data.s;
archive_clear_error(&a->archive);
@@ -397,12 +417,16 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry)
a->mode &= ~S_ISVTX;
a->mode &= ~a->user_umask;
}
+#if !defined(_WIN32) || defined(__CYGWIN__)
if (a->flags & ARCHIVE_EXTRACT_OWNER)
a->todo |= TODO_OWNER;
+#endif
if (a->flags & ARCHIVE_EXTRACT_TIME)
a->todo |= TODO_TIMES;
if (a->flags & ARCHIVE_EXTRACT_ACL)
a->todo |= TODO_ACLS;
+ if (a->flags & ARCHIVE_EXTRACT_XATTR)
+ a->todo |= TODO_XATTR;
if (a->flags & ARCHIVE_EXTRACT_FFLAGS)
a->todo |= TODO_FFLAGS;
if (a->flags & ARCHIVE_EXTRACT_SECURE_SYMLINKS) {
@@ -417,10 +441,24 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry)
ret = restore_entry(a);
+ /*
+ * TODO: There are rumours that some extended attributes must
+ * be restored before file data is written. If this is true,
+ * then we either need to write all extended attributes both
+ * before and after restoring the data, or find some rule for
+ * determining which must go first and which last. Due to the
+ * many ways people are using xattrs, this may prove to be an
+ * intractable problem.
+ */
+
#ifdef HAVE_FCHDIR
/* If we changed directory above, restore it here. */
if (a->restore_pwd >= 0) {
- fchdir(a->restore_pwd);
+ r = fchdir(a->restore_pwd);
+ if (r != 0) {
+ archive_set_error(&a->archive, errno, "chdir() failure");
+ ret = ARCHIVE_FATAL;
+ }
close(a->restore_pwd);
a->restore_pwd = -1;
}
@@ -438,13 +476,35 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry)
fe->mode = a->mode;
}
- if (a->deferred & TODO_TIMES) {
+ if ((a->deferred & TODO_TIMES)
+ && (archive_entry_mtime_is_set(entry)
+ || archive_entry_atime_is_set(entry))) {
fe = current_fixup(a, archive_entry_pathname(entry));
fe->fixup |= TODO_TIMES;
- fe->mtime = archive_entry_mtime(entry);
- fe->mtime_nanos = archive_entry_mtime_nsec(entry);
- fe->atime = archive_entry_atime(entry);
- fe->atime_nanos = archive_entry_atime_nsec(entry);
+ if (archive_entry_atime_is_set(entry)) {
+ fe->atime = archive_entry_atime(entry);
+ fe->atime_nanos = archive_entry_atime_nsec(entry);
+ } else {
+ /* If atime is unset, use start time. */
+ fe->atime = a->start_time;
+ fe->atime_nanos = 0;
+ }
+ if (archive_entry_mtime_is_set(entry)) {
+ fe->mtime = archive_entry_mtime(entry);
+ fe->mtime_nanos = archive_entry_mtime_nsec(entry);
+ } else {
+ /* If mtime is unset, use start time. */
+ fe->mtime = a->start_time;
+ fe->mtime_nanos = 0;
+ }
+ if (archive_entry_birthtime_is_set(entry)) {
+ fe->birthtime = archive_entry_birthtime(entry);
+ fe->birthtime_nanos = archive_entry_birthtime_nsec(entry);
+ } else {
+ /* If birthtime is unset, use mtime. */
+ fe->birthtime = fe->mtime;
+ fe->birthtime_nanos = fe->mtime_nanos;
+ }
}
if (a->deferred & TODO_FFLAGS) {
@@ -454,7 +514,7 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry)
}
/* We've created the object and are ready to pour data into it. */
- if (ret == ARCHIVE_OK)
+ if (ret >= ARCHIVE_WARN)
a->archive.state = ARCHIVE_STATE_DATA;
/*
* If it's not open, tell our client not to try writing.
@@ -483,87 +543,125 @@ archive_write_disk_set_skip_file(struct archive *_a, dev_t d, ino_t i)
}
static ssize_t
-_archive_write_data_block(struct archive *_a,
- const void *buff, size_t size, off_t offset)
+write_data_block(struct archive_write_disk *a, const char *buff, size_t size)
{
- struct archive_write_disk *a = (struct archive_write_disk *)_a;
+ uint64_t start_size = size;
ssize_t bytes_written = 0;
- ssize_t block_size, bytes_to_write;
- int r = ARCHIVE_OK;
+ ssize_t block_size = 0, bytes_to_write;
- __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
- ARCHIVE_STATE_DATA, "archive_write_disk_block");
- if (a->fd < 0) {
- archive_set_error(&a->archive, 0, "File not open");
+ if (size == 0)
+ return (ARCHIVE_OK);
+
+ if (a->filesize == 0 || a->fd < 0) {
+ archive_set_error(&a->archive, 0,
+ "Attempt to write to an empty file");
return (ARCHIVE_WARN);
}
- archive_clear_error(&a->archive);
if (a->flags & ARCHIVE_EXTRACT_SPARSE) {
+#if HAVE_STRUCT_STAT_ST_BLKSIZE
+ int r;
if ((r = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK)
return (r);
block_size = a->pst->st_blksize;
- } else
- block_size = -1;
-
- if ((off_t)(offset + size) > a->filesize) {
- size = (size_t)(a->filesize - a->offset);
- archive_set_error(&a->archive, 0,
- "Write request too large");
- r = ARCHIVE_WARN;
+#else
+ /* XXX TODO XXX Is there a more appropriate choice here ? */
+ /* This needn't match the filesystem allocation size. */
+ block_size = 16*1024;
+#endif
}
+ /* If this write would run beyond the file size, truncate it. */
+ if (a->filesize >= 0 && (off_t)(a->offset + size) > a->filesize)
+ start_size = size = (size_t)(a->filesize - a->offset);
+
/* Write the data. */
while (size > 0) {
- if (block_size != -1) {
- const char *buf;
+ if (block_size == 0) {
+ bytes_to_write = size;
+ } else {
+ /* We're sparsifying the file. */
+ const char *p, *end;
+ off_t block_end;
- for (buf = buff; size; ++buf, --size, ++offset) {
- if (*buf != '\0')
+ /* Skip leading zero bytes. */
+ for (p = buff, end = buff + size; p < end; ++p) {
+ if (*p != '\0')
break;
}
+ a->offset += p - buff;
+ size -= p - buff;
+ buff = p;
if (size == 0)
break;
- bytes_to_write = block_size - offset % block_size;
- buff = buf;
- } else
+
+ /* Calculate next block boundary after offset. */
+ block_end
+ = (a->offset / block_size + 1) * block_size;
+
+ /* If the adjusted write would cross block boundary,
+ * truncate it to the block boundary. */
bytes_to_write = size;
+ if (a->offset + bytes_to_write > block_end)
+ bytes_to_write = block_end - a->offset;
+ }
/* Seek if necessary to the specified offset. */
- if (offset != a->last_offset) {
- if (lseek(a->fd, offset, SEEK_SET) < 0) {
- archive_set_error(&a->archive, errno, "Seek failed");
+ if (a->offset != a->fd_offset) {
+ if (lseek(a->fd, a->offset, SEEK_SET) < 0) {
+ archive_set_error(&a->archive, errno,
+ "Seek failed");
return (ARCHIVE_FATAL);
}
+ a->fd_offset = a->offset;
+ a->archive.file_position = a->offset;
+ a->archive.raw_position = a->offset;
}
- bytes_written = write(a->fd, buff, size);
+ bytes_written = write(a->fd, buff, bytes_to_write);
if (bytes_written < 0) {
archive_set_error(&a->archive, errno, "Write failed");
return (ARCHIVE_WARN);
}
- buff = (const char *)buff + bytes_written;
+ buff += bytes_written;
size -= bytes_written;
- offset += bytes_written;
- a->last_offset = a->offset = offset;
+ a->offset += bytes_written;
+ a->archive.file_position += bytes_written;
+ a->archive.raw_position += bytes_written;
+ a->fd_offset = a->offset;
}
+ return (start_size - size);
+}
+
+static ssize_t
+_archive_write_data_block(struct archive *_a,
+ const void *buff, size_t size, off_t offset)
+{
+ struct archive_write_disk *a = (struct archive_write_disk *)_a;
+ ssize_t r;
+
+ __archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
+ ARCHIVE_STATE_DATA, "archive_write_disk_block");
+
a->offset = offset;
- return (r);
+ r = write_data_block(a, buff, size);
+ if (r < ARCHIVE_OK)
+ return (r);
+ if ((size_t)r < size) {
+ archive_set_error(&a->archive, 0,
+ "Write request too large");
+ return (ARCHIVE_WARN);
+ }
+ return (ARCHIVE_OK);
}
static ssize_t
_archive_write_data(struct archive *_a, const void *buff, size_t size)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
- int r;
__archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
ARCHIVE_STATE_DATA, "archive_write_data");
- if (a->fd < 0)
- return (ARCHIVE_OK);
- r = _archive_write_data_block(_a, buff, size, a->offset);
- if (r < ARCHIVE_OK)
- return (r);
- return size;
+ return (write_data_block(a, buff, size));
}
static int
@@ -579,24 +677,38 @@ _archive_write_finish_entry(struct archive *_a)
return (ARCHIVE_OK);
archive_clear_error(&a->archive);
- if (a->last_offset != a->filesize && a->fd >= 0) {
+ /* Pad or truncate file to the right size. */
+ if (a->fd < 0) {
+ /* There's no file. */
+ } else if (a->filesize < 0) {
+ /* File size is unknown, so we can't set the size. */
+ } else if (a->fd_offset == a->filesize) {
+ /* Last write ended at exactly the filesize; we're done. */
+ /* Hopefully, this is the common case. */
+ } else {
+#if HAVE_FTRUNCATE
if (ftruncate(a->fd, a->filesize) == -1 &&
a->filesize == 0) {
archive_set_error(&a->archive, errno,
"File size could not be restored");
return (ARCHIVE_FAILED);
}
+#endif
/*
- * Explicitly stat the file as some platforms might not
- * implement the XSI option to extend files via ftruncate.
+ * Not all platforms implement the XSI option to
+ * extend files via ftruncate. Stat() the file again
+ * to see what happened.
*/
a->pst = NULL;
if ((ret = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK)
return (ret);
- if (a->st.st_size != a->filesize) {
+ /* We can use lseek()/write() to extend the file if
+ * ftruncate didn't work or isn't available. */
+ if (a->st.st_size < a->filesize) {
const char nul = '\0';
- if (lseek(a->fd, a->st.st_size - 1, SEEK_SET) < 0) {
- archive_set_error(&a->archive, errno, "Seek failed");
+ if (lseek(a->fd, a->filesize - 1, SEEK_SET) < 0) {
+ archive_set_error(&a->archive, errno,
+ "Seek failed");
return (ARCHIVE_FATAL);
}
if (write(a->fd, &nul, 1) < 0) {
@@ -604,6 +716,7 @@ _archive_write_finish_entry(struct archive *_a)
"Write to restore size failed");
return (ARCHIVE_FATAL);
}
+ a->pst = NULL;
}
}
@@ -636,22 +749,37 @@ _archive_write_finish_entry(struct archive *_a)
int r2 = set_mode(a, a->mode);
if (r2 < ret) ret = r2;
}
- if (a->todo & TODO_TIMES) {
- int r2 = set_time(a);
- if (r2 < ret) ret = r2;
- }
if (a->todo & TODO_ACLS) {
int r2 = set_acls(a);
if (r2 < ret) ret = r2;
}
+
+ /*
+ * Security-related extended attributes (such as
+ * security.capability on Linux) have to be restored last,
+ * since they're implicitly removed by other file changes.
+ */
if (a->todo & TODO_XATTR) {
int r2 = set_xattrs(a);
if (r2 < ret) ret = r2;
}
+
+ /*
+ * Some flags prevent file modification; they must be restored after
+ * file contents are written.
+ */
if (a->todo & TODO_FFLAGS) {
int r2 = set_fflags(a);
if (r2 < ret) ret = r2;
}
+ /*
+ * Time has to be restored after all other metadata;
+ * otherwise atime will get changed.
+ */
+ if (a->todo & TODO_TIMES) {
+ int r2 = set_times(a);
+ if (r2 < ret) ret = r2;
+ }
/* If there's an fd, we can close it now. */
if (a->fd >= 0) {
@@ -718,6 +846,7 @@ archive_write_disk_new(void)
a->archive.vtable = archive_write_disk_vtable();
a->lookup_uid = trivial_lookup_uid;
a->lookup_gid = trivial_lookup_gid;
+ a->start_time = time(NULL);
#ifdef HAVE_GETEUID
a->user_uid = geteuid();
#endif /* HAVE_GETEUID */
@@ -768,7 +897,7 @@ edit_deep_directories(struct archive_write_disk *a)
*tail = '\0'; /* Terminate dir portion */
ret = create_dir(a, a->name);
if (ret == ARCHIVE_OK && chdir(a->name) != 0)
- ret = ARCHIVE_WARN;
+ ret = ARCHIVE_FAILED;
*tail = '/'; /* Restore the / we removed. */
if (ret != ARCHIVE_OK)
return;
@@ -809,7 +938,7 @@ restore_entry(struct archive_write_disk *a)
/* We tried, but couldn't get rid of it. */
archive_set_error(&a->archive, errno,
"Could not unlink");
- return(ARCHIVE_WARN);
+ return(ARCHIVE_FAILED);
}
}
@@ -828,7 +957,7 @@ restore_entry(struct archive_write_disk *a)
&& (a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {
/* If we're not overwriting, we're done. */
archive_set_error(&a->archive, en, "Already exists");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
/*
@@ -843,7 +972,7 @@ restore_entry(struct archive_write_disk *a)
if (rmdir(a->name) != 0) {
archive_set_error(&a->archive, errno,
"Can't remove already-existing dir");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
a->pst = NULL;
/* Try again. */
@@ -853,15 +982,31 @@ restore_entry(struct archive_write_disk *a)
* We know something is in the way, but we don't know what;
* we need to find out before we go any further.
*/
- if (lstat(a->name, &a->st) != 0) {
+ int r = 0;
+ /*
+ * The SECURE_SYMLINK logic has already removed a
+ * symlink to a dir if the client wants that. So
+ * follow the symlink if we're creating a dir.
+ */
+ if (S_ISDIR(a->mode))
+ r = stat(a->name, &a->st);
+ /*
+ * If it's not a dir (or it's a broken symlink),
+ * then don't follow it.
+ */
+ if (r != 0 || !S_ISDIR(a->mode))
+ r = lstat(a->name, &a->st);
+ if (r != 0) {
archive_set_error(&a->archive, errno,
"Can't stat existing object");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
- /* TODO: if it's a symlink... */
-
- if (a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER) {
+ /*
+ * NO_OVERWRITE_NEWER doesn't apply to directories.
+ */
+ if ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE_NEWER)
+ && !S_ISDIR(a->st.st_mode)) {
if (!older(&(a->st), a->entry)) {
archive_set_error(&a->archive, 0,
"File on disk is not older; skipping.");
@@ -883,7 +1028,7 @@ restore_entry(struct archive_write_disk *a)
if (unlink(a->name) != 0) {
archive_set_error(&a->archive, errno,
"Can't unlink already-existing object");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
a->pst = NULL;
/* Try again. */
@@ -893,7 +1038,7 @@ restore_entry(struct archive_write_disk *a)
if (rmdir(a->name) != 0) {
archive_set_error(&a->archive, errno,
"Can't remove already-existing dir");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
/* Try again. */
en = create_filesystem_object(a);
@@ -915,8 +1060,9 @@ restore_entry(struct archive_write_disk *a)
if (en) {
/* Everything failed; give up here. */
- archive_set_error(&a->archive, en, "Can't create '%s'", a->name);
- return (ARCHIVE_WARN);
+ archive_set_error(&a->archive, en, "Can't create '%s'",
+ a->name);
+ return (ARCHIVE_FAILED);
}
a->pst = NULL; /* Cached stat data no longer valid. */
@@ -928,7 +1074,7 @@ restore_entry(struct archive_write_disk *a)
* the failed system call. Note: This function should only ever perform
* a single system call.
*/
-int
+static int
create_filesystem_object(struct archive_write_disk *a)
{
/* Create the entry. */
@@ -940,6 +1086,9 @@ create_filesystem_object(struct archive_write_disk *a)
/* Since link(2) and symlink(2) don't handle modes, we're done here. */
linkname = archive_entry_hardlink(a->entry);
if (linkname != NULL) {
+#if !HAVE_LINK
+ return (EPERM);
+#else
r = link(linkname, a->name) ? errno : 0;
/*
* New cpio and pax formats allow hardlink entries
@@ -953,7 +1102,7 @@ create_filesystem_object(struct archive_write_disk *a)
* If the hardlink does carry data, let the last
* archive entry decide ownership.
*/
- if (r == 0 && a->filesize == 0) {
+ if (r == 0 && a->filesize <= 0) {
a->todo = 0;
a->deferred = 0;
} if (r == 0 && a->filesize > 0) {
@@ -962,10 +1111,16 @@ create_filesystem_object(struct archive_write_disk *a)
r = errno;
}
return (r);
+#endif
}
linkname = archive_entry_symlink(a->entry);
- if (linkname != NULL)
+ if (linkname != NULL) {
+#if HAVE_SYMLINK
return symlink(linkname, a->name) ? errno : 0;
+#else
+ return (EPERM);
+#endif
+ }
/*
* The remaining system calls all set permissions, so let's
@@ -997,22 +1152,22 @@ create_filesystem_object(struct archive_write_disk *a)
* S_IFCHR for the mknod() call. This is correct. */
r = mknod(a->name, mode | S_IFCHR,
archive_entry_rdev(a->entry));
+ break;
#else
/* TODO: Find a better way to warn about our inability
* to restore a char device node. */
return (EINVAL);
#endif /* HAVE_MKNOD */
- break;
case AE_IFBLK:
#ifdef HAVE_MKNOD
r = mknod(a->name, mode | S_IFBLK,
archive_entry_rdev(a->entry));
+ break;
#else
/* TODO: Find a better way to warn about our inability
* to restore a block device node. */
return (EINVAL);
#endif /* HAVE_MKNOD */
- break;
case AE_IFDIR:
mode = (mode | MINIMUM_DIR_MODE) & MAXIMUM_DIR_MODE;
r = mkdir(a->name, mode);
@@ -1032,12 +1187,12 @@ create_filesystem_object(struct archive_write_disk *a)
case AE_IFIFO:
#ifdef HAVE_MKFIFO
r = mkfifo(a->name, mode);
+ break;
#else
/* TODO: Find a better way to warn about our inability
* to restore a fifo. */
return (EINVAL);
#endif /* HAVE_MKFIFO */
- break;
}
/* All the system calls above set errno on failure. */
@@ -1091,11 +1246,24 @@ _archive_write_close(struct archive *_a)
if (p->fixup & TODO_TIMES) {
#ifdef HAVE_UTIMES
/* {f,l,}utimes() are preferred, when available. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ struct __timeval times[2];
+#else
struct timeval times[2];
- times[1].tv_sec = p->mtime;
- times[1].tv_usec = p->mtime_nanos / 1000;
+#endif
times[0].tv_sec = p->atime;
times[0].tv_usec = p->atime_nanos / 1000;
+#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
+ /* if it's valid and not mtime, push the birthtime first */
+ if (((times[1].tv_sec = p->birthtime) < p->mtime) &&
+ (p->birthtime > 0))
+ {
+ times[1].tv_usec = p->birthtime_nanos / 1000;
+ utimes(p->name, times);
+ }
+#endif
+ times[1].tv_sec = p->mtime;
+ times[1].tv_usec = p->mtime_nanos / 1000;
#ifdef HAVE_LUTIMES
lutimes(p->name, times);
#else
@@ -1136,6 +1304,8 @@ _archive_write_finish(struct archive *_a)
(a->cleanup_gid)(a->lookup_gid_data);
if (a->cleanup_uid != NULL && a->lookup_uid_data != NULL)
(a->cleanup_uid)(a->lookup_uid_data);
+ if (a->entry)
+ archive_entry_free(a->entry);
archive_string_free(&a->_name_data);
archive_string_free(&a->archive.error_string);
archive_string_free(&a->path_safe);
@@ -1250,9 +1420,15 @@ current_fixup(struct archive_write_disk *a, const char *pathname)
* 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. */
static int
check_symlinks(struct archive_write_disk *a)
{
+#if !defined(HAVE_LSTAT)
+ /* Platform doesn't have lstat, so we can't look for symlinks. */
+ (void)a; /* UNUSED */
+ return (ARCHIVE_OK);
+#else
char *pn, *p;
char c;
int r;
@@ -1293,7 +1469,7 @@ check_symlinks(struct archive_write_disk *a)
"Could not remove symlink %s",
a->name);
pn[0] = c;
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
a->pst = NULL;
/*
@@ -1317,7 +1493,7 @@ check_symlinks(struct archive_write_disk *a)
"Cannot remove intervening symlink %s",
a->name);
pn[0] = c;
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
a->pst = NULL;
} else {
@@ -1325,7 +1501,7 @@ check_symlinks(struct archive_write_disk *a)
"Cannot extract through symlink %s",
a->name);
pn[0] = c;
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
}
}
@@ -1333,7 +1509,59 @@ check_symlinks(struct archive_write_disk *a)
/* We've checked and/or cleaned the whole path, so remember it. */
archive_strcpy(&a->path_safe, a->name);
return (ARCHIVE_OK);
+#endif
+}
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+/*
+ * 1. Convert a path separator from '\' to '/' .
+ * We shouldn't check multi-byte character directly because some
+ * character-set have been using the '\' character for a part of
+ * its multibyte character code.
+ * 2. Replace unusable characters in Windows with underscore('_').
+ * See also : http://msdn.microsoft.com/en-us/library/aa365247.aspx
+ */
+static void
+cleanup_pathname_win(struct archive_write_disk *a)
+{
+ wchar_t wc;
+ char *p;
+ size_t alen, l;
+
+ alen = 0;
+ l = 0;
+ for (p = a->name; *p != '\0'; p++) {
+ ++alen;
+ if (*p == '\\')
+ l = 1;
+ /* Rewrite the path name if its character is a unusable. */
+ if (*p == ':' || *p == '*' || *p == '?' || *p == '"' ||
+ *p == '<' || *p == '>' || *p == '|')
+ *p = '_';
+ }
+ if (alen == 0 || l == 0)
+ return;
+ /*
+ * Convert path separator.
+ */
+ p = a->name;
+ while (*p != '\0' && alen) {
+ l = mbtowc(&wc, p, alen);
+ if (l == -1) {
+ while (*p != '\0') {
+ if (*p == '\\')
+ *p = '/';
+ ++p;
+ }
+ break;
+ }
+ if (l == 1 && wc == L'\\')
+ *p = '/';
+ p += l;
+ alen -= l;
+ }
}
+#endif
/*
* Canonicalize the pathname. In particular, this strips duplicate
@@ -1346,7 +1574,6 @@ cleanup_pathname(struct archive_write_disk *a)
{
char *dest, *src;
char separator = '\0';
- int lastdotdot = 0; /* True if last elt copied was '..' */
dest = src = a->name;
if (*src == '\0') {
@@ -1355,6 +1582,9 @@ cleanup_pathname(struct archive_write_disk *a)
return (ARCHIVE_FAILED);
}
+#if defined(_WIN32) || defined(__CYGWIN__)
+ cleanup_pathname_win(a);
+#endif
/* Skip leading '/'. */
if (*src == '/')
separator = *src++;
@@ -1385,9 +1615,7 @@ cleanup_pathname(struct archive_write_disk *a)
"Path contains '..'");
return (ARCHIVE_FAILED);
}
- lastdotdot = 1;
- } else
- lastdotdot = 0;
+ }
/*
* Note: Under no circumstances do we
* remove '..' elements. In
@@ -1395,10 +1623,8 @@ cleanup_pathname(struct archive_write_disk *a)
* '/foo/../bar/' should create the
* 'foo' dir as a side-effect.
*/
- } else
- lastdotdot = 0;
- } else
- lastdotdot = 0;
+ }
+ }
/* Copy current element, including leading '/'. */
if (separator)
@@ -1417,13 +1643,6 @@ cleanup_pathname(struct archive_write_disk *a)
* We've just copied zero or more path elements, not including the
* final '/'.
*/
- if (lastdotdot) {
- /* Trailing '..' is always wrong. */
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_MISC,
- "Path contains trailing '..'");
- return (ARCHIVE_FAILED);
- }
if (dest == a->name) {
/*
* Nothing got copied. The path must have been something
@@ -1463,7 +1682,7 @@ create_parent_dir(struct archive_write_disk *a, char *path)
* Create the specified dir, recursing to create parents as necessary.
*
* Returns ARCHIVE_OK if the path exists when we're done here.
- * Otherwise, returns ARCHIVE_WARN.
+ * Otherwise, returns ARCHIVE_FAILED.
* Assumes path is in mutable storage; path is unchanged on exit.
*/
static int
@@ -1475,8 +1694,6 @@ create_dir(struct archive_write_disk *a, char *path)
mode_t mode_final, mode;
int r;
- r = ARCHIVE_OK;
-
/* Check for special names and just skip them. */
slash = strrchr(path, '/');
if (slash == NULL)
@@ -1508,18 +1725,18 @@ create_dir(struct archive_write_disk *a, char *path)
if ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {
archive_set_error(&a->archive, EEXIST,
"Can't create directory '%s'", path);
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
if (unlink(path) != 0) {
archive_set_error(&a->archive, errno,
"Can't create directory '%s': "
"Conflicting file cannot be removed");
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
}
} else if (errno != ENOENT && errno != ENOTDIR) {
/* Stat failed? */
archive_set_error(&a->archive, errno, "Can't test directory '%s'", path);
- return (ARCHIVE_WARN);
+ return (ARCHIVE_FAILED);
} else if (slash != NULL) {
*slash = '\0';
r = create_dir(a, path);
@@ -1559,8 +1776,9 @@ create_dir(struct archive_write_disk *a, char *path)
if (stat(path, &st) == 0 && S_ISDIR(st.st_mode))
return (ARCHIVE_OK);
- archive_set_error(&a->archive, errno, "Failed to create dir '%s'", path);
- return (ARCHIVE_WARN);
+ archive_set_error(&a->archive, errno, "Failed to create dir '%s'",
+ path);
+ return (ARCHIVE_FAILED);
}
/*
@@ -1576,12 +1794,17 @@ create_dir(struct archive_write_disk *a, char *path)
static int
set_ownership(struct archive_write_disk *a)
{
+#ifndef __CYGWIN__
+/* unfortunately, on win32 there is no 'root' user with uid 0,
+ so we just have to try the chown and see if it works */
+
/* If we know we can't change it, don't bother trying. */
if (a->user_uid != 0 && a->user_uid != a->uid) {
archive_set_error(&a->archive, errno,
"Can't set UID=%d", a->uid);
return (ARCHIVE_WARN);
}
+#endif
#ifdef HAVE_FCHOWN
/* If we have an fd, we can avoid a race. */
@@ -1614,48 +1837,62 @@ set_ownership(struct archive_write_disk *a)
return (ARCHIVE_WARN);
}
-#ifdef HAVE_UTIMES
+
+#if defined(HAVE_UTIMENSAT) && defined(HAVE_FUTIMENS)
+/*
+ * utimensat() and futimens() are defined in POSIX.1-2008. They provide ns
+ * resolution and setting times on fd and on symlinks, too.
+ */
+static int
+set_time(int fd, int mode, const char *name,
+ time_t atime, long atime_nsec,
+ time_t mtime, long mtime_nsec)
+{
+ struct timespec ts[2];
+ ts[0].tv_sec = atime;
+ ts[0].tv_nsec = atime_nsec;
+ ts[1].tv_sec = mtime;
+ ts[1].tv_nsec = mtime_nsec;
+ if (fd >= 0)
+ return futimens(fd, ts);
+ return utimensat(AT_FDCWD, name, ts, AT_SYMLINK_NOFOLLOW);
+}
+#elif HAVE_UTIMES
/*
- * The utimes()-family functions provide high resolution and
+ * The utimes()-family functions provide µs-resolution and
* a way to set time on an fd or a symlink. We prefer them
- * when they're available.
+ * when they're available and utimensat/futimens aren't there.
*/
static int
-set_time(struct archive_write_disk *a)
+set_time(int fd, int mode, const char *name,
+ time_t atime, long atime_nsec,
+ time_t mtime, long mtime_nsec)
{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ struct __timeval times[2];
+#else
struct timeval times[2];
+#endif
- times[1].tv_sec = archive_entry_mtime(a->entry);
- times[1].tv_usec = archive_entry_mtime_nsec(a->entry) / 1000;
-
- times[0].tv_sec = archive_entry_atime(a->entry);
- times[0].tv_usec = archive_entry_atime_nsec(a->entry) / 1000;
+ times[0].tv_sec = atime;
+ times[0].tv_usec = atime_nsec / 1000;
+ times[1].tv_sec = mtime;
+ times[1].tv_usec = mtime_nsec / 1000;
#ifdef HAVE_FUTIMES
- if (a->fd >= 0 && futimes(a->fd, times) == 0) {
- return (ARCHIVE_OK);
- }
+ if (fd >= 0)
+ return (futimes(fd, times));
+#else
+ (void)fd; /* UNUSED */
#endif
-
#ifdef HAVE_LUTIMES
- if (lutimes(a->name, times) != 0)
+ (void)mode; /* UNUSED */
+ return (lutimes(name, times));
#else
- if (!S_ISLNK(a->mode) && utimes(a->name, times) != 0)
+ if (S_ISLNK(mode))
+ return (0);
+ return (utimes(name, times));
#endif
- {
- archive_set_error(&a->archive, errno, "Can't update time for %s",
- a->name);
- return (ARCHIVE_WARN);
- }
-
- /*
- * Note: POSIX does not provide a portable way to restore ctime.
- * (Apart from resetting the system clock, which is distasteful.)
- * So, any restoration of ctime will necessarily be OS-specific.
- */
-
- /* XXX TODO: Can FreeBSD restore ctime? XXX */
- return (ARCHIVE_OK);
}
#elif defined(HAVE_UTIME)
/*
@@ -1663,31 +1900,93 @@ set_time(struct archive_write_disk *a)
* if utimes() isn't available.
*/
static int
-set_time(struct archive_write_disk *a)
+set_time(int fd, int mode, const char *name,
+ time_t atime, long atime_nsec,
+ time_t mtime, long mtime_nsec)
{
struct utimbuf times;
-
- times.modtime = archive_entry_mtime(a->entry);
- times.actime = archive_entry_atime(a->entry);
- if (!S_ISLNK(a->mode) && utime(a->name, &times) != 0) {
- archive_set_error(&a->archive, errno,
- "Can't update time for %s", a->name);
- return (ARCHIVE_WARN);
- }
- return (ARCHIVE_OK);
+ (void)fd; /* UNUSED */
+ (void)name; /* UNUSED */
+ (void)atime_nsec; /* UNUSED */
+ (void)mtime_nsec; /* UNUSED */
+ times.actime = atime;
+ times.modtime = mtime;
+ if (S_ISLNK(mode))
+ return (ARCHIVE_OK);
+ return (utime(name, &times));
}
#else
-/* This platform doesn't give us a way to restore the time. */
static int
-set_time(struct archive_write_disk *a)
+set_time(int fd, int mode, const char *name,
+ time_t atime, long atime_nsec,
+ time_t mtime, long mtime_nsec)
{
- (void)a; /* UNUSED */
- archive_set_error(&a->archive, errno,
- "Can't update time for %s", a->name);
return (ARCHIVE_WARN);
}
#endif
+static int
+set_times(struct archive_write_disk *a)
+{
+ time_t atime = a->start_time, mtime = a->start_time;
+ long atime_nsec = 0, mtime_nsec = 0;
+
+ /* If no time was provided, we're done. */
+ if (!archive_entry_atime_is_set(a->entry)
+#if HAVE_STRUCT_STAT_ST_BIRTHTIME
+ && !archive_entry_birthtime_is_set(a->entry)
+#endif
+ && !archive_entry_mtime_is_set(a->entry))
+ return (ARCHIVE_OK);
+
+ /* If no atime was specified, use start time instead. */
+ /* In theory, it would be marginally more correct to use
+ * time(NULL) here, but that would cost us an extra syscall
+ * for little gain. */
+ if (archive_entry_atime_is_set(a->entry)) {
+ atime = archive_entry_atime(a->entry);
+ atime_nsec = archive_entry_atime_nsec(a->entry);
+ }
+
+ /*
+ * If you have struct stat.st_birthtime, we assume BSD birthtime
+ * semantics, in which {f,l,}utimes() updates birthtime to earliest
+ * mtime. So we set the time twice, first using the birthtime,
+ * then using the mtime.
+ */
+#if HAVE_STRUCT_STAT_ST_BIRTHTIME
+ /* If birthtime is set, flush that through to disk first. */
+ if (archive_entry_birthtime_is_set(a->entry))
+ if (set_time(a->fd, a->mode, a->name, atime, atime_nsec,
+ archive_entry_birthtime(a->entry),
+ archive_entry_birthtime_nsec(a->entry))) {
+ archive_set_error(&a->archive, errno,
+ "Can't update time for %s",
+ a->name);
+ return (ARCHIVE_WARN);
+ }
+#endif
+
+ if (archive_entry_mtime_is_set(a->entry)) {
+ mtime = archive_entry_mtime(a->entry);
+ mtime_nsec = archive_entry_mtime_nsec(a->entry);
+ }
+ if (set_time(a->fd, a->mode, a->name,
+ atime, atime_nsec, mtime, mtime_nsec)) {
+ archive_set_error(&a->archive, errno,
+ "Can't update time for %s",
+ a->name);
+ return (ARCHIVE_WARN);
+ }
+
+ /*
+ * Note: POSIX does not provide a portable way to restore ctime.
+ * (Apart from resetting the system clock, which is distasteful.)
+ * So, any restoration of ctime will necessarily be OS-specific.
+ */
+
+ return (ARCHIVE_OK);
+}
static int
set_mode(struct archive_write_disk *a, int mode)
@@ -1706,6 +2005,7 @@ set_mode(struct archive_write_disk *a, int mode)
return (r);
if (a->pst->st_gid != a->gid) {
mode &= ~ S_ISGID;
+#if !defined(_WIN32) || defined(__CYGWIN__)
if (a->flags & ARCHIVE_EXTRACT_OWNER) {
/*
* This is only an error if you
@@ -1718,16 +2018,19 @@ set_mode(struct archive_write_disk *a, int mode)
"Can't restore SGID bit");
r = ARCHIVE_WARN;
}
+#endif
}
/* While we're here, double-check the UID. */
if (a->pst->st_uid != a->uid
&& (a->todo & TODO_SUID)) {
mode &= ~ S_ISUID;
+#if !defined(_WIN32) || defined(__CYGWIN__)
if (a->flags & ARCHIVE_EXTRACT_OWNER) {
archive_set_error(&a->archive, -1,
"Can't restore SUID bit");
r = ARCHIVE_WARN;
}
+#endif
}
a->todo &= ~TODO_SGID_CHECK;
a->todo &= ~TODO_SUID_CHECK;
@@ -1739,11 +2042,13 @@ set_mode(struct archive_write_disk *a, int mode)
*/
if (a->user_uid != a->uid) {
mode &= ~ S_ISUID;
+#if !defined(_WIN32) || defined(__CYGWIN__)
if (a->flags & ARCHIVE_EXTRACT_OWNER) {
archive_set_error(&a->archive, -1,
"Can't make file SUID");
r = ARCHIVE_WARN;
}
+#endif
}
a->todo &= ~TODO_SUID_CHECK;
}
@@ -1861,7 +2166,10 @@ set_fflags(struct archive_write_disk *a)
}
-#if ( defined(HAVE_LCHFLAGS) || defined(HAVE_CHFLAGS) || defined(HAVE_FCHFLAGS) ) && !defined(__linux)
+#if ( defined(HAVE_LCHFLAGS) || defined(HAVE_CHFLAGS) || defined(HAVE_FCHFLAGS) ) && defined(HAVE_STRUCT_STAT_ST_FLAGS)
+/*
+ * BSD reads flags using stat() and sets them with one of {f,l,}chflags()
+ */
static int
set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,
mode_t mode, unsigned long set, unsigned long clear)
@@ -1910,11 +2218,9 @@ set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,
return (ARCHIVE_WARN);
}
-#elif defined(__linux) && defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS)
-
+#elif defined(EXT2_IOC_GETFLAGS) && defined(EXT2_IOC_SETFLAGS)
/*
- * Linux has flags too, but uses ioctl() to access them instead of
- * having a separate chflags() system call.
+ * Linux uses ioctl() to read and write file flags.
*/
static int
set_fflags_platform(struct archive_write_disk *a, int fd, const char *name,
@@ -1982,7 +2288,7 @@ cleanup:
return (ret);
}
-#else /* Not HAVE_CHFLAGS && Not __linux */
+#else
/*
* Of course, some systems have neither BSD chflags() nor Linux' flags
@@ -2171,6 +2477,71 @@ set_xattrs(struct archive_write_disk *a)
}
return (ret);
}
+#elif HAVE_EXTATTR_SET_FILE
+/*
+ * Restore extended attributes - FreeBSD implementation
+ */
+static int
+set_xattrs(struct archive_write_disk *a)
+{
+ struct archive_entry *entry = a->entry;
+ static int warning_done = 0;
+ int ret = ARCHIVE_OK;
+ int i = archive_entry_xattr_reset(entry);
+
+ while (i--) {
+ const char *name;
+ const void *value;
+ size_t size;
+ archive_entry_xattr_next(entry, &name, &value, &size);
+ if (name != NULL) {
+ int e;
+ int namespace;
+
+ if (strncmp(name, "user.", 5) == 0) {
+ /* "user." attributes go to user namespace */
+ name += 5;
+ namespace = EXTATTR_NAMESPACE_USER;
+ } else {
+ /* Warn about other extended attributes. */
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Can't restore extended attribute ``%s''",
+ name);
+ ret = ARCHIVE_WARN;
+ continue;
+ }
+ errno = 0;
+#if HAVE_EXTATTR_SET_FD
+ if (a->fd >= 0)
+ e = extattr_set_fd(a->fd, namespace, name, value, size);
+ else
+#endif
+ /* TODO: should we use extattr_set_link() instead? */
+ {
+ e = extattr_set_file(archive_entry_pathname(entry),
+ namespace, name, value, size);
+ }
+ if (e != (int)size) {
+ if (errno == ENOTSUP) {
+ if (!warning_done) {
+ warning_done = 1;
+ archive_set_error(&a->archive, errno,
+ "Cannot restore extended "
+ "attributes on this file "
+ "system");
+ }
+ } else {
+ archive_set_error(&a->archive, errno,
+ "Failed to set extended attribute");
+ }
+
+ ret = ARCHIVE_WARN;
+ }
+ }
+ }
+ return (ret);
+}
#else
/*
* Restore extended attributes - stub implementation for unsupported systems
@@ -2233,19 +2604,25 @@ older(struct stat *st, struct archive_entry *entry)
/* Definitely older. */
if (st->st_mtimespec.tv_nsec < archive_entry_mtime_nsec(entry))
return (1);
- /* Definitely younger. */
- if (st->st_mtimespec.tv_nsec > archive_entry_mtime_nsec(entry))
- return (0);
#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
/* Definitely older. */
if (st->st_mtim.tv_nsec < archive_entry_mtime_nsec(entry))
return (1);
- /* Definitely older. */
- if (st->st_mtim.tv_nsec > archive_entry_mtime_nsec(entry))
- return (0);
+#elif HAVE_STRUCT_STAT_ST_MTIME_N
+ /* older. */
+ if (st->st_mtime_n < archive_entry_mtime_nsec(entry))
+ return (1);
+#elif HAVE_STRUCT_STAT_ST_UMTIME
+ /* older. */
+ if (st->st_umtime * 1000 < archive_entry_mtime_nsec(entry))
+ return (1);
+#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
+ /* older. */
+ if (st->st_mtime_usec * 1000 < archive_entry_mtime_nsec(entry))
+ return (1);
#else
/* This system doesn't have high-res timestamps. */
#endif
- /* Same age, so not older. */
+ /* Same age or newer, so not older. */
return (0);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_disk_private.h b/archivers/libarchive/files/libarchive/archive_write_disk_private.h
index 1e8ad6922ef..707c0cf03b2 100644
--- a/archivers/libarchive/files/libarchive/archive_write_disk_private.h
+++ b/archivers/libarchive/files/libarchive/archive_write_disk_private.h
@@ -23,9 +23,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_write_disk_private.h,v 1.1 2007/03/03 07:37:36 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_write_disk_private.h 201086 2009-12-28 02:17:53Z kientzle $
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
#ifndef ARCHIVE_WRITE_DISK_PRIVATE_H_INCLUDED
#define ARCHIVE_WRITE_DISK_PRIVATE_H_INCLUDED
diff --git a/archivers/libarchive/files/libarchive/archive_write_disk_set_standard_lookup.c b/archivers/libarchive/files/libarchive/archive_write_disk_set_standard_lookup.c
index 427b87615a0..cfa06e84547 100644
--- a/archivers/libarchive/files/libarchive/archive_write_disk_set_standard_lookup.c
+++ b/archivers/libarchive/files/libarchive/archive_write_disk_set_standard_lookup.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk_set_standard_lookup.c,v 1.4 2007/05/29 01:00:19 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk_set_standard_lookup.c 201083 2009-12-28 02:09:57Z kientzle $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -118,12 +118,35 @@ lookup_gid(void *private_data, const char *gname, gid_t gid)
b->hash = h;
#if HAVE_GRP_H
{
- struct group *grent = getgrnam(gname);
- if (grent != NULL)
- gid = grent->gr_gid;
+ char _buffer[128];
+ size_t bufsize = 128;
+ char *buffer = _buffer;
+ struct group grent, *result;
+ int r;
+
+ for (;;) {
+ result = &grent; /* Old getgrnam_r ignores last arg. */
+ r = getgrnam_r(gname, &grent, buffer, bufsize, &result);
+ if (r == 0)
+ break;
+ if (r != ERANGE)
+ break;
+ bufsize *= 2;
+ if (buffer != _buffer)
+ free(buffer);
+ buffer = malloc(bufsize);
+ if (buffer == NULL)
+ break;
+ }
+ if (result != NULL)
+ gid = result->gr_gid;
+ if (buffer != _buffer)
+ free(buffer);
}
-#elif _WIN32
+#elif defined(_WIN32) && !defined(__CYGWIN__)
/* TODO: do a gname->gid lookup for Windows. */
+#else
+ #error No way to perform gid lookups on this platform
#endif
b->id = gid;
@@ -155,12 +178,35 @@ lookup_uid(void *private_data, const char *uname, uid_t uid)
b->hash = h;
#if HAVE_PWD_H
{
- struct passwd *pwent = getpwnam(uname);
- if (pwent != NULL)
- uid = pwent->pw_uid;
+ char _buffer[128];
+ size_t bufsize = 128;
+ char *buffer = _buffer;
+ struct passwd pwent, *result;
+ int r;
+
+ for (;;) {
+ result = &pwent; /* Old getpwnam_r ignores last arg. */
+ r = getpwnam_r(uname, &pwent, buffer, bufsize, &result);
+ if (r == 0)
+ break;
+ if (r != ERANGE)
+ break;
+ bufsize *= 2;
+ if (buffer != _buffer)
+ free(buffer);
+ buffer = malloc(bufsize);
+ if (buffer == NULL)
+ break;
+ }
+ if (result != NULL)
+ uid = result->pw_uid;
+ if (buffer != _buffer)
+ free(buffer);
}
-#elif _WIN32
+#elif defined(_WIN32) && !defined(__CYGWIN__)
/* TODO: do a uname->uid lookup for Windows. */
+#else
+ #error No way to look up uids on this platform
#endif
b->id = uid;
@@ -186,8 +232,8 @@ hash(const char *p)
as used by ELF for hashing function names. */
unsigned g, h = 0;
while (*p != '\0') {
- h = ( h << 4 ) + *p++;
- if (( g = h & 0xF0000000 )) {
+ h = (h << 4) + *p++;
+ if ((g = h & 0xF0000000) != 0) {
h ^= g >> 24;
h &= 0x0FFFFFFF;
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_open_fd.c b/archivers/libarchive/files/libarchive/archive_write_open_fd.c
index 35e258c4cc2..3a60398710b 100644
--- a/archivers/libarchive/files/libarchive/archive_write_open_fd.c
+++ b/archivers/libarchive/files/libarchive/archive_write_open_fd.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_open_fd.c,v 1.9 2007/01/09 08:05:56 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_open_fd.c 201093 2009-12-28 02:28:44Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -32,6 +32,12 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_open_fd.c,v 1.9 2007/01/09
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
@@ -64,6 +70,9 @@ archive_write_open_fd(struct archive *a, int fd)
return (ARCHIVE_FATAL);
}
mine->fd = fd;
+#if defined(__CYGWIN__) || defined(_WIN32)
+ setmode(mine->fd, O_BINARY);
+#endif
return (archive_write_open(a, mine,
file_open, file_write, file_close));
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_open_filename.c b/archivers/libarchive/files/libarchive/archive_write_open_filename.c
index 72eeb54053d..6a9c77816fd 100644
--- a/archivers/libarchive/files/libarchive/archive_write_open_filename.c
+++ b/archivers/libarchive/files/libarchive/archive_write_open_filename.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_open_filename.c,v 1.20 2008/02/19 05:46:58 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_open_filename.c 191165 2009-04-17 00:39:35Z kientzle $");
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
@@ -71,24 +71,18 @@ archive_write_open_filename(struct archive *a, const char *filename)
{
struct write_file_data *mine;
- if (filename == NULL || filename[0] == '\0') {
- mine = (struct write_file_data *)malloc(sizeof(*mine));
- if (mine == NULL) {
- archive_set_error(a, ENOMEM, "No memory");
- return (ARCHIVE_FATAL);
- }
- mine->filename[0] = '\0'; /* Record that we're using stdout. */
- } else {
- mine = (struct write_file_data *)malloc(sizeof(*mine) + strlen(filename));
- if (mine == NULL) {
- archive_set_error(a, ENOMEM, "No memory");
- return (ARCHIVE_FATAL);
- }
- strcpy(mine->filename, filename);
+ if (filename == NULL || filename[0] == '\0')
+ return (archive_write_open_fd(a, 1));
+
+ mine = (struct write_file_data *)malloc(sizeof(*mine) + strlen(filename));
+ if (mine == NULL) {
+ archive_set_error(a, ENOMEM, "No memory");
+ return (ARCHIVE_FATAL);
}
+ strcpy(mine->filename, filename);
mine->fd = -1;
return (archive_write_open(a, mine,
- file_open, file_write, file_close));
+ file_open, file_write, file_close));
}
static int
@@ -104,21 +98,11 @@ file_open(struct archive *a, void *client_data)
/*
* Open the file.
*/
- if (mine->filename[0] != '\0') {
- mine->fd = open(mine->filename, flags, 0666);
- if (mine->fd < 0) {
- archive_set_error(a, errno, "Failed to open '%s'",
- mine->filename);
- return (ARCHIVE_FATAL);
- }
- } else {
- /*
- * NULL filename is stdout.
- */
- mine->fd = 1;
- /* By default, pad archive when writing to stdout. */
- if (archive_write_get_bytes_in_last_block(a) < 0)
- archive_write_set_bytes_in_last_block(a, 0);
+ mine->fd = open(mine->filename, flags, 0666);
+ if (mine->fd < 0) {
+ archive_set_error(a, errno, "Failed to open '%s'",
+ mine->filename);
+ return (ARCHIVE_FATAL);
}
if (fstat(mine->fd, &st) != 0) {
@@ -172,8 +156,7 @@ file_close(struct archive *a, void *client_data)
struct write_file_data *mine = (struct write_file_data *)client_data;
(void)a; /* UNUSED */
- if (mine->filename[0] != '\0')
- close(mine->fd);
+ close(mine->fd);
free(mine);
return (ARCHIVE_OK);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_private.h b/archivers/libarchive/files/libarchive/archive_write_private.h
index 55c24ad96ca..f9b656555b3 100644
--- a/archivers/libarchive/files/libarchive/archive_write_private.h
+++ b/archivers/libarchive/files/libarchive/archive_write_private.h
@@ -22,9 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/archive_write_private.h,v 1.3 2008/03/15 11:04:45 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/archive_write_private.h 201155 2009-12-29 05:20:12Z kientzle $
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
#ifndef ARCHIVE_WRITE_PRIVATE_H_INCLUDED
#define ARCHIVE_WRITE_PRIVATE_H_INCLUDED
@@ -37,7 +41,7 @@ struct archive_write {
/* Dev/ino of the archive being written. */
dev_t skip_file_dev;
- ino_t skip_file_ino;
+ int64_t skip_file_ino;
/* Utility: Pointer to a block of nulls. */
const unsigned char *nulls;
@@ -77,6 +81,8 @@ struct archive_write {
void *data;
void *config;
int (*init)(struct archive_write *);
+ int (*options)(struct archive_write *,
+ const char *key, const char *value);
int (*finish)(struct archive_write *);
int (*write)(struct archive_write *, const void *, size_t);
} compressor;
@@ -86,7 +92,10 @@ struct archive_write {
* initialized by archive_write_set_format_XXX() calls.
*/
void *format_data;
+ const char *format_name;
int (*format_init)(struct archive_write *);
+ int (*format_options)(struct archive_write *,
+ const char *key, const char *value);
int (*format_finish)(struct archive_write *);
int (*format_destroy)(struct archive_write *);
int (*format_finish_entry)(struct archive_write *);
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c
index 272ae26e520..beb2379e5e4 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_bzip2.c
@@ -25,10 +25,7 @@
#include "archive_platform.h"
-/* Don't compile this if we don't have bzlib. */
-#if HAVE_BZLIB_H
-
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_bzip2.c,v 1.13 2007/12/30 04:58:21 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_bzip2.c 201091 2009-12-28 02:22:41Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -48,6 +45,17 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_bzip2.c,v 1
#include "archive_private.h"
#include "archive_write_private.h"
+#ifndef HAVE_BZLIB_H
+int
+archive_write_set_compression_bzip2(struct archive *a)
+{
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "bzip2 compression not supported on this platform");
+ return (ARCHIVE_FATAL);
+}
+#else
+/* Don't compile this if we don't have bzlib. */
+
struct private_data {
bz_stream stream;
int64_t total_in;
@@ -55,6 +63,9 @@ struct private_data {
size_t compressed_buffer_size;
};
+struct private_config {
+ int compression_level;
+};
/*
* Yuck. bzlib.h is not const-correct, so I need this one bit
@@ -65,6 +76,8 @@ struct private_data {
static int archive_compressor_bzip2_finish(struct archive_write *);
static int archive_compressor_bzip2_init(struct archive_write *);
+static int archive_compressor_bzip2_options(struct archive_write *,
+ const char *, const char *);
static int archive_compressor_bzip2_write(struct archive_write *,
const void *, size_t);
static int drive_compressor(struct archive_write *, struct private_data *,
@@ -77,9 +90,21 @@ int
archive_write_set_compression_bzip2(struct archive *_a)
{
struct archive_write *a = (struct archive_write *)_a;
+ struct private_config *config;
__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_NEW, "archive_write_set_compression_bzip2");
+ config = malloc(sizeof(*config));
+ if (config == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+ a->compressor.config = config;
+ a->compressor.finish = archive_compressor_bzip2_finish;
+ config->compression_level = 9; /* default */
a->compressor.init = &archive_compressor_bzip2_init;
+ a->compressor.options = &archive_compressor_bzip2_options;
+ a->archive.compression_code = ARCHIVE_COMPRESSION_BZIP2;
+ a->archive.compression_name = "bzip2";
return (ARCHIVE_OK);
}
@@ -91,10 +116,9 @@ archive_compressor_bzip2_init(struct archive_write *a)
{
int ret;
struct private_data *state;
+ struct private_config *config;
- a->archive.compression_code = ARCHIVE_COMPRESSION_BZIP2;
- a->archive.compression_name = "bzip2";
-
+ config = (struct private_config *)a->compressor.config;
if (a->client_opener != NULL) {
ret = (a->client_opener)(&a->archive, a->client_data);
if (ret != 0)
@@ -122,10 +146,10 @@ archive_compressor_bzip2_init(struct archive_write *a)
state->stream.next_out = state->compressed;
state->stream.avail_out = state->compressed_buffer_size;
a->compressor.write = archive_compressor_bzip2_write;
- a->compressor.finish = archive_compressor_bzip2_finish;
/* Initialize compression library */
- ret = BZ2_bzCompressInit(&(state->stream), 9, 0, 30);
+ ret = BZ2_bzCompressInit(&(state->stream),
+ config->compression_level, 0, 30);
if (ret == BZ_OK) {
a->compressor.data = state;
return (ARCHIVE_OK);
@@ -161,6 +185,32 @@ archive_compressor_bzip2_init(struct archive_write *a)
}
/*
+ * Set write options.
+ */
+static int
+archive_compressor_bzip2_options(struct archive_write *a, const char *key,
+ const char *value)
+{
+ struct private_config *config;
+
+ config = (struct private_config *)a->compressor.config;
+ if (strcmp(key, "compression-level") == 0) {
+ if (value == NULL || !(value[0] >= '0' && value[0] <= '9') ||
+ value[1] != '\0')
+ return (ARCHIVE_WARN);
+ config->compression_level = value[0] - '0';
+ /* Make '0' be a synonym for '1'. */
+ /* This way, bzip2 compressor supports the same 0..9
+ * range of levels as gzip. */
+ if (config->compression_level < 1)
+ config->compression_level = 1;
+ return (ARCHIVE_OK);
+ }
+
+ return (ARCHIVE_WARN);
+}
+
+/*
* Write data to the compressed stream.
*
* Returns ARCHIVE_OK if all data written, error otherwise.
@@ -205,83 +255,87 @@ archive_compressor_bzip2_finish(struct archive_write *a)
ssize_t bytes_written;
unsigned tocopy;
- state = (struct private_data *)a->compressor.data;
ret = ARCHIVE_OK;
- if (a->client_writer == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
- "No write callback is registered?\n"
- "This is probably an internal programming error.");
- ret = ARCHIVE_FATAL;
- goto cleanup;
- }
+ state = (struct private_data *)a->compressor.data;
+ if (state != NULL) {
+ if (a->client_writer == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_PROGRAMMER,
+ "No write callback is registered?\n"
+ "This is probably an internal programming error.");
+ ret = ARCHIVE_FATAL;
+ goto cleanup;
+ }
- /* By default, always pad the uncompressed data. */
- if (a->pad_uncompressed) {
- tocopy = a->bytes_per_block -
- (state->total_in % a->bytes_per_block);
- while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) {
- SET_NEXT_IN(state, a->nulls);
- state->stream.avail_in = tocopy < a->null_length ?
- tocopy : a->null_length;
- state->total_in += state->stream.avail_in;
- tocopy -= state->stream.avail_in;
- ret = drive_compressor(a, state, 0);
- if (ret != ARCHIVE_OK)
- goto cleanup;
+ /* By default, always pad the uncompressed data. */
+ if (a->pad_uncompressed) {
+ tocopy = a->bytes_per_block -
+ (state->total_in % a->bytes_per_block);
+ while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) {
+ SET_NEXT_IN(state, a->nulls);
+ state->stream.avail_in = tocopy < a->null_length ?
+ tocopy : a->null_length;
+ state->total_in += state->stream.avail_in;
+ tocopy -= state->stream.avail_in;
+ ret = drive_compressor(a, state, 0);
+ if (ret != ARCHIVE_OK)
+ goto cleanup;
+ }
}
- }
- /* Finish compression cycle. */
- if ((ret = drive_compressor(a, state, 1)))
- goto cleanup;
-
- /* Optionally, pad the final compressed block. */
- block_length = state->stream.next_out - state->compressed;
-
-
- /* Tricky calculation to determine size of last block. */
- target_block_length = block_length;
- if (a->bytes_in_last_block <= 0)
- /* Default or Zero: pad to full block */
- target_block_length = a->bytes_per_block;
- else
- /* Round length to next multiple of bytes_in_last_block. */
- target_block_length = a->bytes_in_last_block *
- ( (block_length + a->bytes_in_last_block - 1) /
- a->bytes_in_last_block);
- if (target_block_length > a->bytes_per_block)
- target_block_length = a->bytes_per_block;
- if (block_length < target_block_length) {
- memset(state->stream.next_out, 0,
- target_block_length - block_length);
- block_length = target_block_length;
- }
+ /* Finish compression cycle. */
+ if ((ret = drive_compressor(a, state, 1)))
+ goto cleanup;
+
+ /* Optionally, pad the final compressed block. */
+ block_length = state->stream.next_out - state->compressed;
+
+ /* Tricky calculation to determine size of last block. */
+ if (a->bytes_in_last_block <= 0)
+ /* Default or Zero: pad to full block */
+ target_block_length = a->bytes_per_block;
+ else
+ /* Round length to next multiple of bytes_in_last_block. */
+ target_block_length = a->bytes_in_last_block *
+ ( (block_length + a->bytes_in_last_block - 1) /
+ a->bytes_in_last_block);
+ if (target_block_length > a->bytes_per_block)
+ target_block_length = a->bytes_per_block;
+ if (block_length < target_block_length) {
+ memset(state->stream.next_out, 0,
+ target_block_length - block_length);
+ block_length = target_block_length;
+ }
- /* Write the last block */
- bytes_written = (a->client_writer)(&a->archive, a->client_data,
- state->compressed, block_length);
+ /* Write the last block */
+ bytes_written = (a->client_writer)(&a->archive, a->client_data,
+ state->compressed, block_length);
- /* TODO: Handle short write of final block. */
- if (bytes_written <= 0)
- ret = ARCHIVE_FATAL;
- else {
- a->archive.raw_position += ret;
- ret = ARCHIVE_OK;
- }
+ /* TODO: Handle short write of final block. */
+ if (bytes_written <= 0)
+ ret = ARCHIVE_FATAL;
+ else {
+ a->archive.raw_position += ret;
+ ret = ARCHIVE_OK;
+ }
- /* Cleanup: shut down compressor, release memory, etc. */
+ /* Cleanup: shut down compressor, release memory, etc. */
cleanup:
- switch (BZ2_bzCompressEnd(&(state->stream))) {
- case BZ_OK:
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
- "Failed to clean up compressor");
- ret = ARCHIVE_FATAL;
- }
+ switch (BZ2_bzCompressEnd(&(state->stream))) {
+ case BZ_OK:
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+ "Failed to clean up compressor");
+ ret = ARCHIVE_FATAL;
+ }
- free(state->compressed);
- free(state);
+ free(state->compressed);
+ free(state);
+ }
+ /* Free configuration data even if we were never fully initialized. */
+ free(a->compressor.config);
+ a->compressor.config = NULL;
return (ret);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c
index f913a23c53b..77c73ee5f27 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_compress.c
@@ -58,7 +58,7 @@
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_compress.c,v 1.1 2008/03/14 20:35:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_compress.c 201111 2009-12-28 03:33:05Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -243,7 +243,6 @@ output_code(struct archive_write *a, int ocode)
int bits, ret, clear_flg, bit_offset;
clear_flg = ocode == CLEAR;
- bits = state->code_len;
/*
* Since ocode is always >= 8 bits, only need to mask the first
@@ -426,10 +425,9 @@ archive_compressor_compress_finish(struct archive_write *a)
ssize_t block_length, target_block_length, bytes_written;
int ret;
struct private_data *state;
- unsigned tocopy;
+ size_t tocopy;
state = (struct private_data *)a->compressor.data;
- ret = 0;
if (a->client_writer == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
"No write callback is registered? "
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c
index 18abbdf67b5..f0176e25f74 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_gzip.c
@@ -25,10 +25,7 @@
#include "archive_platform.h"
-/* Don't compile this if we don't have zlib. */
-#if HAVE_ZLIB_H
-
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_gzip.c,v 1.16 2008/02/21 03:21:50 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_gzip.c 201081 2009-12-28 02:04:42Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -48,6 +45,17 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_gzip.c,v 1.
#include "archive_private.h"
#include "archive_write_private.h"
+#ifndef HAVE_ZLIB_H
+int
+archive_write_set_compression_gzip(struct archive *a)
+{
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "gzip compression not supported on this platform");
+ return (ARCHIVE_FATAL);
+}
+#else
+/* Don't compile this if we don't have zlib. */
+
struct private_data {
z_stream stream;
int64_t total_in;
@@ -56,6 +64,10 @@ struct private_data {
unsigned long crc;
};
+struct private_config {
+ int compression_level;
+};
+
/*
* Yuck. zlib.h is not const-correct, so I need this one bit
@@ -66,6 +78,8 @@ struct private_data {
static int archive_compressor_gzip_finish(struct archive_write *);
static int archive_compressor_gzip_init(struct archive_write *);
+static int archive_compressor_gzip_options(struct archive_write *,
+ const char *, const char *);
static int archive_compressor_gzip_write(struct archive_write *,
const void *, size_t);
static int drive_compressor(struct archive_write *, struct private_data *,
@@ -79,9 +93,19 @@ int
archive_write_set_compression_gzip(struct archive *_a)
{
struct archive_write *a = (struct archive_write *)_a;
+ struct private_config *config;
__archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_NEW, "archive_write_set_compression_gzip");
+ config = malloc(sizeof(*config));
+ if (config == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+ a->compressor.config = config;
+ a->compressor.finish = &archive_compressor_gzip_finish;
+ config->compression_level = Z_DEFAULT_COMPRESSION;
a->compressor.init = &archive_compressor_gzip_init;
+ a->compressor.options = &archive_compressor_gzip_options;
a->archive.compression_code = ARCHIVE_COMPRESSION_GZIP;
a->archive.compression_name = "gzip";
return (ARCHIVE_OK);
@@ -95,10 +119,10 @@ archive_compressor_gzip_init(struct archive_write *a)
{
int ret;
struct private_data *state;
+ struct private_config *config;
time_t t;
- a->archive.compression_code = ARCHIVE_COMPRESSION_GZIP;
- a->archive.compression_name = "gzip";
+ config = (struct private_config *)a->compressor.config;
if (a->client_opener != NULL) {
ret = (a->client_opener)(&a->archive, a->client_data);
@@ -163,11 +187,10 @@ archive_compressor_gzip_init(struct archive_write *a)
state->stream.avail_out -= 10;
a->compressor.write = archive_compressor_gzip_write;
- a->compressor.finish = archive_compressor_gzip_finish;
/* Initialize compression library. */
ret = deflateInit2(&(state->stream),
- Z_DEFAULT_COMPRESSION,
+ config->compression_level,
Z_DEFLATED,
-15 /* < 0 to suppress zlib header */,
8,
@@ -206,6 +229,27 @@ archive_compressor_gzip_init(struct archive_write *a)
}
/*
+ * Set write options.
+ */
+static int
+archive_compressor_gzip_options(struct archive_write *a, const char *key,
+ const char *value)
+{
+ struct private_config *config;
+
+ config = (struct private_config *)a->compressor.config;
+ if (strcmp(key, "compression-level") == 0) {
+ if (value == NULL || !(value[0] >= '0' && value[0] <= '9') ||
+ value[1] != '\0')
+ return (ARCHIVE_WARN);
+ config->compression_level = value[0] - '0';
+ return (ARCHIVE_OK);
+ }
+
+ return (ARCHIVE_WARN);
+}
+
+/*
* Write data to the compressed stream.
*/
static int
@@ -237,7 +281,6 @@ archive_compressor_gzip_write(struct archive_write *a, const void *buff,
return (ARCHIVE_OK);
}
-
/*
* Finish the compression...
*/
@@ -252,113 +295,117 @@ archive_compressor_gzip_finish(struct archive_write *a)
state = (struct private_data *)a->compressor.data;
ret = 0;
- if (a->client_writer == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
- "No write callback is registered? "
- "This is probably an internal programming error.");
- ret = ARCHIVE_FATAL;
- goto cleanup;
- }
+ if (state != NULL) {
+ if (a->client_writer == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_PROGRAMMER,
+ "No write callback is registered? "
+ "This is probably an internal programming error.");
+ ret = ARCHIVE_FATAL;
+ goto cleanup;
+ }
+
+ /* By default, always pad the uncompressed data. */
+ if (a->pad_uncompressed) {
+ tocopy = a->bytes_per_block -
+ (state->total_in % a->bytes_per_block);
+ while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) {
+ SET_NEXT_IN(state, a->nulls);
+ state->stream.avail_in = tocopy < a->null_length ?
+ tocopy : a->null_length;
+ state->crc = crc32(state->crc, a->nulls,
+ state->stream.avail_in);
+ state->total_in += state->stream.avail_in;
+ tocopy -= state->stream.avail_in;
+ ret = drive_compressor(a, state, 0);
+ if (ret != ARCHIVE_OK)
+ goto cleanup;
+ }
+ }
+
+ /* Finish compression cycle */
+ if (((ret = drive_compressor(a, state, 1))) != ARCHIVE_OK)
+ goto cleanup;
- /* By default, always pad the uncompressed data. */
- if (a->pad_uncompressed) {
- tocopy = a->bytes_per_block -
- (state->total_in % a->bytes_per_block);
- while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) {
- SET_NEXT_IN(state, a->nulls);
- state->stream.avail_in = tocopy < a->null_length ?
- tocopy : a->null_length;
- state->crc = crc32(state->crc, a->nulls,
- state->stream.avail_in);
- state->total_in += state->stream.avail_in;
- tocopy -= state->stream.avail_in;
- ret = drive_compressor(a, state, 0);
- if (ret != ARCHIVE_OK)
+ /* Build trailer: 4-byte CRC and 4-byte length. */
+ trailer[0] = (state->crc)&0xff;
+ trailer[1] = (state->crc >> 8)&0xff;
+ trailer[2] = (state->crc >> 16)&0xff;
+ trailer[3] = (state->crc >> 24)&0xff;
+ trailer[4] = (state->total_in)&0xff;
+ trailer[5] = (state->total_in >> 8)&0xff;
+ trailer[6] = (state->total_in >> 16)&0xff;
+ trailer[7] = (state->total_in >> 24)&0xff;
+
+ /* Add trailer to current block. */
+ tocopy = 8;
+ if (tocopy > state->stream.avail_out)
+ tocopy = state->stream.avail_out;
+ memcpy(state->stream.next_out, trailer, tocopy);
+ state->stream.next_out += tocopy;
+ state->stream.avail_out -= tocopy;
+
+ /* If it overflowed, flush and start a new block. */
+ if (tocopy < 8) {
+ bytes_written = (a->client_writer)(&a->archive, a->client_data,
+ state->compressed, state->compressed_buffer_size);
+ if (bytes_written <= 0) {
+ ret = ARCHIVE_FATAL;
goto cleanup;
+ }
+ a->archive.raw_position += bytes_written;
+ state->stream.next_out = state->compressed;
+ state->stream.avail_out = state->compressed_buffer_size;
+ memcpy(state->stream.next_out, trailer + tocopy, 8-tocopy);
+ state->stream.next_out += 8-tocopy;
+ state->stream.avail_out -= 8-tocopy;
}
- }
- /* Finish compression cycle */
- if (((ret = drive_compressor(a, state, 1))) != ARCHIVE_OK)
- goto cleanup;
-
- /* Build trailer: 4-byte CRC and 4-byte length. */
- trailer[0] = (state->crc)&0xff;
- trailer[1] = (state->crc >> 8)&0xff;
- trailer[2] = (state->crc >> 16)&0xff;
- trailer[3] = (state->crc >> 24)&0xff;
- trailer[4] = (state->total_in)&0xff;
- trailer[5] = (state->total_in >> 8)&0xff;
- trailer[6] = (state->total_in >> 16)&0xff;
- trailer[7] = (state->total_in >> 24)&0xff;
-
- /* Add trailer to current block. */
- tocopy = 8;
- if (tocopy > state->stream.avail_out)
- tocopy = state->stream.avail_out;
- memcpy(state->stream.next_out, trailer, tocopy);
- state->stream.next_out += tocopy;
- state->stream.avail_out -= tocopy;
-
- /* If it overflowed, flush and start a new block. */
- if (tocopy < 8) {
+ /* Optionally, pad the final compressed block. */
+ block_length = state->stream.next_out - state->compressed;
+
+ /* Tricky calculation to determine size of last block. */
+ if (a->bytes_in_last_block <= 0)
+ /* Default or Zero: pad to full block */
+ target_block_length = a->bytes_per_block;
+ else
+ /* Round length to next multiple of bytes_in_last_block. */
+ target_block_length = a->bytes_in_last_block *
+ ( (block_length + a->bytes_in_last_block - 1) /
+ a->bytes_in_last_block);
+ if (target_block_length > a->bytes_per_block)
+ target_block_length = a->bytes_per_block;
+ if (block_length < target_block_length) {
+ memset(state->stream.next_out, 0,
+ target_block_length - block_length);
+ block_length = target_block_length;
+ }
+
+ /* Write the last block */
bytes_written = (a->client_writer)(&a->archive, a->client_data,
- state->compressed, state->compressed_buffer_size);
+ state->compressed, block_length);
if (bytes_written <= 0) {
ret = ARCHIVE_FATAL;
goto cleanup;
}
a->archive.raw_position += bytes_written;
- state->stream.next_out = state->compressed;
- state->stream.avail_out = state->compressed_buffer_size;
- memcpy(state->stream.next_out, trailer + tocopy, 8-tocopy);
- state->stream.next_out += 8-tocopy;
- state->stream.avail_out -= 8-tocopy;
- }
- /* Optionally, pad the final compressed block. */
- block_length = state->stream.next_out - state->compressed;
-
-
- /* Tricky calculation to determine size of last block. */
- target_block_length = block_length;
- if (a->bytes_in_last_block <= 0)
- /* Default or Zero: pad to full block */
- target_block_length = a->bytes_per_block;
- else
- /* Round length to next multiple of bytes_in_last_block. */
- target_block_length = a->bytes_in_last_block *
- ( (block_length + a->bytes_in_last_block - 1) /
- a->bytes_in_last_block);
- if (target_block_length > a->bytes_per_block)
- target_block_length = a->bytes_per_block;
- if (block_length < target_block_length) {
- memset(state->stream.next_out, 0,
- target_block_length - block_length);
- block_length = target_block_length;
- }
-
- /* Write the last block */
- bytes_written = (a->client_writer)(&a->archive, a->client_data,
- state->compressed, block_length);
- if (bytes_written <= 0) {
- ret = ARCHIVE_FATAL;
- goto cleanup;
- }
- a->archive.raw_position += bytes_written;
-
- /* Cleanup: shut down compressor, release memory, etc. */
-cleanup:
- switch (deflateEnd(&(state->stream))) {
- case Z_OK:
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Failed to clean up compressor");
- ret = ARCHIVE_FATAL;
+ /* Cleanup: shut down compressor, release memory, etc. */
+ cleanup:
+ switch (deflateEnd(&(state->stream))) {
+ case Z_OK:
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Failed to clean up compressor");
+ ret = ARCHIVE_FATAL;
+ }
+ free(state->compressed);
+ free(state);
}
- free(state->compressed);
- free(state);
+ /* Clean up config area even if we never initialized. */
+ free(a->compressor.config);
+ a->compressor.config = NULL;
return (ret);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_none.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_none.c
index bdecb240d9f..e0216d9e122 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_compression_none.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_none.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_none.c,v 1.16 2007/12/30 04:58:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_none.c 201080 2009-12-28 02:03:54Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -208,11 +208,10 @@ archive_compressor_none_finish(struct archive_write *a)
ssize_t target_block_length;
ssize_t bytes_written;
int ret;
- int ret2;
struct archive_none *state;
state = (struct archive_none *)a->compressor.data;
- ret = ret2 = ARCHIVE_OK;
+ ret = ARCHIVE_OK;
if (a->client_writer == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
"No write callback is registered? "
@@ -225,7 +224,6 @@ archive_compressor_none_finish(struct archive_write *a)
block_length = state->buffer_size - state->avail;
/* Tricky calculation to determine size of last block */
- target_block_length = block_length;
if (a->bytes_in_last_block <= 0)
/* Default or Zero: pad to full block */
target_block_length = a->bytes_per_block;
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c
index 69c5d428633..475ba354032 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c
@@ -25,11 +25,11 @@
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_program.c,v 1.3 2008/06/15 10:45:57 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_program.c 201104 2009-12-28 03:14:30Z kientzle $");
/* This capability is only available on POSIX systems. */
-#if !defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \
- !(defined(HAVE_FORK) || defined(HAVE_VFORK))
+#if (!defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \
+ !(defined(HAVE_FORK) || defined(HAVE_VFORK))) && (!defined(_WIN32) || defined(__CYGWIN__))
#include "archive.h"
/*
@@ -230,11 +230,9 @@ static int
archive_compressor_program_write(struct archive_write *a, const void *buff,
size_t length)
{
- struct private_data *state;
ssize_t ret;
const char *buf;
- state = (struct private_data *)a->compressor.data;
if (a->client_writer == NULL) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
"No write callback is registered? "
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_xz.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_xz.c
new file mode 100644
index 00000000000..f82f6db62e2
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_xz.c
@@ -0,0 +1,438 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_xz.c 201108 2009-12-28 03:28:21Z kientzle $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include <time.h>
+#ifdef HAVE_LZMA_H
+#include <lzma.h>
+#endif
+
+#include "archive.h"
+#include "archive_private.h"
+#include "archive_write_private.h"
+
+#ifndef HAVE_LZMA_H
+int
+archive_write_set_compression_xz(struct archive *a)
+{
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "xz compression not supported on this platform");
+ return (ARCHIVE_FATAL);
+}
+
+int
+archive_write_set_compression_lzma(struct archive *a)
+{
+ archive_set_error(a, ARCHIVE_ERRNO_MISC,
+ "lzma compression not supported on this platform");
+ return (ARCHIVE_FATAL);
+}
+#else
+/* Don't compile this if we don't have liblzma. */
+
+struct private_data {
+ lzma_stream stream;
+ lzma_filter lzmafilters[2];
+ lzma_options_lzma lzma_opt;
+ int64_t total_in;
+ unsigned char *compressed;
+ size_t compressed_buffer_size;
+};
+
+struct private_config {
+ int compression_level;
+};
+
+static int archive_compressor_xz_init(struct archive_write *);
+static int archive_compressor_xz_options(struct archive_write *,
+ const char *, const char *);
+static int archive_compressor_xz_finish(struct archive_write *);
+static int archive_compressor_xz_write(struct archive_write *,
+ const void *, size_t);
+static int drive_compressor(struct archive_write *, struct private_data *,
+ int finishing);
+
+
+/*
+ * Allocate, initialize and return a archive object.
+ */
+int
+archive_write_set_compression_xz(struct archive *_a)
+{
+ struct private_config *config;
+ struct archive_write *a = (struct archive_write *)_a;
+ __archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_set_compression_xz");
+ config = calloc(1, sizeof(*config));
+ if (config == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
+ return (ARCHIVE_FATAL);
+ }
+ a->compressor.config = config;
+ a->compressor.finish = archive_compressor_xz_finish;
+ config->compression_level = LZMA_PRESET_DEFAULT;
+ a->compressor.init = &archive_compressor_xz_init;
+ a->compressor.options = &archive_compressor_xz_options;
+ a->archive.compression_code = ARCHIVE_COMPRESSION_XZ;
+ a->archive.compression_name = "xz";
+ return (ARCHIVE_OK);
+}
+
+/* LZMA is handled identically, we just need a different compression
+ * code set. (The liblzma setup looks at the code to determine
+ * the one place that XZ and LZMA require different handling.) */
+int
+archive_write_set_compression_lzma(struct archive *_a)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ int r = archive_write_set_compression_xz(_a);
+ if (r != ARCHIVE_OK)
+ return (r);
+ a->archive.compression_code = ARCHIVE_COMPRESSION_LZMA;
+ a->archive.compression_name = "lzma";
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_compressor_xz_init_stream(struct archive_write *a,
+ struct private_data *state)
+{
+ int ret;
+
+ state->stream = (lzma_stream)LZMA_STREAM_INIT;
+ state->stream.next_out = state->compressed;
+ state->stream.avail_out = state->compressed_buffer_size;
+ if (a->archive.compression_code == ARCHIVE_COMPRESSION_XZ)
+ ret = lzma_stream_encoder(&(state->stream),
+ state->lzmafilters, LZMA_CHECK_CRC64);
+ else
+ ret = lzma_alone_encoder(&(state->stream), &state->lzma_opt);
+ if (ret == LZMA_OK)
+ return (ARCHIVE_OK);
+
+ switch (ret) {
+ case LZMA_MEM_ERROR:
+ archive_set_error(&a->archive, ENOMEM,
+ "Internal error initializing compression library: "
+ "Cannot allocate memory");
+ break;
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Internal error initializing compression library: "
+ "It's a bug in liblzma");
+ break;
+ }
+ return (ARCHIVE_FATAL);
+}
+
+/*
+ * Setup callback.
+ */
+static int
+archive_compressor_xz_init(struct archive_write *a)
+{
+ int ret;
+ struct private_data *state;
+ struct private_config *config;
+
+ if (a->client_opener != NULL) {
+ ret = (a->client_opener)(&a->archive, a->client_data);
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ }
+
+ state = (struct private_data *)malloc(sizeof(*state));
+ if (state == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate data for compression");
+ return (ARCHIVE_FATAL);
+ }
+ memset(state, 0, sizeof(*state));
+ config = a->compressor.config;
+
+ /*
+ * See comment above. We should set compressed_buffer_size to
+ * max(bytes_per_block, 65536), but the code can't handle that yet.
+ */
+ state->compressed_buffer_size = a->bytes_per_block;
+ state->compressed = (unsigned char *)malloc(state->compressed_buffer_size);
+ if (state->compressed == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate data for compression buffer");
+ free(state);
+ return (ARCHIVE_FATAL);
+ }
+ a->compressor.write = archive_compressor_xz_write;
+
+ /* Initialize compression library. */
+ if (lzma_lzma_preset(&state->lzma_opt, config->compression_level)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Internal error initializing compression library");
+ free(state->compressed);
+ free(state);
+ }
+ state->lzmafilters[0].id = LZMA_FILTER_LZMA2;
+ state->lzmafilters[0].options = &state->lzma_opt;
+ state->lzmafilters[1].id = LZMA_VLI_UNKNOWN;/* Terminate */
+ ret = archive_compressor_xz_init_stream(a, state);
+ if (ret == LZMA_OK) {
+ a->compressor.data = state;
+ return (0);
+ }
+ /* Library setup failed: clean up. */
+ free(state->compressed);
+ free(state);
+
+ return (ARCHIVE_FATAL);
+}
+
+/*
+ * Set write options.
+ */
+static int
+archive_compressor_xz_options(struct archive_write *a, const char *key,
+ const char *value)
+{
+ struct private_config *config;
+
+ config = (struct private_config *)a->compressor.config;
+ if (strcmp(key, "compression-level") == 0) {
+ if (value == NULL || !(value[0] >= '0' && value[0] <= '9') ||
+ value[1] != '\0')
+ return (ARCHIVE_WARN);
+ config->compression_level = value[0] - '0';
+ if (config->compression_level > 6)
+ config->compression_level = 6;
+ return (ARCHIVE_OK);
+ }
+
+ return (ARCHIVE_WARN);
+}
+
+/*
+ * Write data to the compressed stream.
+ */
+static int
+archive_compressor_xz_write(struct archive_write *a, const void *buff,
+ size_t length)
+{
+ struct private_data *state;
+ int ret;
+
+ state = (struct private_data *)a->compressor.data;
+ if (a->client_writer == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+ "No write callback is registered? "
+ "This is probably an internal programming error.");
+ return (ARCHIVE_FATAL);
+ }
+
+ /* Update statistics */
+ state->total_in += length;
+
+ /* Compress input data to output buffer */
+ state->stream.next_in = buff;
+ state->stream.avail_in = length;
+ if ((ret = drive_compressor(a, state, 0)) != ARCHIVE_OK)
+ return (ret);
+
+ a->archive.file_position += length;
+ return (ARCHIVE_OK);
+}
+
+
+/*
+ * Finish the compression...
+ */
+static int
+archive_compressor_xz_finish(struct archive_write *a)
+{
+ ssize_t block_length, target_block_length, bytes_written;
+ int ret;
+ struct private_data *state;
+ unsigned tocopy;
+
+ ret = ARCHIVE_OK;
+ state = (struct private_data *)a->compressor.data;
+ if (state != NULL) {
+ if (a->client_writer == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_PROGRAMMER,
+ "No write callback is registered? "
+ "This is probably an internal programming error.");
+ ret = ARCHIVE_FATAL;
+ goto cleanup;
+ }
+
+ /* By default, always pad the uncompressed data. */
+ if (a->pad_uncompressed) {
+ tocopy = a->bytes_per_block -
+ (state->total_in % a->bytes_per_block);
+ while (tocopy > 0 && tocopy < (unsigned)a->bytes_per_block) {
+ state->stream.next_in = a->nulls;
+ state->stream.avail_in = tocopy < a->null_length ?
+ tocopy : a->null_length;
+ state->total_in += state->stream.avail_in;
+ tocopy -= state->stream.avail_in;
+ ret = drive_compressor(a, state, 0);
+ if (ret != ARCHIVE_OK)
+ goto cleanup;
+ }
+ }
+
+ /* Finish compression cycle */
+ if (((ret = drive_compressor(a, state, 1))) != ARCHIVE_OK)
+ goto cleanup;
+
+ /* Optionally, pad the final compressed block. */
+ block_length = state->stream.next_out - state->compressed;
+
+ /* Tricky calculation to determine size of last block. */
+ if (a->bytes_in_last_block <= 0)
+ /* Default or Zero: pad to full block */
+ target_block_length = a->bytes_per_block;
+ else
+ /* Round length to next multiple of bytes_in_last_block. */
+ target_block_length = a->bytes_in_last_block *
+ ( (block_length + a->bytes_in_last_block - 1) /
+ a->bytes_in_last_block);
+ if (target_block_length > a->bytes_per_block)
+ target_block_length = a->bytes_per_block;
+ if (block_length < target_block_length) {
+ memset(state->stream.next_out, 0,
+ target_block_length - block_length);
+ block_length = target_block_length;
+ }
+
+ /* Write the last block */
+ bytes_written = (a->client_writer)(&a->archive, a->client_data,
+ state->compressed, block_length);
+ if (bytes_written <= 0) {
+ ret = ARCHIVE_FATAL;
+ goto cleanup;
+ }
+ a->archive.raw_position += bytes_written;
+
+ /* Cleanup: shut down compressor, release memory, etc. */
+ cleanup:
+ lzma_end(&(state->stream));
+ free(state->compressed);
+ free(state);
+ }
+ free(a->compressor.config);
+ a->compressor.config = NULL;
+ return (ret);
+}
+
+/*
+ * Utility function to push input data through compressor,
+ * writing full output blocks as necessary.
+ *
+ * Note that this handles both the regular write case (finishing ==
+ * false) and the end-of-archive case (finishing == true).
+ */
+static int
+drive_compressor(struct archive_write *a, struct private_data *state, int finishing)
+{
+ ssize_t bytes_written;
+ int ret;
+
+ for (;;) {
+ if (state->stream.avail_out == 0) {
+ bytes_written = (a->client_writer)(&a->archive,
+ a->client_data, state->compressed,
+ state->compressed_buffer_size);
+ if (bytes_written <= 0) {
+ /* TODO: Handle this write failure */
+ return (ARCHIVE_FATAL);
+ } else if ((size_t)bytes_written < state->compressed_buffer_size) {
+ /* Short write: Move remaining to
+ * front of block and keep filling */
+ memmove(state->compressed,
+ state->compressed + bytes_written,
+ state->compressed_buffer_size - bytes_written);
+ }
+ a->archive.raw_position += bytes_written;
+ state->stream.next_out
+ = state->compressed +
+ state->compressed_buffer_size - bytes_written;
+ state->stream.avail_out = bytes_written;
+ }
+
+ /* If there's nothing to do, we're done. */
+ if (!finishing && state->stream.avail_in == 0)
+ return (ARCHIVE_OK);
+
+ ret = lzma_code(&(state->stream),
+ finishing ? LZMA_FINISH : LZMA_RUN );
+
+ switch (ret) {
+ case LZMA_OK:
+ /* In non-finishing case, check if compressor
+ * consumed everything */
+ if (!finishing && state->stream.avail_in == 0)
+ return (ARCHIVE_OK);
+ /* In finishing case, this return always means
+ * there's more work */
+ break;
+ case LZMA_STREAM_END:
+ /* This return can only occur in finishing case. */
+ if (finishing)
+ return (ARCHIVE_OK);
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "lzma compression data error");
+ return (ARCHIVE_FATAL);
+ case LZMA_MEMLIMIT_ERROR:
+ archive_set_error(&a->archive, ENOMEM,
+ "lzma compression error: "
+ "%ju MiB would have been needed",
+ (lzma_memusage(&(state->stream)) + 1024 * 1024 -1)
+ / (1024 * 1024));
+ return (ARCHIVE_FATAL);
+ default:
+ /* Any other return value indicates an error. */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "lzma compression failed:"
+ " lzma_code() call returned status %d",
+ ret);
+ return (ARCHIVE_FATAL);
+ }
+ }
+}
+
+#endif /* HAVE_LZMA_H */
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format.c b/archivers/libarchive/files/libarchive/archive_write_set_format.c
index e5f89211a2c..b1593fbe6d8 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format.c,v 1.5 2007/06/22 05:47:00 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format.c 201168 2009-12-29 06:15:32Z kientzle $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -44,6 +44,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] =
{ ARCHIVE_FORMAT_CPIO, archive_write_set_format_cpio },
{ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC, archive_write_set_format_cpio_newc },
{ ARCHIVE_FORMAT_CPIO_POSIX, archive_write_set_format_cpio },
+ { ARCHIVE_FORMAT_MTREE, archive_write_set_format_mtree },
{ ARCHIVE_FORMAT_SHAR, archive_write_set_format_shar },
{ ARCHIVE_FORMAT_SHAR_BASE, archive_write_set_format_shar },
{ ARCHIVE_FORMAT_SHAR_DUMP, archive_write_set_format_shar_dump },
@@ -52,6 +53,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] =
{ ARCHIVE_FORMAT_TAR_PAX_RESTRICTED,
archive_write_set_format_pax_restricted },
{ ARCHIVE_FORMAT_TAR_USTAR, archive_write_set_format_ustar },
+ { ARCHIVE_FORMAT_ZIP, archive_write_set_format_zip },
{ 0, NULL }
};
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
index 7176e6e2f40..b492ceaa56b 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c
@@ -26,7 +26,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ar.c,v 1.7 2008/05/26 17:00:23 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_ar.c 201108 2009-12-28 03:28:21Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -125,6 +125,7 @@ archive_write_set_format_ar(struct archive_write *a)
memset(ar, 0, sizeof(*ar));
a->format_data = ar;
+ a->format_name = "ar";
a->format_write_header = archive_write_ar_header;
a->format_write_data = archive_write_ar_data;
a->format_finish = archive_write_ar_finish;
@@ -144,7 +145,6 @@ archive_write_ar_header(struct archive_write *a, struct archive_entry *entry)
const char *filename;
int64_t size;
- ret = 0;
append_fn = 0;
ar = (struct ar_w *)a->format_data;
ar->is_strtab = 0;
@@ -389,6 +389,9 @@ archive_write_ar_destroy(struct archive_write *a)
ar = (struct ar_w *)a->format_data;
+ if (ar == NULL)
+ return (ARCHIVE_OK);
+
if (ar->has_strtab > 0) {
free(ar->strtab);
ar->strtab = NULL;
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_by_name.c b/archivers/libarchive/files/libarchive/archive_write_set_format_by_name.c
index 0d7cae4867d..a0921199c22 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_by_name.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_by_name.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_by_name.c,v 1.7 2007/06/22 05:47:00 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_by_name.c 201168 2009-12-29 06:15:32Z kientzle $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -44,11 +44,12 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_by_name.c,v 1.7
static
struct { const char *name; int (*setter)(struct archive *); } names[] =
{
- { "arbsd", archive_write_set_format_ar_bsd },
{ "ar", archive_write_set_format_ar_bsd },
+ { "arbsd", archive_write_set_format_ar_bsd },
{ "argnu", archive_write_set_format_ar_svr4 },
{ "arsvr4", archive_write_set_format_ar_svr4 },
{ "cpio", archive_write_set_format_cpio },
+ { "mtree", archive_write_set_format_mtree },
{ "newc", archive_write_set_format_cpio_newc },
{ "odc", archive_write_set_format_cpio },
{ "pax", archive_write_set_format_pax },
@@ -56,6 +57,7 @@ struct { const char *name; int (*setter)(struct archive *); } names[] =
{ "shar", archive_write_set_format_shar },
{ "shardump", archive_write_set_format_shar_dump },
{ "ustar", archive_write_set_format_ustar },
+ { "zip", archive_write_set_format_zip },
{ NULL, NULL }
};
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c
index 61042999efa..4e8e1e0bdca 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_cpio.c,v 1.14 2008/03/15 11:04:45 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_cpio.c 201170 2009-12-29 06:34:23Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -54,6 +54,12 @@ static int64_t format_octal_recursive(int64_t, char *, int);
struct cpio {
uint64_t entry_bytes_remaining;
+
+ int64_t ino_next;
+
+ struct { int64_t old; int new;} *ino_list;
+ size_t ino_list_size;
+ size_t ino_list_next;
};
struct cpio_header {
@@ -92,6 +98,7 @@ archive_write_set_format_cpio(struct archive *_a)
a->format_data = cpio;
a->pad_uncompressed = 1;
+ a->format_name = "cpio";
a->format_write_header = archive_write_cpio_header;
a->format_write_data = archive_write_cpio_data;
a->format_finish_entry = archive_write_cpio_finish_entry;
@@ -102,34 +109,102 @@ archive_write_set_format_cpio(struct archive *_a)
return (ARCHIVE_OK);
}
+/*
+ * Ino values are as long as 64 bits on some systems; cpio format
+ * only allows 18 bits and relies on the ino values to identify hardlinked
+ * files. So, we can't merely "hash" the ino numbers since collisions
+ * would corrupt the archive. Instead, we generate synthetic ino values
+ * to store in the archive and maintain a map of original ino values to
+ * synthetic ones so we can preserve hardlink information.
+ *
+ * TODO: Make this more efficient. It's not as bad as it looks (most
+ * files don't have any hardlinks and we don't do any work here for those),
+ * but it wouldn't be hard to do better.
+ *
+ * TODO: Work with dev/ino pairs here instead of just ino values.
+ */
+static int
+synthesize_ino_value(struct cpio *cpio, struct archive_entry *entry)
+{
+ int64_t ino = archive_entry_ino64(entry);
+ int ino_new;
+ size_t i;
+
+ /*
+ * If no index number was given, don't assign one. In
+ * particular, this handles the end-of-archive marker
+ * correctly by giving it a zero index value. (This is also
+ * why we start our synthetic index numbers with one below.)
+ */
+ if (ino == 0)
+ return (0);
+
+ /* Don't store a mapping if we don't need to. */
+ if (archive_entry_nlink(entry) < 2) {
+ return ++cpio->ino_next;
+ }
+
+ /* Look up old ino; if we have it, this is a hardlink
+ * and we reuse the same value. */
+ for (i = 0; i < cpio->ino_list_next; ++i) {
+ if (cpio->ino_list[i].old == ino)
+ return (cpio->ino_list[i].new);
+ }
+
+ /* Assign a new index number. */
+ ino_new = ++cpio->ino_next;
+
+ /* Ensure space for the new mapping. */
+ if (cpio->ino_list_size <= cpio->ino_list_next) {
+ size_t newsize = cpio->ino_list_size < 512
+ ? 512 : cpio->ino_list_size * 2;
+ void *newlist = realloc(cpio->ino_list,
+ sizeof(cpio->ino_list[0]) * newsize);
+ if (newlist == NULL)
+ return (-1);
+
+ cpio->ino_list_size = newsize;
+ cpio->ino_list = newlist;
+ }
+
+ /* Record and return the new value. */
+ cpio->ino_list[cpio->ino_list_next].old = ino;
+ cpio->ino_list[cpio->ino_list_next].new = ino_new;
+ ++cpio->ino_list_next;
+ return (ino_new);
+}
+
static int
archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
{
struct cpio *cpio;
const char *p, *path;
- int pathlength, ret;
+ int pathlength, ret, ret2;
+ int64_t ino;
struct cpio_header h;
cpio = (struct cpio *)a->format_data;
- ret = 0;
+ ret2 = ARCHIVE_OK;
path = archive_entry_pathname(entry);
- pathlength = strlen(path) + 1; /* Include trailing null. */
+ pathlength = (int)strlen(path) + 1; /* Include trailing null. */
memset(&h, 0, sizeof(h));
format_octal(070707, &h.c_magic, sizeof(h.c_magic));
format_octal(archive_entry_dev(entry), &h.c_dev, sizeof(h.c_dev));
- /*
- * TODO: Generate artificial inode numbers rather than just
- * re-using the ones off the disk. That way, the 18-bit c_ino
- * field only limits the number of files in the archive.
- */
- if (archive_entry_ino(entry) > 0777777) {
- archive_set_error(&a->archive, ERANGE, "large inode number truncated");
- ret = ARCHIVE_WARN;
+
+ ino = synthesize_ino_value(cpio, entry);
+ if (ino < 0) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory for ino translation table");
+ return (ARCHIVE_FATAL);
+ } else if (ino > 0777777) {
+ archive_set_error(&a->archive, ERANGE,
+ "Too many files for this cpio format");
+ return (ARCHIVE_FATAL);
}
+ format_octal(ino & 0777777, &h.c_ino, sizeof(h.c_ino));
- format_octal(archive_entry_ino(entry) & 0777777, &h.c_ino, sizeof(h.c_ino));
format_octal(archive_entry_mode(entry), &h.c_mode, sizeof(h.c_mode));
format_octal(archive_entry_uid(entry), &h.c_uid, sizeof(h.c_uid));
format_octal(archive_entry_gid(entry), &h.c_gid, sizeof(h.c_gid));
@@ -168,6 +243,8 @@ archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
if (p != NULL && *p != '\0')
ret = (a->compressor.write)(a, p, strlen(p));
+ if (ret == ARCHIVE_OK)
+ ret = ret2;
return (ret);
}
@@ -216,17 +293,15 @@ format_octal_recursive(int64_t v, char *p, int s)
return (v);
v = format_octal_recursive(v, p+1, s-1);
*p = '0' + (v & 7);
- return (v >>= 3);
+ return (v >> 3);
}
static int
archive_write_cpio_finish(struct archive_write *a)
{
- struct cpio *cpio;
int er;
struct archive_entry *trailer;
- cpio = (struct cpio *)a->format_data;
trailer = archive_entry_new();
/* nlink = 1 here for GNU cpio compat. */
archive_entry_set_nlink(trailer, 1);
@@ -242,6 +317,7 @@ archive_write_cpio_destroy(struct archive_write *a)
struct cpio *cpio;
cpio = (struct cpio *)a->format_data;
+ free(cpio->ino_list);
free(cpio);
a->format_data = NULL;
return (ARCHIVE_OK);
@@ -251,7 +327,8 @@ static int
archive_write_cpio_finish_entry(struct archive_write *a)
{
struct cpio *cpio;
- int to_write, ret;
+ size_t to_write;
+ int ret;
cpio = (struct cpio *)a->format_data;
ret = ARCHIVE_OK;
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c
index b5a2a028419..0af0890952e 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_cpio_newc.c
@@ -25,7 +25,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_cpio_newc.c,v 1.4 2008/03/15 11:04:45 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_cpio_newc.c 201160 2009-12-29 05:41:57Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -75,6 +75,9 @@ struct cpio_header_newc {
char c_checksum[8];
};
+/* Logic trick: difference between 'n' and next multiple of 4 */
+#define PAD4(n) (3 & (1 + ~(n)))
+
/*
* Set output format to 'cpio' format.
*/
@@ -97,6 +100,7 @@ archive_write_set_format_cpio_newc(struct archive *_a)
a->format_data = cpio;
a->pad_uncompressed = 1;
+ a->format_name = "cpio";
a->format_write_header = archive_write_newc_header;
a->format_write_data = archive_write_newc_data;
a->format_finish_entry = archive_write_newc_finish_entry;
@@ -110,28 +114,34 @@ archive_write_set_format_cpio_newc(struct archive *_a)
static int
archive_write_newc_header(struct archive_write *a, struct archive_entry *entry)
{
+ int64_t ino;
struct cpio *cpio;
const char *p, *path;
- int pathlength, ret;
+ int pathlength, ret, ret2;
struct cpio_header_newc h;
int pad;
cpio = (struct cpio *)a->format_data;
- ret = 0;
+ ret2 = ARCHIVE_OK;
path = archive_entry_pathname(entry);
- pathlength = strlen(path) + 1; /* Include trailing null. */
+ pathlength = (int)strlen(path) + 1; /* Include trailing null. */
memset(&h, 0, sizeof(h));
format_hex(0x070701, &h.c_magic, sizeof(h.c_magic));
- format_hex(archive_entry_devmajor(entry), &h.c_devmajor, sizeof(h.c_devmajor));
- format_hex(archive_entry_devminor(entry), &h.c_devminor, sizeof(h.c_devminor));
- if (archive_entry_ino(entry) > 0xffffffff) {
- archive_set_error(&a->archive, ERANGE, "large inode number truncated");
- ret = ARCHIVE_WARN;
+ format_hex(archive_entry_devmajor(entry), &h.c_devmajor,
+ sizeof(h.c_devmajor));
+ format_hex(archive_entry_devminor(entry), &h.c_devminor,
+ sizeof(h.c_devminor));
+
+ ino = archive_entry_ino64(entry);
+ if (ino > 0xffffffff) {
+ archive_set_error(&a->archive, ERANGE,
+ "large inode number truncated");
+ ret2 = ARCHIVE_WARN;
}
- format_hex(archive_entry_ino(entry) & 0xffffffff, &h.c_ino, sizeof(h.c_ino));
+ format_hex(ino & 0xffffffff, &h.c_ino, sizeof(h.c_ino));
format_hex(archive_entry_mode(entry), &h.c_mode, sizeof(h.c_mode));
format_hex(archive_entry_uid(entry), &h.c_uid, sizeof(h.c_uid));
format_hex(archive_entry_gid(entry), &h.c_gid, sizeof(h.c_gid));
@@ -168,24 +178,26 @@ archive_write_newc_header(struct archive_write *a, struct archive_entry *entry)
ret = (a->compressor.write)(a, path, pathlength);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- pad = 0x3 & - (pathlength + sizeof(struct cpio_header_newc));
+ pad = PAD4(pathlength + sizeof(struct cpio_header_newc));
if (pad)
ret = (a->compressor.write)(a, "\0\0\0", pad);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
cpio->entry_bytes_remaining = archive_entry_size(entry);
- cpio->padding = 3 & (-cpio->entry_bytes_remaining);
+ cpio->padding = PAD4(cpio->entry_bytes_remaining);
/* Write the symlink now. */
if (p != NULL && *p != '\0') {
ret = (a->compressor.write)(a, p, strlen(p));
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- pad = 0x3 & -strlen(p);
+ pad = PAD4(strlen(p));
ret = (a->compressor.write)(a, "\0\0\0", pad);
}
+ if (ret == ARCHIVE_OK)
+ ret = ret2;
return (ret);
}
@@ -234,17 +246,15 @@ format_hex_recursive(int64_t v, char *p, int s)
return (v);
v = format_hex_recursive(v, p+1, s-1);
*p = "0123456789abcdef"[v & 0xf];
- return (v >>= 4);
+ return (v >> 4);
}
static int
archive_write_newc_finish(struct archive_write *a)
{
- struct cpio *cpio;
int er;
struct archive_entry *trailer;
- cpio = (struct cpio *)a->format_data;
trailer = archive_entry_new();
archive_entry_set_nlink(trailer, 1);
archive_entry_set_pathname(trailer, "TRAILER!!!");
@@ -268,10 +278,10 @@ static int
archive_write_newc_finish_entry(struct archive_write *a)
{
struct cpio *cpio;
- int to_write, ret;
+ size_t to_write;
+ int ret;
cpio = (struct cpio *)a->format_data;
- ret = ARCHIVE_OK;
while (cpio->entry_bytes_remaining > 0) {
to_write = cpio->entry_bytes_remaining < a->null_length ?
cpio->entry_bytes_remaining : a->null_length;
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_mtree.c b/archivers/libarchive/files/libarchive/archive_write_set_format_mtree.c
new file mode 100644
index 00000000000..7feeca92e62
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_mtree.c
@@ -0,0 +1,1050 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2008 Joerg Sonnenberger
+ * 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 "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_mtree.c 201171 2009-12-29 06:39:07Z kientzle $");
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_write_private.h"
+
+#include "archive_hash.h"
+
+#define INDENTNAMELEN 15
+#define MAXLINELEN 80
+
+struct mtree_writer {
+ struct archive_entry *entry;
+ struct archive_string ebuf;
+ struct archive_string buf;
+ int first;
+ uint64_t entry_bytes_remaining;
+ struct {
+ int output;
+ int processed;
+ struct archive_string parent;
+ mode_t type;
+ int keys;
+ uid_t uid;
+ gid_t gid;
+ mode_t mode;
+ unsigned long fflags_set;
+ unsigned long fflags_clear;
+ } set;
+ /* chekc sum */
+ int compute_sum;
+ uint32_t crc;
+ uint64_t crc_len;
+#ifdef ARCHIVE_HAS_MD5
+ archive_md5_ctx md5ctx;
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+ archive_rmd160_ctx rmd160ctx;
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+ archive_sha1_ctx sha1ctx;
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+ archive_sha256_ctx sha256ctx;
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+ archive_sha384_ctx sha384ctx;
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+ archive_sha512_ctx sha512ctx;
+#endif
+ /* Keyword options */
+ int keys;
+#define F_CKSUM 0x00000001 /* check sum */
+#define F_DEV 0x00000002 /* device type */
+#define F_DONE 0x00000004 /* directory done */
+#define F_FLAGS 0x00000008 /* file flags */
+#define F_GID 0x00000010 /* gid */
+#define F_GNAME 0x00000020 /* group name */
+#define F_IGN 0x00000040 /* ignore */
+#define F_MAGIC 0x00000080 /* name has magic chars */
+#define F_MD5 0x00000100 /* MD5 digest */
+#define F_MODE 0x00000200 /* mode */
+#define F_NLINK 0x00000400 /* number of links */
+#define F_NOCHANGE 0x00000800 /* If owner/mode "wrong", do
+ * not change */
+#define F_OPT 0x00001000 /* existence optional */
+#define F_RMD160 0x00002000 /* RIPEMD160 digest */
+#define F_SHA1 0x00004000 /* SHA-1 digest */
+#define F_SIZE 0x00008000 /* size */
+#define F_SLINK 0x00010000 /* symbolic link */
+#define F_TAGS 0x00020000 /* tags */
+#define F_TIME 0x00040000 /* modification time */
+#define F_TYPE 0x00080000 /* file type */
+#define F_UID 0x00100000 /* uid */
+#define F_UNAME 0x00200000 /* user name */
+#define F_VISIT 0x00400000 /* file visited */
+#define F_SHA256 0x00800000 /* SHA-256 digest */
+#define F_SHA384 0x01000000 /* SHA-384 digest */
+#define F_SHA512 0x02000000 /* SHA-512 digest */
+
+ /* Options */
+ int dironly; /* if the dironly is 1, ignore everything except
+ * directory type files. like mtree(8) -d option.
+ */
+ int indent; /* if the indent is 1, indent writing data. */
+};
+
+#define DEFAULT_KEYS (F_DEV | F_FLAGS | F_GID | F_GNAME | F_SLINK | F_MODE\
+ | F_NLINK | F_SIZE | F_TIME | F_TYPE | F_UID\
+ | F_UNAME)
+
+#define COMPUTE_CRC(var, ch) (var) = (var) << 8 ^ crctab[(var) >> 24 ^ (ch)]
+static const uint32_t crctab[] = {
+ 0x0,
+ 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
+ 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
+ 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
+ 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,
+ 0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f,
+ 0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a,
+ 0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
+ 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58,
+ 0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033,
+ 0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe,
+ 0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
+ 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4,
+ 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
+ 0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5,
+ 0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
+ 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07,
+ 0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c,
+ 0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,
+ 0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
+ 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b,
+ 0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698,
+ 0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d,
+ 0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
+ 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f,
+ 0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
+ 0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80,
+ 0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
+ 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a,
+ 0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629,
+ 0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c,
+ 0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
+ 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,
+ 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65,
+ 0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8,
+ 0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
+ 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2,
+ 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
+ 0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74,
+ 0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
+ 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21,
+ 0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a,
+ 0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087,
+ 0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
+ 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d,
+ 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce,
+ 0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,
+ 0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
+ 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09,
+ 0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
+ 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf,
+ 0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
+};
+
+static int
+mtree_safe_char(char c)
+{
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
+ return 1;
+ if (c >= '0' && c <= '9')
+ return 1;
+ if (c == 35 || c == 61 || c == 92)
+ return 0; /* #, = and \ are always quoted */
+
+ if (c >= 33 && c <= 47) /* !"$%&'()*+,-./ */
+ return 1;
+ if (c >= 58 && c <= 64) /* :;<>?@ */
+ return 1;
+ if (c >= 91 && c <= 96) /* []^_` */
+ return 1;
+ if (c >= 123 && c <= 126) /* {|}~ */
+ return 1;
+ return 0;
+}
+
+static void
+mtree_quote(struct archive_string *s, const char *str)
+{
+ const char *start;
+ char buf[4];
+ unsigned char c;
+
+ for (start = str; *str != '\0'; ++str) {
+ if (mtree_safe_char(*str))
+ continue;
+ if (start != str)
+ archive_strncat(s, start, str - start);
+ c = (unsigned char)*str;
+ buf[0] = '\\';
+ buf[1] = (c / 64) + '0';
+ buf[2] = (c / 8 % 8) + '0';
+ buf[3] = (c % 8) + '0';
+ archive_strncat(s, buf, 4);
+ start = str + 1;
+ }
+
+ if (start != str)
+ archive_strncat(s, start, str - start);
+}
+
+static void
+mtree_indent(struct mtree_writer *mtree)
+{
+ int i, fn;
+ const char *r, *s, *x;
+
+ fn = 1;
+ s = r = mtree->ebuf.s;
+ x = NULL;
+ while (*r == ' ')
+ r++;
+ while ((r = strchr(r, ' ')) != NULL) {
+ if (fn) {
+ fn = 0;
+ archive_strncat(&mtree->buf, s, r - s);
+ if (r -s > INDENTNAMELEN) {
+ archive_strncat(&mtree->buf, " \\\n", 3);
+ for (i = 0; i < (INDENTNAMELEN + 1); i++)
+ archive_strappend_char(&mtree->buf, ' ');
+ } else {
+ for (i = r -s; i < (INDENTNAMELEN + 1); i++)
+ archive_strappend_char(&mtree->buf, ' ');
+ }
+ s = ++r;
+ x = NULL;
+ continue;
+ }
+ if (r - s <= MAXLINELEN - 3 - INDENTNAMELEN)
+ x = r++;
+ else {
+ if (x == NULL)
+ x = r;
+ archive_strncat(&mtree->buf, s, x - s);
+ archive_strncat(&mtree->buf, " \\\n", 3);
+ for (i = 0; i < (INDENTNAMELEN + 1); i++)
+ archive_strappend_char(&mtree->buf, ' ');
+ s = r = ++x;
+ x = NULL;
+ }
+ }
+ if (x != NULL && strlen(s) > MAXLINELEN - 3 - INDENTNAMELEN) {
+ /* Last keyword is longer. */
+ archive_strncat(&mtree->buf, s, x - s);
+ archive_strncat(&mtree->buf, " \\\n", 3);
+ for (i = 0; i < (INDENTNAMELEN + 1); i++)
+ archive_strappend_char(&mtree->buf, ' ');
+ s = ++x;
+ }
+ archive_strcat(&mtree->buf, s);
+ archive_string_empty(&mtree->ebuf);
+}
+
+#if !defined(_WIN32) || defined(__CYGWIN__)
+static size_t
+dir_len(struct archive_entry *entry)
+{
+ const char *path, *r;
+
+ path = archive_entry_pathname(entry);
+ r = strrchr(path, '/');
+ if (r == NULL)
+ return (0);
+ /* Include a separator size */
+ return (r - path + 1);
+}
+
+#else /* _WIN32 && !__CYGWIN__ */
+/*
+ * Note: We should use wide-character for findng '\' character,
+ * a directory separator on Windows, because some character-set have
+ * been using the '\' character for a part of its multibyte character
+ * code.
+ */
+static size_t
+dir_len(struct archive_entry *entry)
+{
+ wchar_t wc;
+ const char *path;
+ const char *p, *rp;
+ size_t al, l, size;
+
+ path = archive_entry_pathname(entry);
+ al = l = -1;
+ for (p = path; *p != '\0'; ++p) {
+ if (*p == '\\')
+ al = l = p - path;
+ else if (*p == '/')
+ al = p - path;
+ }
+ if (l == -1)
+ goto alen;
+ size = p - path;
+ rp = p = path;
+ while (*p != '\0') {
+ l = mbtowc(&wc, p, size);
+ if (l == -1)
+ goto alen;
+ if (l == 1 && (wc == L'/' || wc == L'\\'))
+ rp = p;
+ p += l;
+ size -= l;
+ }
+ return (rp - path + 1);
+alen:
+ if (al == -1)
+ return (0);
+ return (al + 1);
+}
+#endif /* _WIN32 && !__CYGWIN__ */
+
+static int
+parent_dir_changed(struct archive_string *dir, struct archive_entry *entry)
+{
+ const char *path;
+ size_t l;
+
+ l = dir_len(entry);
+ path = archive_entry_pathname(entry);
+ if (archive_strlen(dir) > 0) {
+ if (l == 0) {
+ archive_string_empty(dir);
+ return (1);
+ }
+ if (strncmp(dir->s, path, l) == 0)
+ return (0); /* The parent directory is the same. */
+ } else if (l == 0)
+ return (0); /* The parent directory is the same. */
+ archive_strncpy(dir, path, l);
+ return (1);
+}
+
+/*
+ * Write /set keyword. It means set global datas.
+ * [directory-only mode]
+ * - It is only once to write /set keyword. It is using values of the
+ * first entry.
+ * [normal mode]
+ * - Write /set keyword. It is using values of the first entry whose
+ * filetype is a regular file.
+ * - When a parent directory of the entry whose filetype is the regular
+ * file is changed, check the global datas and write it again if its
+ * values are different from the entry's.
+ */
+static void
+set_global(struct mtree_writer *mtree, struct archive_entry *entry)
+{
+ struct archive_string setstr;
+ struct archive_string unsetstr;
+ const char *name;
+ int keys, oldkeys, effkeys;
+ mode_t set_type = 0;
+
+ switch (archive_entry_filetype(entry)) {
+ case AE_IFLNK: case AE_IFSOCK: case AE_IFCHR:
+ case AE_IFBLK: case AE_IFIFO:
+ break;
+ case AE_IFDIR:
+ if (mtree->dironly)
+ set_type = AE_IFDIR;
+ break;
+ case AE_IFREG:
+ default: /* Handle unknown file types as regular files. */
+ if (!mtree->dironly)
+ set_type = AE_IFREG;
+ break;
+ }
+ if (set_type == 0)
+ return;
+ if (mtree->set.processed &&
+ !parent_dir_changed(&mtree->set.parent, entry))
+ return;
+ /* At first, save a parent directory of the entry for following
+ * entries. */
+ if (!mtree->set.processed && set_type == AE_IFREG)
+ parent_dir_changed(&mtree->set.parent, entry);
+
+ archive_string_init(&setstr);
+ archive_string_init(&unsetstr);
+ keys = mtree->keys & (F_FLAGS | F_GID | F_GNAME | F_NLINK | F_MODE
+ | F_TYPE | F_UID | F_UNAME);
+ oldkeys = mtree->set.keys;
+ effkeys = keys;
+ if (mtree->set.processed) {
+ /*
+ * Check the global datas for whether it needs updating.
+ */
+ effkeys &= ~F_TYPE;
+ if ((oldkeys & (F_UNAME | F_UID)) != 0 &&
+ mtree->set.uid == archive_entry_uid(entry))
+ effkeys &= ~(F_UNAME | F_UID);
+ if ((oldkeys & (F_GNAME | F_GID)) != 0 &&
+ mtree->set.gid == archive_entry_gid(entry))
+ effkeys &= ~(F_GNAME | F_GID);
+ if ((oldkeys & F_MODE) != 0 &&
+ mtree->set.mode == (archive_entry_mode(entry) & 07777))
+ effkeys &= ~F_MODE;
+ if ((oldkeys & F_FLAGS) != 0) {
+ unsigned long fflags_set;
+ unsigned long fflags_clear;
+
+ archive_entry_fflags(entry, &fflags_set, &fflags_clear);
+ if (fflags_set == mtree->set.fflags_set &&
+ fflags_clear == mtree->set.fflags_clear)
+ effkeys &= ~F_FLAGS;
+ }
+ }
+ if ((keys & effkeys & F_TYPE) != 0) {
+ mtree->set.type = set_type;
+ if (set_type == AE_IFDIR)
+ archive_strcat(&setstr, " type=dir");
+ else
+ archive_strcat(&setstr, " type=file");
+ }
+ if ((keys & effkeys & F_UNAME) != 0) {
+ if ((name = archive_entry_uname(entry)) != NULL) {
+ archive_strcat(&setstr, " uname=");
+ mtree_quote(&setstr, name);
+ } else if ((oldkeys & F_UNAME) != 0)
+ archive_strcat(&unsetstr, " uname");
+ else
+ keys &= ~F_UNAME;
+ }
+ if ((keys & effkeys & F_UID) != 0) {
+ mtree->set.uid = archive_entry_uid(entry);
+ archive_string_sprintf(&setstr, " uid=%jd",
+ (intmax_t)mtree->set.uid);
+ }
+ if ((keys & effkeys & F_GNAME) != 0) {
+ if ((name = archive_entry_gname(entry)) != NULL) {
+ archive_strcat(&setstr, " gname=");
+ mtree_quote(&setstr, name);
+ } else if ((oldkeys & F_GNAME) != 0)
+ archive_strcat(&unsetstr, " gname");
+ else
+ keys &= ~F_GNAME;
+ }
+ if ((keys & effkeys & F_GID) != 0) {
+ mtree->set.gid = archive_entry_gid(entry);
+ archive_string_sprintf(&setstr, " gid=%jd",
+ (intmax_t)mtree->set.gid);
+ }
+ if ((keys & effkeys & F_MODE) != 0) {
+ mtree->set.mode = archive_entry_mode(entry) & 07777;
+ archive_string_sprintf(&setstr, " mode=%o", mtree->set.mode);
+ }
+ if ((keys & effkeys & F_FLAGS) != 0) {
+ if ((name = archive_entry_fflags_text(entry)) != NULL) {
+ archive_strcat(&setstr, " flags=");
+ mtree_quote(&setstr, name);
+ archive_entry_fflags(entry, &mtree->set.fflags_set,
+ &mtree->set.fflags_clear);
+ } else if ((oldkeys & F_FLAGS) != 0)
+ archive_strcat(&unsetstr, " flags");
+ else
+ keys &= ~F_FLAGS;
+ }
+ if (unsetstr.length > 0)
+ archive_string_sprintf(&mtree->buf, "/unset%s\n", unsetstr.s);
+ archive_string_free(&unsetstr);
+ if (setstr.length > 0)
+ archive_string_sprintf(&mtree->buf, "/set%s\n", setstr.s);
+ archive_string_free(&setstr);
+ mtree->set.keys = keys;
+ mtree->set.processed = 1;
+ /* On directory-only mode, it is only once to write /set keyword. */
+ if (mtree->dironly)
+ mtree->set.output = 0;
+}
+
+static int
+get_keys(struct mtree_writer *mtree, struct archive_entry *entry)
+{
+ int keys;
+
+ keys = mtree->keys;
+ if (mtree->set.keys == 0)
+ return (keys);
+ if ((mtree->set.keys & (F_GNAME | F_GID)) != 0 &&
+ mtree->set.gid == archive_entry_gid(entry))
+ keys &= ~(F_GNAME | F_GID);
+ if ((mtree->set.keys & (F_UNAME | F_UID)) != 0 &&
+ mtree->set.uid == archive_entry_uid(entry))
+ keys &= ~(F_UNAME | F_UID);
+ if (mtree->set.keys & F_FLAGS) {
+ unsigned long set, clear;
+
+ archive_entry_fflags(entry, &set, &clear);
+ if (mtree->set.fflags_set == set &&
+ mtree->set.fflags_clear == clear)
+ keys &= ~F_FLAGS;
+ }
+ if ((mtree->set.keys & F_MODE) != 0 &&
+ mtree->set.mode == (archive_entry_mode(entry) & 07777))
+ keys &= ~F_MODE;
+
+ switch (archive_entry_filetype(entry)) {
+ case AE_IFLNK: case AE_IFSOCK: case AE_IFCHR:
+ case AE_IFBLK: case AE_IFIFO:
+ break;
+ case AE_IFDIR:
+ if ((mtree->set.keys & F_TYPE) != 0 &&
+ mtree->set.type == AE_IFDIR)
+ keys &= ~F_TYPE;
+ break;
+ case AE_IFREG:
+ default: /* Handle unknown file types as regular files. */
+ if ((mtree->set.keys & F_TYPE) != 0 &&
+ mtree->set.type == AE_IFREG)
+ keys &= ~F_TYPE;
+ break;
+ }
+
+ return (keys);
+}
+
+static int
+archive_write_mtree_header(struct archive_write *a,
+ struct archive_entry *entry)
+{
+ struct mtree_writer *mtree= a->format_data;
+ struct archive_string *str;
+ const char *path;
+
+ mtree->entry = archive_entry_clone(entry);
+ path = archive_entry_pathname(mtree->entry);
+
+ if (mtree->first) {
+ mtree->first = 0;
+ archive_strcat(&mtree->buf, "#mtree\n");
+ }
+ if (mtree->set.output)
+ set_global(mtree, entry);
+
+ archive_string_empty(&mtree->ebuf);
+ str = (mtree->indent)? &mtree->ebuf : &mtree->buf;
+ if (!mtree->dironly || archive_entry_filetype(entry) == AE_IFDIR)
+ mtree_quote(str, path);
+
+ mtree->entry_bytes_remaining = archive_entry_size(entry);
+ if ((mtree->keys & F_CKSUM) != 0 &&
+ archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->compute_sum |= F_CKSUM;
+ mtree->crc = 0;
+ mtree->crc_len = 0;
+ } else
+ mtree->compute_sum &= ~F_CKSUM;
+#ifdef ARCHIVE_HAS_MD5
+ if ((mtree->keys & F_MD5) != 0 &&
+ archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->compute_sum |= F_MD5;
+ archive_md5_init(&mtree->md5ctx);
+ } else
+ mtree->compute_sum &= ~F_MD5;
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+ if ((mtree->keys & F_RMD160) != 0 &&
+ archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->compute_sum |= F_RMD160;
+ archive_rmd160_init(&mtree->rmd160ctx);
+ } else
+ mtree->compute_sum &= ~F_RMD160;
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+ if ((mtree->keys & F_SHA1) != 0 &&
+ archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->compute_sum |= F_SHA1;
+ archive_sha1_init(&mtree->sha1ctx);
+ } else
+ mtree->compute_sum &= ~F_SHA1;
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+ if ((mtree->keys & F_SHA256) != 0 &&
+ archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->compute_sum |= F_SHA256;
+ archive_sha256_init(&mtree->sha256ctx);
+ } else
+ mtree->compute_sum &= ~F_SHA256;
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+ if ((mtree->keys & F_SHA384) != 0 &&
+ archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->compute_sum |= F_SHA384;
+ archive_sha384_init(&mtree->sha384ctx);
+ } else
+ mtree->compute_sum &= ~F_SHA384;
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+ if ((mtree->keys & F_SHA512) != 0 &&
+ archive_entry_filetype(entry) == AE_IFREG) {
+ mtree->compute_sum |= F_SHA512;
+ archive_sha512_init(&mtree->sha512ctx);
+ } else
+ mtree->compute_sum &= ~F_SHA512;
+#endif
+
+ return (ARCHIVE_OK);
+}
+
+#if defined(ARCHIVE_HAS_MD5) || defined(ARCHIVE_HAS_RMD160) || \
+ defined(ARCHIVE_HAS_SHA1) || defined(ARCHIVE_HAS_SHA256) || \
+ defined(ARCHIVE_HAS_SHA384) || defined(ARCHIVE_HAS_SHA512)
+static void
+strappend_bin(struct archive_string *s, const unsigned char *bin, int n)
+{
+ static const char hex[] = "0123456789abcdef";
+ int i;
+
+ for (i = 0; i < n; i++) {
+ archive_strappend_char(s, hex[bin[i] >> 4]);
+ archive_strappend_char(s, hex[bin[i] & 0x0f]);
+ }
+}
+#endif
+
+static int
+archive_write_mtree_finish_entry(struct archive_write *a)
+{
+ struct mtree_writer *mtree = a->format_data;
+ struct archive_entry *entry;
+ struct archive_string *str;
+ const char *name;
+ int keys, ret;
+
+ entry = mtree->entry;
+ if (entry == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+ "Finished entry without being open first.");
+ return (ARCHIVE_FATAL);
+ }
+ mtree->entry = NULL;
+
+ if (mtree->dironly && archive_entry_filetype(entry) != AE_IFDIR) {
+ archive_entry_free(entry);
+ return (ARCHIVE_OK);
+ }
+
+ str = (mtree->indent)? &mtree->ebuf : &mtree->buf;
+ keys = get_keys(mtree, entry);
+ if ((keys & F_NLINK) != 0 &&
+ archive_entry_nlink(entry) != 1 &&
+ archive_entry_filetype(entry) != AE_IFDIR)
+ archive_string_sprintf(str,
+ " nlink=%u", archive_entry_nlink(entry));
+
+ if ((keys & F_GNAME) != 0 &&
+ (name = archive_entry_gname(entry)) != NULL) {
+ archive_strcat(str, " gname=");
+ mtree_quote(str, name);
+ }
+ if ((keys & F_UNAME) != 0 &&
+ (name = archive_entry_uname(entry)) != NULL) {
+ archive_strcat(str, " uname=");
+ mtree_quote(str, name);
+ }
+ if ((keys & F_FLAGS) != 0 &&
+ (name = archive_entry_fflags_text(entry)) != NULL) {
+ archive_strcat(str, " flags=");
+ mtree_quote(str, name);
+ }
+ if ((keys & F_TIME) != 0)
+ archive_string_sprintf(str, " time=%jd.%jd",
+ (intmax_t)archive_entry_mtime(entry),
+ (intmax_t)archive_entry_mtime_nsec(entry));
+ if ((keys & F_MODE) != 0)
+ archive_string_sprintf(str, " mode=%o",
+ archive_entry_mode(entry) & 07777);
+ if ((keys & F_GID) != 0)
+ archive_string_sprintf(str, " gid=%jd",
+ (intmax_t)archive_entry_gid(entry));
+ if ((keys & F_UID) != 0)
+ archive_string_sprintf(str, " uid=%jd",
+ (intmax_t)archive_entry_uid(entry));
+
+ switch (archive_entry_filetype(entry)) {
+ case AE_IFLNK:
+ if ((keys & F_TYPE) != 0)
+ archive_strcat(str, " type=link");
+ if ((keys & F_SLINK) != 0) {
+ archive_strcat(str, " link=");
+ mtree_quote(str, archive_entry_symlink(entry));
+ }
+ break;
+ case AE_IFSOCK:
+ if ((keys & F_TYPE) != 0)
+ archive_strcat(str, " type=socket");
+ break;
+ case AE_IFCHR:
+ if ((keys & F_TYPE) != 0)
+ archive_strcat(str, " type=char");
+ if ((keys & F_DEV) != 0) {
+ archive_string_sprintf(str,
+ " device=native,%d,%d",
+ archive_entry_rdevmajor(entry),
+ archive_entry_rdevminor(entry));
+ }
+ break;
+ case AE_IFBLK:
+ if ((keys & F_TYPE) != 0)
+ archive_strcat(str, " type=block");
+ if ((keys & F_DEV) != 0) {
+ archive_string_sprintf(str,
+ " device=native,%d,%d",
+ archive_entry_rdevmajor(entry),
+ archive_entry_rdevminor(entry));
+ }
+ break;
+ case AE_IFDIR:
+ if ((keys & F_TYPE) != 0)
+ archive_strcat(str, " type=dir");
+ break;
+ case AE_IFIFO:
+ if ((keys & F_TYPE) != 0)
+ archive_strcat(str, " type=fifo");
+ break;
+ case AE_IFREG:
+ default: /* Handle unknown file types as regular files. */
+ if ((keys & F_TYPE) != 0)
+ archive_strcat(str, " type=file");
+ if ((keys & F_SIZE) != 0)
+ archive_string_sprintf(str, " size=%jd",
+ (intmax_t)archive_entry_size(entry));
+ break;
+ }
+
+ if (mtree->compute_sum & F_CKSUM) {
+ uint64_t len;
+ /* Include the length of the file. */
+ for (len = mtree->crc_len; len != 0; len >>= 8)
+ COMPUTE_CRC(mtree->crc, len & 0xff);
+ mtree->crc = ~mtree->crc;
+ archive_string_sprintf(str, " cksum=%ju",
+ (uintmax_t)mtree->crc);
+ }
+#ifdef ARCHIVE_HAS_MD5
+ if (mtree->compute_sum & F_MD5) {
+ unsigned char buf[16];
+
+ archive_md5_final(&mtree->md5ctx, buf);
+ archive_strcat(str, " md5digest=");
+ strappend_bin(str, buf, sizeof(buf));
+ }
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+ if (mtree->compute_sum & F_RMD160) {
+ unsigned char buf[20];
+
+ archive_rmd160_final(&mtree->rmd160ctx, buf);
+ archive_strcat(str, " rmd160digest=");
+ strappend_bin(str, buf, sizeof(buf));
+ }
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+ if (mtree->compute_sum & F_SHA1) {
+ unsigned char buf[20];
+
+ archive_sha1_final(&mtree->sha1ctx, buf);
+ archive_strcat(str, " sha1digest=");
+ strappend_bin(str, buf, sizeof(buf));
+ }
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+ if (mtree->compute_sum & F_SHA256) {
+ unsigned char buf[32];
+
+ archive_sha256_final(&mtree->sha256ctx, buf);
+ archive_strcat(str, " sha256digest=");
+ strappend_bin(str, buf, sizeof(buf));
+ }
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+ if (mtree->compute_sum & F_SHA384) {
+ unsigned char buf[48];
+
+ archive_sha384_final(&mtree->sha384ctx, buf);
+ archive_strcat(str, " sha384digest=");
+ strappend_bin(str, buf, sizeof(buf));
+ }
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+ if (mtree->compute_sum & F_SHA512) {
+ unsigned char buf[64];
+
+ archive_sha512_final(&mtree->sha512ctx, buf);
+ archive_strcat(str, " sha512digest=");
+ strappend_bin(str, buf, sizeof(buf));
+ }
+#endif
+ archive_strcat(str, "\n");
+ if (mtree->indent)
+ mtree_indent(mtree);
+
+ archive_entry_free(entry);
+
+ if (mtree->buf.length > 32768) {
+ ret = (a->compressor.write)(a, mtree->buf.s, mtree->buf.length);
+ archive_string_empty(&mtree->buf);
+ } else
+ ret = ARCHIVE_OK;
+
+ return (ret == ARCHIVE_OK ? ret : ARCHIVE_FATAL);
+}
+
+static int
+archive_write_mtree_finish(struct archive_write *a)
+{
+ struct mtree_writer *mtree= a->format_data;
+
+ archive_write_set_bytes_in_last_block(&a->archive, 1);
+
+ return (a->compressor.write)(a, mtree->buf.s, mtree->buf.length);
+}
+
+static ssize_t
+archive_write_mtree_data(struct archive_write *a, const void *buff, size_t n)
+{
+ struct mtree_writer *mtree= a->format_data;
+
+ if (n > mtree->entry_bytes_remaining)
+ n = mtree->entry_bytes_remaining;
+ if (mtree->dironly)
+ /* We don't need compute a regular file sum */
+ return (n);
+ if (mtree->compute_sum & F_CKSUM) {
+ /*
+ * Compute a POSIX 1003.2 checksum
+ */
+ const unsigned char *p;
+ size_t nn;
+
+ for (nn = n, p = buff; nn--; ++p)
+ COMPUTE_CRC(mtree->crc, *p);
+ mtree->crc_len += n;
+ }
+#ifdef ARCHIVE_HAS_MD5
+ if (mtree->compute_sum & F_MD5)
+ archive_md5_update(&mtree->md5ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_RMD160
+ if (mtree->compute_sum & F_RMD160)
+ archive_rmd160_update(&mtree->rmd160ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA1
+ if (mtree->compute_sum & F_SHA1)
+ archive_sha1_update(&mtree->sha1ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA256
+ if (mtree->compute_sum & F_SHA256)
+ archive_sha256_update(&mtree->sha256ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA384
+ if (mtree->compute_sum & F_SHA384)
+ archive_sha384_update(&mtree->sha384ctx, buff, n);
+#endif
+#ifdef ARCHIVE_HAS_SHA512
+ if (mtree->compute_sum & F_SHA512)
+ archive_sha512_update(&mtree->sha512ctx, buff, n);
+#endif
+ return (n);
+}
+
+static int
+archive_write_mtree_destroy(struct archive_write *a)
+{
+ struct mtree_writer *mtree= a->format_data;
+
+ if (mtree == NULL)
+ return (ARCHIVE_OK);
+
+ archive_entry_free(mtree->entry);
+ archive_string_free(&mtree->ebuf);
+ archive_string_free(&mtree->buf);
+ archive_string_free(&mtree->set.parent);
+ free(mtree);
+ a->format_data = NULL;
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_mtree_options(struct archive_write *a, const char *key,
+ const char *value)
+{
+ struct mtree_writer *mtree= a->format_data;
+ int keybit = 0;
+
+ switch (key[0]) {
+ case 'a':
+ if (strcmp(key, "all") == 0)
+ keybit = ~0;
+ break;
+ case 'c':
+ if (strcmp(key, "cksum") == 0)
+ keybit = F_CKSUM;
+ break;
+ case 'd':
+ if (strcmp(key, "device") == 0)
+ keybit = F_DEV;
+ else if (strcmp(key, "dironly") == 0) {
+ mtree->dironly = (value != NULL)? 1: 0;
+ return (ARCHIVE_OK);
+ }
+ break;
+ case 'f':
+ if (strcmp(key, "flags") == 0)
+ keybit = F_FLAGS;
+ break;
+ case 'g':
+ if (strcmp(key, "gid") == 0)
+ keybit = F_GID;
+ else if (strcmp(key, "gname") == 0)
+ keybit = F_GNAME;
+ break;
+ case 'i':
+ if (strcmp(key, "indent") == 0) {
+ mtree->indent = (value != NULL)? 1: 0;
+ return (ARCHIVE_OK);
+ }
+ break;
+ case 'l':
+ if (strcmp(key, "link") == 0)
+ keybit = F_SLINK;
+ break;
+ case 'm':
+ if (strcmp(key, "md5") == 0 ||
+ strcmp(key, "md5digest") == 0)
+ keybit = F_MD5;
+ if (strcmp(key, "mode") == 0)
+ keybit = F_MODE;
+ break;
+ case 'n':
+ if (strcmp(key, "nlink") == 0)
+ keybit = F_NLINK;
+ break;
+ case 'r':
+ if (strcmp(key, "ripemd160digest") == 0 ||
+ strcmp(key, "rmd160") == 0 ||
+ strcmp(key, "rmd160digest") == 0)
+ keybit = F_RMD160;
+ break;
+ case 's':
+ if (strcmp(key, "sha1") == 0 ||
+ strcmp(key, "sha1digest") == 0)
+ keybit = F_SHA1;
+ if (strcmp(key, "sha256") == 0 ||
+ strcmp(key, "sha256digest") == 0)
+ keybit = F_SHA256;
+ if (strcmp(key, "sha384") == 0 ||
+ strcmp(key, "sha384digest") == 0)
+ keybit = F_SHA384;
+ if (strcmp(key, "sha512") == 0 ||
+ strcmp(key, "sha512digest") == 0)
+ keybit = F_SHA512;
+ if (strcmp(key, "size") == 0)
+ keybit = F_SIZE;
+ break;
+ case 't':
+ if (strcmp(key, "time") == 0)
+ keybit = F_TIME;
+ else if (strcmp(key, "type") == 0)
+ keybit = F_TYPE;
+ break;
+ case 'u':
+ if (strcmp(key, "uid") == 0)
+ keybit = F_UID;
+ else if (strcmp(key, "uname") == 0)
+ keybit = F_UNAME;
+ else if (strcmp(key, "use-set") == 0) {
+ mtree->set.output = (value != NULL)? 1: 0;
+ return (ARCHIVE_OK);
+ }
+ break;
+ }
+ if (keybit != 0) {
+ if (value != NULL)
+ mtree->keys |= keybit;
+ else
+ mtree->keys &= ~keybit;
+ return (ARCHIVE_OK);
+ }
+
+ return (ARCHIVE_WARN);
+}
+
+int
+archive_write_set_format_mtree(struct archive *_a)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ struct mtree_writer *mtree;
+
+ if (a->format_destroy != NULL)
+ (a->format_destroy)(a);
+
+ if ((mtree = malloc(sizeof(*mtree))) == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate mtree data");
+ return (ARCHIVE_FATAL);
+ }
+
+ mtree->entry = NULL;
+ mtree->first = 1;
+ memset(&(mtree->set), 0, sizeof(mtree->set));
+ archive_string_init(&mtree->set.parent);
+ mtree->keys = DEFAULT_KEYS;
+ mtree->dironly = 0;
+ mtree->indent = 0;
+ archive_string_init(&mtree->ebuf);
+ archive_string_init(&mtree->buf);
+ a->format_data = mtree;
+ a->format_destroy = archive_write_mtree_destroy;
+
+ a->pad_uncompressed = 0;
+ a->format_name = "mtree";
+ a->format_options = archive_write_mtree_options;
+ a->format_write_header = archive_write_mtree_header;
+ a->format_finish = archive_write_mtree_finish;
+ a->format_write_data = archive_write_mtree_data;
+ a->format_finish_entry = archive_write_mtree_finish_entry;
+ a->archive.archive_format = ARCHIVE_FORMAT_MTREE;
+ a->archive.archive_format_name = "mtree";
+
+ return (ARCHIVE_OK);
+}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c
index 3e294cdf0a8..00c3f3f08cc 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_pax.c,v 1.47 2008/05/26 17:00:23 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_pax.c 201162 2009-12-29 05:47:46Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -111,6 +111,7 @@ archive_write_set_format_pax(struct archive *_a)
a->format_data = pax;
a->pad_uncompressed = 1;
+ a->format_name = "pax";
a->format_write_header = archive_write_pax_header;
a->format_write_data = archive_write_pax_data;
a->format_finish = archive_write_pax_finish;
@@ -203,6 +204,16 @@ utf8_encode(const wchar_t *wval)
utf8len = 0;
for (wp = wval; *wp != L'\0'; ) {
wc = *wp++;
+
+ if (wc >= 0xd800 && wc <= 0xdbff
+ && *wp >= 0xdc00 && *wp <= 0xdfff) {
+ /* This is a surrogate pair. Combine into a
+ * full Unicode value before encoding into
+ * UTF-8. */
+ wc = (wc - 0xd800) << 10; /* High 10 bits */
+ wc += (*wp++ - 0xdc00); /* Low 10 bits */
+ wc += 0x10000; /* Skip BMP */
+ }
if (wc <= 0x7f)
utf8len++;
else if (wc <= 0x7ff)
@@ -226,6 +237,12 @@ utf8_encode(const wchar_t *wval)
for (wp = wval, p = utf8_value; *wp != L'\0'; ) {
wc = *wp++;
+ if (wc >= 0xd800 && wc <= 0xdbff
+ && *wp >= 0xdc00 && *wp <= 0xdfff) {
+ /* Combine surrogate pair. */
+ wc = (wc - 0xd800) << 10;
+ wc += *wp++ - 0xdc00 + 0x10000;
+ }
if (wc <= 0x7f) {
*p++ = (char)wc;
} else if (wc <= 0x7ff) {
@@ -290,7 +307,7 @@ add_pax_attr(struct archive_string *as, const char *key, const char *value)
* PAX attributes have the following layout:
* <len> <space> <key> <=> <value> <nl>
*/
- len = 1 + strlen(key) + 1 + strlen(value) + 1;
+ len = 1 + (int)strlen(key) + 1 + (int)strlen(value) + 1;
/*
* The <len> field includes the length of the <len> field, so
@@ -345,7 +362,7 @@ archive_write_pax_header_xattrs(struct pax *pax, struct archive_entry *entry)
url_encoded_name = url_encode(name);
if (url_encoded_name != NULL) {
/* Convert narrow-character to wide-character. */
- int wcs_length = strlen(url_encoded_name);
+ size_t wcs_length = strlen(url_encoded_name);
wcs_name = (wchar_t *)malloc((wcs_length + 1) * sizeof(wchar_t));
if (wcs_name == NULL)
__archive_errx(1, "No memory for xattr conversion");
@@ -435,8 +452,14 @@ archive_write_pax_header(struct archive_write *a,
free(t);
}
break;
+ case AE_IFSOCK:
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "tar format cannot archive socket");
+ return (ARCHIVE_WARN);
default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
"tar format cannot archive this (type=0%lo)",
(unsigned long)archive_entry_filetype(entry_original));
return (ARCHIVE_WARN);
@@ -456,7 +479,7 @@ archive_write_pax_header(struct archive_write *a,
path = archive_entry_pathname(entry_main);
path_w = archive_entry_pathname_w(entry_main);
if (path != NULL && path_w == NULL) {
- archive_set_error(&a->archive, EILSEQ,
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Can't translate pathname '%s' to UTF-8", path);
ret = ARCHIVE_WARN;
hdrcharset = "BINARY";
@@ -464,7 +487,7 @@ archive_write_pax_header(struct archive_write *a,
uname = archive_entry_uname(entry_main);
uname_w = archive_entry_uname_w(entry_main);
if (uname != NULL && uname_w == NULL) {
- archive_set_error(&a->archive, EILSEQ,
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Can't translate uname '%s' to UTF-8", uname);
ret = ARCHIVE_WARN;
hdrcharset = "BINARY";
@@ -472,7 +495,7 @@ archive_write_pax_header(struct archive_write *a,
gname = archive_entry_gname(entry_main);
gname_w = archive_entry_gname_w(entry_main);
if (gname != NULL && gname_w == NULL) {
- archive_set_error(&a->archive, EILSEQ,
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Can't translate gname '%s' to UTF-8", gname);
ret = ARCHIVE_WARN;
hdrcharset = "BINARY";
@@ -486,7 +509,7 @@ archive_write_pax_header(struct archive_write *a,
linkpath_w = archive_entry_symlink_w(entry_main);
}
if (linkpath != NULL && linkpath_w == NULL) {
- archive_set_error(&a->archive, EILSEQ,
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Can't translate linkpath '%s' to UTF-8", linkpath);
ret = ARCHIVE_WARN;
hdrcharset = "BINARY";
@@ -602,7 +625,7 @@ archive_write_pax_header(struct archive_write *a,
}
/* If numeric GID is too large, add 'gid' to pax extended attrs. */
- if (archive_entry_gid(entry_main) >= (1 << 18)) {
+ if ((unsigned int)archive_entry_gid(entry_main) >= (1 << 18)) {
add_pax_attr_int(&(pax->pax_header), "gid",
archive_entry_gid(entry_main));
need_extension = 1;
@@ -627,7 +650,7 @@ archive_write_pax_header(struct archive_write *a,
}
/* If numeric UID is too large, add 'uid' to pax extended attrs. */
- if (archive_entry_uid(entry_main) >= (1 << 18)) {
+ if ((unsigned int)archive_entry_uid(entry_main) >= (1 << 18)) {
add_pax_attr_int(&(pax->pax_header), "uid",
archive_entry_uid(entry_main));
need_extension = 1;
@@ -762,6 +785,15 @@ archive_write_pax_header(struct archive_write *a,
archive_entry_atime(entry_main),
archive_entry_atime_nsec(entry_main));
+ /* Store birth/creationtime only if it's earlier than mtime */
+ if (archive_entry_birthtime_is_set(entry_main) &&
+ archive_entry_birthtime(entry_main)
+ < archive_entry_mtime(entry_main))
+ add_pax_attr_time(&(pax->pax_header),
+ "LIBARCHIVE.creationtime",
+ archive_entry_birthtime(entry_main),
+ archive_entry_birthtime_nsec(entry_main));
+
/* I use a star-compatible file flag attribute. */
p = archive_entry_fflags_text(entry_main);
if (p != NULL && *p != '\0')
@@ -787,7 +819,7 @@ archive_write_pax_header(struct archive_write *a,
add_pax_attr_int(&(pax->pax_header), "SCHILY.dev",
archive_entry_dev(entry_main));
add_pax_attr_int(&(pax->pax_header), "SCHILY.ino",
- archive_entry_ino(entry_main));
+ archive_entry_ino64(entry_main));
add_pax_attr_int(&(pax->pax_header), "SCHILY.nlink",
archive_entry_nlink(entry_main));
@@ -855,7 +887,6 @@ archive_write_pax_header(struct archive_write *a,
uid_t uid;
gid_t gid;
mode_t mode;
- long ns;
pax_attr_entry = archive_entry_new();
p = archive_entry_pathname(entry_main);
@@ -865,12 +896,12 @@ archive_write_pax_header(struct archive_write *a,
archive_strlen(&(pax->pax_header)));
/* Copy uid/gid (but clip to ustar limits). */
uid = archive_entry_uid(entry_main);
- if (uid >= 1 << 18)
- uid = (1 << 18) - 1;
+ if ((unsigned int)uid >= 1 << 18)
+ uid = (uid_t)(1 << 18) - 1;
archive_entry_set_uid(pax_attr_entry, uid);
gid = archive_entry_gid(entry_main);
- if (gid >= 1 << 18)
- gid = (1 << 18) - 1;
+ if ((unsigned int)gid >= 1 << 18)
+ gid = (gid_t)(1 << 18) - 1;
archive_entry_set_gid(pax_attr_entry, gid);
/* Copy mode over (but not setuid/setgid bits) */
mode = archive_entry_mode(entry_main);
@@ -893,17 +924,12 @@ archive_write_pax_header(struct archive_write *a,
/* Copy mtime, but clip to ustar limits. */
s = archive_entry_mtime(entry_main);
- ns = archive_entry_mtime_nsec(entry_main);
- if (s < 0) { s = 0; ns = 0; }
- if (s > 0x7fffffff) { s = 0x7fffffff; ns = 0; }
- archive_entry_set_mtime(pax_attr_entry, s, ns);
-
- /* Ditto for atime. */
- s = archive_entry_atime(entry_main);
- ns = archive_entry_atime_nsec(entry_main);
- if (s < 0) { s = 0; ns = 0; }
- if (s > 0x7fffffff) { s = 0x7fffffff; ns = 0; }
- archive_entry_set_atime(pax_attr_entry, s, ns);
+ if (s < 0) { s = 0; }
+ if (s >= 0x7fffffff) { s = 0x7fffffff; }
+ archive_entry_set_mtime(pax_attr_entry, s, 0);
+
+ /* Standard ustar doesn't support atime. */
+ archive_entry_set_atime(pax_attr_entry, 0, 0);
/* Standard ustar doesn't support ctime. */
archive_entry_set_ctime(pax_attr_entry, 0, 0);
@@ -917,7 +943,8 @@ archive_write_pax_header(struct archive_write *a,
if (r != 0) {
const char *msg = "archive_write_pax_header: "
"'x' header failed?! This can't happen.\n";
- write(2, msg, strlen(msg));
+ size_t u = write(2, msg, strlen(msg));
+ (void)u; /* UNUSED */
exit(1);
}
r = (a->compressor.write)(a, paxbuff, 512);
@@ -998,7 +1025,7 @@ build_ustar_entry_name(char *dest, const char *src, size_t src_length,
char *p;
int need_slash = 0; /* Was there a trailing slash? */
size_t suffix_length = 99;
- int insert_length;
+ size_t insert_length;
/* Length of additional dir element to be added. */
if (insert == NULL)
@@ -1092,7 +1119,7 @@ build_ustar_entry_name(char *dest, const char *src, size_t src_length,
p += filename_end - filename;
if (need_slash)
*p++ = '/';
- *p++ = '\0';
+ *p = '\0';
return (dest);
}
@@ -1183,13 +1210,11 @@ build_pax_attribute_name(char *dest, const char *src)
static int
archive_write_pax_finish(struct archive_write *a)
{
- struct pax *pax;
int r;
if (a->compressor.write == NULL)
return (ARCHIVE_OK);
- pax = (struct pax *)a->format_data;
r = write_nulls(a, 512 * 2);
return (r);
}
@@ -1200,6 +1225,9 @@ archive_write_pax_destroy(struct archive_write *a)
struct pax *pax;
pax = (struct pax *)a->format_data;
+ if (pax == NULL)
+ return (ARCHIVE_OK);
+
archive_string_free(&pax->pax_header);
free(pax);
a->format_data = NULL;
@@ -1221,7 +1249,8 @@ archive_write_pax_finish_entry(struct archive_write *a)
static int
write_nulls(struct archive_write *a, size_t padding)
{
- int ret, to_write;
+ int ret;
+ size_t to_write;
while (padding > 0) {
to_write = padding < a->null_length ? padding : a->null_length;
@@ -1352,6 +1381,6 @@ base64_encode(const char *s, size_t len)
break;
}
/* Add trailing NUL character so output is a valid C string. */
- *d++ = '\0';
+ *d = '\0';
return (out);
}
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c
index b5d16e09d13..62a875b98d3 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_shar.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2008 Joerg Sonnenberger
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,12 +25,11 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_shar.c,v 1.19 2008/03/15 11:04:45 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_shar.c 189438 2009-03-06 05:58:56Z kientzle $");
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
-#include <stdarg.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@ -49,13 +49,14 @@ struct shar {
struct archive_entry *entry;
int has_data;
char *last_dir;
- char outbuff[1024];
- size_t outbytes;
+
+ /* Line buffer for uuencoded dump format */
+ char outbuff[45];
size_t outpos;
- int uuavail;
- char uubuffer[3];
+
int wrote_header;
struct archive_string work;
+ struct archive_string quoted_name;
};
static int archive_write_shar_finish(struct archive_write *);
@@ -67,23 +68,33 @@ static ssize_t archive_write_shar_data_sed(struct archive_write *,
static ssize_t archive_write_shar_data_uuencode(struct archive_write *,
const void * buff, size_t);
static int archive_write_shar_finish_entry(struct archive_write *);
-static int shar_printf(struct archive_write *, const char *fmt, ...);
-static void uuencode_group(struct shar *);
-static int
-shar_printf(struct archive_write *a, const char *fmt, ...)
+/*
+ * Copy the given string to the buffer, quoting all shell meta characters
+ * found.
+ */
+static void
+shar_quote(struct archive_string *buf, const char *str, int in_shell)
{
- struct shar *shar;
- va_list ap;
- int ret;
-
- shar = (struct shar *)a->format_data;
- va_start(ap, fmt);
- archive_string_empty(&(shar->work));
- archive_string_vsprintf(&(shar->work), fmt, ap);
- ret = ((a->compressor.write)(a, shar->work.s, strlen(shar->work.s)));
- va_end(ap);
- return (ret);
+ static const char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";
+ size_t len;
+
+ while (*str != '\0') {
+ if ((len = strcspn(str, meta)) != 0) {
+ archive_strncat(buf, str, len);
+ str += len;
+ } else if (*str == '\n') {
+ if (in_shell)
+ archive_strcat(buf, "\"\n\"");
+ else
+ archive_strcat(buf, "\\n");
+ ++str;
+ } else {
+ archive_strappend_char(buf, '\\');
+ archive_strappend_char(buf, *str);
+ ++str;
+ }
+ }
}
/*
@@ -105,9 +116,12 @@ archive_write_set_format_shar(struct archive *_a)
return (ARCHIVE_FATAL);
}
memset(shar, 0, sizeof(*shar));
+ archive_string_init(&shar->work);
+ archive_string_init(&shar->quoted_name);
a->format_data = shar;
a->pad_uncompressed = 0;
+ a->format_name = "shar";
a->format_write_header = archive_write_shar_header;
a->format_finish = archive_write_shar_finish;
a->format_destroy = archive_write_shar_destroy;
@@ -146,16 +160,11 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
const char *name;
char *p, *pp;
struct shar *shar;
- int ret;
shar = (struct shar *)a->format_data;
if (!shar->wrote_header) {
- ret = shar_printf(a, "#!/bin/sh\n");
- if (ret != ARCHIVE_OK)
- return (ret);
- ret = shar_printf(a, "# This is a shell archive\n");
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_strcat(&shar->work, "#!/bin/sh\n");
+ archive_strcat(&shar->work, "# This is a shell archive\n");
shar->wrote_header = 1;
}
@@ -192,10 +201,11 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
}
}
+ archive_string_empty(&shar->quoted_name);
+ shar_quote(&shar->quoted_name, name, 1);
+
/* Stock preparation for all file types. */
- ret = shar_printf(a, "echo x %s\n", name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_string_sprintf(&shar->work, "echo x %s\n", shar->quoted_name.s);
if (archive_entry_filetype(entry) != AE_IFDIR) {
/* Try to create the dir. */
@@ -210,12 +220,10 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
/* Don't try to "mkdir ." */
free(p);
} else if (shar->last_dir == NULL) {
- ret = shar_printf(a,
- "mkdir -p %s > /dev/null 2>&1\n", p);
- if (ret != ARCHIVE_OK) {
- free(p);
- return (ret);
- }
+ archive_strcat(&shar->work, "mkdir -p ");
+ shar_quote(&shar->work, p, 1);
+ archive_strcat(&shar->work,
+ " > /dev/null 2>&1\n");
shar->last_dir = p;
} else if (strcmp(p, shar->last_dir) == 0) {
/* We've already created this exact dir. */
@@ -225,13 +233,10 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
/* We've already created a subdir. */
free(p);
} else {
- ret = shar_printf(a,
- "mkdir -p %s > /dev/null 2>&1\n", p);
- if (ret != ARCHIVE_OK) {
- free(p);
- return (ret);
- }
- free(shar->last_dir);
+ archive_strcat(&shar->work, "mkdir -p ");
+ shar_quote(&shar->work, p, 1);
+ archive_strcat(&shar->work,
+ " > /dev/null 2>&1\n");
shar->last_dir = p;
}
} else {
@@ -242,51 +247,47 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
/* Handle file-type specific issues. */
shar->has_data = 0;
if ((linkname = archive_entry_hardlink(entry)) != NULL) {
- ret = shar_printf(a, "ln -f %s %s\n", linkname, name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_strcat(&shar->work, "ln -f ");
+ shar_quote(&shar->work, linkname, 1);
+ archive_string_sprintf(&shar->work, " %s\n",
+ shar->quoted_name.s);
} else if ((linkname = archive_entry_symlink(entry)) != NULL) {
- ret = shar_printf(a, "ln -fs %s %s\n", linkname, name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_strcat(&shar->work, "ln -fs ");
+ shar_quote(&shar->work, linkname, 1);
+ archive_string_sprintf(&shar->work, " %s\n",
+ shar->quoted_name.s);
} else {
switch(archive_entry_filetype(entry)) {
case AE_IFREG:
if (archive_entry_size(entry) == 0) {
/* More portable than "touch." */
- ret = shar_printf(a, "test -e \"%s\" || :> \"%s\"\n", name, name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_string_sprintf(&shar->work,
+ "test -e \"%s\" || :> \"%s\"\n",
+ shar->quoted_name.s, shar->quoted_name.s);
} else {
if (shar->dump) {
- ret = shar_printf(a,
- "uudecode -o %s << 'SHAR_END'\n",
- name);
- if (ret != ARCHIVE_OK)
- return (ret);
- ret = shar_printf(a, "begin %o %s\n",
- archive_entry_mode(entry) & 0777,
- name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_string_sprintf(&shar->work,
+ "uudecode -p > %s << 'SHAR_END'\n",
+ shar->quoted_name.s);
+ archive_string_sprintf(&shar->work,
+ "begin %o ",
+ archive_entry_mode(entry) & 0777);
+ shar_quote(&shar->work, name, 0);
+ archive_strcat(&shar->work, "\n");
} else {
- ret = shar_printf(a,
+ archive_string_sprintf(&shar->work,
"sed 's/^X//' > %s << 'SHAR_END'\n",
- name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ shar->quoted_name.s);
}
shar->has_data = 1;
shar->end_of_line = 1;
shar->outpos = 0;
- shar->outbytes = 0;
}
break;
case AE_IFDIR:
- ret = shar_printf(a, "mkdir -p %s > /dev/null 2>&1\n",
- name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_string_sprintf(&shar->work,
+ "mkdir -p %s > /dev/null 2>&1\n",
+ shar->quoted_name.s);
/* Record that we just created this directory. */
if (shar->last_dir != NULL)
free(shar->last_dir);
@@ -302,23 +303,20 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
*/
break;
case AE_IFIFO:
- ret = shar_printf(a, "mkfifo %s\n", name);
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_string_sprintf(&shar->work,
+ "mkfifo %s\n", shar->quoted_name.s);
break;
case AE_IFCHR:
- ret = shar_printf(a, "mknod %s c %d %d\n", name,
+ archive_string_sprintf(&shar->work,
+ "mknod %s c %d %d\n", shar->quoted_name.s,
archive_entry_rdevmajor(entry),
archive_entry_rdevminor(entry));
- if (ret != ARCHIVE_OK)
- return (ret);
break;
case AE_IFBLK:
- ret = shar_printf(a, "mknod %s b %d %d\n", name,
+ archive_string_sprintf(&shar->work,
+ "mknod %s b %d %d\n", shar->quoted_name.s,
archive_entry_rdevmajor(entry),
archive_entry_rdevminor(entry));
- if (ret != ARCHIVE_OK)
- return (ret);
break;
default:
return (ARCHIVE_WARN);
@@ -328,69 +326,119 @@ archive_write_shar_header(struct archive_write *a, struct archive_entry *entry)
return (ARCHIVE_OK);
}
-/* XXX TODO: This could be more efficient XXX */
static ssize_t
archive_write_shar_data_sed(struct archive_write *a, const void *buff, size_t n)
{
+ static const size_t ensured = 65533;
struct shar *shar;
const char *src;
+ char *buf, *buf_end;
int ret;
size_t written = n;
shar = (struct shar *)a->format_data;
- if (!shar->has_data)
+ if (!shar->has_data || n == 0)
return (0);
src = (const char *)buff;
- ret = ARCHIVE_OK;
- shar->outpos = 0;
- while (n-- > 0) {
- if (shar->end_of_line) {
- shar->outbuff[shar->outpos++] = 'X';
- shar->end_of_line = 0;
+
+ /*
+ * ensure is the number of bytes in buffer before expanding the
+ * current character. Each operation writes the current character
+ * and optionally the start-of-new-line marker. This can happen
+ * twice before entering the loop, so make sure three additional
+ * bytes can be written.
+ */
+ if (archive_string_ensure(&shar->work, ensured + 3) == NULL)
+ __archive_errx(1, "Out of memory");
+
+ if (shar->work.length > ensured) {
+ ret = (*a->compressor.write)(a, shar->work.s,
+ shar->work.length);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ archive_string_empty(&shar->work);
+ }
+ buf = shar->work.s + shar->work.length;
+ buf_end = shar->work.s + ensured;
+
+ if (shar->end_of_line) {
+ *buf++ = 'X';
+ shar->end_of_line = 0;
+ }
+
+ while (n-- != 0) {
+ if ((*buf++ = *src++) == '\n') {
+ if (n == 0)
+ shar->end_of_line = 1;
+ else
+ *buf++ = 'X';
}
- if (*src == '\n')
- shar->end_of_line = 1;
- shar->outbuff[shar->outpos++] = *src++;
- if (shar->outpos > sizeof(shar->outbuff) - 2) {
- ret = (a->compressor.write)(a, shar->outbuff,
- shar->outpos);
+ if (buf >= buf_end) {
+ shar->work.length = buf - shar->work.s;
+ ret = (*a->compressor.write)(a, shar->work.s,
+ shar->work.length);
if (ret != ARCHIVE_OK)
- return (ret);
- shar->outpos = 0;
+ return (ARCHIVE_FATAL);
+ archive_string_empty(&shar->work);
+ buf = shar->work.s;
}
}
- if (shar->outpos > 0)
- ret = (a->compressor.write)(a, shar->outbuff, shar->outpos);
- if (ret != ARCHIVE_OK)
- return (ret);
+ shar->work.length = buf - shar->work.s;
+
return (written);
}
#define UUENC(c) (((c)!=0) ? ((c) & 077) + ' ': '`')
-/* XXX This could be a lot more efficient. XXX */
static void
-uuencode_group(struct shar *shar)
+uuencode_group(const char _in[3], char out[4])
+{
+ const unsigned char *in = (const unsigned char *)_in;
+ int t;
+
+ t = (in[0] << 16) | (in[1] << 8) | in[2];
+ out[0] = UUENC( 0x3f & (t >> 18) );
+ out[1] = UUENC( 0x3f & (t >> 12) );
+ out[2] = UUENC( 0x3f & (t >> 6) );
+ out[3] = UUENC( 0x3f & t );
+}
+
+static void
+uuencode_line(struct shar *shar, const char *inbuf, size_t len)
{
- int t;
-
- t = 0;
- if (shar->uuavail > 0)
- t = 0xff0000 & (shar->uubuffer[0] << 16);
- if (shar->uuavail > 1)
- t |= 0x00ff00 & (shar->uubuffer[1] << 8);
- if (shar->uuavail > 2)
- t |= 0x0000ff & (shar->uubuffer[2]);
- shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t>>18) );
- shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t>>12) );
- shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t>>6) );
- shar->outbuff[shar->outpos++] = UUENC( 0x3f & (t) );
- shar->uuavail = 0;
- shar->outbytes += shar->uuavail;
- shar->outbuff[shar->outpos] = 0;
+ char tmp_buf[3], *buf;
+ size_t alloc_len;
+
+ /* len <= 45 -> expanded to 60 + len byte + new line */
+ alloc_len = shar->work.length + 62;
+ if (archive_string_ensure(&shar->work, alloc_len) == NULL)
+ __archive_errx(1, "Out of memory");
+
+ buf = shar->work.s + shar->work.length;
+ *buf++ = UUENC(len);
+ while (len >= 3) {
+ uuencode_group(inbuf, buf);
+ len -= 3;
+ inbuf += 3;
+ buf += 4;
+ }
+ if (len != 0) {
+ tmp_buf[0] = inbuf[0];
+ if (len == 1)
+ tmp_buf[1] = '\0';
+ else
+ tmp_buf[1] = inbuf[1];
+ tmp_buf[2] = '\0';
+ uuencode_group(inbuf, buf);
+ buf += 4;
+ }
+ *buf++ = '\n';
+ if ((buf - shar->work.s) > (ptrdiff_t)(shar->work.length + 62))
+ __archive_errx(1, "Buffer overflow");
+ shar->work.length = buf - shar->work.s;
}
static ssize_t
@@ -406,21 +454,39 @@ archive_write_shar_data_uuencode(struct archive_write *a, const void *buff,
if (!shar->has_data)
return (ARCHIVE_OK);
src = (const char *)buff;
- n = length;
- while (n-- > 0) {
- if (shar->uuavail == 3)
- uuencode_group(shar);
- if (shar->outpos >= 60) {
- ret = shar_printf(a, "%c%s\n", UUENC(shar->outbytes),
- shar->outbuff);
- if (ret != ARCHIVE_OK)
- return (ret);
- shar->outpos = 0;
- shar->outbytes = 0;
+
+ if (shar->outpos != 0) {
+ n = 45 - shar->outpos;
+ if (n > length)
+ n = length;
+ memcpy(shar->outbuff + shar->outpos, src, n);
+ if (shar->outpos + n < 45) {
+ shar->outpos += n;
+ return length;
}
+ uuencode_line(shar, shar->outbuff, 45);
+ src += n;
+ n = length - n;
+ } else {
+ n = length;
+ }
- shar->uubuffer[shar->uuavail++] = *src++;
- shar->outbytes++;
+ while (n >= 45) {
+ uuencode_line(shar, src, 45);
+ src += 45;
+ n -= 45;
+
+ if (shar->work.length < 65536)
+ continue;
+ ret = (*a->compressor.write)(a, shar->work.s,
+ shar->work.length);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ archive_string_empty(&shar->work);
+ }
+ if (n != 0) {
+ memcpy(shar->outbuff, src, n);
+ shar->outpos = n;
}
return (length);
}
@@ -439,54 +505,43 @@ archive_write_shar_finish_entry(struct archive_write *a)
if (shar->dump) {
/* Finish uuencoded data. */
if (shar->has_data) {
- if (shar->uuavail > 0)
- uuencode_group(shar);
- if (shar->outpos > 0) {
- ret = shar_printf(a, "%c%s\n",
- UUENC(shar->outbytes), shar->outbuff);
- if (ret != ARCHIVE_OK)
- return (ret);
- shar->outpos = 0;
- shar->uuavail = 0;
- shar->outbytes = 0;
- }
- ret = shar_printf(a, "%c\n", UUENC(0));
- if (ret != ARCHIVE_OK)
- return (ret);
- ret = shar_printf(a, "end\n", UUENC(0));
- if (ret != ARCHIVE_OK)
- return (ret);
- ret = shar_printf(a, "SHAR_END\n");
- if (ret != ARCHIVE_OK)
- return (ret);
+ if (shar->outpos > 0)
+ uuencode_line(shar, shar->outbuff,
+ shar->outpos);
+ archive_strcat(&shar->work, "`\nend\n");
+ archive_strcat(&shar->work, "SHAR_END\n");
}
/* Restore file mode, owner, flags. */
/*
* TODO: Don't immediately restore mode for
* directories; defer that to end of script.
*/
- ret = shar_printf(a, "chmod %o %s\n",
- archive_entry_mode(shar->entry) & 07777,
- archive_entry_pathname(shar->entry));
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_string_sprintf(&shar->work, "chmod %o ",
+ archive_entry_mode(shar->entry) & 07777);
+ shar_quote(&shar->work, archive_entry_pathname(shar->entry), 1);
+ archive_strcat(&shar->work, "\n");
u = archive_entry_uname(shar->entry);
g = archive_entry_gname(shar->entry);
if (u != NULL || g != NULL) {
- ret = shar_printf(a, "chown %s%s%s %s\n",
- (u != NULL) ? u : "",
- (g != NULL) ? ":" : "", (g != NULL) ? g : "",
- archive_entry_pathname(shar->entry));
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_strcat(&shar->work, "chown ");
+ if (u != NULL)
+ shar_quote(&shar->work, u, 1);
+ if (g != NULL) {
+ archive_strcat(&shar->work, ":");
+ shar_quote(&shar->work, g, 1);
+ }
+ shar_quote(&shar->work,
+ archive_entry_pathname(shar->entry), 1);
+ archive_strcat(&shar->work, "\n");
}
if ((p = archive_entry_fflags_text(shar->entry)) != NULL) {
- ret = shar_printf(a, "chflags %s %s\n", p,
- archive_entry_pathname(shar->entry));
- if (ret != ARCHIVE_OK)
- return (ret);
+ archive_string_sprintf(&shar->work, "chflags %s ",
+ p, archive_entry_pathname(shar->entry));
+ shar_quote(&shar->work,
+ archive_entry_pathname(shar->entry), 1);
+ archive_strcat(&shar->work, "\n");
}
/* TODO: restore ACLs */
@@ -494,20 +549,24 @@ archive_write_shar_finish_entry(struct archive_write *a)
} else {
if (shar->has_data) {
/* Finish sed-encoded data: ensure last line ends. */
- if (!shar->end_of_line) {
- ret = shar_printf(a, "\n");
- if (ret != ARCHIVE_OK)
- return (ret);
- }
- ret = shar_printf(a, "SHAR_END\n");
- if (ret != ARCHIVE_OK)
- return (ret);
+ if (!shar->end_of_line)
+ archive_strappend_char(&shar->work, '\n');
+ archive_strcat(&shar->work, "SHAR_END\n");
}
}
archive_entry_free(shar->entry);
shar->entry = NULL;
- return (0);
+
+ if (shar->work.length < 65536)
+ return (ARCHIVE_OK);
+
+ ret = (*a->compressor.write)(a, shar->work.s, shar->work.length);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ archive_string_empty(&shar->work);
+
+ return (ARCHIVE_OK);
}
static int
@@ -529,17 +588,22 @@ archive_write_shar_finish(struct archive_write *a)
* shar format, then sets another format (which would invoke
* shar_finish to free the format-specific data).
*/
- if (shar->wrote_header) {
- ret = shar_printf(a, "exit\n");
- if (ret != ARCHIVE_OK)
- return (ret);
- /* Shar output is never padded. */
- archive_write_set_bytes_in_last_block(&a->archive, 1);
- /*
- * TODO: shar should also suppress padding of
- * uncompressed data within gzip/bzip2 streams.
- */
- }
+ if (shar->wrote_header == 0)
+ return (ARCHIVE_OK);
+
+ archive_strcat(&shar->work, "exit\n");
+
+ ret = (*a->compressor.write)(a, shar->work.s, shar->work.length);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+
+ /* Shar output is never padded. */
+ archive_write_set_bytes_in_last_block(&a->archive, 1);
+ /*
+ * TODO: shar should also suppress padding of
+ * uncompressed data within gzip/bzip2 streams.
+ */
+
return (ARCHIVE_OK);
}
@@ -549,11 +613,13 @@ archive_write_shar_destroy(struct archive_write *a)
struct shar *shar;
shar = (struct shar *)a->format_data;
- if (shar->entry != NULL)
- archive_entry_free(shar->entry);
- if (shar->last_dir != NULL)
- free(shar->last_dir);
+ if (shar == NULL)
+ return (ARCHIVE_OK);
+
+ archive_entry_free(shar->entry);
+ free(shar->last_dir);
archive_string_free(&(shar->work));
+ archive_string_free(&(shar->quoted_name));
free(shar);
a->format_data = NULL;
return (ARCHIVE_OK);
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c
index 8aed25d1f99..1de273fc2df 100644
--- a/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c
@@ -24,7 +24,7 @@
*/
#include "archive_platform.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ustar.c,v 1.27 2008/05/26 17:00:23 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_ustar.c 191579 2009-04-27 18:35:03Z kientzle $");
#ifdef HAVE_ERRNO_H
@@ -181,6 +181,7 @@ archive_write_set_format_ustar(struct archive *_a)
a->format_data = ustar;
a->pad_uncompressed = 1; /* Mimic gtar in this respect. */
+ a->format_name = "ustar";
a->format_write_header = archive_write_ustar_header;
a->format_write_data = archive_write_ustar_data;
a->format_finish = archive_write_ustar_finish;
@@ -413,8 +414,14 @@ __archive_write_format_header_ustar(struct archive_write *a, char h[512],
case AE_IFBLK: h[USTAR_typeflag_offset] = '4' ; break;
case AE_IFDIR: h[USTAR_typeflag_offset] = '5' ; break;
case AE_IFIFO: h[USTAR_typeflag_offset] = '6' ; break;
+ case AE_IFSOCK:
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "tar format cannot archive socket");
+ return (ARCHIVE_FAILED);
default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
"tar format cannot archive this (mode=0%lo)",
(unsigned long)archive_entry_mode(entry));
ret = ARCHIVE_FAILED;
diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_zip.c b/archivers/libarchive/files/libarchive/archive_write_set_format_zip.c
new file mode 100644
index 00000000000..14cc6697df0
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/archive_write_set_format_zip.c
@@ -0,0 +1,667 @@
+/*-
+ * Copyright (c) 2008 Anselm Strauss
+ * Copyright (c) 2009 Joerg Sonnenberger
+ * 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.
+ */
+
+/*
+ * Development supported by Google Summer of Code 2008.
+ */
+
+/*
+ * The current implementation is very limited:
+ *
+ * - No encryption support.
+ * - No ZIP64 support.
+ * - No support for splitting and spanning.
+ * - Only supports regular file and folder entries.
+ *
+ * Note that generally data in ZIP files is little-endian encoded,
+ * with some exceptions.
+ *
+ * TODO: Since Libarchive is generally 64bit oriented, but this implementation
+ * does not yet support sizes exceeding 32bit, it is highly fragile for
+ * big archives. This should change when ZIP64 is finally implemented, otherwise
+ * some serious checking has to be done.
+ *
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_zip.c 201168 2009-12-29 06:15:32Z kientzle $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_ZLIB_H
+#include <zlib.h>
+#endif
+
+#include "archive.h"
+#include "archive_endian.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_write_private.h"
+
+#ifndef HAVE_ZLIB_H
+#include "archive_crc32.h"
+#endif
+
+#define ZIP_SIGNATURE_LOCAL_FILE_HEADER 0x04034b50
+#define ZIP_SIGNATURE_DATA_DESCRIPTOR 0x08074b50
+#define ZIP_SIGNATURE_FILE_HEADER 0x02014b50
+#define ZIP_SIGNATURE_CENTRAL_DIRECTORY_END 0x06054b50
+#define ZIP_SIGNATURE_EXTRA_TIMESTAMP 0x5455
+#define ZIP_SIGNATURE_EXTRA_UNIX 0x7855
+#define ZIP_VERSION_EXTRACT 0x0014 /* ZIP version 2.0 is needed. */
+#define ZIP_VERSION_BY 0x0314 /* Made by UNIX, using ZIP version 2.0. */
+#define ZIP_FLAGS 0x08 /* Flagging bit 3 (count from 0) for using data descriptor. */
+
+enum compression {
+ COMPRESSION_STORE = 0
+#ifdef HAVE_ZLIB_H
+ ,
+ COMPRESSION_DEFLATE = 8
+#endif
+};
+
+static ssize_t archive_write_zip_data(struct archive_write *, const void *buff, size_t s);
+static int archive_write_zip_finish(struct archive_write *);
+static int archive_write_zip_destroy(struct archive_write *);
+static int archive_write_zip_finish_entry(struct archive_write *);
+static int archive_write_zip_header(struct archive_write *, struct archive_entry *);
+static unsigned int dos_time(const time_t);
+static size_t path_length(struct archive_entry *);
+static int write_path(struct archive_entry *, struct archive_write *);
+
+struct zip_local_file_header {
+ char signature[4];
+ char version[2];
+ char flags[2];
+ char compression[2];
+ char timedate[4];
+ char crc32[4];
+ char compressed_size[4];
+ char uncompressed_size[4];
+ char filename_length[2];
+ char extra_length[2];
+};
+
+struct zip_file_header {
+ char signature[4];
+ char version_by[2];
+ char version_extract[2];
+ char flags[2];
+ char compression[2];
+ char timedate[4];
+ char crc32[4];
+ char compressed_size[4];
+ char uncompressed_size[4];
+ char filename_length[2];
+ char extra_length[2];
+ char comment_length[2];
+ char disk_number[2];
+ char attributes_internal[2];
+ char attributes_external[4];
+ char offset[4];
+};
+
+struct zip_data_descriptor {
+ char signature[4]; /* Not mandatory, but recommended by specification. */
+ char crc32[4];
+ char compressed_size[4];
+ char uncompressed_size[4];
+};
+
+struct zip_extra_data_local {
+ char time_id[2];
+ char time_size[2];
+ char time_flag[1];
+ char mtime[4];
+ char atime[4];
+ char ctime[4];
+ char unix_id[2];
+ char unix_size[2];
+ char unix_uid[2];
+ char unix_gid[2];
+};
+
+struct zip_extra_data_central {
+ char time_id[2];
+ char time_size[2];
+ char time_flag[1];
+ char mtime[4];
+ char unix_id[2];
+ char unix_size[2];
+};
+
+struct zip_file_header_link {
+ struct zip_file_header_link *next;
+ struct archive_entry *entry;
+ off_t offset;
+ unsigned long crc32;
+ off_t compressed_size;
+ enum compression compression;
+};
+
+struct zip {
+ struct zip_data_descriptor data_descriptor;
+ struct zip_file_header_link *central_directory;
+ struct zip_file_header_link *central_directory_end;
+ int64_t offset;
+ int64_t written_bytes;
+ int64_t remaining_data_bytes;
+ enum compression compression;
+
+#ifdef HAVE_ZLIB_H
+ z_stream stream;
+ size_t len_buf;
+ unsigned char *buf;
+#endif
+};
+
+struct zip_central_directory_end {
+ char signature[4];
+ char disk[2];
+ char start_disk[2];
+ char entries_disk[2];
+ char entries[2];
+ char size[4];
+ char offset[4];
+ char comment_length[2];
+};
+
+static int
+archive_write_zip_options(struct archive_write *a, const char *key,
+ const char *value)
+{
+ struct zip *zip = a->format_data;
+
+ if (strcmp(key, "compression") == 0) {
+ if (strcmp(value, "deflate") == 0) {
+#ifdef HAVE_ZLIB_H
+ zip->compression = COMPRESSION_DEFLATE;
+#else
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "deflate compression not supported");
+ return ARCHIVE_WARN;
+#endif
+ } else if (strcmp(value, "store") == 0)
+ zip->compression = COMPRESSION_STORE;
+ else
+ return (ARCHIVE_WARN);
+ return (ARCHIVE_OK);
+ }
+ return (ARCHIVE_WARN);
+}
+
+int
+archive_write_set_format_zip(struct archive *_a)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ struct zip *zip;
+
+ /* If another format was already registered, unregister it. */
+ if (a->format_destroy != NULL)
+ (a->format_destroy)(a);
+
+ zip = (struct zip *) calloc(1, sizeof(*zip));
+ if (zip == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't allocate zip data");
+ return (ARCHIVE_FATAL);
+ }
+ zip->central_directory = NULL;
+ zip->central_directory_end = NULL;
+ zip->offset = 0;
+ zip->written_bytes = 0;
+ zip->remaining_data_bytes = 0;
+
+#ifdef HAVE_ZLIB_H
+ zip->compression = COMPRESSION_DEFLATE;
+ zip->len_buf = 65536;
+ zip->buf = malloc(zip->len_buf);
+ if (zip->buf == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't allocate compression buffer");
+ return (ARCHIVE_FATAL);
+ }
+#else
+ zip->compression = COMPRESSION_STORE;
+#endif
+
+ a->format_data = zip;
+
+ a->pad_uncompressed = 0; /* Actually not needed for now, since no compression support yet. */
+ a->format_name = "zip";
+ a->format_options = archive_write_zip_options;
+ a->format_write_header = archive_write_zip_header;
+ a->format_write_data = archive_write_zip_data;
+ a->format_finish_entry = archive_write_zip_finish_entry;
+ a->format_finish = archive_write_zip_finish;
+ a->format_destroy = archive_write_zip_destroy;
+ a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
+ a->archive.archive_format_name = "ZIP";
+
+ archive_le32enc(&zip->data_descriptor.signature,
+ ZIP_SIGNATURE_DATA_DESCRIPTOR);
+
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
+{
+ struct zip *zip;
+ struct zip_local_file_header h;
+ struct zip_extra_data_local e;
+ struct zip_data_descriptor *d;
+ struct zip_file_header_link *l;
+ int ret;
+ int64_t size;
+ mode_t type;
+
+ /* Entries other than a regular file or a folder are skipped. */
+ type = archive_entry_filetype(entry);
+ if ((type != AE_IFREG) & (type != AE_IFDIR)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Filetype not supported");
+ return ARCHIVE_FAILED;
+ };
+
+ /* Directory entries should have a size of 0. */
+ if (type == AE_IFDIR)
+ archive_entry_set_size(entry, 0);
+
+ zip = a->format_data;
+ d = &zip->data_descriptor;
+ size = archive_entry_size(entry);
+ zip->remaining_data_bytes = size;
+
+ /* Append archive entry to the central directory data. */
+ l = (struct zip_file_header_link *) malloc(sizeof(*l));
+ if (l == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't allocate zip header data");
+ return (ARCHIVE_FATAL);
+ }
+ l->entry = archive_entry_clone(entry);
+ /* Initialize the CRC variable and potentially the local crc32(). */
+ l->crc32 = crc32(0, NULL, 0);
+ l->compression = zip->compression;
+ l->compressed_size = 0;
+ l->next = NULL;
+ if (zip->central_directory == NULL) {
+ zip->central_directory = l;
+ } else {
+ zip->central_directory_end->next = l;
+ }
+ zip->central_directory_end = l;
+
+ /* Store the offset of this header for later use in central directory. */
+ l->offset = zip->written_bytes;
+
+ memset(&h, 0, sizeof(h));
+ archive_le32enc(&h.signature, ZIP_SIGNATURE_LOCAL_FILE_HEADER);
+ archive_le16enc(&h.version, ZIP_VERSION_EXTRACT);
+ archive_le16enc(&h.flags, ZIP_FLAGS);
+ archive_le16enc(&h.compression, zip->compression);
+ archive_le32enc(&h.timedate, dos_time(archive_entry_mtime(entry)));
+ archive_le16enc(&h.filename_length, (uint16_t)path_length(entry));
+
+ switch (zip->compression) {
+ case COMPRESSION_STORE:
+ /* Setting compressed and uncompressed sizes even when specification says
+ * to set to zero when using data descriptors. Otherwise the end of the
+ * data for an entry is rather difficult to find. */
+ archive_le32enc(&h.compressed_size, size);
+ archive_le32enc(&h.uncompressed_size, size);
+ break;
+#ifdef HAVE_ZLIB_H
+ case COMPRESSION_DEFLATE:
+ archive_le32enc(&h.uncompressed_size, size);
+
+ zip->stream.zalloc = Z_NULL;
+ zip->stream.zfree = Z_NULL;
+ zip->stream.opaque = Z_NULL;
+ zip->stream.next_out = zip->buf;
+ zip->stream.avail_out = zip->len_buf;
+ if (deflateInit2(&zip->stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,
+ -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
+ archive_set_error(&a->archive, ENOMEM, "Can't init deflate compressor");
+ return (ARCHIVE_FATAL);
+ }
+ break;
+#endif
+ }
+
+ /* Formatting extra data. */
+ archive_le16enc(&h.extra_length, sizeof(e));
+ archive_le16enc(&e.time_id, ZIP_SIGNATURE_EXTRA_TIMESTAMP);
+ archive_le16enc(&e.time_size, sizeof(e.time_flag) +
+ sizeof(e.mtime) + sizeof(e.atime) + sizeof(e.ctime));
+ e.time_flag[0] = 0x07;
+ archive_le32enc(&e.mtime, archive_entry_mtime(entry));
+ archive_le32enc(&e.atime, archive_entry_atime(entry));
+ archive_le32enc(&e.ctime, archive_entry_ctime(entry));
+
+ archive_le16enc(&e.unix_id, ZIP_SIGNATURE_EXTRA_UNIX);
+ archive_le16enc(&e.unix_size, sizeof(e.unix_uid) + sizeof(e.unix_gid));
+ archive_le16enc(&e.unix_uid, archive_entry_uid(entry));
+ archive_le16enc(&e.unix_gid, archive_entry_gid(entry));
+
+ archive_le32enc(&d->uncompressed_size, size);
+
+ ret = (a->compressor.write)(a, &h, sizeof(h));
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += sizeof(h);
+
+ ret = write_path(entry, a);
+ if (ret <= ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += ret;
+
+ ret = (a->compressor.write)(a, &e, sizeof(e));
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += sizeof(e);
+
+ return (ARCHIVE_OK);
+}
+
+static ssize_t
+archive_write_zip_data(struct archive_write *a, const void *buff, size_t s)
+{
+ int ret;
+ struct zip *zip = a->format_data;
+ struct zip_file_header_link *l = zip->central_directory_end;
+
+ if ((int64_t)s > zip->remaining_data_bytes)
+ s = (size_t)zip->remaining_data_bytes;
+
+ if (s == 0) return 0;
+
+ switch (zip->compression) {
+ case COMPRESSION_STORE:
+ ret = (a->compressor.write)(a, buff, s);
+ if (ret != ARCHIVE_OK) return (ret);
+ zip->written_bytes += s;
+ zip->remaining_data_bytes -= s;
+ l->compressed_size += s;
+ l->crc32 = crc32(l->crc32, buff, s);
+ return (s);
+#if HAVE_ZLIB_H
+ case COMPRESSION_DEFLATE:
+ zip->stream.next_in = (unsigned char*)(uintptr_t)buff;
+ zip->stream.avail_in = s;
+ do {
+ ret = deflate(&zip->stream, Z_NO_FLUSH);
+ if (ret == Z_STREAM_ERROR)
+ return (ARCHIVE_FATAL);
+ if (zip->stream.avail_out == 0) {
+ ret = (a->compressor.write)(a, zip->buf, zip->len_buf);
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ l->compressed_size += zip->len_buf;
+ zip->written_bytes += zip->len_buf;
+ zip->stream.next_out = zip->buf;
+ zip->stream.avail_out = zip->len_buf;
+ }
+ } while (zip->stream.avail_in != 0);
+ zip->remaining_data_bytes -= s;
+ /* If we have it, use zlib's fast crc32() */
+ l->crc32 = crc32(l->crc32, buff, s);
+ return (s);
+#endif
+
+ default:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Invalid ZIP compression type");
+ return ARCHIVE_FATAL;
+ }
+}
+
+static int
+archive_write_zip_finish_entry(struct archive_write *a)
+{
+ /* Write the data descripter after file data has been written. */
+ int ret;
+ struct zip *zip = a->format_data;
+ struct zip_data_descriptor *d = &zip->data_descriptor;
+ struct zip_file_header_link *l = zip->central_directory_end;
+#if HAVE_ZLIB_H
+ size_t reminder;
+#endif
+
+ switch(zip->compression) {
+ case COMPRESSION_STORE:
+ break;
+#if HAVE_ZLIB_H
+ case COMPRESSION_DEFLATE:
+ for (;;) {
+ ret = deflate(&zip->stream, Z_FINISH);
+ if (ret == Z_STREAM_ERROR)
+ return (ARCHIVE_FATAL);
+ reminder = zip->len_buf - zip->stream.avail_out;
+ ret = (a->compressor.write)(a, zip->buf, reminder);
+ if (ret != ARCHIVE_OK)
+ return (ret);
+ l->compressed_size += reminder;
+ zip->written_bytes += reminder;
+ zip->stream.next_out = zip->buf;
+ if (zip->stream.avail_out != 0)
+ break;
+ zip->stream.avail_out = zip->len_buf;
+ }
+ deflateEnd(&zip->stream);
+ break;
+#endif
+ }
+
+ archive_le32enc(&d->crc32, l->crc32);
+ archive_le32enc(&d->compressed_size, l->compressed_size);
+ ret = (a->compressor.write)(a, d, sizeof(*d));
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += sizeof(*d);
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_zip_finish(struct archive_write *a)
+{
+ struct zip *zip;
+ struct zip_file_header_link *l;
+ struct zip_file_header h;
+ struct zip_central_directory_end end;
+ struct zip_extra_data_central e;
+ off_t offset_start, offset_end;
+ int entries;
+ int ret;
+
+ zip = a->format_data;
+ l = zip->central_directory;
+
+ /*
+ * Formatting central directory file header fields that are fixed for all entries.
+ * Fields not used (and therefor 0) are:
+ *
+ * - comment_length
+ * - disk_number
+ * - attributes_internal
+ */
+ memset(&h, 0, sizeof(h));
+ archive_le32enc(&h.signature, ZIP_SIGNATURE_FILE_HEADER);
+ archive_le16enc(&h.version_by, ZIP_VERSION_BY);
+ archive_le16enc(&h.version_extract, ZIP_VERSION_EXTRACT);
+ archive_le16enc(&h.flags, ZIP_FLAGS);
+
+ entries = 0;
+ offset_start = zip->written_bytes;
+
+ /* Formatting individual header fields per entry and
+ * writing each entry. */
+ while (l != NULL) {
+ archive_le16enc(&h.compression, l->compression);
+ archive_le32enc(&h.timedate, dos_time(archive_entry_mtime(l->entry)));
+ archive_le32enc(&h.crc32, l->crc32);
+ archive_le32enc(&h.compressed_size, l->compressed_size);
+ archive_le32enc(&h.uncompressed_size, archive_entry_size(l->entry));
+ archive_le16enc(&h.filename_length, (uint16_t)path_length(l->entry));
+ archive_le16enc(&h.extra_length, sizeof(e));
+ archive_le16enc(&h.attributes_external[2], archive_entry_mode(l->entry));
+ archive_le32enc(&h.offset, l->offset);
+
+ /* Formatting extra data. */
+ archive_le16enc(&e.time_id, ZIP_SIGNATURE_EXTRA_TIMESTAMP);
+ archive_le16enc(&e.time_size, sizeof(e.mtime) + sizeof(e.time_flag));
+ e.time_flag[0] = 0x07;
+ archive_le32enc(&e.mtime, archive_entry_mtime(l->entry));
+ archive_le16enc(&e.unix_id, ZIP_SIGNATURE_EXTRA_UNIX);
+ archive_le16enc(&e.unix_size, 0x0000);
+
+ ret = (a->compressor.write)(a, &h, sizeof(h));
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += sizeof(h);
+
+ ret = write_path(l->entry, a);
+ if (ret <= ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += ret;
+
+ ret = (a->compressor.write)(a, &e, sizeof(e));
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += sizeof(e);
+
+ l = l->next;
+ entries++;
+ }
+ offset_end = zip->written_bytes;
+
+ /* Formatting end of central directory. */
+ memset(&end, 0, sizeof(end));
+ archive_le32enc(&end.signature, ZIP_SIGNATURE_CENTRAL_DIRECTORY_END);
+ archive_le16enc(&end.entries_disk, entries);
+ archive_le16enc(&end.entries, entries);
+ archive_le32enc(&end.size, offset_end - offset_start);
+ archive_le32enc(&end.offset, offset_start);
+
+ /* Writing end of central directory. */
+ ret = (a->compressor.write)(a, &end, sizeof(end));
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += sizeof(end);
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_zip_destroy(struct archive_write *a)
+{
+ struct zip *zip;
+ struct zip_file_header_link *l;
+
+ zip = a->format_data;
+ while (zip->central_directory != NULL) {
+ l = zip->central_directory;
+ zip->central_directory = l->next;
+ archive_entry_free(l->entry);
+ free(l);
+ }
+#ifdef HAVE_ZLIB_H
+ free(zip->buf);
+#endif
+ free(zip);
+ a->format_data = NULL;
+ return (ARCHIVE_OK);
+}
+
+/* Convert into MSDOS-style date/time. */
+static unsigned int
+dos_time(const time_t unix_time)
+{
+ struct tm *t;
+ unsigned int dt;
+
+ /* This will not preserve time when creating/extracting the archive
+ * on two systems with different time zones. */
+ t = localtime(&unix_time);
+
+ dt = 0;
+ dt += ((t->tm_year - 80) & 0x7f) << 9;
+ dt += ((t->tm_mon + 1) & 0x0f) << 5;
+ dt += (t->tm_mday & 0x1f);
+ dt <<= 16;
+ dt += (t->tm_hour & 0x1f) << 11;
+ dt += (t->tm_min & 0x3f) << 5;
+ dt += (t->tm_sec & 0x3e) >> 1; /* Only counting every 2 seconds. */
+ return dt;
+}
+
+static size_t
+path_length(struct archive_entry *entry)
+{
+ mode_t type;
+ const char *path;
+
+ type = archive_entry_filetype(entry);
+ path = archive_entry_pathname(entry);
+
+ if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) {
+ return strlen(path) + 1;
+ } else {
+ return strlen(path);
+ }
+}
+
+static int
+write_path(struct archive_entry *entry, struct archive_write *archive)
+{
+ int ret;
+ const char *path;
+ mode_t type;
+ size_t written_bytes;
+
+ path = archive_entry_pathname(entry);
+ type = archive_entry_filetype(entry);
+ written_bytes = 0;
+
+ ret = (archive->compressor.write)(archive, path, strlen(path));
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ written_bytes += strlen(path);
+
+ /* Folders are recognized by a traling slash. */
+ if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) {
+ ret = (archive->compressor.write)(archive, "/", 1);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ written_bytes += 1;
+ }
+
+ return ((int)written_bytes);
+}
diff --git a/archivers/libarchive/files/libarchive/config_freebsd.h b/archivers/libarchive/files/libarchive/config_freebsd.h
index 4182b71df47..fad40871415 100644
--- a/archivers/libarchive/files/libarchive/config_freebsd.h
+++ b/archivers/libarchive/files/libarchive/config_freebsd.h
@@ -22,28 +22,47 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/config_freebsd.h,v 1.10 2008/06/15 05:12:47 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/config_freebsd.h 201079 2009-12-28 02:01:42Z kientzle $
*/
-/* FreeBSD 5.0 and later have ACL support. */
+/* FreeBSD 5.0 and later have ACL and extattr support. */
#if __FreeBSD__ > 4
#define HAVE_ACL_CREATE_ENTRY 1
+#define HAVE_ACL_GET_LINK_NP 1
+#define HAVE_ACL_GET_PERM_NP 1
#define HAVE_ACL_INIT 1
#define HAVE_ACL_SET_FD 1
#define HAVE_ACL_SET_FD_NP 1
#define HAVE_ACL_SET_FILE 1
#define HAVE_ACL_USER 1
+#define HAVE_EXTATTR_GET_FILE 1
+#define HAVE_EXTATTR_LIST_FILE 1
+#define HAVE_EXTATTR_SET_FD 1
+#define HAVE_EXTATTR_SET_FILE 1
+#define HAVE_SYS_ACL_H 1
+#define HAVE_SYS_EXTATTR_H 1
+#endif
+
+#ifdef WITH_OPENSSL
+#define HAVE_OPENSSL_MD5_H 1
+#define HAVE_OPENSSL_RIPEMD_H 1
+#define HAVE_OPENSSL_SHA_H 1
+#define HAVE_SHA384 1
+#define HAVE_SHA512 1
#endif
+#define HAVE_BSDXML_H 1
#define HAVE_BZLIB_H 1
#define HAVE_CHFLAGS 1
#define HAVE_CHOWN 1
#define HAVE_DECL_INT64_MAX 1
#define HAVE_DECL_INT64_MIN 1
#define HAVE_DECL_SIZE_MAX 1
+#define HAVE_DECL_SSIZE_MAX 1
#define HAVE_DECL_STRERROR_R 1
#define HAVE_DECL_UINT32_MAX 1
#define HAVE_DECL_UINT64_MAX 1
+#define HAVE_DIRENT_H 1
#define HAVE_EFTYPE 1
#define HAVE_EILSEQ 1
#define HAVE_ERRNO_H 1
@@ -55,6 +74,7 @@
#define HAVE_FCNTL_H 1
#define HAVE_FSEEKO 1
#define HAVE_FSTAT 1
+#define HAVE_FTRUNCATE 1
#define HAVE_FUTIMES 1
#define HAVE_GETEUID 1
#define HAVE_GETPID 1
@@ -64,10 +84,13 @@
#define HAVE_LCHMOD 1
#define HAVE_LCHOWN 1
#define HAVE_LIMITS_H 1
+#define HAVE_LINK 1
+#define HAVE_LSTAT 1
#define HAVE_LUTIMES 1
#define HAVE_MALLOC 1
+#define HAVE_MD5 1
+#define HAVE_MD5_H 1
#define HAVE_MEMMOVE 1
-#define HAVE_MEMSET 1
#define HAVE_MKDIR 1
#define HAVE_MKFIFO 1
#define HAVE_MKNOD 1
@@ -75,8 +98,15 @@
#define HAVE_POLL 1
#define HAVE_POLL_H 1
#define HAVE_PWD_H 1
+#define HAVE_READLINK 1
+#define HAVE_RMD160 1
#define HAVE_SELECT 1
#define HAVE_SETENV 1
+#define HAVE_SHA_H 1
+#define HAVE_SHA1 1
+#define HAVE_SHA256 1
+#define HAVE_SHA256_H 1
+#define HAVE_SIGNAL_H 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRCHR 1
@@ -86,8 +116,13 @@
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRRCHR 1
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
+#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
+#define HAVE_STRUCT_STAT_ST_FLAGS 1
#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
-#define HAVE_SYS_ACL_H 1
+#define HAVE_SYMLINK 1
+#define HAVE_SYS_CDEFS_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_SELECT_H 1
#define HAVE_SYS_STAT_H 1
@@ -110,7 +145,6 @@
#define HAVE_WMEMCMP 1
#define HAVE_WMEMCPY 1
#define HAVE_ZLIB_H 1
-#define STDC_HEADERS 1
#define TIME_WITH_SYS_TIME 1
/* FreeBSD 4 and earlier lack intmax_t/uintmax_t */
diff --git a/archivers/libarchive/files/libarchive/filter_fork.c b/archivers/libarchive/files/libarchive/filter_fork.c
index c746a186f52..604ad633f55 100644
--- a/archivers/libarchive/files/libarchive/filter_fork.c
+++ b/archivers/libarchive/files/libarchive/filter_fork.c
@@ -29,7 +29,7 @@
#if defined(HAVE_PIPE) && defined(HAVE_FCNTL) && \
(defined(HAVE_FORK) || defined(HAVE_VFORK))
-__FBSDID("$FreeBSD: src/lib/libarchive/filter_fork.c,v 1.4 2008/06/15 10:45:57 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/filter_fork.c 182958 2008-09-12 05:33:00Z kientzle $");
#if defined(HAVE_POLL)
# if defined(HAVE_POLL_H)
@@ -61,7 +61,7 @@ __archive_create_child(const char *path, int *child_stdin, int *child_stdout)
if (pipe(stdin_pipe) == -1)
goto state_allocated;
- if (stdin_pipe[0] == STDOUT_FILENO) {
+ if (stdin_pipe[0] == 1 /* stdout */) {
if ((tmp = dup(stdin_pipe[0])) == -1)
goto stdin_opened;
close(stdin_pipe[0]);
@@ -69,7 +69,7 @@ __archive_create_child(const char *path, int *child_stdin, int *child_stdout)
}
if (pipe(stdout_pipe) == -1)
goto stdin_opened;
- if (stdout_pipe[1] == STDIN_FILENO) {
+ if (stdout_pipe[1] == 0 /* stdin */) {
if ((tmp = dup(stdout_pipe[1])) == -1)
goto stdout_opened;
close(stdout_pipe[1]);
@@ -86,16 +86,16 @@ __archive_create_child(const char *path, int *child_stdin, int *child_stdout)
case 0:
close(stdin_pipe[1]);
close(stdout_pipe[0]);
- if (dup2(stdin_pipe[0], STDIN_FILENO) == -1)
+ if (dup2(stdin_pipe[0], 0 /* stdin */) == -1)
_exit(254);
- if (stdin_pipe[0] != STDIN_FILENO)
+ if (stdin_pipe[0] != 0 /* stdin */)
close(stdin_pipe[0]);
- if (dup2(stdout_pipe[1], STDOUT_FILENO) == -1)
+ if (dup2(stdout_pipe[1], 1 /* stdout */) == -1)
_exit(254);
- if (stdout_pipe[1] != STDOUT_FILENO)
+ if (stdout_pipe[1] != 1 /* stdout */)
close(stdout_pipe[1]);
execlp(path, path, (char *)NULL);
- _exit(254);
+ _exit(254);
default:
close(stdin_pipe[0]);
close(stdout_pipe[1]);
diff --git a/archivers/libarchive/files/libarchive/filter_fork.h b/archivers/libarchive/files/libarchive/filter_fork.h
index 685efda09fc..453d032d1c8 100644
--- a/archivers/libarchive/files/libarchive/filter_fork.h
+++ b/archivers/libarchive/files/libarchive/filter_fork.h
@@ -22,9 +22,13 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/filter_fork.h,v 1.1 2007/05/29 01:00:20 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/filter_fork.h 201087 2009-12-28 02:18:26Z kientzle $
*/
+#ifndef __LIBARCHIVE_BUILD
+#error This header is only to be used internally to libarchive.
+#endif
+
#ifndef FILTER_FORK_H
#define FILTER_FORK_H
diff --git a/archivers/libarchive/files/libarchive/filter_fork_windows.c b/archivers/libarchive/files/libarchive/filter_fork_windows.c
new file mode 100644
index 00000000000..38b7097ee99
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/filter_fork_windows.c
@@ -0,0 +1,113 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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 "archive_platform.h"
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+
+#include "filter_fork.h"
+
+pid_t
+__archive_create_child(const char *path, int *child_stdin, int *child_stdout)
+{
+ HANDLE childStdout[2], childStdin[2], childStdinWr, childStdoutRd;
+ SECURITY_ATTRIBUTES secAtts;
+ STARTUPINFO staInfo;
+ PROCESS_INFORMATION childInfo;
+ char cmd[MAX_PATH];
+ DWORD mode;
+
+ secAtts.nLength = sizeof(SECURITY_ATTRIBUTES);
+ secAtts.bInheritHandle = TRUE;
+ secAtts.lpSecurityDescriptor = NULL;
+ if (CreatePipe(&childStdout[0], &childStdout[1], &secAtts, 0) == 0)
+ goto fail;
+ if (DuplicateHandle(GetCurrentProcess(), childStdout[0],
+ GetCurrentProcess(), &childStdoutRd, 0, FALSE,
+ DUPLICATE_SAME_ACCESS) == 0) {
+ CloseHandle(childStdout[0]);
+ CloseHandle(childStdout[1]);
+ goto fail;
+ }
+ CloseHandle(childStdout[0]);
+
+ if (CreatePipe(&childStdin[0], &childStdin[1], &secAtts, 0) == 0) {
+ CloseHandle(childStdoutRd);
+ CloseHandle(childStdout[1]);
+ goto fail;
+ }
+
+ if (DuplicateHandle(GetCurrentProcess(), childStdin[1],
+ GetCurrentProcess(), &childStdinWr, 0, FALSE,
+ DUPLICATE_SAME_ACCESS) == 0) {
+ CloseHandle(childStdoutRd);
+ CloseHandle(childStdout[1]);
+ CloseHandle(childStdin[0]);
+ CloseHandle(childStdin[1]);
+ goto fail;
+ }
+ CloseHandle(childStdin[1]);
+
+ memset(&staInfo, 0, sizeof(staInfo));
+ staInfo.cb = sizeof(staInfo);
+ staInfo.hStdOutput = childStdout[1];
+ staInfo.hStdInput = childStdin[0];
+ staInfo.wShowWindow = SW_HIDE;
+ staInfo.dwFlags = STARTF_USEFILLATTRIBUTE | STARTF_USECOUNTCHARS |
+ STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
+ strncpy(cmd, path, sizeof(cmd)-1);
+ cmd[sizeof(cmd)-1] = '\0';
+ if (CreateProcessA(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL,
+ &staInfo, &childInfo) == 0) {
+ CloseHandle(childStdoutRd);
+ CloseHandle(childStdout[1]);
+ CloseHandle(childStdin[0]);
+ CloseHandle(childStdinWr);
+ goto fail;
+ }
+ WaitForInputIdle(childInfo.hProcess, INFINITE);
+ CloseHandle(childInfo.hProcess);
+ CloseHandle(childInfo.hThread);
+
+ mode = PIPE_NOWAIT;
+ SetNamedPipeHandleState(childStdoutRd, &mode, NULL, NULL);
+ *child_stdout = _open_osfhandle((intptr_t)childStdoutRd, _O_RDONLY);
+ *child_stdin = _open_osfhandle((intptr_t)childStdinWr, _O_WRONLY);
+
+ return (childInfo.dwProcessId);
+
+fail:
+ return (-1);
+}
+
+void
+__archive_check_child(int in, int out)
+{
+ (void)in; /* UNSED */
+ (void)out; /* UNSED */
+ Sleep(100);
+}
+
+#endif /* _WIN32 && !__CYGWIN__ */
diff --git a/archivers/libarchive/files/libarchive/libarchive-formats.5 b/archivers/libarchive/files/libarchive/libarchive-formats.5
index dd054a93916..0acdb50c2bd 100644
--- a/archivers/libarchive/files/libarchive/libarchive-formats.5
+++ b/archivers/libarchive/files/libarchive/libarchive-formats.5
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2003-2007 Tim Kientzle
+.\" Copyright (c) 2003-2009 Tim Kientzle
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -22,10 +22,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/libarchive-formats.5,v 1.16 2008/05/26 17:00:23 kientzle Exp $
+.\" $FreeBSD: head/lib/libarchive/libarchive-formats.5 201077 2009-12-28 01:50:23Z kientzle $
.\"
-.Dd April 27, 2004
-.Dt libarchive-formats 3
+.Dd December 27, 2009
+.Dt libarchive-formats 5
.Os
.Sh NAME
.Nm libarchive-formats
@@ -45,7 +45,8 @@ limitations of the current library support.
Note that just because a format is supported by libarchive does not
imply that a program that uses libarchive will support that format.
Applications that use libarchive specify which formats they wish
-to support.
+to support, though many programs do use libarchive convenience
+functions to enable all supported formats.
.Ss Tar Formats
The
.Xr libarchive 3
@@ -83,8 +84,8 @@ library can read and write POSIX-compliant pax interchange format
archives.
Pax interchange format archives are an extension of the older ustar
format that adds a separate entry with additional attributes stored
-as key/value pairs.
-The presence of this additional entry is the only difference between
+as key/value pairs immediately before each regular entry.
+The presence of these additional entries is the only difference between
pax interchange format and the older ustar format.
The extended attributes are of unlimited length and are stored
as UTF-8 Unicode strings.
@@ -93,8 +94,9 @@ to define custom keys by preceding them with the vendor name in all uppercase.
When writing pax archives, libarchive uses many of the SCHILY keys
defined by Joerg Schilling's
.Dq star
-archiver.
-The libarchive library can read most of the SCHILY keys.
+archiver and a few LIBARCHIVE keys.
+The libarchive library can read most of the SCHILY keys
+and most of the GNU keys introduced by GNU tar.
It silently ignores any keywords that it does not understand.
.It Cm restricted pax
The libarchive library can also write pax archives in which it
@@ -130,16 +132,30 @@ This name is limited to 100 bytes.
Extended attributes, file flags, and other extended
security information cannot be stored.
.It
-Archive entries are limited to 2 gigabytes in size.
+Archive entries are limited to 8 gigabytes in size.
.El
Note that the pax interchange format has none of these restrictions.
.El
.Pp
-The libarchive library can also read a variety of commonly-used extensions to
+The libarchive library also reads a variety of commonly-used extensions to
the basic tar format.
-In particular, it supports base-256 values in certain numeric fields.
-This essentially removes the limitations on file size, modification time,
+These extensions are recognized automatically whenever they appear.
+.Bl -tag -width indent
+.It Numeric extensions.
+The POSIX standards require fixed-length numeric fields to be written with
+some character position reserved for terminators.
+Libarchive allows these fields to be written without terminator characters.
+This extends the allowable range; in particular, ustar archives with this
+extension can support entries up to 64 gigabytes in size.
+Libarchive also recognizes base-256 values in most numeric fields.
+This essentially removes all limitations on file size, modification time,
and device numbers.
+.It Solaris extensions
+Libarchive recognizes ACL and extended attribute records written
+by Solaris tar.
+Currently, libarchive only has support for old-style ACLs; the
+newer NFSv4 ACLs are recognized but discarded.
+.El
.Pp
The first tar program appeared in Seventh Edition Unix in 1979.
The first official standard for the tar file format was the
@@ -156,20 +172,26 @@ and
format archives.
A cpio archive stores each entry as a fixed-size header followed
by a variable-length filename and variable-length data.
-Unlike tar, cpio does only minimal padding of the header or file data.
-There are a variety of cpio formats, which differ primarily in
+Unlike the tar format, the cpio format does only minimal padding
+of the header or file data.
+There are several cpio variants, which differ primarily in
how they store the initial header: some store the values as
octal or hexadecimal numbers in ASCII, others as binary values of
varying byte order and length.
.Bl -tag -width indent
.It Cm binary
-The libarchive library can read both big-endian and little-endian
+The libarchive library transparently reads both big-endian and little-endian
variants of the original binary cpio format.
This format used 32-bit binary values for file size and mtime,
and 16-bit binary values for the other fields.
.It Cm odc
The libarchive library can both read and write this
-POSIX-standard format.
+POSIX-standard format, which is officially known as the
+.Dq cpio interchange format
+or the
+.Dq octet-oriented cpio archive format
+and sometimes unofficially referred to as the
+.Dq old character format .
This format stores the header contents as octal values in ASCII.
It is standard, portable, and immune from byte-order confusion.
File sizes and mtime are limited to 33 bits (8GB file size),
@@ -236,17 +258,29 @@ shardump archives less portable than plain shar archives.
.Ss ISO9660 format
Libarchive can read and extract from files containing ISO9660-compliant
CDROM images.
-It also has partial support for Rockridge extensions.
-In many cases, this can remove the need to burn a physical CDROM.
+In many cases, this can remove the need to burn a physical CDROM
+just in order to read the files contained in an ISO9660 image.
It also avoids security and complexity issues that come with
virtual mounts and loopback devices.
+Libarchive supports the most common Rockridge extensions and has partial
+support for Joliet extensions.
+If both extensions are present, the Joliet extensions will be
+used and the Rockridge extensions will be ignored.
+In particular, this can create problems with hardlinks and symlinks,
+which are supported by Rockridge but not by Joliet.
.Ss Zip format
-Libarchive can extract from most zip format archives.
-It currently only supports uncompressed entries and entries
-compressed with the
+Libarchive can read and write zip format archives that have
+uncompressed entries and entries compressed with the
.Dq deflate
algorithm.
Older zip compression algorithms are not supported.
+It can extract jar archives, archives that use Zip64 extensions and many
+self-extracting zip archives.
+Libarchive reads Zip archives as they are being streamed,
+which allows it to read archives of arbitrary size.
+It currently does not use the central directory; this
+limits libarchive's ability to support some self-extracting
+archives and ones that have been modified in certain ways.
.Ss Archive (library) file format
The Unix archive format (commonly created by the
.Xr ar 1
@@ -258,15 +292,56 @@ The ar format has never been standardised.
There are two common variants:
the GNU format derived from SVR4,
and the BSD format, which first appeared in 4.4BSD.
-Libarchive provides read and write support for both variants.
+The two differ primarily in their handling of filenames
+longer than 15 characters:
+the GNU/SVR4 variant writes a filename table at the beginning of the archive;
+the BSD format stores each long filename in an extension
+area adjacent to the entry.
+Libarchive can read both extensions,
+including archives that may include both types of long filenames.
+Programs using libarchive can write GNU/SVR4 format
+if they provide a filename table to be written into
+the archive before any of the entries.
+Any entries whose names are not in the filename table
+will be written using BSD-style long filenames.
+This can cause problems for programs such as
+GNU ld that do not support the BSD-style long filenames.
.Ss mtree
-Libarchive can read files in
-.Xr mtree 5
-format. This format is not a true archive format, but rather a description
-of a file hierarchy. When requested, libarchive obtains the contents of
-the files described by the
+Libarchive can read and write files in
.Xr mtree 5
-format from files on disk instead.
+format.
+This format is not a true archive format, but rather a textual description
+of a file hierarchy in which each line specifies the name of a file and
+provides specific metadata about that file.
+Libarchive can read all of the keywords supported by both
+the NetBSD and FreeBSD versions of
+.Xr mtree 1 ,
+although many of the keywords cannot currently be stored in an
+.Tn archive_entry
+object.
+When writing, libarchive supports use of the
+.Xr archive_write_set_options 3
+interface to specify which keywords should be included in the
+output.
+If libarchive was compiled with access to suitable
+cryptographic libraries (such as the OpenSSL libraries),
+it can compute hash entries such as
+.Cm sha512
+or
+.Cm md5
+from file data being written to the mtree writer.
+.Pp
+When reading an mtree file, libarchive will locate the corresponding
+files on disk using the
+.Cm contents
+keyword if present or the regular filename.
+If it can locate and open the file on disk, it will use that
+to fill in any metadata that is missing from the mtree file
+and will read the file contents and return those to the program
+using libarchive.
+If it cannot locate and open the file on disk, libarchive
+will return an error for any attempt to read the entry
+body.
.Sh SEE ALSO
.Xr ar 1 ,
.Xr cpio 1 ,
diff --git a/archivers/libarchive/files/libarchive/tar.5 b/archivers/libarchive/files/libarchive/tar.5
index 06873268097..aafd535a1a5 100644
--- a/archivers/libarchive/files/libarchive/tar.5
+++ b/archivers/libarchive/files/libarchive/tar.5
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2003-2007 Tim Kientzle
+.\" Copyright (c) 2003-2009 Tim Kientzle
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -22,10 +22,10 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/lib/libarchive/tar.5,v 1.18 2008/05/26 17:00:23 kientzle Exp $
+.\" $FreeBSD: head/lib/libarchive/tar.5 201077 2009-12-28 01:50:23Z kientzle $
.\"
-.Dd May 20, 2004
-.Dt TAR 5
+.Dd December 27, 2009
+.Dt tar 5
.Os
.Sh NAME
.Nm tar
@@ -55,8 +55,11 @@ number of records with each I/O operation.
These
.Dq blocks
are always a multiple of the record size.
-The most common block size\(emand the maximum supported by historic
-implementations\(emis 10240 bytes or 20 records.
+The maximum block size supported by early
+implementations was 10240 bytes or 20 records.
+This is still the default for most implementations
+although block sizes of 1MiB (2048 records) or larger are
+commonly used with modern high-speed tape drives.
(Note: the terms
.Dq block
and
@@ -71,7 +74,7 @@ necessary.
This section describes the variant implemented by the tar command
included in
.At v7 ,
-which is one of the earliest widely-used versions of the tar program.
+which seems to be the earliest widely-used version of the tar program.
.Pp
The header record for an old-style
.Nm
@@ -272,16 +275,19 @@ when they are set and the corresponding names exist on
the system.
.It Va devmajor , Va devminor
Major and minor numbers for character device or block device entry.
-.It Va prefix
-First part of pathname.
+.It Va name , Va prefix
If the pathname is too long to fit in the 100 bytes provided by the standard
format, it can be split at any
.Pa /
-character with the first portion going here.
+character with the first portion going into the prefix field.
If the prefix field is not empty, the reader will prepend
the prefix value and a
.Pa /
character to the regular name field to obtain the full pathname.
+The standard does not require a trailing
+.Pa /
+character on directory names, though most implementations still
+include this for compatibility reasons.
.El
.Pp
Note that all unused bytes must be set to
@@ -308,7 +314,7 @@ unless they fill the entire field.
happens to have a
.Pa /
as the 156th character.)
-POSIX requires numeric fields to be zero-padded in the front, and allows
+POSIX requires numeric fields to be zero-padded in the front, and requires
them to be terminated with either space or
.Dv NUL
characters.
@@ -390,6 +396,11 @@ user or group information available (such as when NIS/YP or LDAP services
are temporarily unavailable).
.It Cm SCHILY.devminor , Cm SCHILY.devmajor
The full minor and major numbers for device nodes.
+.It Cm SCHILY.fflags
+The file flags.
+.It Cm SCHILY.realsize
+The full size of the file on disk.
+XXX explain? XXX
.It Cm SCHILY.dev, Cm SCHILY.ino , Cm SCHILY.nlinks
The device number, inode number, and link count for the entry.
In particular, note that a pax interchange format archive using Joerg
@@ -560,9 +571,6 @@ plus
When extracting, GNU tar checks that the header file name is the one it is
expecting, that the header offset is in the correct sequence, and that
the sum of offset and size is equal to realsize.
-FreeBSD's version of GNU tar does not handle the corner case of an
-archive's being continued in the middle of a long name or other
-extension header.
.It "N"
Type "N" records are no longer generated by GNU tar.
They contained a
@@ -575,6 +583,8 @@ or
.Dq Symlink %s to %s\en ;
in either case, both
filenames are escaped using K&R C syntax.
+Due to security concerns, "N" records are now generally ignored
+when reading archives.
.It "S"
This is a
.Dq sparse
@@ -644,6 +654,66 @@ entry; the
.Va realsize
field will indicate the total size of the file.
.El
+.Ss GNU tar pax archives
+GNU tar 1.14 (XXX check this XXX) and later will write
+pax interchange format archives when you specify the
+.Fl -posix
+flag.
+This format uses custom keywords to store sparse file information.
+There have been three iterations of this support, referred to
+as
+.Dq 0.0 ,
+.Dq 0.1 ,
+and
+.Dq 1.0 .
+.Bl -tag -width indent
+.It Cm GNU.sparse.numblocks , Cm GNU.sparse.offset , Cm GNU.sparse.numbytes , Cm GNU.sparse.size
+The
+.Dq 0.0
+format used an initial
+.Cm GNU.sparse.numblocks
+attribute to indicate the number of blocks in the file, a pair of
+.Cm GNU.sparse.offset
+and
+.Cm GNU.sparse.numbytes
+to indicate the offset and size of each block,
+and a single
+.Cm GNU.sparse.size
+to indicate the full size of the file.
+This is not the same as the size in the tar header because the
+latter value does not include the size of any holes.
+This format required that the order of attributes be preserved and
+relied on readers accepting multiple appearances of the same attribute
+names, which is not officially permitted by the standards.
+.It Cm GNU.sparse.map
+The
+.Dq 0.1
+format used a single attribute that stored a comma-separated
+list of decimal numbers.
+Each pair of numbers indicated the offset and size, respectively,
+of a block of data.
+This does not work well if the archive is extracted by an archiver
+that does not recognize this extension, since many pax implementations
+simply discard unrecognized attributes.
+.It Cm GNU.sparse.major , Cm GNU.sparse.minor , Cm GNU.sparse.name , Cm GNU.sparse.realsize
+The
+.Dq 1.0
+format stores the sparse block map in one or more 512-byte blocks
+prepended to the file data in the entry body.
+The pax attributes indicate the existence of this map
+(via the
+.Cm GNU.sparse.major
+and
+.Cm GNU.sparse.minor
+fields)
+and the full size of the file.
+The
+.Cm GNU.sparse.name
+holds the true name of the file.
+To avoid confusion, the name stored in the regular tar header
+is a modified name so that extraction errors will be apparent
+to users.
+.El
.Ss Solaris Tar
XXX More Details Needed XXX
.Pp
@@ -667,16 +737,42 @@ An additional
.Cm A
entry is used to store an ACL for the following regular entry.
The body of this entry contains a seven-digit octal number
-(whose value is 01000000 plus the number of ACL entries)
followed by a zero byte, followed by the
textual ACL description.
+The octal value is the number of ACL entries
+plus a constant that indicates the ACL type: 01000000
+for POSIX.1e ACLs and 03000000 for NFSv4 ACLs.
.El
+.Ss AIX Tar
+XXX More details needed XXX
+.Ss Mac OS X Tar
+The tar distributed with Apple's Mac OS X stores most regular files
+as two separate entries in the tar archive.
+The two entries have the same name except that the first
+one has
+.Dq ._
+added to the beginning of the name.
+This first entry stores the
+.Dq resource fork
+with additional attributes for the file.
+The Mac OS X
+.Fn CopyFile
+API is used to separate a file on disk into separate
+resource and data streams and to reassemble those separate
+streams when the file is restored to disk.
.Ss Other Extensions
-One common extension, utilized by GNU tar, star, and other newer
+One obvious extension to increase the size of files is to
+eliminate the terminating characters from the various
+numeric fields.
+For example, the standard only allows the size field to contain
+11 octal digits, reserving the twelfth byte for a trailing
+NUL character.
+Allowing 12 octal digits allows file sizes up to 64 GB.
+.Pp
+Another extension, utilized by GNU tar, star, and other newer
.Nm
-implementations, permits binary numbers in the standard numeric
-fields.
-This is flagged by setting the high bit of the first character.
+implementations, permits binary numbers in the standard numeric fields.
+This is flagged by setting the high bit of the first byte.
This permits 95-bit values for the length and time fields
and 63-bit values for the uid, gid, and device numbers.
GNU tar supports this extension for the
@@ -686,12 +782,9 @@ all numeric fields.
Note that this extension is largely obsoleted by the extended attribute
record provided by the pax interchange format.
.Pp
-Another early GNU extension allowed base-64 values rather
-than octal.
-This extension was short-lived and such archives are almost never seen.
-However, there is still code in GNU tar to support them; this code is
-responsible for a very cryptic warning message that is sometimes seen when
-GNU tar encounters a damaged archive.
+Another early GNU extension allowed base-64 values rather than octal.
+This extension was short-lived and is no longer supported by any
+implementation.
.Sh SEE ALSO
.Xr ar 1 ,
.Xr pax 1 ,
@@ -722,9 +815,17 @@ John Gilmore's
.Nm pdtar
public-domain implementation (circa 1987) was highly influential
and formed the basis of
-.Nm GNU tar .
+.Nm GNU tar
+(circa 1988).
Joerg Shilling's
.Nm star
archiver is another open-source (GPL) archiver (originally developed
circa 1985) which features complete support for pax interchange
format.
+.Pp
+This documentation was written as part of the
+.Nm libarchive
+and
+.Nm bsdtar
+project by
+.An Tim Kientzle Aq kientzle@FreeBSD.org .
diff --git a/archivers/libarchive/files/libarchive/test/CMakeLists.txt b/archivers/libarchive/files/libarchive/test/CMakeLists.txt
new file mode 100644
index 00000000000..626340a4161
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/CMakeLists.txt
@@ -0,0 +1,158 @@
+############################################
+#
+# How to build libarchive_test
+#
+############################################
+IF(ENABLE_TEST)
+ FOREACH (_src ${libarchive_SOURCES})
+ LIST(APPEND parent_libarchive_SOURCES "../${_src}")
+ ENDFOREACH(_src)
+
+ SET(libarchive_test_SOURCES
+ ${parent_libarchive_SOURCES}
+ main.c
+ read_open_memory.c
+ test.h
+ test_acl_basic.c
+ test_acl_freebsd.c
+ test_acl_pax.c
+ test_archive_api_feature.c
+ test_bad_fd.c
+ test_compat_bzip2.c
+ test_compat_cpio.c
+ test_compat_gtar.c
+ test_compat_gzip.c
+ test_compat_lzma.c
+ test_compat_solaris_tar_acl.c
+ test_compat_tar_hardlink.c
+ test_compat_xz.c
+ test_compat_zip.c
+ test_empty_write.c
+ test_entry.c
+ test_entry_strmode.c
+ test_extattr_freebsd.c
+ test_fuzz.c
+ test_link_resolver.c
+ test_open_fd.c
+ test_open_file.c
+ test_open_filename.c
+ test_pax_filename_encoding.c
+ test_read_compress_program.c
+ test_read_data_large.c
+ test_read_disk.c
+ test_read_disk_entry_from_file.c
+ test_read_extract.c
+ test_read_file_nonexistent.c
+ test_read_format_ar.c
+ test_read_format_cpio_bin.c
+ test_read_format_cpio_bin_Z.c
+ test_read_format_cpio_bin_be.c
+ test_read_format_cpio_bin_bz2.c
+ test_read_format_cpio_bin_gz.c
+ test_read_format_cpio_bin_lzma.c
+ test_read_format_cpio_bin_xz.c
+ test_read_format_cpio_odc.c
+ test_read_format_cpio_svr4_bzip2_rpm.c
+ test_read_format_cpio_svr4_gzip.c
+ test_read_format_cpio_svr4_gzip_rpm.c
+ test_read_format_cpio_svr4c_Z.c
+ test_read_format_empty.c
+ test_read_format_gtar_gz.c
+ test_read_format_gtar_lzma.c
+ test_read_format_gtar_sparse.c
+ test_read_format_iso_gz.c
+ test_read_format_iso_multi_extent.c
+ test_read_format_isojoliet_bz2.c
+ test_read_format_isojoliet_long.c
+ test_read_format_isojoliet_rr.c
+ test_read_format_isorr_bz2.c
+ test_read_format_isorr_ce.c
+ test_read_format_isorr_new_bz2.c
+ test_read_format_isorr_rr_moved.c
+ test_read_format_isozisofs_bz2.c
+ test_read_format_mtree.c
+ test_read_format_pax_bz2.c
+ test_read_format_raw.c
+ test_read_format_tar.c
+ test_read_format_tar_empty_filename.c
+ test_read_format_tbz.c
+ test_read_format_tgz.c
+ test_read_format_tlz.c
+ test_read_format_txz.c
+ test_read_format_tz.c
+ test_read_format_xar.c
+ test_read_format_zip.c
+ test_read_large.c
+ test_read_pax_truncated.c
+ test_read_position.c
+ test_read_truncated.c
+ test_read_uu.c
+ test_tar_filenames.c
+ test_tar_large.c
+ test_ustar_filenames.c
+ test_write_compress.c
+ test_write_compress_bzip2.c
+ test_write_compress_gzip.c
+ test_write_compress_lzma.c
+ test_write_compress_program.c
+ test_write_compress_xz.c
+ test_write_disk.c
+ test_write_disk_failures.c
+ test_write_disk_hardlink.c
+ test_write_disk_perms.c
+ test_write_disk_secure.c
+ test_write_disk_sparse.c
+ test_write_disk_symlink.c
+ test_write_disk_times.c
+ test_write_format_ar.c
+ test_write_format_cpio.c
+ test_write_format_cpio_empty.c
+ test_write_format_cpio_odc.c
+ test_write_format_cpio_newc.c
+ test_write_format_mtree.c
+ test_write_format_pax.c
+ test_write_format_shar_empty.c
+ test_write_format_tar.c
+ test_write_format_tar_empty.c
+ test_write_format_tar_ustar.c
+ test_write_format_zip.c
+ test_write_format_zip_empty.c
+ test_write_format_zip_no_compression.c
+ test_write_open_memory.c
+ )
+
+ #
+ # Register target
+ #
+ ADD_EXECUTABLE(libarchive_test ${libarchive_test_SOURCES})
+ TARGET_LINK_LIBRARIES(libarchive_test ${ADDITIONAL_LIBS})
+ SET_PROPERTY(TARGET libarchive_test PROPERTY COMPILE_DEFINITIONS
+ LIBARCHIVE_STATIC LIST_H)
+
+ #
+ # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
+ #
+ GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
+ ${CMAKE_CURRENT_LIST_FILE} ${libarchive_test_SOURCES})
+ SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
+ ${CMAKE_CURRENT_BINARY_DIR})
+
+ # list.h has a line DEFINE_TEST(testname) for every
+ # test. We can use that to define the tests for cmake by
+ # defining a DEFINE_TEST macro and reading list.h in.
+ MACRO (DEFINE_TEST _testname)
+ ADD_TEST_28(
+ NAME libarchive_${_testname}
+ COMMAND libarchive_test -vv
+ -r ${CMAKE_CURRENT_SOURCE_DIR}
+ ${_testname})
+ ENDMACRO (DEFINE_TEST _testname)
+
+ INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
+
+ # Experimental new test handling
+ ADD_CUSTOM_TARGET(run_libarchive_test
+ COMMAND libarchive_test -r ${CMAKE_CURRENT_SOURCE_DIR})
+ ADD_DEPENDENCIES(run_all_tests run_libarchive_test)
+ENDIF(ENABLE_TEST)
+
diff --git a/archivers/libarchive/files/libarchive/test/README b/archivers/libarchive/files/libarchive/test/README
new file mode 100644
index 00000000000..235a70b0233
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/README
@@ -0,0 +1,63 @@
+$FreeBSD: src/lib/libarchive/test/README,v 1.3 2008/01/01 22:28:04 kientzle Exp $
+
+This is the test harness for libarchive.
+
+It compiles into a single program "libarchive_test" that is intended
+to exercise as much of the library as possible. It is, of course,
+very much a work in progress.
+
+Each test is a function named test_foo in a file named test_foo.c.
+Note that the file name is the same as the function name.
+Each file must start with this line:
+
+ #include "test.h"
+
+The test function must be declared with a line of this form
+
+ DEFINE_TEST(test_foo)
+
+Nothing else should appear on that line.
+
+When you add a test, please update the Makefile to add your
+file to the list of tests. The Makefile and main.c use various
+macro trickery to automatically collect a list of test functions
+to be invoked.
+
+Each test function can rely on the following:
+
+ * The current directory will be a freshly-created empty directory
+ suitable for that test. (The top-level main() creates a
+ directory for each separate test and chdir()s to that directory
+ before running the test.)
+
+ * The test function should use assert(), assertA() and similar macros
+ defined in test.h. If you need to add new macros of this form, feel
+ free to do so. The current macro set includes assertEqualInt() and
+ assertEqualString() that print out additional detail about their
+ arguments if the assertion does fail. 'A' versions also accept
+ a struct archive * and display any error message from there on
+ failure.
+
+ * You are encouraged to document each assertion with a failure() call
+ just before the assert. The failure() function is a printf-like
+ function whose text is displayed only if the assertion fails. It
+ can be used to display additional information relevant to the failure:
+
+ failure("The data read from file %s did not match the data written to that file.", filename);
+ assert(strcmp(buff1, buff2) == 0);
+
+ * Tests are encouraged to be economical with their memory and disk usage,
+ though this is not essential. The test is occasionally run under
+ a memory debugger to try to locate memory leaks in the library;
+ as a result, tests should be careful to release any memory they
+ allocate.
+
+ * Disable tests on specific platforms as necessary. Please don't
+ use config.h to adjust feature requirements, as I want the tests
+ to also serve as a check on the configure process. The following
+ form is appropriate:
+
+#if !defined(__PLATFORM) && !defined(__Platform2__)
+ assert(xxxx)
+#endif
+
diff --git a/archivers/libarchive/files/libarchive/test/list.h b/archivers/libarchive/files/libarchive/test/list.h
index 278821ad974..10efb873a64 100644
--- a/archivers/libarchive/files/libarchive/test/list.h
+++ b/archivers/libarchive/files/libarchive/test/list.h
@@ -1,61 +1,106 @@
DEFINE_TEST(test_acl_basic)
+DEFINE_TEST(test_acl_freebsd)
DEFINE_TEST(test_acl_pax)
DEFINE_TEST(test_archive_api_feature)
DEFINE_TEST(test_bad_fd)
+DEFINE_TEST(test_compat_bzip2)
+DEFINE_TEST(test_compat_cpio)
DEFINE_TEST(test_compat_gtar)
+DEFINE_TEST(test_compat_gzip)
+DEFINE_TEST(test_compat_lzma)
+DEFINE_TEST(test_compat_solaris_tar_acl)
DEFINE_TEST(test_compat_tar_hardlink)
+DEFINE_TEST(test_compat_xz)
DEFINE_TEST(test_compat_zip)
DEFINE_TEST(test_empty_write)
DEFINE_TEST(test_entry)
DEFINE_TEST(test_entry_strmode)
+DEFINE_TEST(test_extattr_freebsd)
+DEFINE_TEST(test_fuzz)
DEFINE_TEST(test_link_resolver)
-DEFINE_TEST(test_pax_filename_encoding_1)
-DEFINE_TEST(test_pax_filename_encoding_2)
-DEFINE_TEST(test_pax_filename_encoding_3)
+DEFINE_TEST(test_open_fd)
+DEFINE_TEST(test_open_file)
+DEFINE_TEST(test_open_filename)
+DEFINE_TEST(test_pax_filename_encoding)
DEFINE_TEST(test_read_compress_program)
DEFINE_TEST(test_read_data_large)
+DEFINE_TEST(test_read_disk)
+DEFINE_TEST(test_read_disk_entry_from_file)
DEFINE_TEST(test_read_extract)
+DEFINE_TEST(test_read_file_nonexistent)
DEFINE_TEST(test_read_format_ar)
DEFINE_TEST(test_read_format_cpio_bin)
DEFINE_TEST(test_read_format_cpio_bin_Z)
+DEFINE_TEST(test_read_format_cpio_bin_be)
DEFINE_TEST(test_read_format_cpio_bin_bz2)
DEFINE_TEST(test_read_format_cpio_bin_gz)
+DEFINE_TEST(test_read_format_cpio_bin_lzma)
+DEFINE_TEST(test_read_format_cpio_bin_xz)
DEFINE_TEST(test_read_format_cpio_odc)
+DEFINE_TEST(test_read_format_cpio_svr4_bzip2_rpm)
DEFINE_TEST(test_read_format_cpio_svr4_gzip)
+DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm)
DEFINE_TEST(test_read_format_cpio_svr4c_Z)
DEFINE_TEST(test_read_format_empty)
DEFINE_TEST(test_read_format_gtar_gz)
+DEFINE_TEST(test_read_format_gtar_lzma)
DEFINE_TEST(test_read_format_gtar_sparse)
DEFINE_TEST(test_read_format_iso_gz)
+DEFINE_TEST(test_read_format_iso_multi_extent)
+DEFINE_TEST(test_read_format_isojoliet_bz2)
+DEFINE_TEST(test_read_format_isojoliet_long)
+DEFINE_TEST(test_read_format_isojoliet_rr)
DEFINE_TEST(test_read_format_isorr_bz2)
+DEFINE_TEST(test_read_format_isorr_ce)
+DEFINE_TEST(test_read_format_isorr_new_bz2)
+DEFINE_TEST(test_read_format_isorr_rr_moved)
+DEFINE_TEST(test_read_format_isozisofs_bz2)
DEFINE_TEST(test_read_format_mtree)
DEFINE_TEST(test_read_format_pax_bz2)
+DEFINE_TEST(test_read_format_raw)
DEFINE_TEST(test_read_format_tar)
DEFINE_TEST(test_read_format_tar_empty_filename)
DEFINE_TEST(test_read_format_tbz)
DEFINE_TEST(test_read_format_tgz)
+DEFINE_TEST(test_read_format_tlz)
+DEFINE_TEST(test_read_format_txz)
DEFINE_TEST(test_read_format_tz)
+DEFINE_TEST(test_read_format_xar)
DEFINE_TEST(test_read_format_zip)
DEFINE_TEST(test_read_large)
DEFINE_TEST(test_read_pax_truncated)
DEFINE_TEST(test_read_position)
DEFINE_TEST(test_read_truncated)
+DEFINE_TEST(test_read_uu)
DEFINE_TEST(test_tar_filenames)
DEFINE_TEST(test_tar_large)
DEFINE_TEST(test_ustar_filenames)
DEFINE_TEST(test_write_compress)
+DEFINE_TEST(test_write_compress_bzip2)
+DEFINE_TEST(test_write_compress_gzip)
+DEFINE_TEST(test_write_compress_lzma)
DEFINE_TEST(test_write_compress_program)
+DEFINE_TEST(test_write_compress_xz)
DEFINE_TEST(test_write_disk)
+DEFINE_TEST(test_write_disk_failures)
DEFINE_TEST(test_write_disk_hardlink)
DEFINE_TEST(test_write_disk_perms)
DEFINE_TEST(test_write_disk_secure)
+DEFINE_TEST(test_write_disk_sparse)
+DEFINE_TEST(test_write_disk_symlink)
+DEFINE_TEST(test_write_disk_times)
DEFINE_TEST(test_write_format_ar)
DEFINE_TEST(test_write_format_cpio)
DEFINE_TEST(test_write_format_cpio_empty)
DEFINE_TEST(test_write_format_cpio_newc)
DEFINE_TEST(test_write_format_cpio_odc)
+DEFINE_TEST(test_write_format_mtree)
+DEFINE_TEST(test_write_format_pax)
DEFINE_TEST(test_write_format_shar_empty)
DEFINE_TEST(test_write_format_tar)
DEFINE_TEST(test_write_format_tar_empty)
DEFINE_TEST(test_write_format_tar_ustar)
+DEFINE_TEST(test_write_format_zip)
+DEFINE_TEST(test_write_format_zip_empty)
+DEFINE_TEST(test_write_format_zip_no_compression)
DEFINE_TEST(test_write_open_memory)
diff --git a/archivers/libarchive/files/libarchive/test/main.c b/archivers/libarchive/files/libarchive/test/main.c
index 83d3147d9f8..b143074d119 100644
--- a/archivers/libarchive/files/libarchive/test/main.c
+++ b/archivers/libarchive/files/libarchive/test/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2003-2009 Tim Kientzle
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -23,12 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*
- * Various utility routines useful for test programs.
- * Each test program is linked against this file.
- */
#include "test.h"
-
#include <errno.h>
#include <locale.h>
#include <stdarg.h>
@@ -38,354 +33,472 @@
* This same file is used pretty much verbatim for all test harnesses.
*
* The next few lines are the only differences.
+ * TODO: Move this into a separate configuration header, have all test
+ * suites share one copy of this file.
*/
-#undef PROGRAM /* Testing a library, not a program. */
+__FBSDID("$FreeBSD: head/lib/libarchive/test/main.c 201247 2009-12-30 05:59:21Z kientzle $");
+#define KNOWNREF "test_compat_gtar_1.tar.uu"
#define ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */
+#undef PROGRAM /* Testing a library, not a program. */
+#define LIBRARY "libarchive"
#define EXTRA_DUMP(x) archive_error_string((struct archive *)(x))
#define EXTRA_VERSION archive_version()
-__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.13 2008/06/15 10:35:22 kientzle Exp $");
/*
- * "list.h" is simply created by "grep DEFINE_TEST"; it has
- * a line like
- * DEFINE_TEST(test_function)
- * for each test.
- * Include it here with a suitable DEFINE_TEST to declare all of the
- * test functions.
+ *
+ * Windows support routines
+ *
+ * Note: Configuration is a tricky issue. Using HAVE_* feature macros
+ * in the test harness is dangerous because they cover up
+ * configuration errors. The classic example of this is omitting a
+ * configure check. If libarchive and libarchive_test both look for
+ * the same feature macro, such errors are hard to detect. Platform
+ * macros (e.g., _WIN32 or __GNUC__) are a little better, but can
+ * easily lead to very messy code. It's best to limit yourself
+ * to only the most generic programming techniques in the test harness
+ * and thus avoid conditionals altogether. Where that's not possible,
+ * try to minimize conditionals by grouping platform-specific tests in
+ * one place (e.g., test_acl_freebsd) or by adding new assert()
+ * functions (e.g., assertMakeHardlink()) to cover up platform
+ * differences. Platform-specific coding in libarchive_test is often
+ * a symptom that some capability is missing from libarchive itself.
*/
-#undef DEFINE_TEST
-#define DEFINE_TEST(name) void name(void);
-#include "list.h"
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <io.h>
+#include <windows.h>
+#ifndef F_OK
+#define F_OK (0)
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(m) ((m) & _S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(m) ((m) & _S_IFREG)
+#endif
+#if !defined(__BORLANDC__)
+#define access _access
+#define chdir _chdir
+#endif
+#ifndef fileno
+#define fileno _fileno
+#endif
+/*#define fstat _fstat64*/
+#if !defined(__BORLANDC__)
+#define getcwd _getcwd
+#endif
+#define lstat stat
+/*#define lstat _stat64*/
+/*#define stat _stat64*/
+#define rmdir _rmdir
+#if !defined(__BORLANDC__)
+#define strdup _strdup
+#define umask _umask
+#endif
+#define int64_t __int64
+#endif
+
+#if defined(HAVE__CrtSetReportMode)
+# include <crtdbg.h>
+#endif
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+void *GetFunctionKernel32(const char *name)
+{
+ static HINSTANCE lib;
+ static int set;
+ if (!set) {
+ set = 1;
+ lib = LoadLibrary("kernel32.dll");
+ }
+ if (lib == NULL) {
+ fprintf(stderr, "Can't load kernel32.dll?!\n");
+ exit(1);
+ }
+ return (void *)GetProcAddress(lib, name);
+}
+
+static int
+my_CreateSymbolicLinkA(const char *linkname, const char *target, int flags)
+{
+ static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, DWORD);
+ static int set;
+ if (!set) {
+ set = 1;
+ f = GetFunctionKernel32("CreateSymbolicLinkA");
+ }
+ return f == NULL ? 0 : (*f)(linkname, target, flags);
+}
+
+static int
+my_CreateHardLinkA(const char *linkname, const char *target)
+{
+ static BOOLEAN (WINAPI *f)(LPCSTR, LPCSTR, LPSECURITY_ATTRIBUTES);
+ static int set;
+ if (!set) {
+ set = 1;
+ f = GetFunctionKernel32("CreateHardLinkA");
+ }
+ return f == NULL ? 0 : (*f)(linkname, target, NULL);
+}
+
+int
+my_GetFileInformationByName(const char *path, BY_HANDLE_FILE_INFORMATION *bhfi)
+{
+ HANDLE h;
+ int r;
+
+ memset(bhfi, 0, sizeof(*bhfi));
+ h = CreateFile(path, FILE_READ_ATTRIBUTES, 0, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (h == INVALID_HANDLE_VALUE)
+ return (0);
+ r = GetFileInformationByHandle(h, bhfi);
+ CloseHandle(h);
+ return (r);
+}
+#endif
-/* Interix doesn't define these in a standard header. */
-#if __INTERIX__
-extern char *optarg;
-extern int optind;
+#if defined(HAVE__CrtSetReportMode)
+static void
+invalid_parameter_handler(const wchar_t * expression,
+ const wchar_t * function, const wchar_t * file,
+ unsigned int line, uintptr_t pReserved)
+{
+ /* nop */
+}
#endif
+/*
+ *
+ * OPTIONS FLAGS
+ *
+ */
+
/* Enable core dump on failure. */
static int dump_on_failure = 0;
-/* Default is to remove temp dirs for successful tests. */
+/* Default is to remove temp dirs and log data for successful tests. */
static int keep_temp_files = 0;
-/* Default is to print some basic information about each test. */
-static int quiet_flag = 0;
-/* Default is to summarize repeated failures. */
-static int verbose = 0;
-/* Cumulative count of component failures. */
+/* Default is to just report pass/fail for each test. */
+static int verbosity = 0;
+#define VERBOSITY_SUMMARY_ONLY -1 /* -q */
+#define VERBOSITY_PASSFAIL 0 /* Default */
+#define VERBOSITY_LIGHT_REPORT 1 /* -v */
+#define VERBOSITY_FULL 2 /* -vv */
+/* A few places generate even more output for verbosity > VERBOSITY_FULL,
+ * mostly for debugging the test harness itself. */
+/* Cumulative count of assertion failures. */
static int failures = 0;
-/* Cumulative count of skipped component tests. */
+/* Cumulative count of reported skips. */
static int skips = 0;
-/* Cumulative count of assertions. */
+/* Cumulative count of assertions checked. */
static int assertions = 0;
/* Directory where uuencoded reference files can be found. */
-static char *refdir;
-
-/*
- * My own implementation of the standard assert() macro emits the
- * message in the same format as GCC (file:line: message).
- * It also includes some additional useful information.
- * This makes it a lot easier to skim through test failures in
- * Emacs. ;-)
- *
- * It also supports a few special features specifically to simplify
- * test harnesses:
- * failure(fmt, args) -- Stores a text string that gets
- * printed if the following assertion fails, good for
- * explaining subtle tests.
- */
-static char msg[4096];
-
-/*
- * For each test source file, we remember how many times each
- * failure was reported.
- */
-static const char *failed_filename = NULL;
-static struct line {
- int line;
- int count;
-} failed_lines[1000];
+static const char *refdir;
/*
- * Count this failure; return the number of previous failures.
+ * Report log information selectively to console and/or disk log.
*/
-static int
-previous_failures(const char *filename, int line)
+static int log_console = 0;
+static FILE *logfile;
+static void
+vlogprintf(const char *fmt, va_list ap)
{
- unsigned int i;
- int count;
+#ifdef va_copy
+ va_list lfap;
+ va_copy(lfap, ap);
+#endif
+ if (log_console)
+ vfprintf(stdout, fmt, ap);
+ if (logfile != NULL)
+#ifdef va_copy
+ vfprintf(logfile, fmt, lfap);
+ va_end(lfap);
+#else
+ vfprintf(logfile, fmt, ap);
+#endif
+}
- if (failed_filename == NULL || strcmp(failed_filename, filename) != 0)
- memset(failed_lines, 0, sizeof(failed_lines));
- failed_filename = filename;
+static void
+logprintf(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vlogprintf(fmt, ap);
+ va_end(ap);
+}
- for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
- if (failed_lines[i].line == line) {
- count = failed_lines[i].count;
- failed_lines[i].count++;
- return (count);
- }
- if (failed_lines[i].line == 0) {
- failed_lines[i].line = line;
- failed_lines[i].count = 1;
- return (0);
- }
- }
- return (0);
+/* Set up a message to display only if next assertion fails. */
+static char msgbuff[4096];
+static const char *msg, *nextmsg;
+void
+failure(const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vsprintf(msgbuff, fmt, ap);
+ va_end(ap);
+ nextmsg = msgbuff;
}
/*
* Copy arguments into file-local variables.
+ * This was added to permit vararg assert() functions without needing
+ * variadic wrapper macros. Turns out that the vararg capability is almost
+ * never used, so almost all of the vararg assertions can be simplified
+ * by removing the vararg capability and reworking the wrapper macro to
+ * pass __FILE__, __LINE__ directly into the function instead of using
+ * this hook. I suspect this machinery is used so rarely that we
+ * would be better off just removing it entirely. That would simplify
+ * the code here noticably.
*/
static const char *test_filename;
static int test_line;
static void *test_extra;
-void test_setup(const char *filename, int line)
+void assertion_setup(const char *filename, int line)
{
test_filename = filename;
test_line = line;
}
+/* Called at the beginning of each assert() function. */
+static void
+assertion_count(const char *file, int line)
+{
+ (void)file; /* UNUSED */
+ (void)line; /* UNUSED */
+ ++assertions;
+ /* Proper handling of "failure()" message. */
+ msg = nextmsg;
+ nextmsg = NULL;
+ /* Uncomment to print file:line after every assertion.
+ * Verbose, but occasionally useful in tracking down crashes. */
+ /* printf("Checked %s:%d\n", file, line); */
+}
+
/*
- * Inform user that we're skipping a test.
+ * For each test source file, we remember how many times each
+ * assertion was reported. Cleared before each new test,
+ * used by test_summarize().
*/
-void
-test_skipping(const char *fmt, ...)
+static struct line {
+ int count;
+ int skip;
+} failed_lines[10000];
+
+/* Count this failure, setup up log destination and handle initial report. */
+static void
+failure_start(const char *filename, int line, const char *fmt, ...)
{
va_list ap;
- if (previous_failures(test_filename, test_line))
- return;
+ /* Record another failure for this line. */
+ ++failures;
+ /* test_filename = filename; */
+ failed_lines[line].count++;
+
+ /* Determine whether to log header to console. */
+ switch (verbosity) {
+ case VERBOSITY_LIGHT_REPORT:
+ log_console = (failed_lines[line].count < 2);
+ break;
+ default:
+ log_console = (verbosity >= VERBOSITY_FULL);
+ }
+ /* Log file:line header for this failure */
va_start(ap, fmt);
- fprintf(stderr, " *** SKIPPING: ");
- vfprintf(stderr, fmt, ap);
- fprintf(stderr, "\n");
+#if _MSC_VER
+ logprintf("%s(%d): ", filename, line);
+#else
+ logprintf("%s:%d: ", filename, line);
+#endif
+ vlogprintf(fmt, ap);
va_end(ap);
- ++skips;
+ logprintf("\n");
+
+ if (msg != NULL && msg[0] != '\0') {
+ logprintf(" Description: %s\n", msg);
+ msg = NULL;
+ }
+
+ /* Determine whether to log details to console. */
+ if (verbosity == VERBOSITY_LIGHT_REPORT)
+ log_console = 0;
}
-/* Common handling of failed tests. */
+/* Complete reporting of failed tests. */
+/*
+ * The 'extra' hook here is used by libarchive to include libarchive
+ * error messages with assertion failures. It could also be used
+ * to add strerror() output, for example. Just define the EXTRA_DUMP()
+ * macro appropriately.
+ */
static void
-report_failure(void *extra)
+failure_finish(void *extra)
{
- if (msg[0] != '\0') {
- fprintf(stderr, " Description: %s\n", msg);
- msg[0] = '\0';
- }
-
+ (void)extra; /* UNUSED (maybe) */
#ifdef EXTRA_DUMP
if (extra != NULL)
- fprintf(stderr, " detail: %s\n", EXTRA_DUMP(extra));
-#else
- (void)extra; /* UNUSED */
+ logprintf(" detail: %s\n", EXTRA_DUMP(extra));
#endif
if (dump_on_failure) {
fprintf(stderr,
" *** forcing core dump so failure can be debugged ***\n");
- *(char *)(NULL) = 0;
+ abort();
exit(1);
}
}
-/*
- * Summarize repeated failures in the just-completed test file.
- * The reports above suppress multiple failures from the same source
- * line; this reports on any tests that did fail multiple times.
- */
-static int
-summarize_comparator(const void *a0, const void *b0)
-{
- const struct line *a = a0, *b = b0;
- if (a->line == 0 && b->line == 0)
- return (0);
- if (a->line == 0)
- return (1);
- if (b->line == 0)
- return (-1);
- return (a->line - b->line);
-}
-
-static void
-summarize(void)
-{
- unsigned int i;
-
- qsort(failed_lines, sizeof(failed_lines)/sizeof(failed_lines[0]),
- sizeof(failed_lines[0]), summarize_comparator);
- for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
- if (failed_lines[i].line == 0)
- break;
- if (failed_lines[i].count > 1)
- fprintf(stderr, "%s:%d: Failed %d times\n",
- failed_filename, failed_lines[i].line,
- failed_lines[i].count);
- }
- /* Clear the failure history for the next file. */
- memset(failed_lines, 0, sizeof(failed_lines));
-}
-
-/* Set up a message to display only after a test fails. */
+/* Inform user that we're skipping some checks. */
void
-failure(const char *fmt, ...)
+test_skipping(const char *fmt, ...)
{
+ char buff[1024];
va_list ap;
+
va_start(ap, fmt);
- vsprintf(msg, fmt, ap);
+ vsprintf(buff, fmt, ap);
va_end(ap);
+ /* failure_start() isn't quite right, but is awfully convenient. */
+ failure_start(test_filename, test_line, "SKIPPING: %s", buff);
+ --failures; /* Undo failures++ in failure_start() */
+ /* Don't failure_finish() here. */
+ /* Mark as skip, so doesn't count as failed test. */
+ failed_lines[test_line].skip = 1;
+ ++skips;
}
+/*
+ *
+ * ASSERTIONS
+ *
+ */
+
/* Generic assert() just displays the failed condition. */
int
-test_assert(const char *file, int line, int value, const char *condition, void *extra)
+assertion_assert(const char *file, int line, int value,
+ const char *condition, void *extra)
{
- ++assertions;
- if (value) {
- msg[0] = '\0';
- return (value);
+ assertion_count(file, line);
+ if (!value) {
+ failure_start(file, line, "Assertion failed: %s", condition);
+ failure_finish(extra);
}
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (value);
- fprintf(stderr, "%s:%d: Assertion failed\n", file, line);
- fprintf(stderr, " Condition: %s\n", condition);
- report_failure(extra);
return (value);
}
-/* assertEqualInt() displays the values of the two integers. */
+/* chdir() and report any errors */
int
-test_assert_equal_int(const char *file, int line,
- int v1, const char *e1, int v2, const char *e2, void *extra)
+assertion_chdir(const char *file, int line, const char *pathname)
{
- ++assertions;
- if (v1 == v2) {
- msg[0] = '\0';
+ assertion_count(file, line);
+ if (chdir(pathname) == 0)
return (1);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: Ints not equal\n",
- file, line);
- fprintf(stderr, " %s=%d\n", e1, v1);
- fprintf(stderr, " %s=%d\n", e2, v2);
- report_failure(extra);
+ failure_start(file, line, "chdir(\"%s\")", pathname);
+ failure_finish(NULL);
+ return (0);
+
+}
+
+/* Verify two integers are equal. */
+int
+assertion_equal_int(const char *file, int line,
+ long long v1, const char *e1, long long v2, const char *e2, void *extra)
+{
+ assertion_count(file, line);
+ if (v1 == v2)
+ return (1);
+ failure_start(file, line, "%s != %s", e1, e2);
+ logprintf(" %s=%lld (0x%llx, 0%llo)\n", e1, v1, v1, v1);
+ logprintf(" %s=%lld (0x%llx, 0%llo)\n", e2, v2, v2, v2);
+ failure_finish(extra);
return (0);
}
-static void strdump(const char *p)
+static void strdump(const char *e, const char *p)
{
+ const char *q = p;
+
+ logprintf(" %s = ", e);
if (p == NULL) {
- fprintf(stderr, "(null)");
+ logprintf("NULL");
return;
}
- fprintf(stderr, "\"");
+ logprintf("\"");
while (*p != '\0') {
unsigned int c = 0xff & *p++;
switch (c) {
- case '\a': fprintf(stderr, "\a"); break;
- case '\b': fprintf(stderr, "\b"); break;
- case '\n': fprintf(stderr, "\n"); break;
- case '\r': fprintf(stderr, "\r"); break;
+ case '\a': printf("\a"); break;
+ case '\b': printf("\b"); break;
+ case '\n': printf("\n"); break;
+ case '\r': printf("\r"); break;
default:
if (c >= 32 && c < 127)
- fprintf(stderr, "%c", c);
+ logprintf("%c", c);
else
- fprintf(stderr, "\\x%02X", c);
+ logprintf("\\x%02X", c);
}
}
- fprintf(stderr, "\"");
+ logprintf("\"");
+ logprintf(" (length %d)\n", q == NULL ? -1 : (int)strlen(q));
}
-/* assertEqualString() displays the values of the two strings. */
+/* Verify two strings are equal, dump them if not. */
int
-test_assert_equal_string(const char *file, int line,
+assertion_equal_string(const char *file, int line,
const char *v1, const char *e1,
const char *v2, const char *e2,
void *extra)
{
- ++assertions;
- if (v1 == NULL || v2 == NULL) {
- if (v1 == v2) {
- msg[0] = '\0';
- return (1);
- }
- } else if (strcmp(v1, v2) == 0) {
- msg[0] = '\0';
+ assertion_count(file, line);
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && strcmp(v1, v2) == 0))
return (1);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: Strings not equal\n",
- file, line);
- fprintf(stderr, " %s = ", e1);
- strdump(v1);
- fprintf(stderr, " (length %d)\n", v1 == NULL ? 0 : strlen(v1));
- fprintf(stderr, " %s = ", e2);
- strdump(v2);
- fprintf(stderr, " (length %d)\n", v2 == NULL ? 0 : strlen(v2));
- report_failure(extra);
+ failure_start(file, line, "%s != %s", e1, e2);
+ strdump(e1, v1);
+ strdump(e2, v2);
+ failure_finish(extra);
return (0);
}
-static void wcsdump(const wchar_t *w)
+static void
+wcsdump(const char *e, const wchar_t *w)
{
+ logprintf(" %s = ", e);
if (w == NULL) {
- fprintf(stderr, "(null)");
+ logprintf("(null)");
return;
}
- fprintf(stderr, "\"");
+ logprintf("\"");
while (*w != L'\0') {
unsigned int c = *w++;
if (c >= 32 && c < 127)
- fprintf(stderr, "%c", c);
+ logprintf("%c", c);
else if (c < 256)
- fprintf(stderr, "\\x%02X", c);
+ logprintf("\\x%02X", c);
else if (c < 0x10000)
- fprintf(stderr, "\\u%04X", c);
+ logprintf("\\u%04X", c);
else
- fprintf(stderr, "\\U%08X", c);
+ logprintf("\\U%08X", c);
}
- fprintf(stderr, "\"");
+ logprintf("\"\n");
}
-/* assertEqualWString() displays the values of the two strings. */
+/* Verify that two wide strings are equal, dump them if not. */
int
-test_assert_equal_wstring(const char *file, int line,
+assertion_equal_wstring(const char *file, int line,
const wchar_t *v1, const char *e1,
const wchar_t *v2, const char *e2,
void *extra)
{
- ++assertions;
- if (v1 == NULL) {
- if (v2 == NULL) {
- msg[0] = '\0';
- return (1);
- }
- } else if (v2 == NULL) {
- if (v1 == NULL) {
- msg[0] = '\0';
- return (1);
- }
- } else if (wcscmp(v1, v2) == 0) {
- msg[0] = '\0';
+ assertion_count(file, line);
+ if (v1 == v2 || wcscmp(v1, v2) == 0)
return (1);
- }
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: Unicode strings not equal\n",
- file, line);
- fprintf(stderr, " %s = ", e1);
- wcsdump(v1);
- fprintf(stderr, "\n");
- fprintf(stderr, " %s = ", e2);
- wcsdump(v2);
- fprintf(stderr, "\n");
- report_failure(extra);
+ failure_start(file, line, "%s != %s", e1, e2);
+ wcsdump(e1, v1);
+ wcsdump(e2, v2);
+ failure_finish(extra);
return (0);
}
@@ -400,226 +513,950 @@ hexdump(const char *p, const char *ref, size_t l, size_t offset)
size_t i, j;
char sep;
+ if (p == NULL) {
+ logprintf("(null)\n");
+ return;
+ }
for(i=0; i < l; i+=16) {
- fprintf(stderr, "%04x", i + offset);
+ logprintf("%04x", (unsigned)(i + offset));
sep = ' ';
for (j = 0; j < 16 && i + j < l; j++) {
if (ref != NULL && p[i + j] != ref[i + j])
sep = '_';
- fprintf(stderr, "%c%02x", sep, 0xff & (int)p[i+j]);
+ logprintf("%c%02x", sep, 0xff & (int)p[i+j]);
if (ref != NULL && p[i + j] == ref[i + j])
sep = ' ';
}
for (; j < 16; j++) {
- fprintf(stderr, "%c ", sep);
+ logprintf("%c ", sep);
sep = ' ';
}
- fprintf(stderr, "%c", sep);
+ logprintf("%c", sep);
for (j=0; j < 16 && i + j < l; j++) {
int c = p[i + j];
if (c >= ' ' && c <= 126)
- fprintf(stderr, "%c", c);
+ logprintf("%c", c);
else
- fprintf(stderr, ".");
+ logprintf(".");
}
- fprintf(stderr, "\n");
+ logprintf("\n");
}
}
-/* assertEqualMem() displays the values of the two memory blocks. */
-/* TODO: For long blocks, hexdump the first bytes that actually differ. */
+/* Verify that two blocks of memory are the same, display the first
+ * block of differences if they're not. */
int
-test_assert_equal_mem(const char *file, int line,
- const char *v1, const char *e1,
- const char *v2, const char *e2,
+assertion_equal_mem(const char *file, int line,
+ const void *_v1, const char *e1,
+ const void *_v2, const char *e2,
size_t l, const char *ld, void *extra)
{
- ++assertions;
- if (v1 == NULL || v2 == NULL) {
- if (v1 == v2) {
- msg[0] = '\0';
- return (1);
- }
- } else if (memcmp(v1, v2, l) == 0) {
- msg[0] = '\0';
+ const char *v1 = (const char *)_v1;
+ const char *v2 = (const char *)_v2;
+ size_t offset;
+
+ assertion_count(file, line);
+ if (v1 == v2 || (v1 != NULL && v2 != NULL && memcmp(v1, v2, l) == 0))
return (1);
+
+ failure_start(file, line, "%s != %s", e1, e2);
+ logprintf(" size %s = %d\n", ld, (int)l);
+ /* Dump 48 bytes (3 lines) so that the first difference is
+ * in the second line. */
+ offset = 0;
+ while (l > 64 && memcmp(v1, v2, 32) == 0) {
+ /* Two lines agree, so step forward one line. */
+ v1 += 16;
+ v2 += 16;
+ l -= 16;
+ offset += 16;
}
- failures ++;
- if (!verbose && previous_failures(file, line))
- return (0);
- fprintf(stderr, "%s:%d: Assertion failed: memory not equal\n",
- file, line);
- fprintf(stderr, " size %s = %d\n", ld, (int)l);
- fprintf(stderr, " Dump of %s\n", e1);
- hexdump(v1, v2, l < 32 ? l : 32, 0);
- fprintf(stderr, " Dump of %s\n", e2);
- hexdump(v2, v1, l < 32 ? l : 32, 0);
- fprintf(stderr, "\n");
- report_failure(extra);
+ logprintf(" Dump of %s\n", e1);
+ hexdump(v1, v2, l < 64 ? l : 64, offset);
+ logprintf(" Dump of %s\n", e2);
+ hexdump(v2, v1, l < 64 ? l : 64, offset);
+ logprintf("\n");
+ failure_finish(extra);
return (0);
}
+/* Verify that the named file exists and is empty. */
int
-test_assert_empty_file(const char *f1fmt, ...)
+assertion_empty_file(const char *f1fmt, ...)
{
char buff[1024];
char f1[1024];
struct stat st;
va_list ap;
ssize_t s;
- int fd;
-
+ FILE *f;
+ assertion_count(test_filename, test_line);
va_start(ap, f1fmt);
vsprintf(f1, f1fmt, ap);
va_end(ap);
if (stat(f1, &st) != 0) {
- fprintf(stderr, "%s:%d: Could not stat: %s\n", test_filename, test_line, f1);
- report_failure(NULL);
+ failure_start(test_filename, test_line, "Stat failed: %s", f1);
+ failure_finish(NULL);
return (0);
}
if (st.st_size == 0)
return (1);
- failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
- return (0);
-
- fprintf(stderr, "%s:%d: File not empty: %s\n", test_filename, test_line, f1);
- fprintf(stderr, " File size: %d\n", (int)st.st_size);
- fprintf(stderr, " Contents:\n");
- fd = open(f1, O_RDONLY);
- if (fd < 0) {
- fprintf(stderr, " Unable to open %s\n", f1);
+ failure_start(test_filename, test_line, "File should be empty: %s", f1);
+ logprintf(" File size: %d\n", (int)st.st_size);
+ logprintf(" Contents:\n");
+ f = fopen(f1, "rb");
+ if (f == NULL) {
+ logprintf(" Unable to open %s\n", f1);
} else {
- s = sizeof(buff) < st.st_size ? sizeof(buff) : st.st_size;
- s = read(fd, buff, s);
+ s = ((off_t)sizeof(buff) < st.st_size) ?
+ (ssize_t)sizeof(buff) : (ssize_t)st.st_size;
+ s = fread(buff, 1, s, f);
hexdump(buff, NULL, s, 0);
+ fclose(f);
}
- report_failure(NULL);
+ failure_finish(NULL);
return (0);
}
-/* assertEqualFile() asserts that two files have the same contents. */
+/* Verify that the named file exists and is not empty. */
+int
+assertion_non_empty_file(const char *f1fmt, ...)
+{
+ char f1[1024];
+ struct stat st;
+ va_list ap;
+
+ assertion_count(test_filename, test_line);
+ va_start(ap, f1fmt);
+ vsprintf(f1, f1fmt, ap);
+ va_end(ap);
+
+ if (stat(f1, &st) != 0) {
+ failure_start(test_filename, test_line, "Stat failed: %s", f1);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (st.st_size == 0) {
+ failure_start(test_filename, test_line, "File empty: %s", f1);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (1);
+}
+
+/* Verify that two files have the same contents. */
/* TODO: hexdump the first bytes that actually differ. */
int
-test_assert_equal_file(const char *f1, const char *f2pattern, ...)
+assertion_equal_file(const char *fn1, const char *f2pattern, ...)
{
- char f2[1024];
+ char fn2[1024];
va_list ap;
char buff1[1024];
char buff2[1024];
- int fd1, fd2;
+ FILE *f1, *f2;
int n1, n2;
+ assertion_count(test_filename, test_line);
va_start(ap, f2pattern);
- vsprintf(f2, f2pattern, ap);
+ vsprintf(fn2, f2pattern, ap);
va_end(ap);
- fd1 = open(f1, O_RDONLY);
- fd2 = open(f2, O_RDONLY);
+ f1 = fopen(fn1, "rb");
+ f2 = fopen(fn2, "rb");
for (;;) {
- n1 = read(fd1, buff1, sizeof(buff1));
- n2 = read(fd2, buff2, sizeof(buff2));
+ n1 = fread(buff1, 1, sizeof(buff1), f1);
+ n2 = fread(buff2, 1, sizeof(buff2), f2);
if (n1 != n2)
break;
- if (n1 == 0 && n2 == 0)
+ if (n1 == 0 && n2 == 0) {
+ fclose(f1);
+ fclose(f2);
return (1);
+ }
if (memcmp(buff1, buff2, n1) != 0)
break;
}
- failures ++;
- if (!verbose && previous_failures(test_filename, test_line))
- return (0);
- fprintf(stderr, "%s:%d: Files are not identical\n",
- test_filename, test_line);
- fprintf(stderr, " file1=\"%s\"\n", f1);
- fprintf(stderr, " file2=\"%s\"\n", f2);
- report_failure(test_extra);
+ fclose(f1);
+ fclose(f2);
+ failure_start(test_filename, test_line, "Files not identical");
+ logprintf(" file1=\"%s\"\n", fn1);
+ logprintf(" file2=\"%s\"\n", fn2);
+ failure_finish(test_extra);
return (0);
}
+/* Verify that the named file does exist. */
int
-test_assert_file_exists(const char *fpattern, ...)
+assertion_file_exists(const char *fpattern, ...)
{
char f[1024];
va_list ap;
+ assertion_count(test_filename, test_line);
va_start(ap, fpattern);
vsprintf(f, fpattern, ap);
va_end(ap);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ if (!_access(f, 0))
+ return (1);
+#else
if (!access(f, F_OK))
return (1);
- if (!previous_failures(test_filename, test_line)) {
- fprintf(stderr, "%s:%d: File doesn't exist\n",
- test_filename, test_line);
- fprintf(stderr, " file=\"%s\"\n", f);
- report_failure(test_extra);
- }
+#endif
+ failure_start(test_filename, test_line, "File should exist: %s", f);
+ failure_finish(test_extra);
return (0);
}
+/* Verify that the named file doesn't exist. */
int
-test_assert_file_not_exists(const char *fpattern, ...)
+assertion_file_not_exists(const char *fpattern, ...)
{
char f[1024];
va_list ap;
+ assertion_count(test_filename, test_line);
va_start(ap, fpattern);
vsprintf(f, fpattern, ap);
va_end(ap);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ if (_access(f, 0))
+ return (1);
+#else
if (access(f, F_OK))
return (1);
- if (!previous_failures(test_filename, test_line)) {
- fprintf(stderr, "%s:%d: File exists and shouldn't\n",
- test_filename, test_line);
- fprintf(stderr, " file=\"%s\"\n", f);
- report_failure(test_extra);
- }
+#endif
+ failure_start(test_filename, test_line, "File should not exist: %s", f);
+ failure_finish(test_extra);
return (0);
}
-/* assertFileContents() asserts the contents of a file. */
+/* Compare the contents of a file to a block of memory. */
int
-test_assert_file_contents(const void *buff, int s, const char *fpattern, ...)
+assertion_file_contents(const void *buff, int s, const char *fpattern, ...)
{
- char f[1024];
+ char fn[1024];
va_list ap;
char *contents;
- int fd;
+ FILE *f;
int n;
+ assertion_count(test_filename, test_line);
va_start(ap, fpattern);
- vsprintf(f, fpattern, ap);
+ vsprintf(fn, fpattern, ap);
va_end(ap);
- fd = open(f, O_RDONLY);
+ f = fopen(fn, "rb");
+ if (f == NULL) {
+ failure_start(test_filename, test_line,
+ "File should exist: %s", fn);
+ failure_finish(test_extra);
+ return (0);
+ }
contents = malloc(s * 2);
- n = read(fd, contents, s * 2);
+ n = fread(contents, 1, s * 2, f);
+ fclose(f);
if (n == s && memcmp(buff, contents, s) == 0) {
free(contents);
return (1);
}
- failures ++;
- if (!previous_failures(test_filename, test_line)) {
- fprintf(stderr, "%s:%d: File contents don't match\n",
- test_filename, test_line);
- fprintf(stderr, " file=\"%s\"\n", f);
- if (n > 0)
- hexdump(contents, buff, n, 0);
- else {
- fprintf(stderr, " File empty, contents should be:\n");
- hexdump(buff, NULL, s, 0);
+ failure_start(test_filename, test_line, "File contents don't match");
+ logprintf(" file=\"%s\"\n", fn);
+ if (n > 0)
+ hexdump(contents, buff, n > 512 ? 512 : n, 0);
+ else {
+ logprintf(" File empty, contents should be:\n");
+ hexdump(buff, NULL, s > 512 ? 512 : n, 0);
+ }
+ failure_finish(test_extra);
+ free(contents);
+ return (0);
+}
+
+/* Check the contents of a text file, being tolerant of line endings. */
+int
+assertion_text_file_contents(const char *buff, const char *fn)
+{
+ char *contents;
+ const char *btxt, *ftxt;
+ FILE *f;
+ int n, s;
+
+ assertion_count(test_filename, test_line);
+ f = fopen(fn, "r");
+ s = strlen(buff);
+ contents = malloc(s * 2 + 128);
+ n = fread(contents, 1, s * 2 + 128 - 1, f);
+ if (n >= 0)
+ contents[n] = '\0';
+ fclose(f);
+ /* Compare texts. */
+ btxt = buff;
+ ftxt = (const char *)contents;
+ while (*btxt != '\0' && *ftxt != '\0') {
+ if (*btxt == *ftxt) {
+ ++btxt;
+ ++ftxt;
+ continue;
}
- report_failure(test_extra);
+ if (btxt[0] == '\n' && ftxt[0] == '\r' && ftxt[1] == '\n') {
+ /* Pass over different new line characters. */
+ ++btxt;
+ ftxt += 2;
+ continue;
+ }
+ break;
+ }
+ if (*btxt == '\0' && *ftxt == '\0') {
+ free(contents);
+ return (1);
}
+ failure_start(test_filename, test_line, "Contents don't match");
+ logprintf(" file=\"%s\"\n", fn);
+ if (n > 0)
+ hexdump(contents, buff, n, 0);
+ else {
+ logprintf(" File empty, contents should be:\n");
+ hexdump(buff, NULL, s, 0);
+ }
+ failure_finish(test_extra);
free(contents);
return (0);
}
+/* Test that two paths point to the same file. */
+/* As a side-effect, asserts that both files exist. */
+static int
+is_hardlink(const char *file, int line,
+ const char *path1, const char *path2)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ BY_HANDLE_FILE_INFORMATION bhfi1, bhfi2;
+ int r;
+
+ assertion_count(file, line);
+ r = my_GetFileInformationByName(path1, &bhfi1);
+ if (r == 0) {
+ failure_start(file, line, "File %s can't be inspected?", path1);
+ failure_finish(NULL);
+ return (0);
+ }
+ r = my_GetFileInformationByName(path2, &bhfi2);
+ if (r == 0) {
+ failure_start(file, line, "File %s can't be inspected?", path2);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (bhfi1.dwVolumeSerialNumber == bhfi2.dwVolumeSerialNumber
+ && bhfi1.nFileIndexHigh == bhfi2.nFileIndexHigh
+ && bhfi1.nFileIndexLow == bhfi2.nFileIndexLow);
+#else
+ struct stat st1, st2;
+ int r;
+
+ assertion_count(file, line);
+ r = lstat(path1, &st1);
+ if (r != 0) {
+ failure_start(file, line, "File should exist: %s", path1);
+ failure_finish(NULL);
+ return (0);
+ }
+ r = lstat(path2, &st2);
+ if (r != 0) {
+ failure_start(file, line, "File should exist: %s", path2);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (st1.st_ino == st2.st_ino && st1.st_dev == st2.st_dev);
+#endif
+}
+
+int
+assertion_is_hardlink(const char *file, int line,
+ const char *path1, const char *path2)
+{
+ if (is_hardlink(file, line, path1, path2))
+ return (1);
+ failure_start(file, line,
+ "Files %s and %s are not hardlinked", path1, path2);
+ failure_finish(NULL);
+ return (0);
+}
+
+int
+assertion_is_not_hardlink(const char *file, int line,
+ const char *path1, const char *path2)
+{
+ if (!is_hardlink(file, line, path1, path2))
+ return (1);
+ failure_start(file, line,
+ "Files %s and %s should not be hardlinked", path1, path2);
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Verify a/b/mtime of 'pathname'. */
+/* If 'recent', verify that it's within last 10 seconds. */
+static int
+assertion_file_time(const char *file, int line,
+ const char *pathname, long t, long nsec, char type, int recent)
+{
+ long long filet, filet_nsec;
+ int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define EPOC_TIME (116444736000000000ULL)
+ FILETIME ftime, fbirthtime, fatime, fmtime;
+ ULARGE_INTEGER wintm;
+ HANDLE h;
+ ftime.dwLowDateTime = 0;
+ ftime.dwHighDateTime = 0;
+
+ assertion_count(file, line);
+ h = CreateFile(pathname, FILE_READ_ATTRIBUTES, 0, NULL,
+ OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ failure_start(file, line, "Can't access %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ r = GetFileTime(h, &fbirthtime, &fatime, &fmtime);
+ switch (type) {
+ case 'a': ftime = fatime; break;
+ case 'b': ftime = fbirthtime; break;
+ case 'm': ftime = fmtime; break;
+ }
+ CloseHandle(h);
+ if (r == 0) {
+ failure_start(file, line, "Can't GetFileTime %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ wintm.LowPart = ftime.dwLowDateTime;
+ wintm.HighPart = ftime.dwHighDateTime;
+ filet = (wintm.QuadPart - EPOC_TIME) / 10000000;
+ filet_nsec = ((wintm.QuadPart - EPOC_TIME) % 10000000) * 100;
+ nsec = (nsec / 100) * 100; /* Round the request */
+#else
+ struct stat st;
+
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0) {
+ failure_start(file, line, "Can't stat %s\n", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ switch (type) {
+ case 'a': filet = st.st_atime; break;
+ case 'm': filet = st.st_mtime; break;
+ case 'b': filet = 0; break;
+ default: fprintf(stderr, "INTERNAL: Bad type %c for file time", type);
+ exit(1);
+ }
+#if defined(__FreeBSD__)
+ switch (type) {
+ case 'a': filet_nsec = st.st_atimespec.tv_nsec; break;
+ case 'b': filet = st.st_birthtime;
+ 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);
+ exit(1);
+ }
+ /* FreeBSD generally only stores to microsecond res, so round. */
+ filet_nsec = (filet_nsec / 1000) * 1000;
+ nsec = (nsec / 1000) * 1000;
+#else
+ filet_nsec = nsec = 0; /* Generic POSIX only has whole seconds. */
+ if (type == 'b') return (1); /* Generic POSIX doesn't have birthtime */
+#if defined(__HAIKU__)
+ if (type == 'a') return (1); /* Haiku doesn't have atime. */
+#endif
+#endif
+#endif
+ if (recent) {
+ /* Check that requested time is up-to-date. */
+ time_t now = time(NULL);
+ if (filet < now - 10 || filet > now + 1) {
+ failure_start(file, line,
+ "File %s has %ctime %ld, %ld seconds ago\n",
+ pathname, type, filet, now - filet);
+ failure_finish(NULL);
+ return (0);
+ }
+ } else if (filet != t || filet_nsec != nsec) {
+ failure_start(file, line,
+ "File %s has %ctime %ld.%09ld, expected %ld.%09ld",
+ pathname, type, filet, filet_nsec, t, nsec);
+ failure_finish(NULL);
+ return (0);
+ }
+ return (1);
+}
+
+/* Verify atime of 'pathname'. */
+int
+assertion_file_atime(const char *file, int line,
+ const char *pathname, long t, long nsec)
+{
+ return assertion_file_time(file, line, pathname, t, nsec, 'a', 0);
+}
+
+/* Verify atime of 'pathname' is up-to-date. */
+int
+assertion_file_atime_recent(const char *file, int line, const char *pathname)
+{
+ return assertion_file_time(file, line, pathname, 0, 0, 'a', 1);
+}
+
+/* Verify birthtime of 'pathname'. */
+int
+assertion_file_birthtime(const char *file, int line,
+ const char *pathname, long t, long nsec)
+{
+ return assertion_file_time(file, line, pathname, t, nsec, 'b', 0);
+}
+
+/* Verify birthtime of 'pathname' is up-to-date. */
+int
+assertion_file_birthtime_recent(const char *file, int line,
+ const char *pathname)
+{
+ return assertion_file_time(file, line, pathname, 0, 0, 'b', 1);
+}
+
+/* Verify mtime of 'pathname'. */
+int
+assertion_file_mtime(const char *file, int line,
+ const char *pathname, long t, long nsec)
+{
+ return assertion_file_time(file, line, pathname, t, nsec, 'm', 0);
+}
+
+/* Verify mtime of 'pathname' is up-to-date. */
+int
+assertion_file_mtime_recent(const char *file, int line, const char *pathname)
+{
+ return assertion_file_time(file, line, pathname, 0, 0, 'm', 1);
+}
+
+/* Verify number of links to 'pathname'. */
+int
+assertion_file_nlinks(const char *file, int line,
+ const char *pathname, int nlinks)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ int r;
+
+ assertion_count(file, line);
+ r = my_GetFileInformationByName(pathname, &bhfi);
+ if (r != 0 && bhfi.nNumberOfLinks == (DWORD)nlinks)
+ return (1);
+ failure_start(file, line, "File %s has %d links, expected %d",
+ pathname, bhfi.nNumberOfLinks, nlinks);
+ failure_finish(NULL);
+ return (0);
+#else
+ struct stat st;
+ int r;
+
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r == 0 && st.st_nlink == nlinks)
+ return (1);
+ failure_start(file, line, "File %s has %d links, expected %d",
+ pathname, st.st_nlink, nlinks);
+ failure_finish(NULL);
+ return (0);
+#endif
+}
+
+/* Verify size of 'pathname'. */
+int
+assertion_file_size(const char *file, int line, const char *pathname, long size)
+{
+ int64_t filesize;
+ int r;
+
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ {
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ r = !my_GetFileInformationByName(pathname, &bhfi);
+ filesize = ((int64_t)bhfi.nFileSizeHigh << 32) + bhfi.nFileSizeLow;
+ }
+#else
+ {
+ struct stat st;
+ r = lstat(pathname, &st);
+ filesize = st.st_size;
+ }
+#endif
+ if (r == 0 && filesize == size)
+ return (1);
+ failure_start(file, line, "File %s has size %ld, expected %ld",
+ pathname, (long)filesize, (long)size);
+ failure_finish(NULL);
+ return (0);
+}
+
+/* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */
+int
+assertion_is_dir(const char *file, int line, const char *pathname, int mode)
+{
+ struct stat st;
+ int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)mode; /* UNUSED */
+#endif
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0) {
+ failure_start(file, line, "Dir should exist: %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (!S_ISDIR(st.st_mode)) {
+ failure_start(file, line, "%s is not a dir", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ /* Windows doesn't handle permissions the same way as POSIX,
+ * so just ignore the mode tests. */
+ /* TODO: Can we do better here? */
+ if (mode >= 0 && mode != (st.st_mode & 07777)) {
+ failure_start(file, line, "Dir %s has wrong mode", pathname);
+ logprintf(" Expected: 0%3o\n", mode);
+ logprintf(" Found: 0%3o\n", st.st_mode & 07777);
+ failure_finish(NULL);
+ return (0);
+ }
+#endif
+ return (1);
+}
+
+/* Verify that 'pathname' is a regular file. If 'mode' is >= 0,
+ * verify that too. */
+int
+assertion_is_reg(const char *file, int line, const char *pathname, int mode)
+{
+ struct stat st;
+ int r;
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)mode; /* UNUSED */
+#endif
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0 || !S_ISREG(st.st_mode)) {
+ failure_start(file, line, "File should exist: %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ /* Windows doesn't handle permissions the same way as POSIX,
+ * so just ignore the mode tests. */
+ /* TODO: Can we do better here? */
+ if (mode >= 0 && mode != (st.st_mode & 07777)) {
+ failure_start(file, line, "File %s has wrong mode", pathname);
+ logprintf(" Expected: 0%3o\n", mode);
+ logprintf(" Found: 0%3o\n", st.st_mode & 07777);
+ failure_finish(NULL);
+ return (0);
+ }
+#endif
+ return (1);
+}
+
+/* Check whether 'pathname' is a symbolic link. If 'contents' is
+ * non-NULL, verify that the symlink has those contents. */
+static int
+is_symlink(const char *file, int line,
+ const char *pathname, const char *contents)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)pathname; /* UNUSED */
+ (void)contents; /* UNUSED */
+ assertion_count(file, line);
+ /* Windows sort-of has real symlinks, but they're only usable
+ * by privileged users and are crippled even then, so there's
+ * really not much point in bothering with this. */
+ return (0);
+#else
+ char buff[300];
+ struct stat st;
+ ssize_t linklen;
+ int r;
+
+ assertion_count(file, line);
+ r = lstat(pathname, &st);
+ if (r != 0) {
+ failure_start(file, line,
+ "Symlink should exist: %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (!S_ISLNK(st.st_mode))
+ return (0);
+ if (contents == NULL)
+ return (1);
+ linklen = readlink(pathname, buff, sizeof(buff));
+ if (linklen < 0) {
+ failure_start(file, line, "Can't read symlink %s", pathname);
+ failure_finish(NULL);
+ return (0);
+ }
+ buff[linklen] = '\0';
+ if (strcmp(buff, contents) != 0)
+ return (0);
+ return (1);
+#endif
+}
+
+/* Assert that path is a symlink that (optionally) contains contents. */
+int
+assertion_is_symlink(const char *file, int line,
+ const char *path, const char *contents)
+{
+ if (is_symlink(file, line, path, contents))
+ return (1);
+ if (contents)
+ failure_start(file, line, "File %s is not a symlink to %s",
+ path, contents);
+ else
+ failure_start(file, line, "File %s is not a symlink", path);
+ failure_finish(NULL);
+ return (0);
+}
+
+
+/* Create a directory and report any errors. */
+int
+assertion_make_dir(const char *file, int line, const char *dirname, int mode)
+{
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ (void)mode; /* UNUSED */
+ if (0 == _mkdir(dirname))
+ return (1);
+#else
+ if (0 == mkdir(dirname, mode))
+ return (1);
+#endif
+ failure_start(file, line, "Could not create directory %s", dirname);
+ failure_finish(NULL);
+ return(0);
+}
+
+/* Create a file with the specified contents and report any failures. */
+int
+assertion_make_file(const char *file, int line,
+ const char *path, int mode, const char *contents)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* TODO: Rework this to set file mode as well. */
+ FILE *f;
+ (void)mode; /* UNUSED */
+ assertion_count(file, line);
+ f = fopen(path, "wb");
+ if (f == NULL) {
+ failure_start(file, line, "Could not create file %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (contents != NULL) {
+ if (strlen(contents)
+ != fwrite(contents, 1, strlen(contents), f)) {
+ fclose(f);
+ failure_start(file, line,
+ "Could not write file %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ }
+ fclose(f);
+ return (1);
+#else
+ int fd;
+ assertion_count(file, line);
+ fd = open(path, O_CREAT | O_WRONLY, mode >= 0 ? mode : 0644);
+ if (fd < 0) {
+ failure_start(file, line, "Could not create %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ if (contents != NULL) {
+ if ((ssize_t)strlen(contents)
+ != write(fd, contents, strlen(contents))) {
+ close(fd);
+ failure_start(file, line, "Could not write to %s", path);
+ failure_finish(NULL);
+ return (0);
+ }
+ }
+ close(fd);
+ return (1);
+#endif
+}
+
+/* Create a hardlink and report any failures. */
+int
+assertion_make_hardlink(const char *file, int line,
+ const char *newpath, const char *linkto)
+{
+ int succeeded;
+
+ assertion_count(file, line);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ succeeded = my_CreateHardLinkA(newpath, linkto);
+#elif HAVE_LINK
+ succeeded = !link(linkto, newpath);
+#else
+ succeeded = 0;
+#endif
+ if (succeeded)
+ return (1);
+ failure_start(file, line, "Could not create hardlink");
+ logprintf(" New link: %s\n", newpath);
+ logprintf(" Old name: %s\n", linkto);
+ failure_finish(NULL);
+ return(0);
+}
+
+/* Create a symlink and report any failures. */
+int
+assertion_make_symlink(const char *file, int line,
+ const char *newpath, const char *linkto)
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ int targetIsDir = 0; /* TODO: Fix this */
+ assertion_count(file, line);
+ if (my_CreateSymbolicLinkA(newpath, linkto, targetIsDir))
+ return (1);
+#elif HAVE_SYMLINK
+ assertion_count(file, line);
+ if (0 == symlink(linkto, newpath))
+ return (1);
+#endif
+ failure_start(file, line, "Could not create symlink");
+ logprintf(" New link: %s\n", newpath);
+ logprintf(" Old name: %s\n", linkto);
+ failure_finish(NULL);
+ return(0);
+}
+
+/* Set umask, report failures. */
+int
+assertion_umask(const char *file, int line, int mask)
+{
+ assertion_count(file, line);
+ (void)file; /* UNUSED */
+ (void)line; /* UNUSED */
+ umask(mask);
+ return (1);
+}
+
+/*
+ *
+ * UTILITIES for use by tests.
+ *
+ */
+
+/*
+ * Check whether platform supports symlinks. This is intended
+ * for tests to use in deciding whether to bother testing symlink
+ * support; if the platform doesn't support symlinks, there's no point
+ * in checking whether the program being tested can create them.
+ *
+ * Note that the first time this test is called, we actually go out to
+ * disk to create and verify a symlink. This is necessary because
+ * symlink support is actually a property of a particular filesystem
+ * and can thus vary between directories on a single system. After
+ * the first call, this returns the cached result from memory, so it's
+ * safe to call it as often as you wish.
+ */
+int
+canSymlink(void)
+{
+ /* Remember the test result */
+ static int value = 0, tested = 0;
+ if (tested)
+ return (value);
+
+ ++tested;
+ assertion_make_file(__FILE__, __LINE__, "canSymlink.0", 0644, "a");
+ /* Note: Cygwin has its own symlink() emulation that does not
+ * use the Win32 CreateSymbolicLink() function. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ value = my_CreateSymbolicLinkA("canSymlink.1", "canSymlink.0", 0)
+ && is_symlink(__FILE__, __LINE__, "canSymlink.1", "canSymlink.0");
+#elif HAVE_SYMLINK
+ value = (0 == symlink("canSymlink.0", "canSymlink.1"))
+ && is_symlink(__FILE__, __LINE__, "canSymlink.1","canSymlink.0");
+#endif
+ return (value);
+}
+
+/*
+ * Can this platform run the gzip program?
+ */
+/* Platform-dependent options for hiding the output of a subcommand. */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static const char *redirectArgs = ">NUL 2>NUL"; /* Win32 cmd.exe */
+#else
+static const char *redirectArgs = ">/dev/null 2>/dev/null"; /* POSIX 'sh' */
+#endif
+int
+canGzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("gzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Can this platform run the gunzip program?
+ */
+int
+canGunzip(void)
+{
+ static int tested = 0, value = 0;
+ if (!tested) {
+ tested = 1;
+ if (systemf("gunzip -V %s", redirectArgs) == 0)
+ value = 1;
+ }
+ return (value);
+}
+
+/*
+ * Sleep as needed; useful for verifying disk timestamp changes by
+ * ensuring that the wall-clock time has actually changed before we
+ * go back to re-read something from disk.
+ */
+void
+sleepUntilAfter(time_t t)
+{
+ while (t >= time(NULL))
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ Sleep(500);
+#else
+ sleep(1);
+#endif
+}
+
/*
* Call standard system() call, but build up the command line using
* sprintf() conventions.
@@ -633,6 +1470,8 @@ systemf(const char *fmt, ...)
va_start(ap, fmt);
vsprintf(buff, fmt, ap);
+ if (verbosity > VERBOSITY_FULL)
+ logprintf("Cmd: %s\n", buff);
r = system(buff);
va_end(ap);
return (r);
@@ -651,112 +1490,263 @@ slurpfile(size_t * sizep, const char *fmt, ...)
va_list ap;
char *p;
ssize_t bytes_read;
- int fd;
+ FILE *f;
int r;
va_start(ap, fmt);
vsprintf(filename, fmt, ap);
va_end(ap);
- fd = open(filename, O_RDONLY);
- if (fd < 0) {
+ f = fopen(filename, "rb");
+ if (f == NULL) {
/* Note: No error; non-existent file is okay here. */
return (NULL);
}
- r = fstat(fd, &st);
+ r = fstat(fileno(f), &st);
if (r != 0) {
- fprintf(stderr, "Can't stat file %s\n", filename);
- close(fd);
+ logprintf("Can't stat file %s\n", filename);
+ fclose(f);
return (NULL);
}
- p = malloc(st.st_size + 1);
+ p = malloc((size_t)st.st_size + 1);
if (p == NULL) {
- fprintf(stderr, "Can't allocate %ld bytes of memory to read file %s\n", (long int)st.st_size, filename);
- close(fd);
+ logprintf("Can't allocate %ld bytes of memory to read file %s\n",
+ (long int)st.st_size, filename);
+ fclose(f);
return (NULL);
}
- bytes_read = read(fd, p, st.st_size);
+ bytes_read = fread(p, 1, (size_t)st.st_size, f);
if (bytes_read < st.st_size) {
- fprintf(stderr, "Can't read file %s\n", filename);
- close(fd);
+ logprintf("Can't read file %s\n", filename);
+ fclose(f);
free(p);
return (NULL);
}
p[st.st_size] = '\0';
if (sizep != NULL)
*sizep = (size_t)st.st_size;
- close(fd);
+ fclose(f);
return (p);
}
+/* Read a uuencoded file from the reference directory, decode, and
+ * write the result into the current directory. */
+#define UUDECODE(c) (((c) - 0x20) & 0x3f)
+void
+extract_reference_file(const char *name)
+{
+ char buff[1024];
+ FILE *in, *out;
+
+ sprintf(buff, "%s/%s.uu", refdir, name);
+ in = fopen(buff, "r");
+ failure("Couldn't open reference file %s", buff);
+ assert(in != NULL);
+ if (in == NULL)
+ return;
+ /* Read up to and including the 'begin' line. */
+ for (;;) {
+ if (fgets(buff, sizeof(buff), in) == NULL) {
+ /* TODO: This is a failure. */
+ return;
+ }
+ if (memcmp(buff, "begin ", 6) == 0)
+ break;
+ }
+ /* Now, decode the rest and write it. */
+ /* Not a lot of error checking here; the input better be right. */
+ out = fopen(name, "wb");
+ while (fgets(buff, sizeof(buff), in) != NULL) {
+ char *p = buff;
+ int bytes;
+
+ if (memcmp(buff, "end", 3) == 0)
+ break;
+
+ bytes = UUDECODE(*p++);
+ while (bytes > 0) {
+ int n = 0;
+ /* Write out 1-3 bytes from that. */
+ if (bytes > 0) {
+ n = UUDECODE(*p++) << 18;
+ n |= UUDECODE(*p++) << 12;
+ fputc(n >> 16, out);
+ --bytes;
+ }
+ if (bytes > 0) {
+ n |= UUDECODE(*p++) << 6;
+ fputc((n >> 8) & 0xFF, out);
+ --bytes;
+ }
+ if (bytes > 0) {
+ n |= UUDECODE(*p++);
+ fputc(n & 0xFF, out);
+ --bytes;
+ }
+ }
+ }
+ fclose(out);
+ fclose(in);
+}
+
/*
- * "list.h" is automatically generated; it just has a lot of lines like:
- * DEFINE_TEST(function_name)
- * It's used above to declare all of the test functions.
- * We reuse it here to define a list of all tests (functions and names).
+ *
+ * TEST management
+ *
+ */
+
+/*
+ * "list.h" is simply created by "grep DEFINE_TEST test_*.c"; it has
+ * a line like
+ * DEFINE_TEST(test_function)
+ * for each test.
*/
+
+/* Use "list.h" to declare all of the test functions. */
+#undef DEFINE_TEST
+#define DEFINE_TEST(name) void name(void);
+#include "list.h"
+
+/* Use "list.h" to create a list of all tests (functions and names). */
#undef DEFINE_TEST
-#define DEFINE_TEST(n) { n, #n },
-struct { void (*func)(void); const char *name; } tests[] = {
+#define DEFINE_TEST(n) { n, #n, 0 },
+struct { void (*func)(void); const char *name; int failures; } tests[] = {
#include "list.h"
};
/*
- * Each test is run in a private work dir. Those work dirs
- * do have consistent and predictable names, in case a group
- * of tests need to collaborate. However, there is no provision
- * for requiring that tests run in a certain order.
+ * Summarize repeated failures in the just-completed test.
*/
-static int test_run(int i, const char *tmpdir)
+static void
+test_summarize(const char *filename, int failed)
{
- int failures_before = failures;
+ unsigned int i;
- if (!quiet_flag) {
- printf("%d: %s\n", i, tests[i].name);
+ switch (verbosity) {
+ case VERBOSITY_SUMMARY_ONLY:
+ printf(failed ? "E" : ".");
fflush(stdout);
+ break;
+ case VERBOSITY_PASSFAIL:
+ printf(failed ? "FAIL\n" : "ok\n");
+ break;
}
- /*
- * Always explicitly chdir() in case the last test moved us to
- * a strange place.
- */
- if (chdir(tmpdir)) {
- fprintf(stderr,
- "ERROR: Couldn't chdir to temp dir %s\n",
- tmpdir);
- exit(1);
+ log_console = (verbosity == VERBOSITY_LIGHT_REPORT);
+
+ for (i = 0; i < sizeof(failed_lines)/sizeof(failed_lines[0]); i++) {
+ if (failed_lines[i].count > 1 && !failed_lines[i].skip)
+ logprintf("%s:%d: Summary: Failed %d times\n",
+ filename, i, failed_lines[i].count);
+ }
+ /* Clear the failure history for the next file. */
+ memset(failed_lines, 0, sizeof(failed_lines));
+}
+
+/*
+ * Actually run a single test, with appropriate setup and cleanup.
+ */
+static int
+test_run(int i, const char *tmpdir)
+{
+ char logfilename[64];
+ int failures_before = failures;
+ int oldumask;
+
+ switch (verbosity) {
+ case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */
+ break;
+ case VERBOSITY_PASSFAIL: /* rest of line will include ok/FAIL marker */
+ printf("%3d: %-50s", i, tests[i].name);
+ fflush(stdout);
+ break;
+ default: /* Title of test, details will follow */
+ printf("%3d: %s\n", i, tests[i].name);
}
- /* Create a temp directory for this specific test. */
- if (mkdir(tests[i].name, 0755)) {
+
+ /* Chdir to the top-level work directory. */
+ if (!assertChdir(tmpdir)) {
fprintf(stderr,
- "ERROR: Couldn't create temp dir ``%s''\n",
- tests[i].name);
+ "ERROR: Can't chdir to top work dir %s\n", tmpdir);
exit(1);
}
- /* Chdir() to that work directory. */
- if (chdir(tests[i].name)) {
+ /* Create a log file for this test. */
+ sprintf(logfilename, "%s.log", tests[i].name);
+ logfile = fopen(logfilename, "w");
+ fprintf(logfile, "%s\n\n", tests[i].name);
+ /* Chdir() to a work dir for this specific test. */
+ if (!assertMakeDir(tests[i].name, 0755)
+ || !assertChdir(tests[i].name)) {
fprintf(stderr,
- "ERROR: Couldn't chdir to temp dir ``%s''\n",
- tests[i].name);
+ "ERROR: Can't chdir to work dir %s/%s\n",
+ tmpdir, tests[i].name);
exit(1);
}
/* Explicitly reset the locale before each test. */
setlocale(LC_ALL, "C");
- /* Run the actual test. */
+ /* Record the umask before we run the test. */
+ umask(oldumask = umask(0));
+ /*
+ * Run the actual test.
+ */
(*tests[i].func)();
- /* Summarize the results of this test. */
- summarize();
- /* If there were no failures, we can remove the work dir. */
- if (failures == failures_before) {
- if (!keep_temp_files && chdir(tmpdir) == 0) {
+ /*
+ * Clean up and report afterwards.
+ */
+ /* Restore umask */
+ umask(oldumask);
+ /* Reset locale. */
+ setlocale(LC_ALL, "C");
+ /* Reset directory. */
+ if (!assertChdir(tmpdir)) {
+ fprintf(stderr, "ERROR: Couldn't chdir to temp dir %s\n",
+ tmpdir);
+ exit(1);
+ }
+ /* Report per-test summaries. */
+ tests[i].failures = failures - failures_before;
+ test_summarize(test_filename, tests[i].failures);
+ /* Close the per-test log file. */
+ fclose(logfile);
+ logfile = NULL;
+ /* If there were no failures, we can remove the work dir and logfile. */
+ if (tests[i].failures == 0) {
+ if (!keep_temp_files && assertChdir(tmpdir)) {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* Make sure not to leave empty directories.
+ * Sometimes a processing of closing files used by tests
+ * is not done, then rmdir will be failed and it will
+ * leave a empty test directory. So we should wait a few
+ * seconds and retry rmdir. */
+ int r, t;
+ for (t = 0; t < 10; t++) {
+ if (t > 0)
+ Sleep(1000);
+ r = systemf("rmdir /S /Q %s", tests[i].name);
+ if (r == 0)
+ break;
+ }
+ systemf("del %s", logfilename);
+#else
systemf("rm -rf %s", tests[i].name);
+ systemf("rm %s", logfilename);
+#endif
}
}
/* Return appropriate status. */
- return (failures == failures_before ? 0 : 1);
+ return (tests[i].failures);
}
-static void usage(const char *program)
+/*
+ *
+ *
+ * MAIN and support routines.
+ *
+ *
+ */
+
+static void
+usage(const char *program)
{
static const int limit = sizeof(tests) / sizeof(tests[0]);
int i;
@@ -782,92 +1772,129 @@ static void usage(const char *program)
exit(1);
}
-#define UUDECODE(c) (((c) - 0x20) & 0x3f)
-
-void
-extract_reference_file(const char *name)
+static char *
+get_refdir(const char *d)
{
- char buff[1024];
- FILE *in, *out;
+ char tried[512] = { '\0' };
+ char buff[128];
+ char *pwd, *p;
+
+ /* If a dir was specified, try that */
+ if (d != NULL) {
+ pwd = NULL;
+ snprintf(buff, sizeof(buff), "%s", d);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+ goto failure;
+ }
- sprintf(buff, "%s/%s.uu", refdir, name);
- in = fopen(buff, "r");
- failure("Couldn't open reference file %s", buff);
- assert(in != NULL);
- if (in == NULL)
- return;
- /* Read up to and including the 'begin' line. */
- for (;;) {
- if (fgets(buff, sizeof(buff), in) == NULL) {
- /* TODO: This is a failure. */
- return;
- }
- if (memcmp(buff, "begin ", 6) == 0)
- break;
+ /* Get the current dir. */
+ pwd = getcwd(NULL, 0);
+ while (pwd[strlen(pwd) - 1] == '\n')
+ pwd[strlen(pwd) - 1] = '\0';
+
+ /* Look for a known file. */
+ snprintf(buff, sizeof(buff), "%s", pwd);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ snprintf(buff, sizeof(buff), "%s/test", pwd);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+#if defined(LIBRARY)
+ snprintf(buff, sizeof(buff), "%s/%s/test", pwd, LIBRARY);
+#else
+ snprintf(buff, sizeof(buff), "%s/%s/test", pwd, PROGRAM);
+#endif
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ if (memcmp(pwd, "/usr/obj", 8) == 0) {
+ snprintf(buff, sizeof(buff), "%s", pwd + 8);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
+
+ snprintf(buff, sizeof(buff), "%s/test", pwd + 8);
+ p = slurpfile(NULL, "%s/%s", buff, KNOWNREF);
+ if (p != NULL) goto success;
+ strncat(tried, buff, sizeof(tried) - strlen(tried) - 1);
+ strncat(tried, "\n", sizeof(tried) - strlen(tried) - 1);
}
- /* Now, decode the rest and write it. */
- /* Not a lot of error checking here; the input better be right. */
- out = fopen(name, "w");
- while (fgets(buff, sizeof(buff), in) != NULL) {
- char *p = buff;
- int bytes;
- if (memcmp(buff, "end", 3) == 0)
- break;
+failure:
+ printf("Unable to locate known reference file %s\n", KNOWNREF);
+ printf(" Checked following directories:\n%s\n", tried);
+#if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
+ DebugBreak();
+#endif
+ exit(1);
- bytes = UUDECODE(*p++);
- while (bytes > 0) {
- int n = 0;
- /* Write out 1-3 bytes from that. */
- if (bytes > 0) {
- n = UUDECODE(*p++) << 18;
- n |= UUDECODE(*p++) << 12;
- fputc(n >> 16, out);
- --bytes;
- }
- if (bytes > 0) {
- n |= UUDECODE(*p++) << 6;
- fputc((n >> 8) & 0xFF, out);
- --bytes;
- }
- if (bytes > 0) {
- n |= UUDECODE(*p++);
- fputc(n & 0xFF, out);
- --bytes;
- }
- }
- }
- fclose(out);
- fclose(in);
+success:
+ free(p);
+ free(pwd);
+ return strdup(buff);
}
-
-int main(int argc, char **argv)
+int
+main(int argc, char **argv)
{
static const int limit = sizeof(tests) / sizeof(tests[0]);
- int i, tests_run = 0, tests_failed = 0, opt;
+ int i, tests_run = 0, tests_failed = 0, option;
time_t now;
char *refdir_alloc = NULL;
- char *progname, *p;
+ const char *progname;
+ const char *tmp, *option_arg, *p;
char tmpdir[256];
char tmpdir_timestamp[256];
+ (void)argc; /* UNUSED */
+
+#if defined(HAVE__CrtSetReportMode)
+ /* To stop to run the default invalid parameter handler. */
+ _set_invalid_parameter_handler(invalid_parameter_handler);
+ /* Disable annoying assertion message box. */
+ _CrtSetReportMode(_CRT_ASSERT, 0);
+#endif
+
/*
* Name of this program, used to build root of our temp directory
* tree.
*/
progname = p = argv[0];
while (*p != '\0') {
- if (*p == '/')
+ /* Support \ or / dir separators for Windows compat. */
+ if (*p == '/' || *p == '\\')
progname = p + 1;
++p;
}
#ifdef PROGRAM
/* Get the target program from environment, if available. */
- testprog = getenv(ENVBASE);
+ testprogfile = getenv(ENVBASE);
#endif
+ if (getenv("TMPDIR") != NULL)
+ tmp = getenv("TMPDIR");
+ else if (getenv("TMP") != NULL)
+ tmp = getenv("TMP");
+ else if (getenv("TEMP") != NULL)
+ tmp = getenv("TEMP");
+ else if (getenv("TEMPDIR") != NULL)
+ tmp = getenv("TEMPDIR");
+ else
+ tmp = "/tmp";
+
/* Allow -d to be controlled through the environment. */
if (getenv(ENVBASE "_DEBUG") != NULL)
dump_on_failure = 1;
@@ -876,46 +1903,86 @@ int main(int argc, char **argv)
refdir = getenv(ENVBASE "_TEST_FILES");
/*
- * Parse options.
+ * Parse options, without using getopt(), which isn't available
+ * on all platforms.
*/
- while ((opt = getopt(argc, argv, "dkp:qr:v")) != -1) {
- switch (opt) {
- case 'd':
- dump_on_failure = 1;
+ ++argv; /* Skip program name */
+ while (*argv != NULL) {
+ if (**argv != '-')
break;
- case 'k':
- keep_temp_files = 1;
- break;
- case 'p':
+ p = *argv++;
+ ++p; /* Skip '-' */
+ while (*p != '\0') {
+ option = *p++;
+ option_arg = NULL;
+ /* If 'opt' takes an argument, parse that. */
+ if (option == 'p' || option == 'r') {
+ if (*p != '\0')
+ option_arg = p;
+ else if (*argv == NULL) {
+ fprintf(stderr,
+ "Option -%c requires argument.\n",
+ option);
+ usage(progname);
+ } else
+ option_arg = *argv++;
+ p = ""; /* End of this option word. */
+ }
+
+ /* Now, handle the option. */
+ switch (option) {
+ case 'd':
+ dump_on_failure = 1;
+ break;
+ case 'k':
+ keep_temp_files = 1;
+ break;
+ case 'p':
#ifdef PROGRAM
- testprog = optarg;
+ testprogfile = option_arg;
#else
- usage(progname);
+ usage(progname);
#endif
- break;
- case 'q':
- quiet_flag++;
- break;
- case 'r':
- refdir = optarg;
- break;
- case 'v':
- verbose = 1;
- break;
- case '?':
- default:
- usage(progname);
+ break;
+ case 'q':
+ verbosity--;
+ break;
+ case 'r':
+ refdir = option_arg;
+ break;
+ case 'v':
+ verbosity++;
+ break;
+ default:
+ usage(progname);
+ }
}
}
- argc -= optind;
- argv += optind;
/*
* Sanity-check that our options make sense.
*/
#ifdef PROGRAM
- if (testprog == NULL)
+ if (testprogfile == NULL)
usage(progname);
+ {
+ char *testprg;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* Command.com sometimes rejects '/' separators. */
+ testprg = strdup(testprogfile);
+ for (i = 0; testprg[i] != '\0'; i++) {
+ if (testprg[i] == '/')
+ testprg[i] = '\\';
+ }
+ testprogfile = testprg;
+#endif
+ /* Quote the name that gets put into shell command lines. */
+ testprg = malloc(strlen(testprogfile) + 3);
+ strcpy(testprg, "\"");
+ strcat(testprg, testprogfile);
+ strcat(testprg, "\"");
+ testprog = testprg;
+ }
#endif
/*
@@ -924,40 +1991,37 @@ int main(int argc, char **argv)
* to make it easier to track the results of multiple tests.
*/
now = time(NULL);
- for (i = 0; i < 1000; i++) {
+ for (i = 0; ; i++) {
strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
"%Y-%m-%dT%H.%M.%S",
localtime(&now));
- sprintf(tmpdir, "/tmp/%s.%s-%03d", progname, tmpdir_timestamp, i);
- if (mkdir(tmpdir,0755) == 0)
+ sprintf(tmpdir, "%s/%s.%s-%03d", tmp, progname,
+ tmpdir_timestamp, i);
+ if (assertMakeDir(tmpdir,0755))
break;
- if (errno == EEXIST)
- continue;
- fprintf(stderr, "ERROR: Unable to create temp directory %s\n",
- tmpdir);
- exit(1);
+ if (i >= 999) {
+ fprintf(stderr,
+ "ERROR: Unable to create temp directory %s\n",
+ tmpdir);
+ exit(1);
+ }
}
/*
* If the user didn't specify a directory for locating
- * reference files, use the current directory for that.
+ * reference files, try to find the reference files in
+ * the "usual places."
*/
- if (refdir == NULL) {
- systemf("/bin/pwd > %s/refdir", tmpdir);
- refdir = refdir_alloc = slurpfile(NULL, "%s/refdir", tmpdir);
- p = refdir + strlen(refdir);
- while (p[-1] == '\n') {
- --p;
- *p = '\0';
- }
- systemf("rm %s/refdir", tmpdir);
- }
+ refdir = refdir_alloc = get_refdir(refdir);
/*
* Banner with basic information.
*/
- if (!quiet_flag) {
- printf("Running tests in: %s\n", tmpdir);
+ printf("\n");
+ printf("If tests fail or crash, details will be in:\n");
+ printf(" %s\n", tmpdir);
+ printf("\n");
+ if (verbosity > VERBOSITY_SUMMARY_ONLY) {
printf("Reference files will be read from: %s\n", refdir);
#ifdef PROGRAM
printf("Running tests on: %s\n", testprog);
@@ -965,12 +2029,15 @@ int main(int argc, char **argv)
printf("Exercising: ");
fflush(stdout);
printf("%s\n", EXTRA_VERSION);
+ } else {
+ printf("Running ");
+ fflush(stdout);
}
/*
* Run some or all of the individual tests.
*/
- if (argc == 0) {
+ if (*argv == NULL) {
/* Default: Run all tests. */
for (i = 0; i < limit; i++) {
if (test_run(i, tmpdir))
@@ -979,15 +2046,30 @@ int main(int argc, char **argv)
}
} else {
while (*(argv) != NULL) {
- i = atoi(*argv);
- if (**argv < '0' || **argv > '9' || i < 0 || i >= limit) {
- printf("*** INVALID Test %s\n", *argv);
- usage(progname);
+ if (**argv >= '0' && **argv <= '9') {
+ i = atoi(*argv);
+ if (i < 0 || i >= limit) {
+ printf("*** INVALID Test %s\n", *argv);
+ free(refdir_alloc);
+ usage(progname);
+ /* usage() never returns */
+ }
} else {
- if (test_run(i, tmpdir))
- tests_failed++;
- tests_run++;
+ for (i = 0; i < limit; ++i) {
+ if (strcmp(*argv, tests[i].name) == 0)
+ break;
+ }
+ if (i >= limit) {
+ printf("*** INVALID Test ``%s''\n",
+ *argv);
+ free(refdir_alloc);
+ usage(progname);
+ /* usage() never returns */
+ }
}
+ if (test_run(i, tmpdir))
+ tests_failed++;
+ tests_run++;
argv++;
}
}
@@ -995,20 +2077,38 @@ int main(int argc, char **argv)
/*
* Report summary statistics.
*/
- if (!quiet_flag) {
+ if (verbosity > VERBOSITY_SUMMARY_ONLY) {
+ printf("\n");
+ printf("Totals:\n");
+ printf(" Tests run: %8d\n", tests_run);
+ printf(" Tests failed: %8d\n", tests_failed);
+ printf(" Assertions checked:%8d\n", assertions);
+ printf(" Assertions failed: %8d\n", failures);
+ printf(" Skips reported: %8d\n", skips);
+ }
+ if (failures) {
+ printf("\n");
+ printf("Failing tests:\n");
+ for (i = 0; i < limit; ++i) {
+ if (tests[i].failures)
+ printf(" %d: %s (%d failures)\n", i,
+ tests[i].name, tests[i].failures);
+ }
printf("\n");
- printf("%d of %d tests reported failures\n",
- tests_failed, tests_run);
- printf(" Total of %d assertions checked.\n", assertions);
- printf(" Total of %d assertions failed.\n", failures);
- printf(" Total of %d assertions skipped.\n", skips);
+ printf("Details for failing tests: %s\n", tmpdir);
+ printf("\n");
+ } else {
+ if (verbosity == VERBOSITY_SUMMARY_ONLY)
+ printf("\n");
+ printf("%d tests passed, no failures\n", tests_run);
}
free(refdir_alloc);
/* If the final tmpdir is empty, we can remove it. */
/* This should be the usual case when all tests succeed. */
+ assertChdir("..");
rmdir(tmpdir);
- return (tests_failed);
+ return (tests_failed ? 1 : 0);
}
diff --git a/archivers/libarchive/files/libarchive/test/read_open_memory.c b/archivers/libarchive/files/libarchive/test/read_open_memory.c
index aacb0123fda..e4e911c2f8b 100644
--- a/archivers/libarchive/files/libarchive/test/read_open_memory.c
+++ b/archivers/libarchive/files/libarchive/test/read_open_memory.c
@@ -24,7 +24,7 @@
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/read_open_memory.c,v 1.2 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/read_open_memory.c 191183 2009-04-17 01:06:31Z kientzle $");
#include <errno.h>
#include <stdlib.h>
@@ -43,21 +43,38 @@ struct read_memory_data {
unsigned char *end;
size_t read_size;
size_t copy_buff_size;
+ size_t copy_buff_offset;
char *copy_buff;
};
static int memory_read_close(struct archive *, void *);
static int memory_read_open(struct archive *, void *);
-#if ARCHIVE_API_VERSION < 2
-static ssize_t memory_read_skip(struct archive *, void *, size_t request);
-#else
static off_t memory_read_skip(struct archive *, void *, off_t request);
-#endif
static ssize_t memory_read(struct archive *, void *, const void **buff);
+static int read_open_memory_internal(struct archive *a, void *buff,
+ size_t size, size_t read_size, int fullapi);
+
int
read_open_memory(struct archive *a, void *buff, size_t size, size_t read_size)
{
+ return read_open_memory_internal(a, buff, size, read_size, 1);
+}
+
+/*
+ * As above, but don't register any optional part of the API, to verify
+ * that internals work correctly with just the minimal entry points.
+ */
+int
+read_open_memory2(struct archive *a, void *buff, size_t size, size_t read_size)
+{
+ return read_open_memory_internal(a, buff, size, read_size, 0);
+}
+
+static int
+read_open_memory_internal(struct archive *a, void *buff,
+ size_t size, size_t read_size, int fullapi)
+{
struct read_memory_data *mine;
mine = (struct read_memory_data *)malloc(sizeof(*mine));
@@ -69,10 +86,16 @@ read_open_memory(struct archive *a, void *buff, size_t size, size_t read_size)
mine->buffer = (unsigned char *)buff;
mine->end = mine->buffer + size;
mine->read_size = read_size;
- mine->copy_buff_size = read_size + 64;
+ mine->copy_buff_offset = 32;
+ mine->copy_buff_size = read_size + mine->copy_buff_offset * 2;
mine->copy_buff = malloc(mine->copy_buff_size);
- return (archive_read_open2(a, mine, memory_read_open,
- memory_read, memory_read_skip, memory_read_close));
+ memset(mine->copy_buff, 0xA5, mine->copy_buff_size);
+ if (fullapi)
+ return (archive_read_open2(a, mine, memory_read_open,
+ memory_read, memory_read_skip, memory_read_close));
+ else
+ return (archive_read_open2(a, mine, NULL,
+ memory_read, NULL, memory_read_close));
}
/*
@@ -102,24 +125,20 @@ memory_read(struct archive *a, void *client_data, const void **buff)
size = mine->end - mine->buffer;
if (size > mine->read_size)
size = mine->read_size;
- memset(mine->copy_buff, 0xA5, mine->copy_buff_size);
- memcpy(mine->copy_buff, mine->buffer, size);
- *buff = mine->copy_buff;
+ else
+ memset(mine->copy_buff, 0xA5, mine->copy_buff_size);
+ memcpy(mine->copy_buff + mine->copy_buff_offset, mine->buffer, size);
+ *buff = mine->copy_buff + mine->copy_buff_offset;
mine->buffer += size;
- return (size);
+ return ((ssize_t)size);
}
/*
* How mean can a skip() routine be? Let's try to find out.
*/
-#if ARCHIVE_API_VERSION < 2
-static ssize_t
-memory_read_skip(struct archive *a, void *client_data, size_t skip)
-#else
static off_t
memory_read_skip(struct archive *a, void *client_data, off_t skip)
-#endif
{
struct read_memory_data *mine = (struct read_memory_data *)client_data;
diff --git a/archivers/libarchive/files/libarchive/test/test.h b/archivers/libarchive/files/libarchive/test/test.h
index fbbf10a8c3d..40c31e13dba 100644
--- a/archivers/libarchive/files/libarchive/test/test.h
+++ b/archivers/libarchive/files/libarchive/test/test.h
@@ -22,7 +22,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: src/lib/libarchive/test/test.h,v 1.10 2008/06/15 10:35:22 kientzle Exp $
+ * $FreeBSD: head/lib/libarchive/test/test.h 201247 2009-12-30 05:59:21Z kientzle $
*/
/* Every test program should #include "test.h" as the first thing. */
@@ -33,39 +33,98 @@
*/
#if defined(HAVE_CONFIG_H)
/* Most POSIX platforms use the 'configure' script to build config.h */
-#include "../../config.h"
+#include "config.h"
#elif defined(__FreeBSD__)
/* Building as part of FreeBSD system requires a pre-built config.h. */
-#include "../config_freebsd.h"
-#elif defined(_WIN32)
+#include "config_freebsd.h"
+#elif defined(_WIN32) && !defined(__CYGWIN__)
/* Win32 can't run the 'configure' script. */
-#include "../config_windows.h"
+#include "config_windows.h"
#else
/* Warn if the library hasn't been (automatically or manually) configured. */
#error Oops: No config.h and no pre-built configuration in test.h.
#endif
+#include <sys/types.h> /* Windows requires this before sys/stat.h */
+#include <sys/stat.h>
+
+#if HAVE_DIRENT_H
#include <dirent.h>
+#endif
+#ifdef HAVE_DIRECT_H
+#include <direct.h>
+#define dirent direct
+#endif
#include <errno.h>
#include <fcntl.h>
+#ifdef HAVE_IO_H
+#include <io.h>
+#endif
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/stat.h>
-#ifndef _WIN32
+#include <time.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <wchar.h>
-
-#ifdef USE_DMALLOC
-#include <dmalloc.h>
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
#endif
-/* No non-FreeBSD platform will have __FBSDID, so just define it here. */
-#ifdef __FreeBSD__
-#include <sys/cdefs.h> /* For __FBSDID */
+/*
+ * System-specific tweaks. We really want to minimize these
+ * as much as possible, since they make it harder to understand
+ * the mainline code.
+ */
+
+/* Windows (including Visual Studio and MinGW but not Cygwin) */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#if !defined(__BORLANDC__)
+#define strdup _strdup
+#endif
+#define LOCALE_UTF8 NULL
#else
-#define __FBSDID(a) /* null */
+#define LOCALE_UTF8 "de_DE.UTF-8"
+#endif
+
+/* Visual Studio */
+#ifdef _MSC_VER
+#define snprintf sprintf_s
+#endif
+
+#if defined(__BORLANDC__)
+#pragma warn -8068 /* Constant out of range in comparison. */
+#endif
+
+/* Cygwin */
+#if defined(__CYGWIN__)
+/* Cygwin-1.7.x is lazy about populating nlinks, so don't
+ * expect it to be accurate. */
+# define NLINKS_INACCURATE_FOR_DIRS
+#endif
+
+/* Haiku OS */
+#if defined(__HAIKU__)
+/* Haiku has typedefs in stdint.h (needed for int64_t) */
+#include <stdint.h>
+#endif
+
+/* Get a real definition for __FBSDID if we can */
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+
+/* If not, define it so as to avoid dangling semicolons. */
+#ifndef __FBSDID
+#define __FBSDID(a) struct _undefined_hack
+#endif
+
+#ifndef O_BINARY
+#define O_BINARY 0
#endif
/*
@@ -75,38 +134,81 @@
#define DEFINE_TEST(name) void name(void); void name(void)
/* An implementation of the standard assert() macro */
-#define assert(e) test_assert(__FILE__, __LINE__, (e), #e, NULL)
-
+#define assert(e) assertion_assert(__FILE__, __LINE__, (e), #e, NULL)
+/* chdir() and error if it fails */
+#define assertChdir(path) \
+ assertion_chdir(__FILE__, __LINE__, path)
/* Assert two integers are the same. Reports value of each one if not. */
-#define assertEqualInt(v1,v2) \
- test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
-
+#define assertEqualInt(v1,v2) \
+ assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* Assert two strings are the same. Reports value of each one if not. */
#define assertEqualString(v1,v2) \
- test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+ assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* As above, but v1 and v2 are wchar_t * */
#define assertEqualWString(v1,v2) \
- test_assert_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
+ assertion_equal_wstring(__FILE__, __LINE__, (v1), #v1, (v2), #v2, NULL)
/* As above, but raw blocks of bytes. */
#define assertEqualMem(v1, v2, l) \
- test_assert_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
+ assertion_equal_mem(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (l), #l, NULL)
/* Assert two files are the same; allow printf-style expansion of second name.
* See below for comments about variable arguments here...
*/
#define assertEqualFile \
- test_setup(__FILE__, __LINE__);test_assert_equal_file
+ assertion_setup(__FILE__, __LINE__);assertion_equal_file
/* Assert that a file is empty; supports printf-style arguments. */
#define assertEmptyFile \
- test_setup(__FILE__, __LINE__);test_assert_empty_file
+ assertion_setup(__FILE__, __LINE__);assertion_empty_file
+/* Assert that a file is not empty; supports printf-style arguments. */
+#define assertNonEmptyFile \
+ assertion_setup(__FILE__, __LINE__);assertion_non_empty_file
+#define assertFileAtime(pathname, sec, nsec) \
+ assertion_file_atime(__FILE__, __LINE__, pathname, sec, nsec)
+#define assertFileAtimeRecent(pathname) \
+ assertion_file_atime_recent(__FILE__, __LINE__, pathname)
+#define assertFileBirthtime(pathname, sec, nsec) \
+ assertion_file_birthtime(__FILE__, __LINE__, pathname, sec, nsec)
+#define assertFileBirthtimeRecent(pathname) \
+ assertion_file_birthtime_recent(__FILE__, __LINE__, pathname)
/* Assert that a file exists; supports printf-style arguments. */
#define assertFileExists \
- test_setup(__FILE__, __LINE__);test_assert_file_exists
+ assertion_setup(__FILE__, __LINE__);assertion_file_exists
/* Assert that a file exists; supports printf-style arguments. */
#define assertFileNotExists \
- test_setup(__FILE__, __LINE__);test_assert_file_not_exists
+ assertion_setup(__FILE__, __LINE__);assertion_file_not_exists
/* Assert that file contents match a string; supports printf-style arguments. */
#define assertFileContents \
- test_setup(__FILE__, __LINE__);test_assert_file_contents
+ assertion_setup(__FILE__, __LINE__);assertion_file_contents
+#define assertFileMtime(pathname, sec, nsec) \
+ assertion_file_mtime(__FILE__, __LINE__, pathname, sec, nsec)
+#define assertFileMtimeRecent(pathname) \
+ assertion_file_mtime_recent(__FILE__, __LINE__, pathname)
+#define assertFileNLinks(pathname, nlinks) \
+ assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
+#define assertFileSize(pathname, size) \
+ assertion_file_size(__FILE__, __LINE__, pathname, size)
+#define assertTextFileContents \
+ assertion_setup(__FILE__, __LINE__);assertion_text_file_contents
+#define assertIsDir(pathname, mode) \
+ assertion_is_dir(__FILE__, __LINE__, pathname, mode)
+#define assertIsHardlink(path1, path2) \
+ assertion_is_hardlink(__FILE__, __LINE__, path1, path2)
+#define assertIsNotHardlink(path1, path2) \
+ assertion_is_not_hardlink(__FILE__, __LINE__, path1, path2)
+#define assertIsReg(pathname, mode) \
+ assertion_is_reg(__FILE__, __LINE__, pathname, mode)
+#define assertIsSymlink(pathname, contents) \
+ assertion_is_symlink(__FILE__, __LINE__, pathname, contents)
+/* Create a directory, report error if it fails. */
+#define assertMakeDir(dirname, mode) \
+ assertion_make_dir(__FILE__, __LINE__, dirname, mode)
+#define assertMakeFile(path, mode, contents) \
+ assertion_make_file(__FILE__, __LINE__, path, mode, contents)
+#define assertMakeHardlink(newfile, oldfile) \
+ assertion_make_hardlink(__FILE__, __LINE__, newfile, oldfile)
+#define assertMakeSymlink(newfile, linkto) \
+ assertion_make_symlink(__FILE__, __LINE__, newfile, linkto)
+#define assertUmask(mask) \
+ assertion_umask(__FILE__, __LINE__, mask)
/*
* This would be simple with C99 variadic macros, but I don't want to
@@ -115,26 +217,60 @@
* but effective.
*/
#define skipping \
- test_setup(__FILE__, __LINE__);test_skipping
+ assertion_setup(__FILE__, __LINE__);test_skipping
/* Function declarations. These are defined in test_utility.c. */
void failure(const char *fmt, ...);
-void test_setup(const char *, int);
+int assertion_assert(const char *, int, int, const char *, void *);
+int assertion_chdir(const char *, int, const char *);
+int assertion_empty_file(const char *, ...);
+int assertion_equal_file(const char *, const char *, ...);
+int assertion_equal_int(const char *, int, long long, const char *, long long, const char *, void *);
+int assertion_equal_mem(const char *, int, const void *, const char *, const void *, const char *, size_t, const char *, void *);
+int assertion_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
+int assertion_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
+int assertion_file_atime(const char *, int, const char *, long, long);
+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_contents(const void *, int, const char *, ...);
+int assertion_file_exists(const char *, ...);
+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);
+int assertion_file_not_exists(const char *, ...);
+int assertion_file_size(const char *, int, const char *, long);
+int assertion_is_dir(const char *, int, const char *, int);
+int assertion_is_hardlink(const char *, int, const char *, const char *);
+int assertion_is_not_hardlink(const char *, int, const char *, const char *);
+int assertion_is_reg(const char *, int, const char *, int);
+int assertion_is_symlink(const char *, int, const char *, const char *);
+int assertion_make_dir(const char *, int, const char *, int);
+int assertion_make_file(const char *, int, const char *, int, const char *);
+int assertion_make_hardlink(const char *, int, const char *newpath, const char *);
+int assertion_make_symlink(const char *, int, const char *newpath, const char *);
+int assertion_non_empty_file(const char *, ...);
+int assertion_text_file_contents(const char *buff, const char *f);
+int assertion_umask(const char *, int, int);
+void assertion_setup(const char *, int);
+
void test_skipping(const char *fmt, ...);
-int test_assert(const char *, int, int, const char *, void *);
-int test_assert_empty_file(const char *, ...);
-int test_assert_equal_file(const char *, const char *, ...);
-int test_assert_equal_int(const char *, int, int, const char *, int, const char *, void *);
-int test_assert_equal_string(const char *, int, const char *v1, const char *, const char *v2, const char *, void *);
-int test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *);
-int test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *);
-int test_assert_file_contents(const void *, int, const char *, ...);
-int test_assert_file_exists(const char *, ...);
-int test_assert_file_not_exists(const char *, ...);
/* Like sprintf, then system() */
int systemf(const char * fmt, ...);
+/* Delay until time() returns a value after this. */
+void sleepUntilAfter(time_t);
+
+/* Return true if this platform can create symlinks. */
+int canSymlink(void);
+
+/* Return true if this platform can run the "gzip" program. */
+int canGzip(void);
+
+/* Return true if this platform can run the "gunzip" program. */
+int canGunzip(void);
+
/* Suck file into string allocated via malloc(). Call free() when done. */
/* Supports printf-style args: slurpfile(NULL, "%s/myfile", refdir); */
char *slurpfile(size_t *, const char *fmt, ...);
@@ -151,21 +287,16 @@ void extract_reference_file(const char *);
/* Special customized read-from-memory interface. */
int read_open_memory(struct archive *, void *, size_t, size_t);
-
-/*
- * ARCHIVE_VERSION_STAMP first appeared in 1.9 and libarchive 2.2.4.
- * We can approximate it for earlier versions, though.
- * This is used to disable tests of features not present in the current
- * version.
- */
-#ifndef ARCHIVE_VERSION_STAMP
-#define ARCHIVE_VERSION_STAMP \
- (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000)
-#endif
+/* "2" version exercises a slightly different set of libarchive APIs. */
+int read_open_memory2(struct archive *, void *, size_t, size_t);
/* Versions of above that accept an archive argument for additional info. */
-#define assertA(e) test_assert(__FILE__, __LINE__, (e), #e, (a))
+#define assertA(e) assertion_assert(__FILE__, __LINE__, (e), #e, (a))
#define assertEqualIntA(a,v1,v2) \
- test_assert_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
+ assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
#define assertEqualStringA(a,v1,v2) \
- test_assert_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
+ assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a))
+
+#ifdef USE_DMALLOC
+#include <dmalloc.h>
+#endif
diff --git a/archivers/libarchive/files/libarchive/test/test_acl_basic.c b/archivers/libarchive/files/libarchive/test/test_acl_basic.c
index effcfb78c48..f66014cdd31 100644
--- a/archivers/libarchive/files/libarchive/test/test_acl_basic.c
+++ b/archivers/libarchive/files/libarchive/test/test_acl_basic.c
@@ -23,12 +23,11 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_basic.c,v 1.4 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_basic.c,v 1.6 2008/10/19 00:13:57 kientzle Exp $");
/*
* Exercise the system-independent portion of the ACL support.
- * Check that archive_entry objects can save and restore ACL data
- * and that pax archive can save and restore ACL data.
+ * Check that archive_entry objects can save and restore ACL data.
*
* This should work on all systems, regardless of whether local
* filesystems support ACLs or not.
@@ -42,7 +41,7 @@ struct acl_t {
const char *name; /* Name of user/group, depending on tag. */
};
-struct acl_t acls0[] = {
+static struct acl_t acls0[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -51,7 +50,7 @@ struct acl_t acls0[] = {
ARCHIVE_ENTRY_ACL_OTHER, 0, "" },
};
-struct acl_t acls1[] = {
+static struct acl_t acls1[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -62,7 +61,7 @@ struct acl_t acls1[] = {
ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
};
-struct acl_t acls2[] = {
+static struct acl_t acls2[] = {
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
{ ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
@@ -165,7 +164,7 @@ compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode)
assert(matched == 1);
}
}
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
/* Known broken before 1.9.0. */
skipping("archive_entry_acl_next() exits with ARCHIVE_EOF");
#else
diff --git a/archivers/libarchive/files/libarchive/test/test_acl_freebsd.c b/archivers/libarchive/files/libarchive/test/test_acl_freebsd.c
new file mode 100644
index 00000000000..be502067f5f
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_acl_freebsd.c
@@ -0,0 +1,255 @@
+/*-
+ * Copyright (c) 2003-2008 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: head/lib/libarchive/test/test_acl_freebsd.c 189427 2009-03-06 04:21:23Z kientzle $");
+
+#if defined(__FreeBSD__) && __FreeBSD__ > 4
+#include <sys/acl.h>
+
+struct myacl_t {
+ int type; /* Type of ACL: "access" or "default" */
+ int permset; /* Permissions for this class of users. */
+ int tag; /* Owner, User, Owning group, group, other, etc. */
+ int qual; /* GID or UID of user/group, depending on tag. */
+ const char *name; /* Name of user/group, depending on tag. */
+};
+
+static struct myacl_t acls2[] = {
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_USER, 77, "user77" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0,
+ ARCHIVE_ENTRY_ACL_USER, 78, "user78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ,
+ ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007,
+ ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_OTHER, -1, "" },
+ { ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_READ | ARCHIVE_ENTRY_ACL_EXECUTE,
+ ARCHIVE_ENTRY_ACL_MASK, -1, "" },
+ { 0, 0, 0, 0, NULL }
+};
+
+static void
+set_acls(struct archive_entry *ae, struct myacl_t *acls)
+{
+ int i;
+
+ archive_entry_acl_clear(ae);
+ for (i = 0; acls[i].name != NULL; i++) {
+ archive_entry_acl_add_entry(ae,
+ acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual,
+ acls[i].name);
+ }
+}
+
+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;
+ int permset = 0;
+
+ acl_get_tag_type(aclent, &tag_type);
+
+ /* translate the silly opaque permset to a bitmap */
+ acl_get_permset(aclent, &opaque_ps);
+ if (acl_get_perm_np(opaque_ps, ACL_EXECUTE))
+ permset |= ARCHIVE_ENTRY_ACL_EXECUTE;
+ if (acl_get_perm_np(opaque_ps, ACL_WRITE))
+ permset |= ARCHIVE_ENTRY_ACL_WRITE;
+ if (acl_get_perm_np(opaque_ps, ACL_READ))
+ permset |= ARCHIVE_ENTRY_ACL_READ;
+
+ if (permset != myacl->permset)
+ return (0);
+
+ switch (tag_type) {
+ case ACL_USER_OBJ:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0);
+ break;
+ case ACL_USER:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_USER)
+ return (0);
+ up = acl_get_qualifier(aclent);
+ u = *up;
+ acl_free(up);
+ if ((uid_t)myacl->qual != u)
+ return (0);
+ break;
+ case ACL_GROUP_OBJ:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP_OBJ) return (0);
+ break;
+ case ACL_GROUP:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_GROUP)
+ return (0);
+ gp = acl_get_qualifier(aclent);
+ g = *gp;
+ acl_free(gp);
+ if ((gid_t)myacl->qual != g)
+ return (0);
+ break;
+ case ACL_MASK:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_MASK) return (0);
+ break;
+ case ACL_OTHER:
+ if (myacl->tag != ARCHIVE_ENTRY_ACL_OTHER) return (0);
+ break;
+ }
+ return (1);
+}
+
+static void
+compare_acls(acl_t acl, struct myacl_t *myacls)
+{
+ int *marker;
+ int entry_id = ACL_FIRST_ENTRY;
+ int matched;
+ int i, n;
+ acl_entry_t acl_entry;
+
+ /* Count ACL entries in myacls array and allocate an indirect array. */
+ for (n = 0; myacls[n].name != NULL; ++n)
+ continue;
+ marker = malloc(sizeof(marker[0]) * n);
+ for (i = 0; i < n; i++)
+ marker[i] = i;
+
+ /*
+ * Iterate over acls in system acl object, try to match each
+ * one with an item in the myacls array.
+ */
+ while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
+ /* After the first time... */
+ entry_id = ACL_NEXT_ENTRY;
+
+ /* Search for a matching entry (tag and qualifier) */
+ for (i = 0, matched = 0; i < n && !matched; i++) {
+ if (acl_match(acl_entry, &myacls[marker[i]])) {
+ /* We found a match; remove it. */
+ marker[i] = marker[n - 1];
+ n--;
+ matched = 1;
+ }
+ }
+
+ /* TODO: Print out more details in this case. */
+ failure("ACL entry on file that shouldn't be there");
+ assert(matched == 1);
+ }
+
+ /* Dump entries in the myacls array that weren't in the system acl. */
+ for (i = 0; i < n; ++i) {
+ failure(" ACL entry missing from file: "
+ "type=%d,permset=%d,tag=%d,qual=%d,name=``%s''\n",
+ myacls[marker[i]].type, myacls[marker[i]].permset,
+ myacls[marker[i]].tag, myacls[marker[i]].qual,
+ myacls[marker[i]].name);
+ assert(0); /* Record this as a failure. */
+ }
+ free(marker);
+}
+
+#endif
+
+
+/*
+ * Verify ACL restore-to-disk. This test is FreeBSD-specific.
+ */
+
+DEFINE_TEST(test_acl_freebsd)
+{
+#if !defined(__FreeBSD__)
+ skipping("FreeBSD-specific ACL restore test");
+#elif __FreeBSD__ < 5
+ skipping("ACL restore supported only on FreeBSD 5.0 and later");
+#else
+ struct stat st;
+ struct archive *a;
+ struct archive_entry *ae;
+ int n, fd;
+ acl_t acl;
+
+ /*
+ * First, do a quick manual set/read of ACL data to
+ * verify that the local filesystem does support ACLs.
+ * If it doesn't, we'll simply skip the remaining tests.
+ */
+ acl = acl_from_text("u::rwx,u:1:rw,g::rwx,g:15:rx,o::rwx,m::rwx");
+ assert((void *)acl != NULL);
+ /* Create a test file and try to set an ACL on it. */
+ fd = open("pretest", O_WRONLY | O_CREAT | O_EXCL, 0777);
+ failure("Could not create test file?!");
+ if (!assert(fd >= 0)) {
+ acl_free(acl);
+ return;
+ }
+
+ n = acl_set_fd(fd, acl);
+ acl_free(acl);
+ if (n != 0 && errno == EOPNOTSUPP) {
+ close(fd);
+ skipping("ACL tests require that ACL support be enabled on the filesystem");
+ return;
+ }
+ failure("acl_set_fd(): errno = %d (%s)",
+ errno, strerror(errno));
+ assertEqualInt(0, n);
+ close(fd);
+
+ /* Create a write-to-disk object. */
+ assert(NULL != (a = archive_write_disk_new()));
+ archive_write_disk_set_options(a,
+ ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL);
+
+ /* Populate an archive entry with some metadata, including ACL info */
+ ae = archive_entry_new();
+ assert(ae != NULL);
+ archive_entry_set_pathname(ae, "test0");
+ archive_entry_set_mtime(ae, 123456, 7890);
+ archive_entry_set_size(ae, 0);
+ set_acls(ae, acls2);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+
+ /* Close the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /* Verify the data on disk. */
+ assertEqualInt(0, stat("test0", &st));
+ assertEqualInt(st.st_mtime, 123456);
+ acl = acl_get_file("test0", ACL_TYPE_ACCESS);
+ assert(acl != (acl_t)NULL);
+ compare_acls(acl, acls2);
+ acl_free(acl);
+#endif
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_acl_pax.c b/archivers/libarchive/files/libarchive/test/test_acl_pax.c
index 1eb3d399a9e..1f0468ca115 100644
--- a/archivers/libarchive/files/libarchive/test/test_acl_pax.c
+++ b/archivers/libarchive/files/libarchive/test/test_acl_pax.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_pax.c,v 1.5 2008/05/26 17:00:24 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_pax.c 201247 2009-12-30 05:59:21Z kientzle $");
/*
* Exercise the system-independent portion of the ACL support.
@@ -151,10 +151,10 @@ static unsigned char reference[] = {
0,0,0,0,0,0,0,0,0,0,'1','1','3',' ','S','C','H','I','L','Y','.','a','c','l',
'.','a','c','c','e','s','s','=','u','s','e','r',':',':','r','-','x',',','g',
'r','o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w',
-'x',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x',
-':','7','8',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',
-':','7','8',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',
-':','7','7',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',
+'x',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7',
+'7',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',':','7',
+'8',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x',
+':','7','8',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',
10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',
' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -386,7 +386,7 @@ compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode)
assert(matched == 1);
}
}
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
/* Known broken before 1.9.0. */
skipping("archive_entry_acl_next() exits with ARCHIVE_EOF");
#else
@@ -406,7 +406,7 @@ DEFINE_TEST(test_acl_pax)
struct archive *a;
struct archive_entry *ae;
size_t used;
- int fd;
+ FILE *f;
/* Write an archive to memory. */
assert(NULL != (a = archive_write_new()));
@@ -446,27 +446,27 @@ DEFINE_TEST(test_acl_pax)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/* Write out the data we generated to a file for manual inspection. */
- assert(-1 < (fd = open("testout", O_WRONLY | O_CREAT | O_TRUNC, 0775)));
- assert(used == (size_t)write(fd, buff, used));
- close(fd);
+ assert(NULL != (f = fopen("testout", "wb")));
+ assertEqualInt(used, (size_t)fwrite(buff, 1, (unsigned int)used, f));
+ fclose(f);
/* Write out the reference data to a file for manual inspection. */
- assert(-1 < (fd = open("reference", O_WRONLY | O_CREAT | O_TRUNC, 0775)));
- assert(sizeof(reference) == write(fd, reference, sizeof(reference)));
- close(fd);
+ assert(NULL != (f = fopen("reference", "wb")));
+ assert(sizeof(reference) == fwrite(reference, 1, sizeof(reference), f));
+ fclose(f);
/* Assert that the generated data matches the built-in reference data.*/
failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
- assert(0 == memcmp(buff, reference, sizeof(reference)));
+ assertEqualMem(buff, reference, sizeof(reference));
failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
- assertEqualInt(used, sizeof(reference));
+ assertEqualInt((int)used, sizeof(reference));
/* Read back each entry and check that the ACL data is right. */
assert(NULL != (a = archive_read_new()));
@@ -509,9 +509,9 @@ DEFINE_TEST(test_acl_pax)
/* Close the archive. */
assertA(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertA(0 == archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_bad_fd.c b/archivers/libarchive/files/libarchive/test/test_bad_fd.c
index 1903cd07ee4..3ea7daacf2e 100644
--- a/archivers/libarchive/files/libarchive/test/test_bad_fd.c
+++ b/archivers/libarchive/files/libarchive/test/test_bad_fd.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_bad_fd.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_bad_fd.c,v 1.2 2008/09/01 05:38:33 kientzle Exp $");
/* Verify that attempting to open an invalid fd returns correct error. */
DEFINE_TEST(test_bad_fd)
@@ -33,9 +33,9 @@ DEFINE_TEST(test_bad_fd)
assertA(0 == archive_read_support_compression_all(a));
assertA(ARCHIVE_FATAL == archive_read_open_fd(a, -1, 1024));
assertA(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertA(0 == archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_bzip2.c b/archivers/libarchive/files/libarchive/test/test_compat_bzip2.c
new file mode 100644
index 00000000000..343f451ae69
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_bzip2.c
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 2003-2008 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: head/lib/libarchive/test/test_compat_bzip2.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+ * Verify our ability to read sample files compatibly with bunzip2.
+ *
+ * In particular:
+ * * bunzip2 will read multiple bzip2 streams, concatenating the output
+ * * bunzip2 will stop at the end of a stream if the following data
+ * doesn't start with a bzip2 signature.
+ */
+
+/*
+ * All of the sample files have the same contents; they're just
+ * compressed in different ways.
+ */
+static void
+compat_bzip2(const char *name)
+{
+ const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL };
+ struct archive_entry *ae;
+ struct archive *a;
+ int i;
+
+ assert((a = archive_read_new()) != NULL);
+ if (ARCHIVE_OK != archive_read_support_compression_bzip2(a)) {
+ skipping("Unsupported bzip2");
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
+
+ /* Read entries, match up names with list above. */
+ for (i = 0; i < 6; ++i) {
+ failure("Could not read file %d (%s) from %s", i, n[i], name);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ assertEqualString(n[i], archive_entry_pathname(ae));
+ }
+
+ /* Verify the end-of-archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify that the format detection worked. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
+ assertEqualString(archive_compression_name(a), "bzip2");
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
+
+DEFINE_TEST(test_compat_bzip2)
+{
+ compat_bzip2("test_compat_bzip2_1.tbz");
+ compat_bzip2("test_compat_bzip2_2.tbz");
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_bzip2_1.tbz.uu b/archivers/libarchive/files/libarchive/test/test_compat_bzip2_1.tbz.uu
new file mode 100644
index 00000000000..989af82b2e5
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_bzip2_1.tbz.uu
@@ -0,0 +1,24 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_bzip2_1.tbz.uu 185683 2008-12-06 07:08:08Z kientzle $
+
+begin 644 test_compat_bzip2_1.tbz
+M0EIH.3%!62936;12^)(``#-;D=$00`!_@``!8RT>$`0`$```""``5#5/*'J>
+MD#(&30_5!H4_5-ZH`T``327U4@&L('"(9-%8<7&$I,`:7FXH<P(<:8)$*)(U
+MZH$>+*\GV#JF<`PK29-8'OPDG36S\7<D4X4)"T4OB2!"6F@Y,4%9)E-92FB6
+M4````'N4T1`$`$``?X```6,M'A`$```0``@@`'0:H]$R>HR&C(T:/U0:$U'I
+MJ!ZC0`#VECO\[$10H'-Z@F*:6A1$H$V("2G0Q(U0(8=(7AK$S04#!)RXOAP%
+MP:D%#Q;NO)\4UL23'2[\7<D4X4)!*:)90$)::#DQ05DF4UD;;[2>````6YC1
+M$$`$?X```6,M'A`$`!````@@`'4-4S*,U!HT!HT?J@T)E-I--!H`![6<G^E$
+M$5QJ!S2`*)/,*+VQ9'B0",=3$#5`CA"8<%1\7A4X$T:,-A)F5^*"X5[IR?&-
+M*DDY2+\7<D4X4)`;;[2>0EIH.3%!629364RNM^,```#?L-$00`#_@`0```AG
+M+1X0`!`$```((`!U#5-,:1IH`TT,1^J#)&H]3U`T``!CX[_.[`F40.64EC"D
+M()+?<M#$":=,4$46`@@DBMQ)81MJACLC[V0".0,7#AH=97F?G1I@9U))RD?Q
+M=R13A0D$RNM^,$)::#DQ05DF4UDS!PL0```!6]#1$$``_X``#&<M'A`0``0`
+M``@@`'4-4\2-&@`:#31^J#)3TU&U!H``!B_C_.]`)J4#F929S&D0$F:4(J50
+M&#)@@5&F"H,GH(J*7*@X&>KX6,VP?6Y;F%5$XR[Y/D#*9),K3^+N2*<*$@9@
+MX6(`0EIH.3%!62936>ZM4*4```);D-$00`#O@``(9ST>$`0```@@`'0:IFC2
+M&F@!B:/U0:$R&H:&@`"KS^U=Y`BC`#FY2*9-8%%&13E$@%8ZF(&J!##]!#E`
+MKVL'2LUW2.*<!T+W-B@46%:=GQ<#6Q*DYH/Q=R13A0D.ZM4*4$)::#DQ05DF
+M4UD!Z-!@```!P`'```"```@@`""J;4&8NH/%W)%.%"0`>C08`$)::#DQ05DF
+?4UDI/)=P````0!!```0`(``A`(*#%W)%.%"0*3R7<```
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_bzip2_2.tbz.uu b/archivers/libarchive/files/libarchive/test/test_compat_bzip2_2.tbz.uu
new file mode 100644
index 00000000000..9ba63e8772b
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_bzip2_2.tbz.uu
@@ -0,0 +1,11 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_bzip2_2.tbz.uu 185683 2008-12-06 07:08:08Z kientzle $
+
+begin 644 test_compat_bzip2_2.tbz
+M0EIH.3%!629361HI1P<``4#;D-$00`#_@``)9RT>$`0``!@P`/@#&$Q,F`F`
+M`,83$R8"8``1133"1/2-J-#$/U3@;XVF9V'`Y3882XA$*KO6\WTL`]QU&J"8
+M$-=*Q$\@=`=QJ,TQ;3UH,NPT$-(!"HV&!ZO5D&@P-1D&1@'L<8&209QV9'G`
+MW&PRZ0Q(-BT%&DG*DE.!U*#J.P]*#%-P9G`W9+34:#S&M`;@^1R^![C]:Y)U
+MDF9/(\AR/@?P<CD<CD>@^@I_B[DBG"A(#12C@X!3;VUE(&UO<F4@9&%T82!T
+7:&%T(&ES(&YO="!B>FEP('-T<F5A;0H`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_cpio.c b/archivers/libarchive/files/libarchive/test/test_compat_cpio.c
new file mode 100644
index 00000000000..8f97036c4f3
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_cpio.c
@@ -0,0 +1,106 @@
+/*-
+ * Copyright (c) 2003-2009 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: head/lib/libarchive/test/test_compat_cpio.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+ * Verify our ability to read various sample files.
+ * It should be easy to add any new sample files sent in by users
+ * to this collection of tests.
+ */
+
+/* Copy this function for each test file and adjust it accordingly. */
+
+/*
+ * test_compat_cpio_1.cpio checks heuristics for avoiding false
+ * hardlinks. foo1 and foo2 are files that have nlinks=1 and so
+ * should not be marked as hardlinks even though they have identical
+ * ino values. bar1 and bar2 have nlinks=2 so should be marked
+ * as hardlinks.
+ */
+static void
+test_compat_cpio_1(void)
+{
+ char name[] = "test_compat_cpio_1.cpio";
+ struct archive_entry *ae;
+ struct archive *a;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 17));
+
+ /* Read first entry. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("foo1", archive_entry_pathname(ae));
+ assertEqualString(NULL, archive_entry_hardlink(ae));
+ assertEqualInt(1260250228, archive_entry_mtime(ae));
+ assertEqualInt(1000, archive_entry_uid(ae));
+ assertEqualInt(1000, archive_entry_gid(ae));
+ assertEqualInt(0100644, archive_entry_mode(ae));
+
+ /* Read second entry. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("foo2", archive_entry_pathname(ae));
+ assertEqualString(NULL, archive_entry_hardlink(ae));
+ assertEqualInt(1260250228, archive_entry_mtime(ae));
+ assertEqualInt(1000, archive_entry_uid(ae));
+ assertEqualInt(1000, archive_entry_gid(ae));
+ assertEqualInt(0100644, archive_entry_mode(ae));
+
+ /* Read third entry. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("bar1", archive_entry_pathname(ae));
+ assertEqualString(NULL, archive_entry_hardlink(ae));
+ assertEqualInt(1260250228, archive_entry_mtime(ae));
+ assertEqualInt(1000, archive_entry_uid(ae));
+ assertEqualInt(1000, archive_entry_gid(ae));
+ assertEqualInt(0100644, archive_entry_mode(ae));
+
+ /* Read fourth entry. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("bar2", archive_entry_pathname(ae));
+ assertEqualString("bar1", archive_entry_hardlink(ae));
+ assertEqualInt(1260250228, archive_entry_mtime(ae));
+ assertEqualInt(1000, archive_entry_uid(ae));
+ assertEqualInt(1000, archive_entry_gid(ae));
+ assertEqualInt(0100644, archive_entry_mode(ae));
+
+ /* Verify that the format detection worked. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
+
+DEFINE_TEST(test_compat_cpio)
+{
+ test_compat_cpio_1();
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_cpio_1.cpio.uu b/archivers/libarchive/files/libarchive/test/test_compat_cpio_1.cpio.uu
new file mode 100644
index 00000000000..967a344b409
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_cpio_1.cpio.uu
@@ -0,0 +1,19 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_cpio_1.cpio.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_compat_cpio_1.cpio
+M,#<P-S`Q,#`U-CEE8F4P,#`P.#%A-#`P,#`P,V4X,#`P,#`S93@P,#`P,#`P
+M,31B,61E-#<T,#`P,#`P,#0P,#`P,#`P,#`P,#`P,#4T,#`P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`U,#`P,#`P,#!F;V\Q``!F;V\*,#<P-S`Q,#`U-CEE8F4P
+M,#`P.#%A-#`P,#`P,V4X,#`P,#`S93@P,#`P,#`P,31B,61E-#<T,#`P,#`P
+M,#0P,#`P,#`P,#`P,#`P,#4T,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`U,#`P
+M,#`P,#!F;V\R``!B87(*,#<P-S`Q,#`U-CEE8F4P,#`P.#%A-#`P,#`P,V4X
+M,#`P,#`S93@P,#`P,#`P,C1B,61E-#<T,#`P,#`P,#0P,#`P,#`P,#`P,#`P
+M,#4T,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`U,#`P,#`P,#!B87(Q``!B87H*
+M,#<P-S`Q,#`U-CEE8F4P,#`P.#%A-#`P,#`P,V4X,#`P,#`S93@P,#`P,#`P
+M,C1B,61E-#<T,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#4T,#`P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`U,#`P,#`P,#!B87(R```P-S`W,#$P,#`P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`Q,#`P,#`P,#`P,#`P,#`P,#`P
+M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#`P,&(P,#`P,#`P
+/,%1204E,15(A(2$`````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gtar.c b/archivers/libarchive/files/libarchive/test/test_compat_gtar.c
index 66cd7b02e87..c0a69598e98 100644
--- a/archivers/libarchive/files/libarchive/test/test_compat_gtar.c
+++ b/archivers/libarchive/files/libarchive/test/test_compat_gtar.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_gtar.c,v 1.2 2008/03/12 05:12:23 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_compat_gtar.c 189308 2009-03-03 17:02:51Z kientzle $");
/*
* Verify our ability to read sample files created by GNU tar.
@@ -40,9 +40,10 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_gtar.c,v 1.2 2008/03/12
static void
test_compat_gtar_1(void)
{
- char name[] = "test_compat_gtar_1.tgz";
+ char name[] = "test_compat_gtar_1.tar";
struct archive_entry *ae;
struct archive *a;
+ int r;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
@@ -51,7 +52,11 @@ test_compat_gtar_1(void)
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
/* Read first entry. */
- assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, r = archive_read_next_header(a, &ae));
+ if (r != ARCHIVE_OK) {
+ archive_read_finish(a);
+ return;
+ }
assertEqualString(
"12345678901234567890123456789012345678901234567890"
"12345678901234567890123456789012345678901234567890"
@@ -66,7 +71,11 @@ test_compat_gtar_1(void)
assertEqualInt(0100644, archive_entry_mode(ae));
/* Read second entry. */
- assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, r = archive_read_next_header(a, &ae));
+ if (r != ARCHIVE_OK) {
+ archive_read_finish(a);
+ return;
+ }
assertEqualString(
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij"
"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij"
@@ -90,14 +99,14 @@ test_compat_gtar_1(void)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
/* Verify that the format detection worked. */
- assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP);
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gtar_1.tar.uu b/archivers/libarchive/files/libarchive/test/test_compat_gtar_1.tar.uu
new file mode 100644
index 00000000000..da54476e881
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_gtar_1.tar.uu
@@ -0,0 +1,232 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_gtar_1.tar.uu 189308 2009-03-03 17:02:51Z kientzle $
+begin 644 test_compat_gtar_1.tar
+M+B\N+T!,;VYG3&EN:P``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````"`@("`@,"``("`@("`P(``@("`@(#`@`"`@("`@("`@,S$Q
+M("`@("`@("`@("`P("`Q,#<P,0`@3```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<B`@`')O;W0`
+M````````````````````````````````````=VAE96P`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X
+M.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S
+M-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X
+M.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S
+M-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,```````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````#$R,S0U-C<X.3`Q
+M,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V
+M-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.0`Q
+M,#`V-#0@`"`@,3<U,"``("`Q-S4P(``@("`@("`@("`@,"`Q,#<R-C<P,#$W
+M,R`@,C$P,C``(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(@(`!T:6T`````````````````
+M`````````````````````'1I;0``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````+B\N+T!,;VYG3&EN:P``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````"`@("`@,"``("`@("`P(``@("`@(#`@`"`@("`@
+M("`@,S$Q("`@("`@("`@("`P("`Q,#<P,``@2P``````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!U<W1A<B`@
+M`')O;W0`````````````````````````````````````=VAE96P`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R
+M,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W
+M.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R
+M,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W
+M.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,```
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````"XO+B]`
+M3&]N9TQI;FL`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````@("`@(#`@`"`@("`@,"``("`@("`P(``@("`@("`@(#,Q,2`@("`@
+M("`@("`@,"`@,3`W,#$`($P`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````=7-T87(@(`!R;V]T````````
+M`````````````````````````````'=H965L````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C
+M9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H
+M:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C
+M9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H
+M:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6H`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A8F-D969G:&EJ86)C9&5F
+M9VAI:F%B8V1E9F=H:6IA8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA
+M8F-D969G:&EJ86)C9&5F9VAI:F%B8V1E9F=H:6IA8F-D969G:&D`,3(P-S4U
+M(``@(#$W-3`@`"`@,3<U,"``("`@("`@("`@(#`@,3`W,C8W,#`R-#,@(#0T
+M-3(Q`"`R,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y
+M,#$R,S0U-C<X.3`Q,C,T-38W.#DP,3(S-#4V-S@Y,#$R,S0U-C<X.3`Q,C,T
+M-38W.#DP,3(S-#4V-S@Y`'5S=&%R("``=&EM````````````````````````
+M``````````````!T:6T`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+9````````````````````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gzip.c b/archivers/libarchive/files/libarchive/test/test_compat_gzip.c
new file mode 100644
index 00000000000..a76b2f8f8d7
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_gzip.c
@@ -0,0 +1,97 @@
+/*-
+ * Copyright (c) 2003-2008 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: head/lib/libarchive/test/test_compat_gzip.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+/*
+ * Verify our ability to read sample files compatibly with gunzip.
+ *
+ * In particular:
+ * * gunzip will read multiple gzip streams, concatenating the output
+ * * gunzip will stop at the end of a stream if the following data
+ * doesn't start with a gzip signature.
+ */
+
+/*
+ * All of the sample files have the same contents; they're just
+ * compressed in different ways.
+ */
+static void
+verify(const char *name)
+{
+ const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL };
+ struct archive_entry *ae;
+ struct archive *a;
+ int i,r;
+
+ assert((a = archive_read_new()) != NULL);
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 200));
+
+ /* Read entries, match up names with list above. */
+ for (i = 0; i < 6; ++i) {
+ failure("Could not read file %d (%s) from %s", i, n[i], name);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ if (r != ARCHIVE_OK) {
+ archive_read_finish(a);
+ return;
+ }
+ assertEqualString(n[i], archive_entry_pathname(ae));
+ }
+
+ /* Verify the end-of-archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify that the format detection worked. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP);
+ assertEqualString(archive_compression_name(a), "gzip");
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
+
+DEFINE_TEST(test_compat_gzip)
+{
+ /* This sample has been 'split', each piece compressed separately,
+ * then concatenated. Gunzip will emit the concatenated result. */
+ /* Not supported in libarchive 2.6 and earlier */
+ verify("test_compat_gzip_1.tgz");
+ /* This sample has been compressed as a single stream, but then
+ * some unrelated garbage text has been appended to the end. */
+ verify("test_compat_gzip_2.tgz");
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gzip_1.tgz.uu b/archivers/libarchive/files/libarchive/test/test_compat_gzip_1.tgz.uu
new file mode 100644
index 00000000000..db23f03747e
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_gzip_1.tgz.uu
@@ -0,0 +1,24 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_gzip_1.tgz.uu 185683 2008-12-06 07:08:08Z kientzle $
+
+begin 644 test_compat_gzip_1.tgz
+M'XL(")B^(DD``W1E<W0M<W!L:70N=&%R86$`2S-DH#DP,#`P,S%1`-*&YJ:&
+MR#0,&"L8`H&!J;&9F:&A@H&AH9&),8."`>V=QL!06ER26`1T2G9F:EY)54XJ
+MN>9`/*(`IX<(2#/D&F@GC`(Z``#S<P4"Z`,``!^+"`B8OB))``-T97-T+7-P
+M;&ET+G1A<F%B`&-@P`[2C'!(4!$8&!B8F9@H`&E#<U-#9!H&C!4,@<#`U-C,
+MS-!8P<#0T,C$C$'!@/9.8V`H+2Y)+`(Z)3LS-:^D*B>57',@'E&`TT,$I!EQ
+M#;031@$5`0`Q!<\4Z`,``!^+"`B8OB))``-T97-T+7-P;&ET+G1A<F%C`&-@
+M(`VD&9.H@0Q@8&!@9F*B`*0-S4T-D6D8,%8P!`(#4V,S,T,S!0-#0R-3(P8%
+M`]H[C8&AM+@DL0CHE.S,U+R2JIQ4<LV!>$0!3@\1D&;,-=!.&`5D``#7L]HO
+MZ`,``!^+"`B8OB))``-T97-T+7-P;&ET+G1A<F%D`&-@H`Y(,=1/,Z226;B`
+M@8&!F8F)`I`V-#<U1*9AP%C!$`@,3(W-S(S,%0P,#4U-S1@4#&CL+C`H+2Y)
+M+`(Z)3LS-:^D*B>57',@'E&`TT,$I!ER#;031@$>``"Y*#OBZ`,``!^+"`B8
+MOB))``-T97-T+7-P;&ET+G1A<F%E`&-@H"U(,=1/,Z*Q'08&!F8F)@I`VM#<
+MU!"9A@%C!4,@,#`U-C,S-E`P,#0T-35D4#"@L;O`H+2X)+$(Z)3LS-2\DJJ<
+M5'+-@7A$`4X/$9!FQ#703A@%0```]%Z(F^@#```?BP@(F+XB20`#=&5S="US
+M<&QI="YT87)A9@!C8!@8D&*HGV9,8SL,#`S,3$P4@+2AN:DA,@T#Q@J&0&!@
+M:FQF9FRH8&!H:&IJS*!@0&-W@4%I<4EB$=`IV9FI>255.:GDF@/QB`*<'B(@
+MS9AKH)TPH@``)4=8$>@#```?BP@(F+XB20`#=&5S="US<&QI="YT87)A9P!C
+M8!@%HV`4#'<``(`7"P;H`P``'XL(")B^(DD``W1E<W0M<W!L:70N=&%R86@`
+.8V`8&@``E#SI#J@`````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_gzip_2.tgz.uu b/archivers/libarchive/files/libarchive/test/test_compat_gzip_2.tgz.uu
new file mode 100644
index 00000000000..683b2a1f255
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_gzip_2.tgz.uu
@@ -0,0 +1,11 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_gzip_2.tgz.uu 185683 2008-12-06 07:08:08Z kientzle $
+
+begin 644 test_compat_gzip_2.tgz
+M'XL(`&76(DD``^W800["(!"%8=:>@ALXPP`]CXF=Q&A<:-UX>EN)C5M,AL;P
+MO@V[0A=_.E39F2.B'*.?5QX2?Z\?XGE&27)F]L0<HCA/]D=S[G&?#K?Y*.?3
+M>)V>E_'7YY07\>OZ)Y1W6Q\!-J3!?H^Z_J7TG]%_"QK0?\]4[/>HZS^_^T\!
+M_;>@@OY[=N2]6E\!JOH/P])_2OC^-X'YOV]+_]97@*K^A4K_C/Y;P/S?MZ5_
+MZRM`7?]<^L?_OR8P_P,`].D%,XR2*0`<``!4:&ES(&ES('5N<F5L871E9"!J
+@=6YK(&1A=&$@870@=&AE(&5N9"!O9B!T:&4@9FEL90H`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_lzma.c b/archivers/libarchive/files/libarchive/test/test_compat_lzma.c
new file mode 100644
index 00000000000..6aefbc2ebc3
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_lzma.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2008 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: head/lib/libarchive/test/test_compat_lzma.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+Execute the following to rebuild the data for this program:
+ tail -n +33 test_compat_lzma.c | /bin/sh
+
+# Use lzma command of XZ Utils.
+name=test_compat_lzma_1
+zcmd=lzma
+zsuffix=lzma
+ztar_suffix=tlz
+dir="$name`date +%Y%m%d%H%M%S`.$USER"
+mktarfile()
+{
+mkdir $dir
+echo "f1" > $dir/f1
+echo "f2" > $dir/f2
+echo "f3" > $dir/f3
+mkdir $dir/d1
+echo "f1" > $dir/d1/f1
+echo "f2" > $dir/d1/f2
+echo "f3" > $dir/d1/f3
+(cd $dir; tar cf ../$name.tar f1 f2 f3 d1/f1 d1/f2 d1/f3)
+rm -r $dir
+}
+mktarfile
+$zcmd $name.tar
+mv $name.tar.$zsuffix $name.$ztar_suffix
+echo "This is unrelated junk data at the end of the file" >> $name.$ztar_suffix
+uuencode $name.$ztar_suffix $name.$ztar_suffix > $name.$ztar_suffix.uu
+rm -f $name.$ztar_suffix
+#
+# Use option -e
+#
+name=test_compat_lzma_2
+dir="$name`date +%Y%m%d%H%M%S`.$USER"
+mktarfile
+$zcmd -e $name.tar
+mv $name.tar.$zsuffix $name.$ztar_suffix
+uuencode $name.$ztar_suffix $name.$ztar_suffix > $name.$ztar_suffix.uu
+rm -f $name.$ztar_suffix
+#
+# Use lzma command of LZMA SDK with option -d12.
+#
+name=test_compat_lzma_3
+zcmd=lzmasdk # Change this path to use lzma of LZMA SDK.
+dir="$name`date +%Y%m%d%H%M%S`.$USER"
+mktarfile
+$zcmd e -d12 $name.tar $name.$ztar_suffix
+rm -f $name.tar
+uuencode $name.$ztar_suffix $name.$ztar_suffix > $name.$ztar_suffix.uu
+rm -f $name.$ztar_suffix
+
+exit 0
+*/
+
+/*
+ * Verify our ability to read sample files compatibly with unlzma.
+ *
+ * In particular:
+ * * unlzma will read multiple lzma streams, concatenating the output
+ * * unlzma will read lzma streams which is made by lzma with option -e,
+ * concatenating the output
+ *
+ * Verify our ability to read sample files compatibly with lzma of
+ * LZMA SDK.
+ * * lzma will read lzma streams which is made by lzma with option -d12,
+ * concatenating the output
+ */
+
+/*
+ * All of the sample files have the same contents; they're just
+ * compressed in different ways.
+ */
+static void
+compat_lzma(const char *name)
+{
+ const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL };
+ struct archive_entry *ae;
+ struct archive *a;
+ int i, r;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_lzma(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("lzma reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
+
+ /* Read entries, match up names with list above. */
+ for (i = 0; i < 6; ++i) {
+ failure("Could not read file %d (%s) from %s", i, n[i], name);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ assertEqualString(n[i], archive_entry_pathname(ae));
+ }
+
+ /* Verify the end-of-archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify that the format detection worked. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA);
+ assertEqualString(archive_compression_name(a), "lzma");
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
+
+DEFINE_TEST(test_compat_lzma)
+{
+ /* This sample has been added junk datas to its tail. */
+ compat_lzma("test_compat_lzma_1.tlz");
+ /* This sample has been made by lzma with option -e,
+ * the first byte of which is 0x5e.
+ * Not supported in libarchive 2.7.* and earlier */
+ compat_lzma("test_compat_lzma_2.tlz");
+ /* This sample has been made by lzma of LZMA SDK with
+ * option -d12, second byte and third byte of which is
+ * not zero.
+ * Not supported in libarchive 2.7.* and earlier */
+ compat_lzma("test_compat_lzma_3.tlz");
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_lzma_1.tlz.uu b/archivers/libarchive/files/libarchive/test/test_compat_lzma_1.tlz.uu
new file mode 100644
index 00000000000..57fa501f00d
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_lzma_1.tlz.uu
@@ -0,0 +1,10 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_lzma_1.tlz.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_compat_lzma_1.tlz
+M70``@`#__________P`S##P;IXPT!HUK`DO\DC[V2OB%Z^'=ZT59ANYMTD(/
+M^W;\8!%O7<+P&=#(9W<_!$Z.7/Y<&\(8+E0^,_-\Z"D^P'N0J^4-UH"WMJ<&
+MV-P6=Y[-FY$IFNZ="RF24TO.B7EP[F]BGMJSP[]OZ_P9/#J'T=;7E&&A@J<[
+MA^C'Q*/Y&I)2^T930'MJTK-98U0D9R*-X2^5__6H:+A4:&ES(&ES('5N<F5L
+F871E9"!J=6YK(&1A=&$@870@=&AE(&5N9"!O9B!T:&4@9FEL90H`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_lzma_2.tlz.uu b/archivers/libarchive/files/libarchive/test/test_compat_lzma_2.tlz.uu
new file mode 100644
index 00000000000..ff91d2a608f
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_lzma_2.tlz.uu
@@ -0,0 +1,9 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_lzma_2.tlz.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_compat_lzma_2.tlz
+M7@``@`#__________P`S##P;IXPT!HUK`DO\DC[V2OB%Z^'<FN`(!=!,)@8W
+M9R(6\QIOTA6SGM20X;2'6#3B&HC%2XOX2?D['5WD"`>`W2"/3R1F1:P:&Q9A
+MGH2JJI9$C?8.=WTE:O<1WA@X>DK-Y#SW;I2!P;NYG^2"-(D9/E(D_0XK_H,\
+95*/V"T#E9ZO][@'R,6E&^A([.##_\M#YU@``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_lzma_3.tlz.uu b/archivers/libarchive/files/libarchive/test/test_compat_lzma_3.tlz.uu
new file mode 100644
index 00000000000..bee82897beb
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_lzma_3.tlz.uu
@@ -0,0 +1,9 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_lzma_3.tlz.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_compat_lzma_3.tlz
+M70`0````'``````````S##P;IXPT!HUK`DO\DC[V2OB%Z^'=ZT59ANYMTD(1
+M$Y^=;\4%U_CXKQ*F$OFZKEQUG)1U8="](V<2K"U1\Z6%H(UNQ[Y3.=D'>_G-
+MCO71X+M*7WH7$D1&E9Y$XHW,(`[X";GGTO+,'&1?F%<@`.$-OV;8P1?*M$A"
+:MA+1XONREMK,1('455L=X1>WC#1YW"('I@``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.c b/archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.c
new file mode 100644
index 00000000000..ca1506a355e
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.c
@@ -0,0 +1,128 @@
+/*-
+ * Copyright (c) 2003-2009 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: head/lib/libarchive/test/test_compat_solaris_tar_acl.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+ * Exercise support for reading Solaris-style ACL data
+ * from tar archives.
+ *
+ * This should work on all systems, regardless of whether local
+ * filesystems support ACLs or not.
+ */
+
+DEFINE_TEST(test_compat_solaris_tar_acl)
+{
+ struct archive *a;
+ struct archive_entry *ae;
+ const char *reference1 = "test_compat_solaris_tar_acl.tar";
+ int type, permset, tag, qual;
+ const char *name;
+
+ /* Sample file generated on Solaris 10 */
+ extract_reference_file(reference1);
+ assert(NULL != (a = archive_read_new()));
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ assertA(0 == archive_read_open_filename(a, reference1, 512));
+
+ /* Archive has 1 entry with some ACLs set on it. */
+ assertA(0 == archive_read_next_header(a, &ae));
+ failure("Basic ACLs should set mode to 0644, not %04o",
+ archive_entry_mode(ae)&0777);
+ assertEqualInt((archive_entry_mode(ae) & 0777), 0644);
+ assertEqualInt(7, archive_entry_acl_reset(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
+ assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
+ assertEqualInt(006, permset);
+ assertEqualInt(ARCHIVE_ENTRY_ACL_USER_OBJ, tag);
+ assertEqualInt(-1, qual);
+ assert(name == NULL);
+
+ assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
+ assertEqualInt(004, permset);
+ assertEqualInt(ARCHIVE_ENTRY_ACL_GROUP_OBJ, tag);
+ assertEqualInt(-1, qual);
+ assert(name == NULL);
+
+ assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
+ assertEqualInt(004, permset);
+ assertEqualInt(ARCHIVE_ENTRY_ACL_OTHER, tag);
+ assertEqualInt(-1, qual);
+ assert(name == NULL);
+
+ assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
+ assertEqualInt(001, permset);
+ assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag);
+ assertEqualInt(71, qual);
+ assertEqualString(name, "lp");
+
+ assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
+ assertEqualInt(004, permset);
+ assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag);
+ assertEqualInt(666, qual);
+ assertEqualString(name, "666");
+
+ assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
+ assertEqualInt(007, permset);
+ assertEqualInt(ARCHIVE_ENTRY_ACL_USER, tag);
+ assertEqualInt(1000, qual);
+ assertEqualString(name, "trasz");
+
+ assertEqualInt(ARCHIVE_OK, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+ assertEqualInt(ARCHIVE_ENTRY_ACL_TYPE_ACCESS, type);
+ assertEqualInt(004, permset);
+ assertEqualInt(ARCHIVE_ENTRY_ACL_MASK, tag);
+ assertEqualInt(-1, qual);
+ assertEqualString(name, NULL);
+
+ assertEqualInt(ARCHIVE_EOF, archive_entry_acl_next(ae,
+ ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ &type, &permset, &tag, &qual, &name));
+
+ /* Close the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.tar.uu b/archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.tar.uu
new file mode 100644
index 00000000000..54aabc2dde2
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_solaris_tar_acl.tar.uu
@@ -0,0 +1,61 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_solaris_tar_acl.tar.uu 191576 2009-04-27 18:27:54Z kientzle $
+begin 644 test_acl_solaris.tar
+M9FEL92UW:71H+7!O<VEX+6%C;',`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`P,#`P`#`P,#`P,#`P,30T
+M`#$Q,3<T-C`T,34W`#`P,34Q-S8`00``````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,'1R87-Z
+M````````````````````````````````````<F]O=```````````````````
+M```````````````````P,#`P,C$P`#`P,#`P,3``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````Q,#`P,#`W`'5S97(Z.G)W+2QU<V5R.FQP.BTM
+M>#HW,2QU<V5R.C8V-CIR+2TZ-C8V+'5S97(Z=')A<WHZ<G=X.C$P,#`L9W)O
+M=7`Z.G(M+2QM87-K.G(M+2QO=&AE<CIR+2T``````````3````````/-@```
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````!%&8`````````&L`````,3`P,#`P-P!U
+M<V5R.CIR=RTL=7-E<CIL<#HM+7@Z-S$L=7-E<CHV-C8Z<BTM.C8V-BQU<V5R
+M.G1R87-Z.G)W>#HQ,#`P+&=R;W5P.CIR+2TL;6%S:SIR+69I;&4M=VET:"UP
+M;W-I>"UA8VQS````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`P-C0T`#`P,#$W-3``,#`P,#`P,``P,#`P,#`P,#`P,``Q,3$W-#8P-#$U
+M-P`P,#$U,30T`#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#!T<F%S>@``````````````
+M`````````````````````')O;W0`````````````````````````````````
+M````,#`P,#(Q,``P,#`P,#$P````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+H````````````````````````````````````````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c b/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c
index ae71e9232c5..30785d1fb0c 100644
--- a/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c
+++ b/archivers/libarchive/files/libarchive/test/test_compat_tar_hardlink.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_tar_hardlink.c,v 1.2 2008/03/12 05:12:23 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_tar_hardlink.c,v 1.3 2008/08/11 01:19:36 kientzle Exp $");
/*
* Background: There are two written standards for the tar file format.
@@ -93,7 +93,11 @@ test_compat_tar_hardlink_1(void)
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR);
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_read_finish(a);
+#else
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+#endif
}
DEFINE_TEST(test_compat_tar_hardlink)
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_xz.c b/archivers/libarchive/files/libarchive/test/test_compat_xz.c
new file mode 100644
index 00000000000..c3b790ffbd2
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_xz.c
@@ -0,0 +1,84 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2008 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: head/lib/libarchive/test/test_compat_xz.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+/*
+ * Verify our ability to read sample files compatibly with unxz.
+ *
+ * In particular:
+ * * unxz will read multiple xz streams, concatenating the output
+ */
+
+/*
+ * All of the sample files have the same contents; they're just
+ * compressed in different ways.
+ */
+static void
+compat_xz(const char *name)
+{
+ const char *n[7] = { "f1", "f2", "f3", "d1/f1", "d1/f2", "d1/f3", NULL };
+ struct archive_entry *ae;
+ struct archive *a;
+ int i, r;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_xz(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("xz reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
+
+ /* Read entries, match up names with list above. */
+ for (i = 0; i < 6; ++i) {
+ failure("Could not read file %d (%s) from %s", i, n[i], name);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ assertEqualString(n[i], archive_entry_pathname(ae));
+ }
+
+ /* Verify the end-of-archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify that the format detection worked. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_XZ);
+ assertEqualString(archive_compression_name(a), "xz");
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
+
+DEFINE_TEST(test_compat_xz)
+{
+ compat_xz("test_compat_xz_1.txz");
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_xz_1.txz.uu b/archivers/libarchive/files/libarchive/test/test_compat_xz_1.txz.uu
new file mode 100644
index 00000000000..9d4b8e8ee6d
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_compat_xz_1.txz.uu
@@ -0,0 +1,13 @@
+$FreeBSD: head/lib/libarchive/test/test_compat_xz_1.txz.uu 191183 2009-04-17 01:06:31Z kientzle $
+begin 644 test_compat_gzip_1.txz
+M_3=Z6%H```3FUK1&`@`A`18```!T+^6CX`^?`(-=`#,,/!NGC#0&C6L"2_R2
+M/O9*^(7KX=WM^(=KA(RH"\09$$)!Q_+JUHQ*`]R;ITL_F3/I6:^Q0550A&)B
+MHS@=K]7@K1-9FOIP#PU!I<PUHW+W#<F(6FSL/<?5:4*>?E5&IHH&Q=N>_C&G
+M-$G]+L[\,B<7%8&$NO5K31*Y>"D^*ZG,Z=H```"KU50H$1^1S``!GP&@'P``
+MLZ042+'$9_L"``````196OTW>EA:```$YM:T1@(`(0$6````="_EH^`,7P!I
+M70``;IBIKOMK%/A?-<U3^2)5\V,DQ(:ZUH:[B'3>TZV0266G?2,[/?\,JE6`
+M__C/SA[W1?*2<Y3NQ'DCK4JEJYHQU`Q\N=H9LL3KRAH,VQQ2OD*@?1NLV]<E
+MF&X."!L\R:Z]=*TJPT/BJ^``````R[PG*'(H!W,``84!X!@``/;+`G2QQ&?[
+(`@`````$65H`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_zip.c b/archivers/libarchive/files/libarchive/test/test_compat_zip.c
index fdeb9c64ac1..d8bc4de3608 100644
--- a/archivers/libarchive/files/libarchive/test/test_compat_zip.c
+++ b/archivers/libarchive/files/libarchive/test/test_compat_zip.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_compat_zip.c,v 1.2 2008/03/12 05:12:23 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_compat_zip.c 196962 2009-09-08 05:02:41Z kientzle $");
/* Copy this function for each test file and adjust it accordingly. */
static void
@@ -32,10 +32,11 @@ test_compat_zip_1(void)
char name[] = "test_compat_zip_1.zip";
struct archive_entry *ae;
struct archive *a;
+ int r;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
- assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
extract_reference_file(name);
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 10240));
@@ -44,7 +45,16 @@ test_compat_zip_1(void)
assertEqualString("META-INF/MANIFEST.MF", archive_entry_pathname(ae));
/* Read second entry. */
- assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ r = archive_read_next_header(a, &ae);
+ if (r != ARCHIVE_OK) {
+ if (strcmp(archive_error_string(a),
+ "libarchive compiled without deflate support (no libz)") == 0) {
+ skipping("Skipping ZIP compression check: %s",
+ archive_error_string(a));
+ goto finish;
+ }
+ }
+ assertEqualIntA(a, ARCHIVE_OK, r);
assertEqualString("tmp.class", archive_entry_pathname(ae));
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
@@ -53,10 +63,11 @@ test_compat_zip_1(void)
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ZIP);
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#else
+finish:
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu b/archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu
index e13a6cac29d..29cdf96b029 100644
--- a/archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu
+++ b/archivers/libarchive/files/libarchive/test/test_compat_zip_1.zip.uu
@@ -1,3 +1,4 @@
+$FreeBSD: src/lib/libarchive/test/test_compat_zip_1.zip.uu,v 1.2 2008/06/30 15:49:12 des Exp $
begin 644 test_compat_zip_1.zip
M4$L#!!0`"``(``B$@S<````````````````4````345402U)3D8O34%.249%
M4U0N34;S3<S+3$LM+M$-2RTJSLS/LU(PU#/@Y7+,0Q)Q+$A,SDA5`(H!)<U!
diff --git a/archivers/libarchive/files/libarchive/test/test_empty_write.c b/archivers/libarchive/files/libarchive/test/test_empty_write.c
index 6a9f3f9c8d5..0523ec362c3 100644
--- a/archivers/libarchive/files/libarchive/test/test_empty_write.c
+++ b/archivers/libarchive/files/libarchive/test/test_empty_write.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_empty_write.c,v 1.2 2008/03/15 11:06:15 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_empty_write.c 189308 2009-03-03 17:02:51Z kientzle $");
DEFINE_TEST(test_empty_write)
{
@@ -31,6 +31,7 @@ DEFINE_TEST(test_empty_write)
struct archive_entry *ae;
struct archive *a;
size_t used;
+ int r;
/*
* Exercise a zero-byte write to a gzip-compressed archive.
@@ -39,28 +40,29 @@ DEFINE_TEST(test_empty_write)
/* Create a new archive in memory. */
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
- assertA(0 == archive_write_set_compression_gzip(a));
- assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
- /* Write a file to it. */
- assert((ae = archive_entry_new()) != NULL);
- archive_entry_copy_pathname(ae, "file");
- archive_entry_set_mode(ae, S_IFREG | 0755);
- archive_entry_set_size(ae, 0);
- assertA(0 == archive_write_header(a, ae));
- archive_entry_free(ae);
-
- /* THE TEST: write zero bytes to this entry. */
- /* This used to crash. */
- assertEqualIntA(a, 0, archive_write_data(a, "", 0));
+ r = archive_write_set_compression_gzip(a);
+ if (r == ARCHIVE_FATAL) {
+ skipping("Empty write to gzip-compressed archive");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_open_memory(a, buff, sizeof(buff), &used));
+ /* Write a file to it. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ archive_entry_set_size(ae, 0);
+ assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
- /* Close out the archive. */
- assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
- archive_write_finish(a);
-#endif
+ /* THE TEST: write zero bytes to this entry. */
+ /* This used to crash. */
+ assertEqualIntA(a, 0, archive_write_data(a, "", 0));
+ /* Close out the archive. */
+ assertA(0 == archive_write_close(a));
+ assertA(0 == archive_write_finish(a));
+ }
/*
* Again, with bzip2 compression.
@@ -69,27 +71,28 @@ DEFINE_TEST(test_empty_write)
/* Create a new archive in memory. */
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
- assertA(0 == archive_write_set_compression_bzip2(a));
- assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
- /* Write a file to it. */
- assert((ae = archive_entry_new()) != NULL);
- archive_entry_copy_pathname(ae, "file");
- archive_entry_set_mode(ae, S_IFREG | 0755);
- archive_entry_set_size(ae, 0);
- assertA(0 == archive_write_header(a, ae));
- archive_entry_free(ae);
-
- /* THE TEST: write zero bytes to this entry. */
- assertEqualIntA(a, 0, archive_write_data(a, "", 0));
+ r = archive_write_set_compression_bzip2(a);
+ if (r == ARCHIVE_FATAL) {
+ skipping("Empty write to bzip2-compressed archive");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_open_memory(a, buff, sizeof(buff), &used));
+ /* Write a file to it. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ archive_entry_set_size(ae, 0);
+ assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
- /* Close out the archive. */
- assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
- archive_write_finish(a);
-#endif
+ /* THE TEST: write zero bytes to this entry. */
+ assertEqualIntA(a, 0, archive_write_data(a, "", 0));
+ /* Close out the archive. */
+ assertA(0 == archive_write_close(a));
+ assertA(0 == archive_write_finish(a));
+ }
/*
* For good measure, one more time with no compression.
@@ -113,9 +116,5 @@ DEFINE_TEST(test_empty_write)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_write_finish(a));
-#else
- archive_write_finish(a);
-#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_entry.c b/archivers/libarchive/files/libarchive/test/test_entry.c
index 52820923803..b6a2da177ac 100644
--- a/archivers/libarchive/files/libarchive/test/test_entry.c
+++ b/archivers/libarchive/files/libarchive/test/test_entry.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_entry.c,v 1.6 2008/05/26 17:00:24 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_entry.c 201247 2009-12-30 05:59:21Z kientzle $");
#include <locale.h>
@@ -51,13 +51,40 @@ DEFINE_TEST(test_entry)
const char *xname; /* For xattr tests. */
const void *xval; /* For xattr tests. */
size_t xsize; /* For xattr tests. */
- int c;
wchar_t wc;
long l;
assert((e = archive_entry_new()) != NULL);
/*
+ * Verify that the AE_IF* defines match S_IF* defines
+ * on this platform. See comments in archive_entry.h.
+ */
+#ifdef S_IFREG
+ assertEqualInt(S_IFREG, AE_IFREG);
+#endif
+#ifdef S_IFLNK
+ assertEqualInt(S_IFLNK, AE_IFLNK);
+#endif
+#ifdef S_IFSOCK
+ assertEqualInt(S_IFSOCK, AE_IFSOCK);
+#endif
+#ifdef S_IFCHR
+ assertEqualInt(S_IFCHR, AE_IFCHR);
+#endif
+/* Work around MinGW, which defines S_IFBLK wrong. */
+/* sourceforge.net/tracker/?func=detail&atid=102435&aid=1942809&group_id=2435 */
+#if defined(S_IFBLK) && !defined(_WIN32)
+ assertEqualInt(S_IFBLK, AE_IFBLK);
+#endif
+#ifdef S_IFDIR
+ assertEqualInt(S_IFDIR, AE_IFDIR);
+#endif
+#ifdef S_IFIFO
+ assertEqualInt(S_IFIFO, AE_IFIFO);
+#endif
+
+ /*
* Basic set/read tests for all fields.
* We should be able to set any field and read
* back the same value.
@@ -69,15 +96,35 @@ DEFINE_TEST(test_entry)
* The following tests are ordered alphabetically by the
* name of the field.
*/
+
/* atime */
archive_entry_set_atime(e, 13579, 24680);
assertEqualInt(archive_entry_atime(e), 13579);
assertEqualInt(archive_entry_atime_nsec(e), 24680);
+ archive_entry_unset_atime(e);
+ assertEqualInt(archive_entry_atime(e), 0);
+ assertEqualInt(archive_entry_atime_nsec(e), 0);
+ assert(!archive_entry_atime_is_set(e));
+
+ /* birthtime */
+ archive_entry_set_birthtime(e, 17579, 24990);
+ assertEqualInt(archive_entry_birthtime(e), 17579);
+ assertEqualInt(archive_entry_birthtime_nsec(e), 24990);
+ archive_entry_unset_birthtime(e);
+ assertEqualInt(archive_entry_birthtime(e), 0);
+ assertEqualInt(archive_entry_birthtime_nsec(e), 0);
+ assert(!archive_entry_birthtime_is_set(e));
+
/* ctime */
archive_entry_set_ctime(e, 13580, 24681);
assertEqualInt(archive_entry_ctime(e), 13580);
assertEqualInt(archive_entry_ctime_nsec(e), 24681);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+ archive_entry_unset_ctime(e);
+ assertEqualInt(archive_entry_ctime(e), 0);
+ assertEqualInt(archive_entry_ctime_nsec(e), 0);
+ assert(!archive_entry_ctime_is_set(e));
+
+#if ARCHIVE_VERSION_NUMBER >= 1009000
/* dev */
archive_entry_set_dev(e, 235);
assertEqualInt(archive_entry_dev(e), 235);
@@ -85,17 +132,21 @@ DEFINE_TEST(test_entry)
skipping("archive_entry_dev()");
#endif
/* devmajor/devminor are tested specially below. */
-#if ARCHIVE_VERSION_STAMP >= 1009000
+
+#if ARCHIVE_VERSION_NUMBER >= 1009000
/* filetype */
archive_entry_set_filetype(e, AE_IFREG);
assertEqualInt(archive_entry_filetype(e), AE_IFREG);
#else
skipping("archive_entry_filetype()");
#endif
+
/* fflags are tested specially below */
+
/* gid */
archive_entry_set_gid(e, 204);
assertEqualInt(archive_entry_gid(e), 204);
+
/* gname */
archive_entry_set_gname(e, "group");
assertEqualString(archive_entry_gname(e), "group");
@@ -104,6 +155,7 @@ DEFINE_TEST(test_entry)
assertEqualWString(archive_entry_gname_w(e), L"wgroup");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_gname_w(e), L"wgroup");
+
/* hardlink */
archive_entry_set_hardlink(e, "hardlinkname");
assertEqualString(archive_entry_hardlink(e), "hardlinkname");
@@ -112,12 +164,18 @@ DEFINE_TEST(test_entry)
assertEqualString(archive_entry_hardlink(e), "hardlinkname2");
memset(buff, 0, sizeof(buff));
assertEqualString(archive_entry_hardlink(e), "hardlinkname2");
+ archive_entry_copy_hardlink(e, NULL);
+ assertEqualString(archive_entry_hardlink(e), NULL);
+ assertEqualWString(archive_entry_hardlink_w(e), NULL);
wcscpy(wbuff, L"whardlink");
archive_entry_copy_hardlink_w(e, wbuff);
assertEqualWString(archive_entry_hardlink_w(e), L"whardlink");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_hardlink_w(e), L"whardlink");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+ archive_entry_copy_hardlink_w(e, NULL);
+ assertEqualString(archive_entry_hardlink(e), NULL);
+ assertEqualWString(archive_entry_hardlink_w(e), NULL);
+#if ARCHIVE_VERSION_NUMBER >= 1009000
/* ino */
archive_entry_set_ino(e, 8593);
assertEqualInt(archive_entry_ino(e), 8593);
@@ -158,17 +216,24 @@ DEFINE_TEST(test_entry)
/* mode */
archive_entry_set_mode(e, 0123456);
assertEqualInt(archive_entry_mode(e), 0123456);
+
/* mtime */
archive_entry_set_mtime(e, 13581, 24682);
assertEqualInt(archive_entry_mtime(e), 13581);
assertEqualInt(archive_entry_mtime_nsec(e), 24682);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+ archive_entry_unset_mtime(e);
+ assertEqualInt(archive_entry_mtime(e), 0);
+ assertEqualInt(archive_entry_mtime_nsec(e), 0);
+ assert(!archive_entry_mtime_is_set(e));
+
+#if ARCHIVE_VERSION_NUMBER >= 1009000
/* nlink */
archive_entry_set_nlink(e, 736);
assertEqualInt(archive_entry_nlink(e), 736);
#else
skipping("archive_entry_nlink()");
#endif
+
/* pathname */
archive_entry_set_pathname(e, "path");
assertEqualString(archive_entry_pathname(e), "path");
@@ -184,7 +249,8 @@ DEFINE_TEST(test_entry)
assertEqualWString(archive_entry_pathname_w(e), L"wpath");
memset(wbuff, 0, sizeof(wbuff));
assertEqualWString(archive_entry_pathname_w(e), L"wpath");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+
+#if ARCHIVE_VERSION_NUMBER >= 1009000
/* rdev */
archive_entry_set_rdev(e, 532);
assertEqualInt(archive_entry_rdev(e), 532);
@@ -192,24 +258,41 @@ DEFINE_TEST(test_entry)
skipping("archive_entry_rdev()");
#endif
/* rdevmajor/rdevminor are tested specially below. */
+
/* size */
archive_entry_set_size(e, 987654321);
assertEqualInt(archive_entry_size(e), 987654321);
+ archive_entry_unset_size(e);
+ assertEqualInt(archive_entry_size(e), 0);
+ assert(!archive_entry_size_is_set(e));
+
+ /* sourcepath */
+ archive_entry_copy_sourcepath(e, "path1");
+ assertEqualString(archive_entry_sourcepath(e), "path1");
+
/* symlink */
archive_entry_set_symlink(e, "symlinkname");
assertEqualString(archive_entry_symlink(e), "symlinkname");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
strcpy(buff, "symlinkname2");
archive_entry_copy_symlink(e, buff);
assertEqualString(archive_entry_symlink(e), "symlinkname2");
memset(buff, 0, sizeof(buff));
assertEqualString(archive_entry_symlink(e), "symlinkname2");
#endif
+ archive_entry_copy_symlink_w(e, NULL);
+ assertEqualWString(archive_entry_symlink_w(e), NULL);
+ assertEqualString(archive_entry_symlink(e), NULL);
archive_entry_copy_symlink_w(e, L"wsymlink");
assertEqualWString(archive_entry_symlink_w(e), L"wsymlink");
+ archive_entry_copy_symlink(e, NULL);
+ assertEqualWString(archive_entry_symlink_w(e), NULL);
+ assertEqualString(archive_entry_symlink(e), NULL);
+
/* uid */
archive_entry_set_uid(e, 83);
assertEqualInt(archive_entry_uid(e), 83);
+
/* uname */
archive_entry_set_uname(e, "user");
assertEqualString(archive_entry_uname(e), "user");
@@ -231,9 +314,13 @@ DEFINE_TEST(test_entry)
/* TODO: Make this system-independent. */
assertEqualString(archive_entry_fflags_text(e),
"uappnd,nouchg,nodump,noopaque,uunlnk");
- /* TODO: Test archive_entry_copy_fflags_text_w() */
+ /* Test archive_entry_copy_fflags_text_w() */
+ archive_entry_copy_fflags_text_w(e, L" ,nouappnd, nouchg, dump,uunlnk");
+ archive_entry_fflags(e, &set, &clear);
+ assertEqualInt(16, set);
+ assertEqualInt(7, clear);
/* Test archive_entry_copy_fflags_text() */
- archive_entry_copy_fflags_text(e, "nouappnd, nouchg, dump,uunlnk");
+ archive_entry_copy_fflags_text(e, " ,nouappnd, nouchg, dump,uunlnk");
archive_entry_fflags(e, &set, &clear);
assertEqualInt(16, set);
assertEqualInt(7, clear);
@@ -247,20 +334,20 @@ DEFINE_TEST(test_entry)
assertEqualInt(0, archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, "xattr1");
assertEqualString(xval, "xattrvalue1");
- assertEqualInt(xsize, 12);
+ assertEqualInt((int)xsize, 12);
assertEqualInt(1, archive_entry_xattr_count(e));
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
- assertEqualInt(xsize, 0);
+ assertEqualInt((int)xsize, 0);
archive_entry_xattr_clear(e);
assertEqualInt(0, archive_entry_xattr_reset(e));
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
- assertEqualInt(xsize, 0);
+ assertEqualInt((int)xsize, 0);
archive_entry_xattr_add_entry(e, "xattr1", "xattrvalue1", 12);
assertEqualInt(1, archive_entry_xattr_reset(e));
archive_entry_xattr_add_entry(e, "xattr2", "xattrvalue2", 12);
@@ -271,7 +358,7 @@ DEFINE_TEST(test_entry)
archive_entry_xattr_next(e, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
- assertEqualInt(xsize, 0);
+ assertEqualInt((int)xsize, 0);
/*
@@ -281,27 +368,29 @@ DEFINE_TEST(test_entry)
/* Set values in 'e' */
archive_entry_clear(e);
archive_entry_set_atime(e, 13579, 24680);
+ archive_entry_set_birthtime(e, 13779, 24990);
archive_entry_set_ctime(e, 13580, 24681);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_dev(e, 235);
#endif
archive_entry_set_fflags(e, 0x55, 0xAA);
archive_entry_set_gid(e, 204);
archive_entry_set_gname(e, "group");
archive_entry_set_hardlink(e, "hardlinkname");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_ino(e, 8593);
#endif
archive_entry_set_mode(e, 0123456);
archive_entry_set_mtime(e, 13581, 24682);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_nlink(e, 736);
#endif
archive_entry_set_pathname(e, "path");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_rdev(e, 532);
#endif
archive_entry_set_size(e, 987654321);
+ archive_entry_copy_sourcepath(e, "source");
archive_entry_set_symlink(e, "symlinkname");
archive_entry_set_uid(e, 83);
archive_entry_set_uname(e, "user");
@@ -317,9 +406,11 @@ DEFINE_TEST(test_entry)
/* Clone should have same contents. */
assertEqualInt(archive_entry_atime(e2), 13579);
assertEqualInt(archive_entry_atime_nsec(e2), 24680);
+ assertEqualInt(archive_entry_birthtime(e2), 13779);
+ assertEqualInt(archive_entry_birthtime_nsec(e2), 24990);
assertEqualInt(archive_entry_ctime(e2), 13580);
assertEqualInt(archive_entry_ctime_nsec(e2), 24681);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_dev(e2), 235);
#endif
archive_entry_fflags(e, &set, &clear);
@@ -328,28 +419,29 @@ DEFINE_TEST(test_entry)
assertEqualInt(archive_entry_gid(e2), 204);
assertEqualString(archive_entry_gname(e2), "group");
assertEqualString(archive_entry_hardlink(e2), "hardlinkname");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_ino(e2), 8593);
#endif
assertEqualInt(archive_entry_mode(e2), 0123456);
assertEqualInt(archive_entry_mtime(e2), 13581);
assertEqualInt(archive_entry_mtime_nsec(e2), 24682);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_nlink(e2), 736);
#endif
assertEqualString(archive_entry_pathname(e2), "path");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_rdev(e2), 532);
#endif
assertEqualInt(archive_entry_size(e2), 987654321);
+ assertEqualString(archive_entry_sourcepath(e2), "source");
assertEqualString(archive_entry_symlink(e2), "symlinkname");
assertEqualInt(archive_entry_uid(e2), 83);
assertEqualString(archive_entry_uname(e2), "user");
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("ACL preserved by archive_entry_clone()");
#else
/* Verify ACL was copied. */
- assertEqualInt(4, c = archive_entry_acl_reset(e2,
+ assertEqualInt(4, archive_entry_acl_reset(e2,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
/* First three are standard permission bits. */
assertEqualInt(0, archive_entry_acl_next(e2,
@@ -386,48 +478,50 @@ DEFINE_TEST(test_entry)
assertEqualInt(qual, 77);
assertEqualString(name, "user77");
#endif
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("xattr data preserved by archive_entry_clone");
#else
/* Verify xattr was copied. */
- assertEqualInt(1, c = archive_entry_xattr_reset(e2));
+ assertEqualInt(1, archive_entry_xattr_reset(e2));
assertEqualInt(0, archive_entry_xattr_next(e2, &xname, &xval, &xsize));
assertEqualString(xname, "xattr1");
assertEqualString(xval, "xattrvalue");
- assertEqualInt(xsize, 11);
+ assertEqualInt((int)xsize, 11);
assertEqualInt(ARCHIVE_WARN,
archive_entry_xattr_next(e2, &xname, &xval, &xsize));
assertEqualString(xname, NULL);
assertEqualString(xval, NULL);
- assertEqualInt(xsize, 0);
+ assertEqualInt((int)xsize, 0);
#endif
/* Change the original */
archive_entry_set_atime(e, 13580, 24690);
+ archive_entry_set_birthtime(e, 13980, 24999);
archive_entry_set_ctime(e, 13590, 24691);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_dev(e, 245);
#endif
archive_entry_set_fflags(e, 0x85, 0xDA);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_filetype(e, AE_IFLNK);
#endif
archive_entry_set_gid(e, 214);
archive_entry_set_gname(e, "grouper");
archive_entry_set_hardlink(e, "hardlinkpath");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_ino(e, 8763);
#endif
archive_entry_set_mode(e, 0123654);
archive_entry_set_mtime(e, 18351, 28642);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_nlink(e, 73);
#endif
archive_entry_set_pathname(e, "pathest");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_rdev(e, 132);
#endif
archive_entry_set_size(e, 987456321);
+ archive_entry_copy_sourcepath(e, "source2");
archive_entry_set_symlink(e, "symlinkpath");
archive_entry_set_uid(e, 93);
archive_entry_set_uname(e, "username");
@@ -437,9 +531,11 @@ DEFINE_TEST(test_entry)
/* Clone should still have same contents. */
assertEqualInt(archive_entry_atime(e2), 13579);
assertEqualInt(archive_entry_atime_nsec(e2), 24680);
+ assertEqualInt(archive_entry_birthtime(e2), 13779);
+ assertEqualInt(archive_entry_birthtime_nsec(e2), 24990);
assertEqualInt(archive_entry_ctime(e2), 13580);
assertEqualInt(archive_entry_ctime_nsec(e2), 24681);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_dev(e2), 235);
#endif
archive_entry_fflags(e2, &set, &clear);
@@ -448,28 +544,29 @@ DEFINE_TEST(test_entry)
assertEqualInt(archive_entry_gid(e2), 204);
assertEqualString(archive_entry_gname(e2), "group");
assertEqualString(archive_entry_hardlink(e2), "hardlinkname");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_ino(e2), 8593);
#endif
assertEqualInt(archive_entry_mode(e2), 0123456);
assertEqualInt(archive_entry_mtime(e2), 13581);
assertEqualInt(archive_entry_mtime_nsec(e2), 24682);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_nlink(e2), 736);
#endif
assertEqualString(archive_entry_pathname(e2), "path");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_rdev(e2), 532);
#endif
assertEqualInt(archive_entry_size(e2), 987654321);
+ assertEqualString(archive_entry_sourcepath(e2), "source");
assertEqualString(archive_entry_symlink(e2), "symlinkname");
assertEqualInt(archive_entry_uid(e2), 83);
assertEqualString(archive_entry_uname(e2), "user");
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("ACL held by clone of archive_entry");
#else
/* Verify ACL was unchanged. */
- assertEqualInt(4, c = archive_entry_acl_reset(e2,
+ assertEqualInt(4, archive_entry_acl_reset(e2,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
/* First three are standard permission bits. */
assertEqualInt(0, archive_entry_acl_next(e2,
@@ -514,7 +611,7 @@ DEFINE_TEST(test_entry)
assertEqualInt(qual, -1);
assertEqualString(name, NULL);
#endif
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("xattr preserved in archive_entry copy");
#else
/* Verify xattr was unchanged. */
@@ -530,13 +627,15 @@ DEFINE_TEST(test_entry)
archive_entry_clear(e);
assertEqualInt(archive_entry_atime(e), 0);
assertEqualInt(archive_entry_atime_nsec(e), 0);
+ assertEqualInt(archive_entry_birthtime(e), 0);
+ assertEqualInt(archive_entry_birthtime_nsec(e), 0);
assertEqualInt(archive_entry_ctime(e), 0);
assertEqualInt(archive_entry_ctime_nsec(e), 0);
assertEqualInt(archive_entry_dev(e), 0);
archive_entry_fflags(e, &set, &clear);
assertEqualInt(clear, 0);
assertEqualInt(set, 0);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_filetype(e), 0);
#endif
assertEqualInt(archive_entry_gid(e), 0);
@@ -546,7 +645,7 @@ DEFINE_TEST(test_entry)
assertEqualInt(archive_entry_mode(e), 0);
assertEqualInt(archive_entry_mtime(e), 0);
assertEqualInt(archive_entry_mtime_nsec(e), 0);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_nlink(e), 0);
#endif
assertEqualString(archive_entry_pathname(e), NULL);
@@ -581,6 +680,7 @@ DEFINE_TEST(test_entry)
st.st_atimespec.tv_nsec = 6543210;
st.st_ctimespec.tv_nsec = 5432109;
st.st_mtimespec.tv_nsec = 3210987;
+ st.st_birthtimespec.tv_nsec = 7459386;
#endif
/* Copy them into the entry. */
archive_entry_copy_stat(e, &st);
@@ -592,7 +692,7 @@ DEFINE_TEST(test_entry)
assertEqualInt(archive_entry_ino(e), 234);
assertEqualInt(archive_entry_mode(e), 077777);
assertEqualInt(archive_entry_mtime(e), 234567);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(archive_entry_nlink(e), 345);
#endif
assertEqualInt(archive_entry_size(e), 123456789);
@@ -602,6 +702,7 @@ DEFINE_TEST(test_entry)
assertEqualInt(archive_entry_atime_nsec(e), 6543210);
assertEqualInt(archive_entry_ctime_nsec(e), 5432109);
assertEqualInt(archive_entry_mtime_nsec(e), 3210987);
+ assertEqualInt(archive_entry_birthtime_nsec(e), 7459386);
#endif
/*
@@ -613,17 +714,17 @@ DEFINE_TEST(test_entry)
/* Set a bunch of fields individually. */
archive_entry_set_atime(e, 456789, 321);
archive_entry_set_ctime(e, 345678, 432);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_dev(e, 123);
#endif
archive_entry_set_gid(e, 34);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_ino(e, 234);
#endif
archive_entry_set_mode(e, 012345);
archive_entry_set_mode(e, 012345);
archive_entry_set_mtime(e, 234567, 543);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_nlink(e, 345);
#endif
archive_entry_set_size(e, 123456789);
@@ -633,16 +734,16 @@ DEFINE_TEST(test_entry)
/* Check that the values match. */
assertEqualInt(pst->st_atime, 456789);
assertEqualInt(pst->st_ctime, 345678);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(pst->st_dev, 123);
#endif
assertEqualInt(pst->st_gid, 34);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(pst->st_ino, 234);
#endif
assertEqualInt(pst->st_mode, 012345);
assertEqualInt(pst->st_mtime, 234567);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
assertEqualInt(pst->st_nlink, 345);
#endif
assertEqualInt(pst->st_size, 123456789);
@@ -661,7 +762,7 @@ DEFINE_TEST(test_entry)
archive_entry_set_ctime(e, 345677, 431);
assert((pst = archive_entry_stat(e)) != NULL);
assertEqualInt(pst->st_ctime, 345677);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_dev(e, 122);
assert((pst = archive_entry_stat(e)) != NULL);
assertEqualInt(pst->st_dev, 122);
@@ -669,7 +770,7 @@ DEFINE_TEST(test_entry)
archive_entry_set_gid(e, 33);
assert((pst = archive_entry_stat(e)) != NULL);
assertEqualInt(pst->st_gid, 33);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_ino(e, 233);
assert((pst = archive_entry_stat(e)) != NULL);
assertEqualInt(pst->st_ino, 233);
@@ -680,7 +781,7 @@ DEFINE_TEST(test_entry)
archive_entry_set_mtime(e, 234566, 542);
assert((pst = archive_entry_stat(e)) != NULL);
assertEqualInt(pst->st_mtime, 234566);
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_nlink(e, 344);
assert((pst = archive_entry_stat(e)) != NULL);
assertEqualInt(pst->st_nlink, 344);
@@ -708,7 +809,7 @@ DEFINE_TEST(test_entry)
* the necessary definitions on every platform.
*/
#if __FreeBSD__
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
archive_entry_set_dev(e, 0x12345678);
assertEqualInt(archive_entry_devmajor(e), major(0x12345678));
assertEqualInt(archive_entry_devminor(e), minor(0x12345678));
@@ -733,7 +834,7 @@ DEFINE_TEST(test_entry)
/*
* Exercise the character-conversion logic, if we can.
*/
- if (NULL == setlocale(LC_ALL, "de_DE.UTF-8")) {
+ if (NULL == LOCALE_UTF8 || NULL == setlocale(LC_ALL, LOCALE_UTF8)) {
skipping("Can't exercise charset-conversion logic without"
" a suitable locale.");
} else {
@@ -777,8 +878,8 @@ DEFINE_TEST(test_entry)
* "c89 plus GNU extensions.")
*/
wcscpy(wbuff, L"xxxAyyyBzzz");
- wbuff[3] = 0x12345678;
- wbuff[7] = 0x5678;
+ wbuff[3] = (wchar_t)0x12345678;
+ wbuff[7] = (wchar_t)0x5678;
/* A wide filename that cannot be converted to narrow. */
archive_entry_copy_pathname_w(e, wbuff);
failure("Converting wide characters from Unicode should fail.");
diff --git a/archivers/libarchive/files/libarchive/test/test_entry_strmode.c b/archivers/libarchive/files/libarchive/test/test_entry_strmode.c
index 2941c4a4c38..ba183db025a 100644
--- a/archivers/libarchive/files/libarchive/test/test_entry_strmode.c
+++ b/archivers/libarchive/files/libarchive/test/test_entry_strmode.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_entry_strmode.c,v 1.1 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_entry_strmode.c 201247 2009-12-30 05:59:21Z kientzle $");
DEFINE_TEST(test_entry_strmode)
{
@@ -31,18 +31,41 @@ DEFINE_TEST(test_entry_strmode)
assert((entry = archive_entry_new()) != NULL);
- archive_entry_set_mode(entry, S_IFREG | 0642);
+ archive_entry_set_mode(entry, AE_IFREG | 0642);
assertEqualString(archive_entry_strmode(entry), "-rw-r---w- ");
- archive_entry_set_mode(entry, S_IFBLK | 03642);
+ /* Regular file + hardlink still shows as regular file. */
+ archive_entry_set_mode(entry, AE_IFREG | 0644);
+ archive_entry_set_hardlink(entry, "link");
+ assertEqualString(archive_entry_strmode(entry), "-rw-r--r-- ");
+
+ archive_entry_set_mode(entry, 0640);
+ archive_entry_set_hardlink(entry, "link");
+ assertEqualString(archive_entry_strmode(entry), "hrw-r----- ");
+ archive_entry_set_hardlink(entry, NULL);
+
+ archive_entry_set_mode(entry, AE_IFDIR | 0777);
+ assertEqualString(archive_entry_strmode(entry), "drwxrwxrwx ");
+
+ archive_entry_set_mode(entry, AE_IFBLK | 03642);
assertEqualString(archive_entry_strmode(entry), "brw-r-S-wT ");
- archive_entry_set_mode(entry, S_IFCHR | 05777);
+ archive_entry_set_mode(entry, AE_IFCHR | 05777);
assertEqualString(archive_entry_strmode(entry), "crwsrwxrwt ");
- archive_entry_set_mode(entry, S_IFLNK | 04000);
+ archive_entry_set_mode(entry, AE_IFSOCK | 0222);
+ assertEqualString(archive_entry_strmode(entry), "s-w--w--w- ");
+
+ archive_entry_set_mode(entry, AE_IFIFO | 0444);
+ assertEqualString(archive_entry_strmode(entry), "pr--r--r-- ");
+
+ archive_entry_set_mode(entry, AE_IFLNK | 04000);
assertEqualString(archive_entry_strmode(entry), "l--S------ ");
+ archive_entry_acl_add_entry(entry, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
+ 0007, ARCHIVE_ENTRY_ACL_GROUP, 78, "group78");
+ assertEqualString(archive_entry_strmode(entry), "l--S------+");
+
/* Release the experimental entry. */
archive_entry_free(entry);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_extattr_freebsd.c b/archivers/libarchive/files/libarchive/test/test_extattr_freebsd.c
new file mode 100644
index 00000000000..4b19d276297
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_extattr_freebsd.c
@@ -0,0 +1,172 @@
+/*-
+ * Copyright (c) 2003-2009 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: head/lib/libarchive/test/test_extattr_freebsd.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+#if defined(__FreeBSD__) && __FreeBSD__ > 4
+#include <sys/extattr.h>
+#endif
+
+/*
+ * Verify extended attribute restore-to-disk. This test is FreeBSD-specific.
+ */
+
+DEFINE_TEST(test_extattr_freebsd)
+{
+#if !defined(__FreeBSD__)
+ skipping("FreeBSD-specific extattr restore test");
+#elif __FreeBSD__ < 5
+ skipping("extattr restore supported only on FreeBSD 5.0 and later");
+#else
+ char buff[64];
+ const char *xname;
+ const void *xval;
+ size_t xsize;
+ struct stat st;
+ struct archive *a;
+ struct archive_entry *ae;
+ int n, fd;
+ int extattr_privilege_bug = 0;
+
+ /*
+ * First, do a quick manual set/read of an extended attribute
+ * to verify that the local filesystem does support it. If it
+ * doesn't, we'll simply skip the remaining tests.
+ */
+ /* Create a test file and try to set an ACL on it. */
+ fd = open("pretest", O_RDWR | O_CREAT, 0777);
+ failure("Could not create test file?!");
+ if (!assert(fd >= 0))
+ return;
+
+ errno = 0;
+ n = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, "testattr", "1234", 4);
+ if (n != 4 && errno == EOPNOTSUPP) {
+ close(fd);
+ skipping("extattr tests require that extattr support be enabled on the filesystem");
+ return;
+ }
+ failure("extattr_set_fd(): errno=%d (%s)", errno, strerror(errno));
+ assertEqualInt(4, n);
+ close(fd);
+
+ /*
+ * Repeat the above, but with file permissions set to 0000.
+ * This should work (extattr_set_fd() should follow fd
+ * permissions, not file permissions), but is known broken on
+ * some versions of FreeBSD.
+ */
+ fd = open("pretest2", O_RDWR | O_CREAT, 00000);
+ failure("Could not create test file?!");
+ if (!assert(fd >= 0))
+ return;
+
+ n = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, "testattr", "1234", 4);
+ if (n != 4) {
+ skipping("Restoring xattr to an unwritable file seems to be broken on this platform");
+ extattr_privilege_bug = 1;
+ }
+ close(fd);
+
+ /* Create a write-to-disk object. */
+ assert(NULL != (a = archive_write_disk_new()));
+ archive_write_disk_set_options(a,
+ ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_XATTR);
+
+ /* Populate an archive entry with an extended attribute. */
+ ae = archive_entry_new();
+ assert(ae != NULL);
+ archive_entry_set_pathname(ae, "test0");
+ archive_entry_set_mtime(ae, 123456, 7890);
+ archive_entry_set_size(ae, 0);
+ archive_entry_set_mode(ae, 0755);
+ archive_entry_xattr_add_entry(ae, "user.foo", "12345", 5);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+
+ /* Another entry; similar but with mode = 0. */
+ ae = archive_entry_new();
+ assert(ae != NULL);
+ archive_entry_set_pathname(ae, "test1");
+ archive_entry_set_mtime(ae, 12345678, 7890);
+ archive_entry_set_size(ae, 0);
+ archive_entry_set_mode(ae, 0);
+ archive_entry_xattr_add_entry(ae, "user.bar", "123456", 6);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+
+ /* Close the archive. */
+ if (extattr_privilege_bug)
+ /* If the bug is here, write_close will return warning. */
+ assertEqualIntA(a, ARCHIVE_WARN, archive_write_close(a));
+ else
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /* Verify the data on disk. */
+ assertEqualInt(0, stat("test0", &st));
+ assertEqualInt(st.st_mtime, 123456);
+ /* Verify extattr */
+ n = extattr_get_file("test0", EXTATTR_NAMESPACE_USER,
+ "foo", buff, sizeof(buff));
+ if (assertEqualInt(n, 5)) {
+ buff[n] = '\0';
+ assertEqualString(buff, "12345");
+ }
+
+ /* Verify the data on disk. */
+ assertEqualInt(0, stat("test1", &st));
+ assertEqualInt(st.st_mtime, 12345678);
+ /* Verify extattr */
+ n = extattr_get_file("test1", EXTATTR_NAMESPACE_USER,
+ "bar", buff, sizeof(buff));
+ if (extattr_privilege_bug) {
+ /* If we have the bug, the extattr won't have been written. */
+ assertEqualInt(n, -1);
+ } else {
+ if (assertEqualInt(n, 6)) {
+ buff[n] = '\0';
+ assertEqualString(buff, "123456");
+ }
+ }
+
+ /* Use libarchive APIs to read the file back into an entry and
+ * verify that the extattr was read correctly. */
+ assert((a = archive_read_disk_new()) != NULL);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_pathname(ae, "test0");
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_disk_entry_from_file(a, ae, -1, NULL));
+ assertEqualInt(1, archive_entry_xattr_reset(ae));
+ assertEqualInt(ARCHIVE_OK,
+ archive_entry_xattr_next(ae, &xname, &xval, &xsize));
+ assertEqualString(xname, "user.foo");
+ assertEqualInt(xsize, 5);
+ assertEqualMem(xval, "12345", xsize);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ archive_entry_free(ae);
+#endif
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_fuzz.c b/archivers/libarchive/files/libarchive/test/test_fuzz.c
new file mode 100644
index 00000000000..e5dede93216
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_fuzz.c
@@ -0,0 +1,166 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_fuzz.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+ * This was inspired by an ISO fuzz tester written by Michal Zalewski
+ * and posted to the "vulnwatch" mailing list on March 17, 2005:
+ * http://seclists.org/vulnwatch/2005/q1/0088.html
+ *
+ * This test simply reads each archive image into memory, pokes
+ * random values into it and runs it through libarchive. It tries
+ * to damage about 1% of each file and repeats the exercise 100 times
+ * with each file.
+ *
+ * Unlike most other tests, this test does not verify libarchive's
+ * responses other than to ensure that libarchive doesn't crash.
+ *
+ * Due to the deliberately random nature of this test, it may be hard
+ * to reproduce failures. Because this test deliberately attempts to
+ * induce crashes, there's little that can be done in the way of
+ * post-failure diagnostics.
+ */
+
+/* Because this works for any archive, we can just re-use the archives
+ * developed for other tests. */
+static struct {
+ int uncompress; /* If 1, decompress the file before fuzzing. */
+ const char *name;
+} files[] = {
+ {0, "test_fuzz_1.iso.Z"}, /* Exercise compress decompressor. */
+ {1, "test_fuzz_1.iso.Z"},
+ {0, "test_compat_bzip2_1.tbz"}, /* Exercise bzip2 decompressor. */
+ {1, "test_compat_bzip2_1.tbz"},
+ {0, "test_compat_gtar_1.tar"},
+ {0, "test_compat_gzip_1.tgz"}, /* Exercise gzip decompressor. */
+ {0, "test_compat_gzip_2.tgz"}, /* Exercise gzip decompressor. */
+ {0, "test_compat_tar_hardlink_1.tar"},
+ {0, "test_compat_xz_1.txz"}, /* Exercise xz decompressor. */
+ {0, "test_compat_zip_1.zip"},
+ {0, "test_read_format_ar.ar"},
+ {0, "test_read_format_cpio_bin_be.cpio"},
+ {0, "test_read_format_cpio_svr4_gzip_rpm.rpm"}, /* Test RPM unwrapper */
+ {0, "test_read_format_gtar_sparse_1_17_posix10_modified.tar"},
+ {0, "test_read_format_mtree.mtree"},
+ {0, "test_read_format_tar_empty_filename.tar"},
+ {0, "test_read_format_zip.zip"},
+ {1, NULL}
+};
+
+DEFINE_TEST(test_fuzz)
+{
+ const void *blk;
+ size_t blk_size;
+ off_t blk_offset;
+ int n;
+
+ for (n = 0; files[n].name != NULL; ++n) {
+ const size_t buffsize = 30000000;
+ const char *filename = files[n].name;
+ struct archive_entry *ae;
+ struct archive *a;
+ char *rawimage, *image;
+ size_t size;
+ int i;
+
+ extract_reference_file(filename);
+ if (files[n].uncompress) {
+ int r;
+ /* Use format_raw to decompress the data. */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_raw(a));
+ r = archive_read_open_filename(a, filename, 16384);
+ if (r != ARCHIVE_OK) {
+ archive_read_finish(a);
+ skipping("Cannot uncompress %s", filename);
+ continue;
+ }
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ rawimage = malloc(buffsize);
+ size = archive_read_data(a, rawimage, buffsize);
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_next_header(a, &ae));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_finish(a));
+ assert(size > 0);
+ failure("Internal buffer is not big enough for "
+ "uncompressed test file: %s", filename);
+ if (!assert(size < buffsize)) {
+ free(rawimage);
+ continue;
+ }
+ } else {
+ rawimage = slurpfile(&size, filename);
+ if (!assert(rawimage != NULL))
+ continue;
+ }
+ image = malloc(size);
+ assert(image != NULL);
+ srand((unsigned)time(NULL));
+
+ for (i = 0; i < 100; ++i) {
+ FILE *f;
+ int j, numbytes;
+
+ /* Fuzz < 1% of the bytes in the archive. */
+ memcpy(image, rawimage, size);
+ numbytes = (int)(rand() % (size / 100));
+ for (j = 0; j < numbytes; ++j)
+ image[rand() % size] = (char)rand();
+
+ /* Save the messed-up image to a file.
+ * If we crash, that file will be useful. */
+ f = fopen("after.test.failure.send.this.file."
+ "to.libarchive.maintainers.with.system.details", "wb");
+ fwrite(image, 1, (size_t)size, f);
+ fclose(f);
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+
+ if (0 == archive_read_open_memory(a, image, size)) {
+ while(0 == archive_read_next_header(a, &ae)) {
+ while (0 == archive_read_data_block(a,
+ &blk, &blk_size, &blk_offset))
+ continue;
+ }
+ archive_read_close(a);
+ }
+ archive_read_finish(a);
+ }
+ free(image);
+ free(rawimage);
+ }
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_fuzz_1.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_fuzz_1.iso.Z.uu
new file mode 100644
index 00000000000..07a3e934da4
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_fuzz_1.iso.Z.uu
@@ -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0!$``F`(0\`2\$LG`43`$>!+
+M_PIY@A2P*P0!IH(O#05@")7"H<`$@`#/]!-@!1#3=4+W4`5``5``HD`%Q`F6
+M0C<]!20!6$"<,"?XTG8"GJ`G=`]Z`C--!20!0\`4`#=-"E.`+WTH.`$.R1#P
+M31,!8<(00$U7`4*`KS`%]-*!@A%@*<C3AD(2("=L(^_T$^`$=`^D@C(=*D`(
+M];0S#5`+U`2UF?`GX-,*=1(`*)@)#_4SG03D(U)`%@`"6`%/`!-0!30!OO2?
+MH"M(`;=TI5!06PKW=#[]3?\*!K44D(\TU$Y`>N5*_]1`=5`M5`_51'51;50?
+MU4AU4JU4+]5,=5/M5#_54'54+55/U51U56U57]58=5:M56_57'57[55_U6!U
+M6"U6C]5D=5EM5I_5:'5:K5:OU6QU6^U6O]5P=5PM5\_5='5=;5??U7AU7JU7
+M[]5\=5_M5__5@'5@+5@/UH1U86U8']:(=6*M6"_6C'5C[5@_UI!U9"U93]:4
+M=65M65_6F'5FK5EOUIQU9^U9?]:@=6@M6H_6I'5I;5J?UJAU:JU:K]:L=6OM
+M6K_6L'5L+5O/UK1U;6U;W]:X=6ZM6^_6O'5O[5O_UL!U<"U<#]?$=7%M7!_7
+MR'5RK5POU\QU<^U</]?0=70M74_7U'5U;5U?U]AU=JU=;]?<=7?M77_7X'5X
+M+5Z/U^1U>6U>G]?H=7JM7J_7['5[[5Z_U_!U?"U?S]?T=7UM7]_7^'5^K5_O
+MU_QU?^U?_]<`=H`M8`_8!':!;6`?V`AV@JU@+]@,=H/M8#_8$':$+6%/V!1V
+MA6UA7]@8=H:M86_8'':'[6%_V"!VB"UBC]@D=HEM8I_8*':*K6*OV"QVB^UB
+4O]@P=HPM8\_8-':-;6/?V#BVW0$`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_open_fd.c b/archivers/libarchive/files/libarchive/test/test_open_fd.c
new file mode 100644
index 00000000000..5e118ad8f43
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_open_fd.c
@@ -0,0 +1,128 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_open_fd.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define open _open
+#if !defined(__BORLANDC__)
+#define lseek _lseek
+#endif
+#define close _close
+#endif
+
+DEFINE_TEST(test_open_fd)
+{
+ char buff[64];
+ struct archive_entry *ae;
+ struct archive *a;
+ int fd;
+
+#if defined(__BORLANDC__)
+ fd = open("test.tar", O_RDWR | O_CREAT | O_BINARY);
+#else
+ fd = open("test.tar", O_RDWR | O_CREAT | O_BINARY, 0777);
+#endif
+ assert(fd >= 0);
+ if (fd < 0)
+ return;
+
+ /* Write an archive through this fd. */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_open_fd(a, fd));
+
+ /*
+ * Write a file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_mtime(ae, 1, 0);
+ archive_entry_copy_pathname(ae, "file");
+ 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));
+
+ /*
+ * Write a second file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file2");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ archive_entry_set_size(ae, 819200);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+
+ /* Close out the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ * Now, read the data back.
+ */
+ assert(lseek(fd, 0, SEEK_SET) == 0);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_fd(a, fd, 512));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(1, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(0, archive_entry_atime(ae));
+ assertEqualInt(0, archive_entry_ctime(ae));
+ assertEqualString("file", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff, 10));
+ assertEqualMem(buff, "12345678", 8);
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("file2", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(819200, archive_entry_size(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+
+ /* Verify the end of the archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ close(fd);
+
+
+ /*
+ * Verify some of the error handling.
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ /* FD 100 shouldn't be open. */
+ assertEqualIntA(a, ARCHIVE_FATAL,
+ archive_read_open_fd(a, 100, 512));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_open_file.c b/archivers/libarchive/files/libarchive/test/test_open_file.c
new file mode 100644
index 00000000000..871249d8729
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_open_file.c
@@ -0,0 +1,108 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_open_file.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+DEFINE_TEST(test_open_file)
+{
+ char buff[64];
+ struct archive_entry *ae;
+ struct archive *a;
+ FILE *f;
+
+ f = fopen("test.tar", "wb");
+ assert(f != NULL);
+ if (f == NULL)
+ return;
+
+ /* Write an archive through this FILE *. */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_open_FILE(a, f));
+
+ /*
+ * Write a file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_mtime(ae, 1, 0);
+ archive_entry_copy_pathname(ae, "file");
+ 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));
+
+ /*
+ * Write a second file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file2");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ archive_entry_set_size(ae, 819200);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+
+ /* Close out the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+ fclose(f);
+
+ /*
+ * Now, read the data back.
+ */
+ f = fopen("test.tar", "rb");
+ assert(f != NULL);
+ if (f == NULL)
+ return;
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_FILE(a, f));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(1, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(0, archive_entry_atime(ae));
+ assertEqualInt(0, archive_entry_ctime(ae));
+ assertEqualString("file", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff, 10));
+ assertEqualMem(buff, "12345678", 8);
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("file2", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(819200, archive_entry_size(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+
+ /* Verify the end of the archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ fclose(f);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_open_filename.c b/archivers/libarchive/files/libarchive/test/test_open_filename.c
new file mode 100644
index 00000000000..07224cde135
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_open_filename.c
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_open_filename.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+DEFINE_TEST(test_open_filename)
+{
+ char buff[64];
+ struct archive_entry *ae;
+ struct archive *a;
+
+ /* Write an archive through this FILE *. */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_open_filename(a, "test.tar"));
+
+ /*
+ * Write a file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_mtime(ae, 1, 0);
+ archive_entry_copy_pathname(ae, "file");
+ 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));
+
+ /*
+ * Write a second file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file2");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ archive_entry_set_size(ae, 819200);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+
+ /* Close out the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ * Now, read the data back.
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_filename(a, "test.tar", 512));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(1, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(0, archive_entry_atime(ae));
+ assertEqualInt(0, archive_entry_ctime(ae));
+ assertEqualString("file", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff, 10));
+ assertEqualMem(buff, "12345678", 8);
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("file2", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(819200, archive_entry_size(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_data_skip(a));
+
+ /* Verify the end of the archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Verify some of the error handling.
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_FATAL,
+ archive_read_open_filename(a, "nonexistent.tar", 512));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c
index aad8327431d..5f1ac935c1e 100644
--- a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c
+++ b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_pax_filename_encoding.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_pax_filename_encoding.c 201247 2009-12-30 05:59:21Z kientzle $");
#include <locale.h>
@@ -40,9 +40,10 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_pax_filename_encoding.c,v 1.2 2
* the right filename returned and that we get a warning only
* if the header isn't marked as binary.
*/
-DEFINE_TEST(test_pax_filename_encoding_1)
+static void
+test_pax_filename_encoding_1(void)
{
- static const char testname[] = "test_pax_filename_encoding.tar.gz";
+ static const char testname[] = "test_pax_filename_encoding.tar";
/*
* \314\214 is a valid 2-byte UTF-8 sequence.
* \374 is invalid in UTF-8.
@@ -57,7 +58,7 @@ DEFINE_TEST(test_pax_filename_encoding_1)
extract_reference_file(testname);
a = archive_read_new();
assertEqualInt(ARCHIVE_OK, archive_read_support_format_tar(a));
- assertEqualInt(ARCHIVE_OK, archive_read_support_compression_gzip(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
assertEqualInt(ARCHIVE_OK,
archive_read_open_filename(a, testname, 10240));
/*
@@ -84,7 +85,8 @@ DEFINE_TEST(test_pax_filename_encoding_1)
* This should work; the underlying implementation should automatically
* fall back to storing the pathname in binary.
*/
-DEFINE_TEST(test_pax_filename_encoding_2)
+static void
+test_pax_filename_encoding_2(void)
{
char filename[] = "abc\314\214mno\374xyz";
struct archive *a;
@@ -105,9 +107,10 @@ DEFINE_TEST(test_pax_filename_encoding_2)
* de_DE.UTF-8 seems to be commonly supported.
*/
/* If it doesn't exist, just warn and return. */
- if (NULL == setlocale(LC_ALL, "de_DE.UTF-8")) {
+ if (LOCALE_UTF8 == NULL
+ || NULL == setlocale(LC_ALL, LOCALE_UTF8)) {
skipping("invalid encoding tests require a suitable locale;"
- " de_DE.UTF-8 not available on this system");
+ " %s not available on this system", LOCALE_UTF8);
return;
}
@@ -183,7 +186,8 @@ DEFINE_TEST(test_pax_filename_encoding_2)
* read it back into "C" locale, which doesn't support the name.
* TODO: Figure out the "right" behavior here.
*/
-DEFINE_TEST(test_pax_filename_encoding_3)
+static void
+test_pax_filename_encoding_3(void)
{
wchar_t badname[] = L"xxxAyyyBzzz";
const char badname_utf8[] = "xxx\xE1\x88\xB4yyy\xE5\x99\xB8zzz";
@@ -202,6 +206,31 @@ DEFINE_TEST(test_pax_filename_encoding_3)
return;
}
+ /* If wctomb is broken, warn and return. */
+ if (wctomb(buff, 0x1234) > 0) {
+ skipping("Cannot test conversion failures because \"C\" "
+ "locale on this system has no invalid characters.");
+ return;
+ }
+
+ /* If wctomb is broken, warn and return. */
+ if (wctomb(buff, 0x1234) > 0) {
+ skipping("Cannot test conversion failures because \"C\" "
+ "locale on this system has no invalid characters.");
+ return;
+ }
+
+ /* Skip test if archive_entry_update_pathname_utf8() is broken. */
+ /* In particular, this is currently broken on Win32 because
+ * setlocale() does not set the default encoding for CP_ACP. */
+ entry = archive_entry_new();
+ if (archive_entry_update_pathname_utf8(entry, badname_utf8)) {
+ archive_entry_free(entry);
+ skipping("Cannot test conversion failures.");
+ return;
+ }
+ archive_entry_free(entry);
+
assert((a = archive_write_new()) != NULL);
assertEqualIntA(a, 0, archive_write_set_format_pax(a));
assertEqualIntA(a, 0, archive_write_set_compression_none(a));
@@ -295,3 +324,10 @@ DEFINE_TEST(test_pax_filename_encoding_3)
assertEqualInt(0, archive_read_close(a));
assertEqualInt(0, archive_read_finish(a));
}
+
+DEFINE_TEST(test_pax_filename_encoding)
+{
+ test_pax_filename_encoding_1();
+ test_pax_filename_encoding_2();
+ test_pax_filename_encoding_3();
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.uu b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.uu
new file mode 100644
index 00000000000..47db1891569
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.tar.uu
@@ -0,0 +1,118 @@
+$FreeBSD: head/lib/libarchive/test/test_pax_filename_encoding.tar.uu 191183 2009-04-17 01:06:31Z kientzle $
+begin 644 test_pax_filename_encoding.tar
+M4&%X2&5A9&5R+V%B8\R,;6YO6'AY>@``````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#8T-"``,#`Q-S4P(``P,#$W-3`@`#`P,#`P,#`P,38V
+M(#$P-S8V-C`W,#,V(#`Q-3,P-@`@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,'1I;0``
+M````````````````````````````````````=&EM````````````````````
+M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````R,2!P871H/6%B8\R,;6YO_'AY>@HR,"!C=&EM
+M93TQ,C`U-3,X-C@U"C(P(&%T:6UE/3$R,#4U,S@V,C8*,3<@4T-(24Q9+F1E
+M=CTX.`HR,B!30TA)3%DN:6YO/30S,34T-#D*,3@@4T-(24Q9+FYL:6YK/3$*
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&%B8\R,;6YO6'AY
+M>@``````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`V-#0@`#`P,3<U,"``,#`Q-S4P(``P,#`P,#`P,#`P-2`Q,#<V-C8P-S`S
+M-B`P,3,S,C4`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#!T:6T`````````````````
+M`````````````````````'1I;0``````````````````````````````````
+M````,#`P,#`P(``P,#`P,#`@````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````2&5L;&\`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!087A(96%D97(O86)CS(QM;F_\>'EZ
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````,#`P-C0T(``P,#$W
+M-3`@`#`P,3<U,"``,#`P,#`P,#`R,3,@,3`W-C8V,#<P,S8@,#$U-30S`"!X
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````'5S=&%R`#`P=&EM````````````````````````````````
+M``````!T:6T``````````````````````````````````````#`P,#`P,"``
+M,#`P,#`P(```````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````#(Q(&AD
+M<F-H87)S970]0DE.05)9"C(Q('!A=&@]86)CS(QM;F_\>'EZ"C(P(&-T:6UE
+M/3$R,#4U-#$W,S4*,C`@871I;64],3(P-34S.#8R-@HQ-R!30TA)3%DN9&5V
+M/3@X"C(R(%-#2$E,62YI;F\]-#,Q-3$R-@HQ."!30TA)3%DN;FQI;FL],0H`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````86)CS(QM;F_\>'EZ````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````#`P,#8T-"``,#`Q-S4P(``P,#$W-3`@
+M`#`P,#`P,#`P,#`U(#$P-S8V-C`W,#,V(#`Q,S4W,0`@,```````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!U
+M<W1A<@`P,'1I;0``````````````````````````````````````=&EM````
+M```````````````````````````````````P,#`P,#`@`#`P,#`P,"``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!(96QL;P``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+C````````````````````````````````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_compress_program.c b/archivers/libarchive/files/libarchive/test/test_read_compress_program.c
index ec688e62999..4e6c610de25 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_compress_program.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_compress_program.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_compress_program.c,v 1.2 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_compress_program.c 201247 2009-12-30 05:59:21Z kientzle $");
static unsigned char archive[] = {
31,139,8,0,222,'C','p','C',0,3,211,'c',160,'=','0','0','0','0','7','5','U',
@@ -34,26 +34,51 @@ static unsigned char archive[] = {
DEFINE_TEST(test_read_compress_program)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
- skipping("archive_read_support_compression_program()");
-#else
+ int r;
struct archive_entry *ae;
struct archive *a;
+
+ /*
+ * First, test handling when a non-existent compression
+ * program is requested.
+ */
+ assert((a = archive_read_new()) != NULL);
+ r = archive_read_support_compression_program(a, "nonexistent");
+ if (r == ARCHIVE_FATAL) {
+ skipping("archive_read_support_compression_program() "
+ "unsupported on this platform");
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_FATAL,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * If we have "gzip -d", try using that.
+ */
+ if (!canGunzip()) {
+ skipping("Can't run gunzip program on this platform");
+ return;
+ }
assert((a = archive_read_new()) != NULL);
- assertEqualIntA(a, 0, archive_read_support_compression_none(a));
- assertEqualIntA(a, 0, archive_read_support_compression_program(a, "gunzip"));
- assert(0 == archive_read_support_format_all(a));
- assertEqualIntA(a, 0, archive_read_open_memory(a, archive, sizeof(archive)));
- assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_PROGRAM);
- assert(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
-#endif
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_none(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_program(a, "gunzip"));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_PROGRAM);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_data_large.c b/archivers/libarchive/files/libarchive/test/test_read_data_large.c
index a690b7b0daa..fe9120b5954 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_data_large.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_data_large.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_data_large.c,v 1.3 2007/05/29 01:00:20 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_data_large.c 201247 2009-12-30 05:59:21Z kientzle $");
/*
* Test read/write of a 10M block of data in a single operation.
@@ -33,6 +33,11 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_data_large.c,v 1.3 2007/05
* had a bug relating to this, fixed in Nov 2006).
*/
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define open _open
+#define close _close
+#endif
+
char buff1[11000000];
char buff2[10000000];
char buff3[10000000];
@@ -43,6 +48,7 @@ DEFINE_TEST(test_read_data_large)
struct archive *a;
char tmpfilename[] = "largefile";
int tmpfilefd;
+ FILE *f;
unsigned int i;
size_t used;
@@ -63,14 +69,14 @@ DEFINE_TEST(test_read_data_large)
archive_entry_set_size(ae, sizeof(buff2));
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
- assertA(sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2)));
+ assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2)));
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/* Check that archive_read_data can handle 10*10^6 at a pop. */
@@ -84,10 +90,10 @@ DEFINE_TEST(test_read_data_large)
failure("Read expected 10MB, but data read didn't match what was written");
assert(0 == memcmp(buff2, buff3, sizeof(buff3)));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/* Check archive_read_data_into_fd */
@@ -96,22 +102,24 @@ DEFINE_TEST(test_read_data_large)
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_open_memory(a, buff1, sizeof(buff1)));
assertA(0 == archive_read_next_header(a, &ae));
- tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT, 0777);
+#if defined(__BORLANDC__)
+ tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY);
+#else
+ tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY, 0777);
+#endif
assert(tmpfilefd != 0);
assertEqualIntA(a, 0, archive_read_data_into_fd(a, tmpfilefd));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
close(tmpfilefd);
- tmpfilefd = open(tmpfilename, O_RDONLY);
- assert(tmpfilefd != 0);
- assertEqualIntA(NULL, sizeof(buff3), read(tmpfilefd, buff3, sizeof(buff3)));
- close(tmpfilefd);
+ f = fopen(tmpfilename, "rb");
+ assert(f != NULL);
+ assertEqualInt(sizeof(buff3), fread(buff3, 1, sizeof(buff3), f));
+ fclose(f);
assert(0 == memcmp(buff2, buff3, sizeof(buff3)));
-
- unlink(tmpfilename);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_disk.c b/archivers/libarchive/files/libarchive/test/test_read_disk.c
new file mode 100644
index 00000000000..d52659bb73b
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_disk.c
@@ -0,0 +1,172 @@
+/*-
+ * Copyright (c) 2003-2009 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: head/lib/libarchive/test/test_read_disk.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+static void
+gname_cleanup(void *d)
+{
+ int *mp = d;
+ assertEqualInt(*mp, 0x13579);
+ *mp = 0x2468;
+}
+
+static const char *
+gname_lookup(void *d, gid_t g)
+{
+ int *mp = d;
+ assertEqualInt(*mp, 0x13579);
+ if (g == 1)
+ return ("FOOGROUP");
+ return ("NOTFOOGROUP");
+}
+
+static void
+uname_cleanup(void *d)
+{
+ int *mp = d;
+ assertEqualInt(*mp, 0x1234);
+ *mp = 0x2345;
+}
+
+static const char *
+uname_lookup(void *d, uid_t u)
+{
+ int *mp = d;
+ assertEqualInt(*mp, 0x1234);
+ if (u == 1)
+ return ("FOO");
+ return ("NOTFOO");
+}
+
+/* We test GID lookup by looking up the name of group number zero and
+ * checking it against the following list. If your system uses a
+ * different conventional name for group number zero, please extend
+ * this array and send us a patch. As always, please keep this list
+ * sorted alphabetically.
+ */
+static const char *zero_groups[] = {
+ "root", /* Linux */
+ "wheel" /* BSD */
+};
+
+DEFINE_TEST(test_read_disk)
+{
+ struct archive *a;
+ int gmagic = 0x13579, umagic = 0x1234;
+ const char *p;
+ size_t i;
+
+ assert((a = archive_read_disk_new()) != NULL);
+
+ /* Default uname/gname lookups always return NULL. */
+ assert(archive_read_disk_gname(a, 0) == NULL);
+ assert(archive_read_disk_uname(a, 0) == NULL);
+
+ /* Register some weird lookup functions. */
+ assertEqualInt(ARCHIVE_OK, archive_read_disk_set_gname_lookup(a,
+ &gmagic, &gname_lookup, &gname_cleanup));
+ /* Verify that our new function got called. */
+ assertEqualString(archive_read_disk_gname(a, 0), "NOTFOOGROUP");
+ assertEqualString(archive_read_disk_gname(a, 1), "FOOGROUP");
+
+ /* De-register. */
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_disk_set_gname_lookup(a, NULL, NULL, NULL));
+ /* Ensure our cleanup function got called. */
+ assertEqualInt(gmagic, 0x2468);
+
+ /* Same thing with uname lookup.... */
+ assertEqualInt(ARCHIVE_OK, archive_read_disk_set_uname_lookup(a,
+ &umagic, &uname_lookup, &uname_cleanup));
+ assertEqualString(archive_read_disk_uname(a, 0), "NOTFOO");
+ assertEqualString(archive_read_disk_uname(a, 1), "FOO");
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_disk_set_uname_lookup(a, NULL, NULL, NULL));
+ assertEqualInt(umagic, 0x2345);
+
+ /* Try the standard lookup functions. */
+ if (archive_read_disk_set_standard_lookup(a) != ARCHIVE_OK) {
+ skipping("standard uname/gname lookup");
+ } else {
+#if defined(__CYGWIN__) || defined(__HAIKU__)
+ /* Some platforms don't have predictable names for
+ * uid=0, so we skip this part of the test. */
+ skipping("standard uname/gname lookup");
+ i = 0;
+ p = zero_groups[0]; /* avoid unused warnings */
+#else
+ /* XXX Someday, we may need to generalize this the
+ * same way we generalized the group name check below.
+ * That's needed only if we encounter a system where
+ * uid 0 is not "root". XXX */
+ assertEqualString(archive_read_disk_uname(a, 0), "root");
+
+ /* Get the group name for group 0 and see if it makes sense. */
+ p = archive_read_disk_gname(a, 0);
+ if (assert(p != NULL)) {
+ i = 0;
+ while (i < sizeof(zero_groups)/sizeof(zero_groups[0])) {
+ if (strcmp(zero_groups[i], p) == 0)
+ break;
+ ++i;
+ }
+ if (i == sizeof(zero_groups)/sizeof(zero_groups[0])) {
+ /* If you get a failure here, either
+ * archive_read_disk_gname() isn't working or
+ * your system uses a different name for group
+ * number zero. If the latter, please add a
+ * new entry to the zero_groups[] array above.
+ */
+ failure("group 0 didn't have any of the expected names");
+ assertEqualString(p, zero_groups[0]);
+ }
+ }
+#endif
+ }
+
+ /* Deregister again and verify the default lookups again. */
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_disk_set_gname_lookup(a, NULL, NULL, NULL));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_disk_set_uname_lookup(a, NULL, NULL, NULL));
+ assert(archive_read_disk_gname(a, 0) == NULL);
+ assert(archive_read_disk_uname(a, 0) == NULL);
+
+ /* Re-register our custom handlers. */
+ gmagic = 0x13579;
+ umagic = 0x1234;
+ assertEqualInt(ARCHIVE_OK, archive_read_disk_set_gname_lookup(a,
+ &gmagic, &gname_lookup, &gname_cleanup));
+ assertEqualInt(ARCHIVE_OK, archive_read_disk_set_uname_lookup(a,
+ &umagic, &uname_lookup, &uname_cleanup));
+
+ /* Destroy the archive. */
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /* Verify our cleanup functions got called. */
+ assertEqualInt(gmagic, 0x2468);
+ assertEqualInt(umagic, 0x2345);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_disk_entry_from_file.c b/archivers/libarchive/files/libarchive/test/test_read_disk_entry_from_file.c
new file mode 100644
index 00000000000..6e34abe441d
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_disk_entry_from_file.c
@@ -0,0 +1,80 @@
+/*-
+ * Copyright (c) 2003-2009 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: head/lib/libarchive/test/test_read_disk_entry_from_file.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+static const char *
+gname_lookup(void *d, gid_t g)
+{
+ (void)d; /* UNUSED */
+ (void)g; /* UNUSED */
+ return ("FOOGROUP");
+}
+
+static const char *
+uname_lookup(void *d, uid_t u)
+{
+ (void)d; /* UNUSED */
+ (void)u; /* UNUSED */
+ return ("FOO");
+}
+
+DEFINE_TEST(test_read_disk_entry_from_file)
+{
+ struct archive *a;
+ struct archive_entry *entry;
+ FILE *f;
+
+ assert((a = archive_read_disk_new()) != NULL);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_disk_set_uname_lookup(a,
+ NULL, &uname_lookup, NULL));
+ assertEqualInt(ARCHIVE_OK, archive_read_disk_set_gname_lookup(a,
+ NULL, &gname_lookup, NULL));
+ assertEqualString(archive_read_disk_uname(a, 0), "FOO");
+ assertEqualString(archive_read_disk_gname(a, 0), "FOOGROUP");
+
+ /* Create a file on disk. */
+ f = fopen("foo", "wb");
+ assert(f != NULL);
+ assertEqualInt(4, fwrite("1234", 1, 4, f));
+ fclose(f);
+
+ /* Use archive_read_disk_entry_from_file to get information about it. */
+ entry = archive_entry_new();
+ assert(entry != NULL);
+ archive_entry_copy_pathname(entry, "foo");
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_disk_entry_from_file(a, entry, -1, NULL));
+
+ /* Verify the information we got back. */
+ assertEqualString(archive_entry_uname(entry), "FOO");
+ assertEqualString(archive_entry_gname(entry), "FOOGROUP");
+ assertEqualInt(archive_entry_size(entry), 4);
+
+ /* Destroy the archive. */
+ archive_entry_free(entry);
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_extract.c b/archivers/libarchive/files/libarchive/test/test_read_extract.c
index ec8483077c2..5696e0d356f 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_extract.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_extract.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_extract.c,v 1.4 2008/06/15 10:35:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_extract.c 201247 2009-12-30 05:59:21Z kientzle $");
#define BUFF_SIZE 1000000
#define FILE_BUFF_SIZE 100000
@@ -32,18 +32,15 @@ DEFINE_TEST(test_read_extract)
{
struct archive_entry *ae;
struct archive *a;
- struct stat st;
size_t used;
- int i;
+ int i, numEntries = 0;
char *buff, *file_buff;
- int fd;
- ssize_t bytes_read;
buff = malloc(BUFF_SIZE);
file_buff = malloc(FILE_BUFF_SIZE);
/* Force the umask to something predictable. */
- umask(022);
+ assertUmask(022);
/* Create a new archive in memory containing various types of entries. */
assert((a = archive_write_new()) != NULL);
@@ -51,12 +48,14 @@ DEFINE_TEST(test_read_extract)
assertA(0 == archive_write_set_compression_none(a));
assertA(0 == archive_write_open_memory(a, buff, BUFF_SIZE, &used));
/* A directory to be restored with EXTRACT_PERM. */
+ ++numEntries;
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "dir_0775");
archive_entry_set_mode(ae, S_IFDIR | 0775);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* A regular file. */
+ ++numEntries;
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "file");
archive_entry_set_mode(ae, S_IFREG | 0755);
@@ -67,49 +66,53 @@ DEFINE_TEST(test_read_extract)
assertA(FILE_BUFF_SIZE == archive_write_data(a, file_buff, FILE_BUFF_SIZE));
archive_entry_free(ae);
/* A directory that should obey umask when restored. */
+ ++numEntries;
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "dir");
archive_entry_set_mode(ae, S_IFDIR | 0777);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* A file in the directory. */
+ ++numEntries;
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "dir/file");
archive_entry_set_mode(ae, S_IFREG | 0700);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* A file in a dir that is not already in the archive. */
+ ++numEntries;
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "dir2/file");
archive_entry_set_mode(ae, S_IFREG | 0000);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* A dir with a trailing /. */
+ ++numEntries;
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "dir3/.");
archive_entry_set_mode(ae, S_IFDIR | 0710);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* Multiple dirs with a single entry. */
+ ++numEntries;
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "dir4/a/../b/../c/");
archive_entry_set_mode(ae, S_IFDIR | 0711);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
/* A symlink. */
- assert((ae = archive_entry_new()) != NULL);
- archive_entry_copy_pathname(ae, "symlink");
- archive_entry_set_mode(ae, S_IFLNK | 0755);
- archive_entry_set_symlink(ae, "file");
- assertA(0 == archive_write_header(a, ae));
- archive_entry_free(ae);
+ if (canSymlink()) {
+ ++numEntries;
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "symlink");
+ archive_entry_set_mode(ae, AE_IFLNK | 0755);
+ archive_entry_set_symlink(ae, "file");
+ assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
+ }
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_write_finish(a));
-#else
- archive_write_finish(a);
-#endif
/* Extract the entries to disk. */
assert((a = archive_read_new()) != NULL);
@@ -121,72 +124,44 @@ DEFINE_TEST(test_read_extract)
assertA(0 == archive_read_next_header(a, &ae));
assertA(0 == archive_read_extract(a, ae, ARCHIVE_EXTRACT_PERM));
/* Rest of entries get restored with no flags. */
- for (i = 0; i < 7; i++) {
- failure("Error reading entry %d", i+1);
+ for (i = 1; i < numEntries; i++) {
+ failure("Error reading entry %d", i);
assertA(0 == archive_read_next_header(a, &ae));
+ failure("Failed to extract entry %d: %s", i,
+ archive_entry_pathname(ae));
assertA(0 == archive_read_extract(a, ae, 0));
}
assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
/* Test the entries on disk. */
/* This first entry was extracted with ARCHIVE_EXTRACT_PERM,
* so the permissions should have been restored exactly,
* including resetting the gid bit on those platforms
* where gid is inherited by subdirs. */
- assert(0 == stat("dir_0775", &st));
failure("This was 0775 in archive, and should be 0775 on disk");
- assertEqualInt(st.st_mode, S_IFDIR | 0775);
+ assertIsDir("dir_0775", 0775);
/* Everything else was extracted without ARCHIVE_EXTRACT_PERM,
* so there may be some sloppiness about gid bits on directories. */
- assert(0 == stat("file", &st));
- failure("st.st_mode=%o should be %o", st.st_mode, S_IFREG | 0755);
- assertEqualInt(st.st_mode, S_IFREG | 0755);
- failure("The file extracted to disk is the wrong size.");
- assert(st.st_size == FILE_BUFF_SIZE);
- fd = open("file", O_RDONLY);
- failure("The file on disk could not be opened.");
- assert(fd != 0);
- bytes_read = read(fd, buff, FILE_BUFF_SIZE);
- failure("The file contents read from disk are the wrong size");
- assert(bytes_read == FILE_BUFF_SIZE);
- failure("The file contents on disk do not match the file contents that were put into the archive.");
- assert(memcmp(buff, file_buff, FILE_BUFF_SIZE) == 0);
- assert(0 == stat("dir", &st));
- failure("This was 0777 in archive, but umask should make it 0755");
+ assertIsReg("file", 0755);
+ assertFileSize("file", FILE_BUFF_SIZE);
+ assertFileContents(file_buff, FILE_BUFF_SIZE, "file");
/* If EXTRACT_PERM wasn't used, be careful to ignore sgid bit
* when checking dir modes, as some systems inherit sgid bit
* from the parent dir. */
- assertEqualInt(0755, st.st_mode & 0777);
- assert(0 == stat("dir/file", &st));
- assert(st.st_mode == (S_IFREG | 0700));
- assert(0 == stat("dir2", &st));
- assertEqualInt(0755, st.st_mode & 0777);
- assert(0 == stat("dir2/file", &st));
- assert(st.st_mode == (S_IFREG | 0000));
- assert(0 == stat("dir3", &st));
- assertEqualInt(0710, st.st_mode & 0777);
- assert(0 == stat("dir4", &st));
- assertEqualInt(0755, st.st_mode & 0777);
- assert(0 == stat("dir4/a", &st));
- assertEqualInt(0755, st.st_mode & 0777);
- assert(0 == stat("dir4/b", &st));
- assertEqualInt(0755, st.st_mode & 0777);
- assert(0 == stat("dir4/c", &st));
- assertEqualInt(0711, st.st_mode & 0777);
- assert(0 == lstat("symlink", &st));
- assert(S_ISLNK(st.st_mode));
-#if HAVE_LCHMOD
- /* Systems that lack lchmod() can't set symlink perms, so skip this. */
- assert((st.st_mode & 07777) == 0755);
-#endif
- assert(0 == stat("symlink", &st));
- assert(st.st_mode == (S_IFREG | 0755));
+ failure("This was 0777 in archive, but umask should make it 0755");
+ assertIsDir("dir", 0755);
+ assertIsReg("dir/file", 0700);
+ assertIsDir("dir2", 0755);
+ assertIsReg("dir2/file", 0000);
+ assertIsDir("dir3", 0710);
+ assertIsDir("dir4", 0755);
+ assertIsDir("dir4/a", 0755);
+ assertIsDir("dir4/b", 0755);
+ assertIsDir("dir4/c", 0711);
+ if (canSymlink())
+ assertIsSymlink("symlink", "file");
free(buff);
free(file_buff);
diff --git a/archivers/libarchive/files/libarchive/test/test_read_file_nonexistent.c b/archivers/libarchive/files/libarchive/test/test_read_file_nonexistent.c
new file mode 100644
index 00000000000..9494dbab6f4
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_file_nonexistent.c
@@ -0,0 +1,37 @@
+/*-
+ * Copyright (c) 2003-2009 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: head/lib/libarchive/test/test_read_file_nonexistent.c 189473 2009-03-07 02:09:21Z kientzle $");
+
+DEFINE_TEST(test_read_file_nonexistent)
+{
+ struct archive* a = archive_read_new();
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_FATAL,
+ archive_read_open_filename(a, "notexistent.tar", 512));
+ archive_read_finish(a);
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_ar.ar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_ar.ar.uu
new file mode 100644
index 00000000000..ae61e59fc7a
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_ar.ar.uu
@@ -0,0 +1,12 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_ar.ar.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 755 test_read_format_ar.ar
+M(3QA<F-H/@HO+R`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
+M("`@("`@("`@("`T,"`@("`@("`@8`IY>7ET='1S<W-A86%F9F8N;R\*:&AH
+M:&IJ:FIK:VMK;&QL;"YO+PH*+S`@("`@("`@("`@("`@(#$Q-S4T-C4V-3(@
+M(#$P,#$@(#`@("`@(#$P,#8T-"`@."`@("`@("`@(&`*-34V-C<W.#AG9VAH
+M+F\O("`@("`@("`@,3$W-30V-38V."`@,3`P,2`@,"`@("`@,3`P-C0T("`T
+M("`@("`@("`@8`HS,S,S+S$Y("`@("`@("`@("`@(#$Q-S4T-C4W,3,@(#$P
+H,#$@(#`@("`@(#$P,#8T-"`@.2`@("`@("`@(&`*.3@W-C4T,S(Q"@``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_ar.c b/archivers/libarchive/files/libarchive/test/test_read_format_ar.c
index 0c01a2bb713..efea38d2c53 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_ar.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_ar.c
@@ -26,48 +26,21 @@
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_ar.c,v 1.5 2008/03/12 21:10:26 kaiw Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_ar.c 201247 2009-12-30 05:59:21Z kientzle $");
-#if ARCHIVE_VERSION_STAMP >= 1009000
-/*
- * This "archive" is created by "GNU ar". Here we try to verify
- * our GNU format handling functionality.
- */
-static unsigned char archive[] = {
-'!','<','a','r','c','h','>',10,'/','/',' ',' ',' ',' ',' ',' ',' ',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
-' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
-' ',' ',' ',' ',' ','4','0',' ',' ',' ',' ',' ',' ',' ',' ','`',10,
-'y','y','y','t','t','t','s','s','s','a','a','a','f','f','f','.','o',
-'/',10,'h','h','h','h','j','j','j','j','k','k','k','k','l','l','l',
-'l','.','o','/',10,10,'/','0',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
-' ',' ',' ',' ','1','1','7','5','4','6','5','6','5','2',' ',' ','1',
-'0','0','1',' ',' ','0',' ',' ',' ',' ',' ','1','0','0','6','4','4',
-' ',' ','8',' ',' ',' ',' ',' ',' ',' ',' ',' ','`',10,'5','5','6',
-'6','7','7','8','8','g','g','h','h','.','o','/',' ',' ',' ',' ',' ',
-' ',' ',' ',' ','1','1','7','5','4','6','5','6','6','8',' ',' ','1',
-'0','0','1',' ',' ','0',' ',' ',' ',' ',' ','1','0','0','6','4','4',
-' ',' ','4',' ',' ',' ',' ',' ',' ',' ',' ',' ','`',10,'3','3','3',
-'3','/','1','9',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
-'1','1','7','5','4','6','5','7','1','3',' ',' ','1','0','0','1',' ',
-' ','0',' ',' ',' ',' ',' ','1','0','0','6','4','4',' ',' ','9',' ',
-' ',' ',' ',' ',' ',' ',' ',' ','`',10,'9','8','7','6','5','4','3',
-'2','1',10};
-
-char buff[64];
-#endif
DEFINE_TEST(test_read_format_ar)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
- skipping("test_read_support_format_ar()");
-#else
+ char buff[64];
+ const char reffile[] = "test_read_format_ar.ar";
struct archive_entry *ae;
struct archive *a;
+
+ extract_reference_file(reffile);
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
+ assertA(0 == archive_read_open_file(a, reffile, 7));
/* Filename table. */
assertA(0 == archive_read_next_header(a, &ae));
@@ -110,10 +83,5 @@ DEFINE_TEST(test_read_format_ar)
/* Test EOF */
assertA(1 == archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
-#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c
index b188228fb6e..fecc0ab4834 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_bin.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_bin.c,v 1.2 2008/09/01 05:38:33 kientzle Exp $");
static unsigned char archive[] = {
199,'q',21,4,177,'y',237,'A',232,3,232,3,2,0,0,0,'p','C',244,'M',2,0,0,0,
@@ -54,10 +54,10 @@ DEFINE_TEST(test_read_format_cpio_bin)
assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c
index 1dcebd33b44..bae370b1717 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_Z.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_bin_Z.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_Z.c 189464 2009-03-07 00:25:33Z kientzle $");
static unsigned char archive[] = {
31,157,144,199,226,'T',' ',16,'+','O',187,' ',232,6,'$',20,0,160,'!',156,
@@ -36,17 +36,25 @@ DEFINE_TEST(test_read_format_cpio_bin_Z)
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assertA(0 == archive_read_next_header(a, &ae));
- assertA(archive_compression(a) == ARCHIVE_COMPRESSION_COMPRESS);
- assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ failure("archive_compression_name(a)=\"%s\"",
+ archive_compression_name(a));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualString(archive_compression_name(a), "compress (.Z)");
+ failure("archive_format_name(a)=\"%s\"",
+ archive_format_name(a));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.c
new file mode 100644
index 00000000000..8cd59dc5d01
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.c
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_be.c 191592 2009-04-27 19:30:09Z kientzle $");
+
+DEFINE_TEST(test_read_format_cpio_bin_be)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ const char *reference = "test_read_format_cpio_bin_be.cpio";
+
+ extract_reference_file(reference);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_filename(a, reference, 10));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString(archive_entry_pathname(ae), "file1111222233334444");
+ assertEqualInt(archive_entry_size(ae), 5);
+ assertEqualInt(archive_entry_mtime(ae), 1240664175);
+ assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0644);
+ assertEqualInt(archive_entry_uid(ae), 1000);
+ assertEqualInt(archive_entry_gid(ae), 0);
+
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_BE);
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.cpio.uu b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.cpio.uu
new file mode 100644
index 00000000000..f29b0713880
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_be.cpio.uu
@@ -0,0 +1,8 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_be.cpio.uu 191592 2009-04-27 19:30:09Z kientzle $
+begin 644 test_read_format_cpio_bin_be.cpio
+M<<<`"#P\@:0#Z`````$``$GS"&\`%0````5F:6QE,3$Q,3(R,C(S,S,S-#0T
+M-```86)C9&4`<<<```````````````$`````````"P````!44D%)3$52(2$A
+M````````````````````````````````````````````````````````````
+3````````````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c
index e2841a7ce03..598c6256ad1 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_bz2.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_bin_bz2.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_bz2.c 201247 2009-12-30 05:59:21Z kientzle $");
static unsigned char archive[] = {
'B','Z','h','9','1','A','Y','&','S','Y',134,'J',208,'4',0,0,30,246,141,253,
@@ -36,19 +36,23 @@ DEFINE_TEST(test_read_format_cpio_bin_bz2)
{
struct archive_entry *ae;
struct archive *a;
+ int r;
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
+ r = archive_read_support_compression_bzip2(a);
+ if (r != ARCHIVE_OK) {
+ skipping("bzip2 support unavailable");
+ archive_read_close(a);
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c
index efabf3196b9..4457fb3c6ff 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_gz.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_bin_gz.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_gz.c 191183 2009-04-17 01:06:31Z kientzle $");
static unsigned char archive[] = {
31,139,8,0,244,'M','p','C',0,3,';','^','(',202,178,177,242,173,227,11,230,
@@ -35,19 +35,27 @@ DEFINE_TEST(test_read_format_cpio_bin_gz)
{
struct archive_entry *ae;
struct archive *a;
+ int r;
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
- assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_BIN_LE);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ failure("archive_read_support_compression_gzip");
+ assertEqualInt(ARCHIVE_OK, r);
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a),
+ ARCHIVE_COMPRESSION_GZIP);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_lzma.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_lzma.c
new file mode 100644
index 00000000000..035b38856d5
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_lzma.c
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_lzma.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+static unsigned char archive[] = {
+ 93, 0, 0,128, 0,255,255,255,255,255,255,255,255, 0, 99,156,
+ 62,160, 67,124,230, 93,220,235,118, 29, 75, 27,226,158, 67,149,
+151, 96, 22, 54,198,209, 63,104,209,148,249,238, 71,187,201,243,
+162, 1, 42, 47, 43,178, 35, 90, 6,156,208, 74,107, 91,229,126,
+ 5, 85,255,136,255, 64, 0
+};
+
+DEFINE_TEST(test_read_format_cpio_bin_lzma)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ int r;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_lzma(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("lzma reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_xz.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_xz.c
new file mode 100644
index 00000000000..813b343fda0
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_bin_xz.c
@@ -0,0 +1,70 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_bin_xz.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+static unsigned char archive[] = {
+ 0xfd, 0x37, 0x7a, 0x58, 0x5a, 0x00, 0x00, 0x04,
+ 0xe6, 0xd6, 0xb4, 0x46, 0x02, 0x00, 0x21, 0x01,
+ 0x16, 0x00, 0x00, 0x00, 0x74, 0x2f, 0xe5, 0xa3,
+ 0xe0, 0x01, 0xff, 0x00, 0x33, 0x5d, 0x00, 0x63,
+ 0x9c, 0x3e, 0xa0, 0x43, 0x7c, 0xe6, 0x5d, 0xdc,
+ 0xeb, 0x76, 0x1d, 0x4b, 0x1b, 0xe2, 0x9e, 0x43,
+ 0x95, 0x97, 0x60, 0x16, 0x36, 0xc6, 0xd1, 0x3f,
+ 0x68, 0xd1, 0x94, 0xf9, 0xee, 0x47, 0xbb, 0xc9,
+ 0xf3, 0xa2, 0x01, 0x2a, 0x2f, 0x2b, 0xb2, 0x23,
+ 0x5a, 0x06, 0x9c, 0xd0, 0x4a, 0x6b, 0x5b, 0x14,
+ 0xb4, 0x00, 0x00, 0x00, 0x91, 0x62, 0x1e, 0x15,
+ 0x04, 0x46, 0x6b, 0x4d, 0x00, 0x01, 0x4f, 0x80,
+ 0x04, 0x00, 0x00, 0x00, 0xa1, 0x4b, 0xdf, 0x03,
+ 0xb1, 0xc4, 0x67, 0xfb, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x04, 0x59, 0x5a
+};
+
+DEFINE_TEST(test_read_format_cpio_bin_xz)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ int r;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_xz(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("xz reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_XZ);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_BIN_LE);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c
index 1d80ef96a6a..6563fcd7e9e 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_odc.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_odc.c,v 1.2 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_odc.c,v 1.3 2008/09/01 05:38:33 kientzle Exp $");
static unsigned char archive[] = {
'0','7','0','7','0','7','0','0','2','0','2','5','0','7','4','6','6','1','0',
@@ -58,10 +58,10 @@ DEFINE_TEST(test_read_format_cpio_odc)
assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_POSIX);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c
new file mode 100644
index 00000000000..3b4170cb787
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c
@@ -0,0 +1,127 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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"
+
+/*
+Execute the following command to rebuild the data for this program:
+ tail -n +32 test_read_format_cpio_svr4_bzip2_rpm.c | /bin/sh
+
+F=test_read_format_cpio_svr4_bzip2_rpm.rpm
+NAME=rpmsample
+TMPRPM=/tmp/rpm
+rm -rf ${TMPRPM}
+mkdir -p ${TMPRPM}/BUILD
+mkdir -p ${TMPRPM}/RPMS
+mkdir -p ${TMPRPM}/SOURCES
+mkdir -p ${TMPRPM}/SPECS
+mkdir -p ${TMPRPM}/SRPMS
+echo "hello" > ${TMPRPM}/BUILD/file1
+echo "hello" > ${TMPRPM}/BUILD/file2
+echo "hello" > ${TMPRPM}/BUILD/file3
+cat > ${TMPRPM}/SPECS/${NAME}.spec <<END
+##
+%define _topdir ${TMPRPM}
+%define _binary_payload w9.bzdio
+
+Summary: Sample data of RPM filter of libarchive
+Name: ${NAME}
+Version: 1.0.0
+Release: 1
+License: BSD
+URL: http://code.google.com/p/libarchive
+BuildArch: noarch
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%install
+rm -rf \$RPM_BUILD_ROOT
+
+mkdir -p \$RPM_BUILD_ROOT%{_sysconfdir}
+install -m 644 file1 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
+install -m 644 file2 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
+install -m 644 file3 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
+TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
+TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
+TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
+
+%files
+%{_sysconfdir}/file1
+%{_sysconfdir}/file2
+%{_sysconfdir}/file3
+
+%description
+Sample data.
+END
+#
+rpmbuild -bb ${TMPRPM}/SPECS/${NAME}.spec
+uuencode ${F} < ${TMPRPM}/RPMS/noarch/${NAME}-1.0.0-1.noarch.rpm > ${F}.uu
+
+rm -rf ${TMPRPM}
+exit 1
+*/
+
+DEFINE_TEST(test_read_format_cpio_svr4_bzip2_rpm)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ const char *name = "test_read_format_cpio_svr4_bzip2_rpm.rpm";
+ int r;
+
+ assert((a = archive_read_new()) != NULL);
+ r = archive_read_support_compression_bzip2(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("bzip2 reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_rpm(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("./etc/file1", archive_entry_pathname(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("./etc/file2", archive_entry_pathname(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("./etc/file3", archive_entry_pathname(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+
+ /* Verify the end-of-archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify that the format detection worked. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
+ assertEqualString(archive_compression_name(a), "bzip2");
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu
new file mode 100644
index 00000000000..884ca9487cb
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu
@@ -0,0 +1,47 @@
+begin 644 test_read_format_cpio_svr4_bzip2_rpm.rpm
+M[:ONVP,``````7)P;7-A;7!L92TQ+C`N,"TQ````````````````````````
+M```````````````````````````````````````````!``4`````````````
+M````````CJWH`0`````````%````5````#X````'````1````!````$-````
+M!@`````````!```#Z`````0````L`````0```^P````'````,````!````/O
+M````!````$`````!,F4X-3)F-39E,#,W83EE.61A9C<W8V(Q,&0P8S4T-65E
+M9&8S-6$U8@````````:<A,!!LG.$S/]SK-(FA0BH6@```@@````^````!___
+M_[`````0`````(ZMZ`$`````````,0```NP````_````!P```MP````0````
+M9`````@``````````0```^@````&`````@````$```/I````!@````P````!
+M```#Z@````8````2`````0```^P````)````%`````$```/M````"0```#P`
+M```!```#[@````0```!,`````0```^\````&````4`````$```/Q````!```
+M`%P````!```#]@````8```!@`````0```_@````)````9`````$```/\````
+M!@```'`````!```#_0````8```"4`````0```_X````&````F@````$```0$
+M````!````*0````#```$!@````,```"P`````P``!`D````#````M@````,`
+M``0*````!````+P````#```$"P````@```#(`````P``!`P````(```!*P``
+M``,```0-````!````3`````#```$#P````@```$\`````P``!!`````(```!
+M2P````,```04````!@```5H````!```$%0````0```%T`````P``!!<````(
+M```!@`````$```08````!````8P````#```$&0````@```&8`````P``!!H`
+M```(```!Z@````,```0H````!@```@`````!```$1P````0```((`````P``
+M!$@````$```"%`````,```1)````"````B`````#```$6`````0```(D````
+M`0``!%D````(```"*`````$```1<````!````C`````#```$70````@```(\
+M`````P``!%X````(```"3@````$```1B````!@```E0````!```$9`````8`
+M``)S`````0``!&4````&```">`````$```1F````!@```GX````!```$;```
+M``8```*``````0``!'0````$```"E`````,```1U````!````J`````#```$
+M=@````@```*L`````P``!'<````$```"Q`````,```1X````!````M`````#
+M0P!R<&US86UP;&4`,2XP+C``,0!386UP;&4@9&%T82!O9B!24$T@9FEL=&5R
+M(&]F(&QI8F%R8VAI=F4`4V%M<&QE(&1A=&$N`````$L)MWQC=64M9&5S:W1O
+M<``````20E-$`%5N<W!E8VEF:65D`&AT='`Z+R]C;V1E+F=O;V=L92YC;VTO
+M<"]L:6)A<F-H:79E`&QI;G5X`&YO87)C:``````````&````!@````:!I(&D
+M@:0``````````5&!``%1@0`!48%B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D
+M,C8Q,3$X-`!B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-`!B,3DT
+M-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-```````````````````````
+M`')O;W0`<F]O=`!R;V]T`')O;W0`<F]O=`!R;V]T`')P;7-A;7!L92TQ+C`N
+M,"TQ+G-R8RYR<&T`________________<G!M<V%M<&QE`````0``2@$``$H!
+M``!*<G!M;&EB*$-O;7!R97-S961&:6QE3F%M97,I`')P;6QI8BA087EL;V%D
+M1FEL97-(879E4')E9FEX*0!R<&UL:6(H4&%Y;&]A9$ES0GII<#(I`#,N,"XT
+M+3$`-"XP+3$`,RXP+C4M,0`T+C<N,```````"`$```@!```(`0``*H<``"J(
+M```JB0`````````(,2XP+C`M,0````````````````!F:6QE,0!F:6QE,@!F
+M:6QE,P`O971C+P`M3S(@+6<@+6UA<F-H/6DS.#8@+6UT=6YE/6DV.#8`8W!I
+M;P!B>FEP,@`Y`&YO87)C:"UR<&TM;&EN=7@`````````````````````````
+M`0````$````!`$%30TE)('1E>'0`9&ER96-T;W)Y````````````````````
+M````````````````````/P````?___SP````$$)::#DQ05DF4UFX89DX``!=
+M?X!,$`@`*`'_X"(D%``[9(0`(`"2B/50T#0#0`](9!%(C1,0&GJ`R`M@PQRG
+M<PN0PPC]8&X[2P=KHS%0Q<^=89M6CI5L`O2\("`W!K-V.;*M63U;6ES%CQI6
+E4,1$DE)B@G&.7I5?NT46(XB0/D,B!$Z-!A_B[DBG"A(7##,G````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c
index 0bd8296da5e..8b19a021b0d 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_svr4_gzip.c 191183 2009-04-17 01:06:31Z kientzle $");
static unsigned char archive[] = {
31,139,8,0,236,'c',217,'D',0,3,'3','0','7','0','7','0','4','0','0',181,'0',
@@ -36,19 +36,26 @@ DEFINE_TEST(test_read_format_cpio_svr4_gzip)
{
struct archive_entry *ae;
struct archive *a;
+ int r;
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
- assert(archive_format(a) == ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a),
+ ARCHIVE_COMPRESSION_GZIP);
+ assertEqualInt(archive_format(a),
+ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c
new file mode 100644
index 00000000000..eb8a38d9df3
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c
@@ -0,0 +1,127 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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"
+
+/*
+Execute the following command to rebuild the data for this program:
+ tail -n +32 test_read_format_cpio_svr4_gzip_rpm.c | /bin/sh
+
+F=test_read_format_cpio_svr4_gzip_rpm.rpm
+NAME=rpmsample
+TMPRPM=/tmp/rpm
+rm -rf ${TMPRPM}
+mkdir -p ${TMPRPM}/BUILD
+mkdir -p ${TMPRPM}/RPMS
+mkdir -p ${TMPRPM}/SOURCES
+mkdir -p ${TMPRPM}/SPECS
+mkdir -p ${TMPRPM}/SRPMS
+echo "hello" > ${TMPRPM}/BUILD/file1
+echo "hello" > ${TMPRPM}/BUILD/file2
+echo "hello" > ${TMPRPM}/BUILD/file3
+cat > ${TMPRPM}/SPECS/${NAME}.spec <<END
+##
+%define _topdir ${TMPRPM}
+%define _binary_payload w9.gzdio
+
+Summary: Sample data of RPM filter of libarchive
+Name: ${NAME}
+Version: 1.0.0
+Release: 1
+License: BSD
+URL: http://code.google.com/p/libarchive
+BuildArch: noarch
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%install
+rm -rf \$RPM_BUILD_ROOT
+
+mkdir -p \$RPM_BUILD_ROOT%{_sysconfdir}
+install -m 644 file1 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
+install -m 644 file2 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
+install -m 644 file3 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
+TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file1
+TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file2
+TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file3
+
+%files
+%{_sysconfdir}/file1
+%{_sysconfdir}/file2
+%{_sysconfdir}/file3
+
+%description
+Sample data.
+END
+#
+rpmbuild -bb ${TMPRPM}/SPECS/${NAME}.spec
+uuencode ${F} < ${TMPRPM}/RPMS/noarch/${NAME}-1.0.0-1.noarch.rpm > ${F}.uu
+
+rm -rf ${TMPRPM}
+exit 1
+*/
+
+DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ const char *name = "test_read_format_cpio_svr4_gzip_rpm.rpm";
+ int r;
+
+ assert((a = archive_read_new()) != NULL);
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_rpm(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ extract_reference_file(name);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2));
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("./etc/file1", archive_entry_pathname(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("./etc/file2", archive_entry_pathname(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualString("./etc/file3", archive_entry_pathname(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+
+ /* Verify the end-of-archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify that the format detection worked. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP);
+ assertEqualString(archive_compression_name(a), "gzip");
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC);
+
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu
new file mode 100644
index 00000000000..54d305b7742
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu
@@ -0,0 +1,46 @@
+begin 644 test_read_format_cpio_svr4_gzip_rpm.rpm
+M[:ONVP,``````7)P;7-A;7!L92TQ+C`N,"TQ````````````````````````
+M```````````````````````````````````````````!``4`````````````
+M````````CJWH`0`````````%````5````#X````'````1````!````$-````
+M!@`````````!```#Z`````0````L`````0```^P````'````,````!````/O
+M````!````$`````!9&9E8V,W,#4T,C@X,V1D-&8P-6%E.#4Y,S<S,&1F,V)D
+M,#$Q,S0V80````````9=A5.[L^@5U91731!5GLHZC0```@@````^````!___
+M_[`````0`````(ZMZ`$`````````,0```L0````_````!P```K0````0````
+M9`````@``````````0```^@````&`````@````$```/I````!@````P````!
+M```#Z@````8````2`````0```^P````)````%`````$```/M````"0```#P`
+M```!```#[@````0```!,`````0```^\````&````4`````$```/Q````!```
+M`%P````!```#]@````8```!@`````0```_@````)````9`````$```/\````
+M!@```'`````!```#_0````8```"4`````0```_X````&````F@````$```0$
+M````!````*0````#```$!@````,```"P`````P``!`D````#````M@````,`
+M``0*````!````+P````#```$"P````@```#(`````P``!`P````(```!*P``
+M``,```0-````!````3`````#```$#P````@```$\`````P``!!`````(```!
+M2P````,```04````!@```5H````!```$%0````0```%T`````P``!!<````(
+M```!@`````$```08````!````8P````"```$&0````@```&4`````@``!!H`
+M```(```!SP````(```0H````!@```=T````!```$1P````0```'D`````P``
+M!$@````$```!\`````,```1)````"````?P````#```$6`````0```(`````
+M`0``!%D````(```"!`````$```1<````!````@P````#```$70````@```(8
+M`````P``!%X````(```"*@````$```1B````!@```C`````!```$9`````8`
+M``)/`````0``!&4````&```"5`````$```1F````!@```ED````!```$;```
+M``8```);`````0``!'0````$```";`````,```1U````!````G@````#```$
+M=@````@```*$`````P``!'<````$```"G`````,```1X````!````J@````#
+M0P!R<&US86UP;&4`,2XP+C``,0!386UP;&4@9&%T82!O9B!24$T@9FEL=&5R
+M(&]F(&QI8F%R8VAI=F4`4V%M<&QE(&1A=&$N`````$L)MAUC=64M9&5S:W1O
+M<``````20E-$`%5N<W!E8VEF:65D`&AT='`Z+R]C;V1E+F=O;V=L92YC;VTO
+M<"]L:6)A<F-H:79E`&QI;G5X`&YO87)C:``````````&````!@````:!I(&D
+M@:0``````````5&!``%1@0`!48%B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D
+M,C8Q,3$X-`!B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-`!B,3DT
+M-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-```````````````````````
+M`')O;W0`<F]O=`!R;V]T`')O;W0`<F]O=`!R;V]T`')P;7-A;7!L92TQ+C`N
+M,"TQ+G-R8RYR<&T`________________<G!M<V%M<&QE`````0``2@$``$IR
+M<&UL:6(H0V]M<')E<W-E9$9I;&5.86UE<RD`<G!M;&EB*%!A>6QO861&:6QE
+M<TAA=F50<F5F:7@I`#,N,"XT+3$`-"XP+3$`-"XW+C``````"`$```@!```(
+M`0``*H<``"J(```JB0`````````(,2XP+C`M,0````````````````!F:6QE
+M,0!F:6QE,@!F:6QE,P`O971C+P`M3S(@+6<@+6UA<F-H/6DS.#8@+6UT=6YE
+M/6DV.#8`8W!I;P!G>FEP`#D`;F]A<F-H+7)P;2UL:6YU>```````````````
+M```````!`````0````$`05-#24D@=&5X=`!D:7)E8W1O<GD`````````````
+M```````````````````````````_````!____/`````0'XL(```````"`S,P
+M-S`W,#0``J-$"W,0;6&8:&*`'8#4&9H:6AA"^690V@))'AM(AC'T]%-+DO73
+M,G-2#1D8&#)2<W+RN1@8#)#=8$$_-QCA<H,E_=Q@C-4-1`!BU:&#)!@C),C1
+3T\<U2%%1$>@$!@"1O'?9"`(`````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c
index d6158a8ca1f..d3f086bbd51 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_cpio_svr4c_Z.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_cpio_svr4c_Z.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_cpio_svr4c_Z.c 189381 2009-03-05 00:31:48Z kientzle $");
static unsigned char archive[] = {
31,157,144,'0','n',4,132,'!',3,6,140,26,'8','n',228,16,19,195,160,'A',26,
@@ -39,17 +39,23 @@ DEFINE_TEST(test_read_format_cpio_svr4c_Z)
struct archive *a;
/* printf("Archive address: start=%X, end=%X\n", archive, archive+sizeof(archive)); */
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assertA(0 == archive_read_next_header(a, &ae));
- assertA(archive_compression(a) == ARCHIVE_COMPRESSION_COMPRESS);
- assertA(archive_format(a) == ARCHIVE_FORMAT_CPIO_SVR4_CRC);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ failure("archive_compression_name(a)=\"%s\"",
+ archive_compression_name(a));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_CRC);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_empty.c b/archivers/libarchive/files/libarchive/test/test_read_format_empty.c
index f6f3e237842..98cfdfa26f5 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_empty.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_empty.c
@@ -23,9 +23,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_empty.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_empty.c 189308 2009-03-03 17:02:51Z kientzle $");
-static unsigned char archive[] = { };
+static unsigned char archive[] = { 0 };
DEFINE_TEST(test_read_format_empty)
{
@@ -34,16 +34,14 @@ DEFINE_TEST(test_read_format_empty)
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
+ assertA(0 == archive_read_open_memory(a, archive, 0));
assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
assertA(archive_format(a) == ARCHIVE_FORMAT_EMPTY);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
-
-
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c
index 307d1d8c72d..3071b1d0b49 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_gz.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_gz.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_gz.c 191183 2009-04-17 01:06:31Z kientzle $");
static unsigned char archive[] = {
31,139,8,0,'+','e',217,'D',0,3,211,211,'g',160,'9','0',0,2,'s','S','S',16,
@@ -36,19 +36,25 @@ DEFINE_TEST(test_read_format_gtar_gz)
{
struct archive_entry *ae;
struct archive *a;
+ int r;
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
- assert(archive_format(a) == ARCHIVE_FORMAT_TAR_GNUTAR);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a),
+ ARCHIVE_COMPRESSION_GZIP);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_lzma.c b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_lzma.c
new file mode 100644
index 00000000000..0e8ff32e57a
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_lzma.c
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 2008 Miklos Vajna
+ * 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: head/lib/libarchive/test/test_read_format_gtar_lzma.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+static unsigned char archive[] = {
+0x5d, 0x0, 0x0, 0x80, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x17, 0xb, 0xbc, 0x1c, 0x7d, 0x1, 0x95, 0xc0, 0x1d, 0x4a, 0x46, 0x9c,
+0x1c, 0xc5, 0x8, 0x82, 0x10, 0xed, 0x84, 0xf6, 0xea, 0x7a, 0xfe, 0x63,
+0x5a, 0x34, 0x5e, 0xf7, 0xc, 0x60, 0xd6, 0x8b, 0xc1, 0x47, 0xaf, 0x11,
+0x6f, 0x18, 0x94, 0x81, 0x74, 0x8a, 0xf8, 0x47, 0xcc, 0xdd, 0xc0, 0xd9,
+0x40, 0xa, 0xc3, 0xac, 0x43, 0x47, 0xb5, 0xac, 0x2b, 0x31, 0xd3, 0x6,
+0xa4, 0x2c, 0x44, 0x80, 0x24, 0x4b, 0xfe, 0x43, 0x22, 0x4e, 0x14, 0x30,
+0x7a, 0xef, 0x99, 0x6e, 0xf, 0x8b, 0xc1, 0x79, 0x93, 0x88, 0x54, 0x73,
+0x59, 0x3f, 0xc, 0xfb, 0xee, 0x9c, 0x83, 0x49, 0x93, 0x33, 0xad, 0x44,
+0xbe, 0x0};
+
+DEFINE_TEST(test_read_format_gtar_lzma)
+{
+ int r;
+
+ struct archive_entry *ae;
+ struct archive *a;
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ r = archive_read_support_compression_lzma(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("lzma reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+
+ assertEqualIntA(a, ARCHIVE_OK, r);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ r = archive_read_open_memory2(a, archive, sizeof(archive), 3);
+ if (r != ARCHIVE_OK) {
+ skipping("Skipping LZMA compression check: %s",
+ archive_error_string(a));
+ goto finish;
+ }
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_GNUTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+finish:
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_read_finish(a);
+#else
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+#endif
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
index b7efea5b82a..d055fc249a7 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse.c,v 1.8 2008/03/12 05:12:23 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_sparse.c 189308 2009-03-03 17:02:51Z kientzle $");
struct contents {
@@ -171,13 +171,6 @@ struct archive_contents {
{ NULL, NULL }
};
-/*
- * A tricky piece of code that verifies the contents of a sparse
- * archive entry against a description as defined at the top of this
- * source file.
- */
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
static void
verify_archive_file(const char *name, struct archive_contents *ac)
{
@@ -187,6 +180,7 @@ verify_archive_file(const char *name, struct archive_contents *ac)
struct contents expect;
/* data, size, offset of block read from archive. */
struct contents actual;
+ const void *p;
struct archive *a;
extract_reference_file(name);
@@ -200,16 +194,19 @@ verify_archive_file(const char *name, struct archive_contents *ac)
while (ac->filename != NULL) {
struct contents *cts = ac->contents;
- assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+ if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae))) {
+ assert(0 == archive_read_finish(a));
+ return;
+ }
failure("Name mismatch in archive %s", name);
assertEqualString(ac->filename, archive_entry_pathname(ae));
expect = *cts++;
while (0 == (err = archive_read_data_block(a,
- (const void **)&actual.d,
- &actual.s, &actual.o))) {
+ &p, &actual.s, &actual.o))) {
+ actual.d = p;
while (actual.s > 0) {
- char c = *(const char *)actual.d;
+ char c = *actual.d;
if(actual.o < expect.o) {
/*
* Any byte before the expected
@@ -247,8 +244,8 @@ verify_archive_file(const char *name, struct archive_contents *ac)
failure("%s: should be end of entry", name);
assertEqualIntA(a, err, ARCHIVE_EOF);
failure("%s: Size returned at EOF must be zero", name);
- assertEqualInt(actual.s, 0);
-#if ARCHIVE_VERSION_STAMP < 1009000
+ assertEqualInt((int)actual.s, 0);
+#if ARCHIVE_VERSION_NUMBER < 1009000
/* libarchive < 1.9 doesn't get this right */
skipping("offset of final sparse chunk");
#else
@@ -263,10 +260,10 @@ verify_archive_file(const char *name, struct archive_contents *ac)
assertEqualIntA(a, ARCHIVE_EOF, err);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
@@ -274,33 +271,33 @@ verify_archive_file(const char *name, struct archive_contents *ac)
DEFINE_TEST(test_read_format_gtar_sparse)
{
/* Two archives that use the "GNU tar sparse format". */
- verify_archive_file("test_read_format_gtar_sparse_1_13.tgz", files);
- verify_archive_file("test_read_format_gtar_sparse_1_17.tgz", files);
+ verify_archive_file("test_read_format_gtar_sparse_1_13.tar", files);
+ verify_archive_file("test_read_format_gtar_sparse_1_17.tar", files);
/*
* libarchive < 1.9 doesn't support the newer --posix sparse formats
* from GNU tar 1.15 and later.
*/
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("read support for GNUtar --posix sparse formats");
#else
/*
* An archive created by GNU tar 1.17 using --posix --sparse-format=0.1
*/
verify_archive_file(
- "test_read_format_gtar_sparse_1_17_posix00.tgz",
+ "test_read_format_gtar_sparse_1_17_posix00.tar",
files);
/*
* An archive created by GNU tar 1.17 using --posix --sparse-format=0.1
*/
verify_archive_file(
- "test_read_format_gtar_sparse_1_17_posix01.tgz",
+ "test_read_format_gtar_sparse_1_17_posix01.tar",
files);
/*
* An archive created by GNU tar 1.17 using --posix --sparse-format=1.0
*/
verify_archive_file(
- "test_read_format_gtar_sparse_1_17_posix10.tgz",
+ "test_read_format_gtar_sparse_1_17_posix10.tar",
files);
/*
* The last test archive here is a little odd. First, it's
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu
new file mode 100644
index 00000000000..86a59ffa47a
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu
@@ -0,0 +1,1370 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_sparse_1_13.tar.uu 191183 2009-04-17 01:06:31Z kientzle $
+begin 644 test_read_format_gtar_sparse_1_13.tar
+M<W!A<G-E````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`Q,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`R,#`Q
+M`#$P-S,S,3`Q,30P`#`Q-S<V-P`@4P``````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<B`@`'1I;0``
+M````````````````````````````````````=&EM````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````P,#`P,S8T,3`P,``P,#`P,#`P
+M,3`P,``P,#`P-S4P,C`P,``P,#`P,#`P,3`P,``P,#`Q,S<W-S<W-P`P,#`P
+M,#`P,#`P,0``````````````````````````````````,#`P,30P,#`P,#``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!S<&%R<V4R````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````,#$P,#8T-``P,#`Q
+M-S4P`#`P,#$W-3``,#`P,#`Q-#(S,#$`,3`W,S,Q,#$Q-#$`,#(R,3,S`"!3
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````'5S=&%R("``=&EM````````````````````````````````
+M``````!T:6T`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````#`P,#`S-C0Q,#`P`#`P,#`P,#`Q,#`P`#`P,#`W-3`R,#`P`#`P,#`P
+M,#`Q,#`P`#`P,#$S,S0S,#`P`#`P,#`P,#`Q,#`P`#`P,#$W,C`T,#`P`#`P
+M,#`P,#`Q,#`P``$P,#4W,34Q-S,P,0```````````````````````#`P,#(S
+M,#0U,#`P`#`P,#`P,#`Q,#`P`#`P,#(V-S`V,#`P`#`P,#`P,#`Q,#`P`#`P
+M,#,R-30W,#`P`#`P,#`P,#`Q,#`P`#`P,#,V-#$Q,#`P`#`P,#`P,#`Q,#`P
+M`#`P,#0R,C4R,#`P`#`P,#`P,#`Q,#`P`#`P,#0V,3$S,#`P`#`P,#`P,#`Q
+M,#`P`#`P,#4Q-S4T,#`P`#`P,#`P,#`Q,#`P`#`P,#4U-C$U,#`P`#`P,#`P
+M,#`Q,#`P`#`P,#8Q-#4V,#`P`#`P,#`P,#`Q,#`P`#`P,#8U,S$W,#`P`#`P
+M,#`P,#`Q,#`P`#`P,#<Q,38P,#`P`#`P,#`P,#`Q,#`P`#`P,#<U,#(R,#`P
+M`#`P,#`P,#`Q,#`P`#`P,3`P-C8S,#`P`#`P,#`P,#`Q,#`P`#`P,3`T-3(T
+M,#`P`#`P,#`P,#`Q,#`P`#`P,3$P,S8U,#`P`#`P,#`P,#`Q,#`P`#`P,3$T
+M,C(V,#`P`#`P,#`P,#`Q,#`P`#`P,3(P,#8W,#`P`#`P,#`P,#`Q,#`P`#`P
+M,3(S-S,P,#`P`#`P,#`P,#`Q,#`P`#`P,3(W-3<Q,#`P`#`P,#`P,#`Q,#`P
+M`#`P,3,S-#,S,#`P`#`P,#`P,#`Q,#`P`#`P,3,W,C<T,#`P`#`P,#`P,#`Q
+M,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`P-3$W-30S,#`P`#`P
+M,#`P,#`Q,#`P``$`````````,#`U,C,T,#0P,#``,#`P,#`P,#$P,#``,#`U
+M,C<R-#4P,#``,#`P,#`P,#$P,#``,#`U,S,Q,#8P,#``,#`P,#`P,#$P,#``
+M,#`U,S8W-#<P,#``,#`P,#`P,#$P,#``,#`U-#(V,3`P,#``,#`P,#`P,#$P
+M,#``,#`U-#8T-3$P,#``,#`P,#`P,#$P,#``,#`U-3(S,3(P,#``,#`P,#`P
+M,#$P,#``,#`U-38Q-30P,#``,#`P,#`P,#$P,#``,#`U-C(P,34P,#``,#`P
+M,#`P,#$P,#``,#`U-C4V-38P,#``,#`P,#`P,#$P,#``,#`U-S$U,3<P,#``
+M,#`P,#`P,#`S,#$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!A````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!N;VXM<W!A<G-E````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````,#$P,#8T-``P,#`Q-S4P`#`P,#$W-3``,#`P
+M,#`P,#`P,#``,3`W,S,Q,#$Q-#$`,#$Q,C$P`"`P````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````'5S=&%R
+M("``=&EM``````````````````````````````````````!T:6T`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+/````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu
new file mode 100644
index 00000000000..c801db84073
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu
@@ -0,0 +1,1370 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_sparse_1_17.tar.uu 189308 2009-03-03 17:02:51Z kientzle $
+begin 644 test_read_format_gtar_sparse_1_17.tar
+M<W!A<G-E````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`R,#`P
+M`#$P-S,S,3`Q,30P`#`Q-S<Q,P`@4P``````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<B`@`'1I;0``
+M````````````````````````````````````=&EM````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````P,#`P,S8T,3`P,``P,#`P,#`P
+M,3`P,``P,#`P-S4P,C`P,``P,#`P,#`P,3`P,``P,#`Q-#`P,#`P,``P,#`P
+M,#`P,#`P,```````````````````````````````````,#`P,30P,#`P,#``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````<W!A<G-E,@``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P
+M,30R,S`Q`#$P-S,S,3`Q,30Q`#`R,C$S,@`@4P``````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!U<W1A<B`@
+M`'1I;0``````````````````````````````````````=&EM````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````P,#`P,S8T,3`P,``P
+M,#`P,#`P,3`P,``P,#`P-S4P,C`P,``P,#`P,#`P,3`P,``P,#`Q,S,T,S`P
+M,``P,#`P,#`P,3`P,``P,#`Q-S(P-#`P,``P,#`P,#`P,3`P,``!,#`U-S$U
+M,3<S,#$````````````````````````P,#`R,S`T-3`P,``P,#`P,#`P,3`P
+M,``P,#`R-C<P-C`P,``P,#`P,#`P,3`P,``P,#`S,C4T-S`P,``P,#`P,#`P
+M,3`P,``P,#`S-C0Q,3`P,``P,#`P,#`P,3`P,``P,#`T,C(U,C`P,``P,#`P
+M,#`P,3`P,``P,#`T-C$Q,S`P,``P,#`P,#`P,3`P,``P,#`U,3<U-#`P,``P
+M,#`P,#`P,3`P,``P,#`U-38Q-3`P,``P,#`P,#`P,3`P,``P,#`V,30U-C`P
+M,``P,#`P,#`P,3`P,``P,#`V-3,Q-S`P,``P,#`P,#`P,3`P,``P,#`W,3$V
+M,#`P,``P,#`P,#`P,3`P,``P,#`W-3`R,C`P,``P,#`P,#`P,3`P,``P,#$P
+M,#8V,S`P,``P,#`P,#`P,3`P,``P,#$P-#4R-#`P,``P,#`P,#`P,3`P,``P
+M,#$Q,#,V-3`P,``P,#`P,#`P,3`P,``P,#$Q-#(R-C`P,``P,#`P,#`P,3`P
+M,``P,#$R,#`V-S`P,``P,#`P,#`P,3`P,``P,#$R,S<S,#`P,``P,#`P,#`P
+M,3`P,``P,#$R-S4W,3`P,``P,#`P,#`P,3`P,``P,#$S,S0S,S`P,``P,#`P
+M,#`P,3`P,``P,#$S-S(W-#`P,``P,#`P,#`P,3`P,``!`````````#`P,30S
+M,3,U,#`P`#`P,#`P,#`Q,#`P`#`P,30V-S<V,#`P`#`P,#`P,#`Q,#`P`#`P
+M,34R-C,W,#`P`#`P,#`P,#`Q,#`P`#`P,34V-3`P,#`P`#`P,#`P,#`Q,#`P
+M`#`P,38R,S0Q,#`P`#`P,#`P,#`Q,#`P`#`P,38V,C`R,#`P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,#`Q,#`P`#`P-30V-#4Q,#`P`#`P
+M,#`P,#`Q,#`P`#`P-34R,S$R,#`P`#`P,#`P,#`Q,#`P`#`P-34V,34T,#`P
+M`#`P,#`P,#`Q,#`P`#`P-38R,#$U,#`P`#`P,#`P,#`Q,#`P`#`P-38U-C4V
+M,#`P`#`P,#`P,#`Q,#`P`#`P-3<Q-3$W,#`P`#`P,#`P,#`P,S`Q````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!A````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!A````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````;F]N+7-P87)S
+M90``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#`P`#$P-S,S,3`Q
+M,30Q`#`Q,3(P-P`@,```````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!U<W1A<B`@`'1I;0``````````````
+M````````````````````````=&EM````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+/````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu
new file mode 100644
index 00000000000..6001635f6ad
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu
@@ -0,0 +1,1597 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix00.tar.uu 189308 2009-03-03 17:02:51Z kientzle $
+begin 644 test_read_format_gtar_sparse_1_17_posix00.tar
+M+B]087A(96%D97)S+C,X-C4Y+W-P87)S90``````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P-#`R
+M`#$P-S,S,3`Q,30R`#`Q,S0W,``@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M```````````````````P,#`P,#`P`#`P,#`P,#``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````R-R!'3E4N<W!A<G-E+G-I>F4],S$T-3<R.`HR
+M-B!'3E4N<W!A<G-E+FYU;6)L;V-K<STS"C(X($=.52YS<&%R<V4N;V9F<V5T
+M/3DY.3DS-@HR-R!'3E4N<W!A<G-E+FYU;6)Y=&5S/34Q,@HR.2!'3E4N<W!A
+M<G-E+F]F9G-E=#TQ.3DY.#<R"C(W($=.52YS<&%R<V4N;G5M8GET97,]-3$R
+M"C(Y($=.52YS<&%R<V4N;V9F<V5T/3,Q-#4W,C@*,C4@1TY5+G-P87)S92YN
+M=6UB>71E<STP"C(P(&%T:6UE/3$Q.3@R.3,V,#$*,C`@8W1I;64],3$Y.#(Y
+M,S8P,`H`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````'-P87)S90``````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,C`P,``Q,#<S,S$P,3$T
+M,``P,3$W,C``(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#!T:6T`````````````````
+M`````````````````````'1I;0``````````````````````````````````
+M````,#`P,#`P,``P,#`P,#`P````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````"XO4&%X
+M2&5A9&5R<RXS.#8U.2]S<&%R<V4R````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````P,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`Q,S$S-P`Q,#<S
+M,S$P,3$T,@`P,3,U-C,`('@`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````=7-T87(`,#``````````````
+M````````````````````````````````````````````````````````````
+M````````````,#`P,#`P,``P,#`P,#`P````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````,C@@1TY5+G-P87)S92YS:7IE/3DY,#`P,#`Q"C(W($=.
+M52YS<&%R<V4N;G5M8FQO8VMS/3DY"C(X($=.52YS<&%R<V4N;V9F<V5T/3DY
+M.3DS-@HR-R!'3E4N<W!A<G-E+FYU;6)Y=&5S/34Q,@HR.2!'3E4N<W!A<G-E
+M+F]F9G-E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S/34Q,@HS,"!'3E4N<W!A<G-E+F]F9G-E=#TY
+M,3DY.3<T-`HR-R!'3E4N<W!A<G-E+FYU;6)Y=&5S/34Q,@HS,"!'3E4N<W!A
+M<G-E+F]F9G-E=#TY,CDY.38X,`HR-R!'3E4N<W!A<G-E+FYU;6)Y=&5S/34Q
+M,@HS,"!'3E4N<W!A<G-E+F]F9G-E=#TY,SDY.38Q-@HR-R!'3E4N<W!A<G-E
+M+FYU;6)Y=&5S/34Q,@HS,"!'3E4N<W!A<G-E+F]F9G-E=#TY-#DY.34U,@HR
+M-R!'3E4N<W!A<G-E+FYU;6)Y=&5S/34Q,@HS,"!'3E4N<W!A<G-E+F]F9G-E
+M=#TY-C`P,#`P,`HR-R!'3E4N<W!A<G-E+FYU;6)Y=&5S/34Q,@HS,"!'3E4N
+M<W!A<G-E+F]F9G-E=#TY-CDY.3DS-@HR-R!'3E4N<W!A<G-E+FYU;6)Y=&5S
+M/34Q,@HS,"!'3E4N<W!A<G-E+F]F9G-E=#TY-SDY.3@W,@HR-R!'3E4N<W!A
+M<G-E+FYU;6)Y=&5S/34Q,@HS,"!'3E4N<W!A<G-E+F]F9G-E=#TY.#DY.3@P
+M.`HR-R!'3E4N<W!A<G-E+FYU;6)Y=&5S/3$Y,PHR,"!A=&EM93TQ,3DX,CDS
+M-C`R"C(P(&-T:6UE/3$Q.3@R.3,V,#$*````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````<W!A<G-E,@``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,30R,S`Q`#$P-S,S,3`Q
+M,30Q`#`Q,C`Q-``@,```````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!U<W1A<@`P,'1I;0``````````````
+M````````````````````````=&EM````````````````````````````````
+M```````P,#`P,#`P`#`P,#`P,#``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!A````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!A````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````N+U!A>$AE861E<G,N,S@V-3DO
+M;F]N+7-P87)S90``````````````````````````````````````````````
+M````````````````````````````````````````````````,#`P,#8T-``P
+M,#`Q-S4P`#`P,#$W-3``,#`P,#`P,#`P-3``,3`W,S,Q,#$Q-#(`,#$T,C4W
+M`"!X````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````'5S=&%R`#`P````````````````````````````````
+M`````````````````````````````````````````````````````#`P,#`P
+M,#``,#`P,#`P,```````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````#(P
+M(&%T:6UE/3$Q.3@R.3,V,#$*,C`@8W1I;64],3$Y.#(Y,S8P,0H`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````;F]N+7-P87)S90``````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q
+M-S4P`#`P,#`P,#`P,#`P`#$P-S,S,3`Q,30Q`#`Q,C4P-P`@,```````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!U<W1A<@`P,'1I;0``````````````````````````````````````=&EM
+M```````````````````````````````````````P,#`P,#`P`#`P,#`P,#``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+H````````````````````````````````````````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu
new file mode 100644
index 00000000000..6a2ad83c4d3
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu
@@ -0,0 +1,1370 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu 189308 2009-03-03 17:02:51Z kientzle $
+begin 644 test_read_format_gtar_sparse_1_17_posix01.tar
+M+B]087A(96%D97)S+C,X-C8Q+W-P87)S90``````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,C4R
+M`#$P-S,S,3`Q,30R`#`Q,S0V-``@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M```````````````````P,#`P,#`P`#`P,#`P,#``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````R-R!'3E4N<W!A<G-E+G-I>F4],S$T-3<R.`HR
+M-B!'3E4N<W!A<G-E+FYU;6)L;V-K<STS"C(V($=.52YS<&%R<V4N;F%M93US
+M<&%R<V4*-3$@1TY5+G-P87)S92YM87`].3DY.3,V+#4Q,BPQ.3DY.#<R+#4Q
+M,BPS,30U-S(X+#`*,C`@871I;64],3$Y.#(Y,S8P,@HR,"!C=&EM93TQ,3DX
+M,CDS-C`P"@``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````"XO1TY54W!A<G-E
+M1FEL92XS.#8V,2]S<&%R<V4`````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,C`P,``Q,#<S,S$P,3$T
+M,``P,34Q-3(`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#!T:6T`````````````````
+M`````````````````````'1I;0``````````````````````````````````
+M````,#`P,#`P,``P,#`P,#`P````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````"XO4&%X
+M2&5A9&5R<RXS.#8V,2]S<&%R<V4R````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````P,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,C8Q,@`Q,#<S
+M,S$P,3$T,P`P,3,U-3$`('@`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````=7-T87(`,#``````````````
+M````````````````````````````````````````````````````````````
+M````````````,#`P,#`P,``P,#`P,#`P````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````,C@@1TY5+G-P87)S92YS:7IE/3DY,#`P,#`Q"C(W($=.
+M52YS<&%R<V4N;G5M8FQO8VMS/3DY"C(W($=.52YS<&%R<V4N;F%M93US<&%R
+M<V4R"C$R.38@1TY5+G-P87)S92YM87`].3DY.3,V+#4Q,BPQ.3DY.#<R+#4Q
+M,BPR.3DY.#`X+#4Q,BPS.3DY-S0T+#4Q,BPT.3DY-C@P+#4Q,BPU.3DY-C$V
+M+#4Q,BP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
+M.38Q-BPU,3(L-C(Y.3DU-3(L-3$R+#8T,#`P,#`P+#4Q,BPV-#DY.3DS-BPU
+M,3(L-C4Y.3DX-S(L-3$R+#8V.3DY.#`X+#4Q,BPV-SDY.3<T-"PU,3(L-C@Y
+M.3DV.#`L-3$R+#8Y.3DY-C$V+#4Q,BPW,#DY.34U,BPU,3(L-S(P,#`P,#`L
+M-3$R+#<R.3DY.3,V+#4Q,BPW,SDY.3@W,BPU,3(L-S0Y.3DX,#@L-3$R+#<U
+M.3DY-S0T+#4Q,BPW-CDY.38X,"PU,3(L-S<Y.3DV,38L-3$R+#<X.3DY-34R
+M+#4Q,BPX,#`P,#`P,"PU,3(L.#`Y.3DY,S8L-3$R+#@Q.3DY.#<R+#4Q,BPX
+M,CDY.3@P."PU,3(L.#,Y.3DW-#0L-3$R+#@T.3DY-C@P+#4Q,BPX-3DY.38Q
+M-BPU,3(L.#8Y.3DU-3(L-3$R+#@X,#`P,#`P+#4Q,BPX.#DY.3DS-BPU,3(L
+M.#DY.3DX-S(L-3$R+#DP.3DY.#`X+#4Q,BPY,3DY.3<T-"PU,3(L.3(Y.3DV
+M.#`L-3$R+#DS.3DY-C$V+#4Q,BPY-#DY.34U,BPU,3(L.38P,#`P,#`L-3$R
+M+#DV.3DY.3,V+#4Q,BPY-SDY.3@W,BPU,3(L.3@Y.3DX,#@L,3DS"C(P(&%T
+M:6UE/3$Q.3@R.3,V,#(*,C`@8W1I;64],3$Y.#(Y,S8P,0H`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````+B]'3E53<&%R<V5&:6QE+C,X-C8Q+W-P87)S
+M93(`````````````````````````````````````````````````````````
+M`````````````````````````````````````#`P,#`V-#0`,#`P,3<U,``P
+M,#`Q-S4P`#`P,#`P,30R,S`Q`#$P-S,S,3`Q,30Q`#`Q-3(T-@`@,```````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!U<W1A<@`P,'1I;0``````````````````````````````````````
+M=&EM```````````````````````````````````````P,#`P,#`P`#`P,#`P
+M,#``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!A````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````N+U!A>$AE861E<G,N,S@V-C$O;F]N+7-P87)S90``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````,#`P,#8T-``P,#`Q-S4P`#`P,#$W-3``,#`P
+M,#`P,#`P-3``,3`W,S,Q,#$Q-#,`,#$T,C4Q`"!X````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````'5S=&%R
+M`#`P````````````````````````````````````````````````````````
+M`````````````````````````````#`P,#`P,#``,#`P,#`P,```````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````#(P(&%T:6UE/3$Q.3@R.3,V,#$*
+M,C`@8W1I;64],3$Y.#(Y,S8P,0H`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````;F]N
+M+7-P87)S90``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#`P`#$P
+M-S,S,3`Q,30Q`#`Q,C4P-P`@,```````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!U<W1A<@`P,'1I;0``````
+M````````````````````````````````=&EM````````````````````````
+M```````````````P,#`P,#`P`#`P,#`P,#``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+/````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu
new file mode 100644
index 00000000000..80e802a46b3
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu
@@ -0,0 +1,1370 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu 189308 2009-03-03 17:02:51Z kientzle $
+begin 644 test_read_format_gtar_sparse_1_17_posix10.tar
+M+B]087A(96%D97)S+C,X-C8S+W-P87)S90``````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,C$U
+M`#$P-S,S,3`Q,30S`#`Q,S0V-@`@>```````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!U<W1A<@`P,```````
+M````````````````````````````````````````````````````````````
+M```````````````````P,#`P,#`P`#`P,#`P,#``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````R,B!'3E4N<W!A<G-E+FUA:F]R/3$*,C(@1TY5
+M+G-P87)S92YM:6YO<CTP"C(V($=.52YS<&%R<V4N;F%M93US<&%R<V4*,S$@
+M1TY5+G-P87)S92YR96%L<VEZ93TS,30U-S(X"C(P(&%T:6UE/3$Q.3@R.3,V
+M,#(*,C`@8W1I;64],3$Y.#(Y,S8P,`H`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````"XO1TY54W!A<G-E
+M1FEL92XS.#8V,R]S<&%R<V4`````````````````````````````````````
+M```````````````````````````````````````````````````````````P
+M,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,S`P,``Q,#<S,S$P,3$T
+M,``P,34Q-34`(#``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````=7-T87(`,#!T:6T`````````````````
+M`````````````````````'1I;0``````````````````````````````````
+M````,#`P,#`P,``P,#`P,#`P````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````,PHY.3DY,S8*-3$R"C$Y.3DX-S(*-3$R"C,Q-#4W,C@*,`H`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````+B]087A(96%D97)S+C,X-C8S+W-P87)S93(`````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P
+M`#`P,#`P,#`P,C$W`#$P-S,S,3`Q,30S`#`Q,S4U,@`@>```````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!U
+M<W1A<@`P,```````````````````````````````````````````````````
+M```````````````````````````````````P,#`P,#`P`#`P,#`P,#``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````R,B!'3E4N<W!A<G-E+FUA
+M:F]R/3$*,C(@1TY5+G-P87)S92YM:6YO<CTP"C(W($=.52YS<&%R<V4N;F%M
+M93US<&%R<V4R"C,R($=.52YS<&%R<V4N<F5A;'-I>F4].3DP,#`P,#$*,C`@
+M871I;64],3$Y.#(Y,S8P,PHR,"!C=&EM93TQ,3DX,CDS-C`Q"@``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`"XO1TY54W!A<G-E1FEL92XS.#8V,R]S<&%R<V4R````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````P,#`P-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#$T-3,P
+M,0`Q,#<S,S$P,3$T,0`P,34R-3,`(#``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````=7-T87(`,#!T:6T`
+M`````````````````````````````````````'1I;0``````````````````
+M````````````````````,#`P,#`P,``P,#`P,#`P````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````.3D*.3DY.3,V"C4Q,@HQ.3DY.#<R"C4Q,@HR
+M.3DY.#`X"C4Q,@HS.3DY-S0T"C4Q,@HT.3DY-C@P"C4Q,@HU.3DY-C$V"C4Q
+M,@HV.3DY-34R"C4Q,@HX,#`P,#`P"C4Q,@HX.3DY.3,V"C4Q,@HY.3DY.#<R
+M"C4Q,@HQ,#DY.3@P.`HU,3(*,3$Y.3DW-#0*-3$R"C$R.3DY-C@P"C4Q,@HQ
+M,SDY.38Q-@HU,3(*,30Y.3DU-3(*-3$R"C$V,#`P,#`P"C4Q,@HQ-CDY.3DS
+M-@HU,3(*,3<Y.3DX-S(*-3$R"C$X.3DY.#`X"C4Q,@HQ.3DY.3<T-`HU,3(*
+M,C`Y.3DV.#`*-3$R"C(Q.3DY-C$V"C4Q,@HR,CDY.34U,@HU,3(*,C0P,#`P
+M,#`*-3$R"C(T.3DY.3,V"C4Q,@HR-3DY.3@W,@HU,3(*,C8Y.3DX,#@*-3$R
+M"C(W.3DY-S0T"C4Q,@HR.#DY.38X,`HU,3(*,CDY.3DV,38*-3$R"C,P.3DY
+M-34R"C4Q,@HS,C`P,#`P,`HU,3(*,S(Y.3DY,S8*-3$R"C,S.3DY.#<R"C4Q
+M,@HS-#DY.3@P.`HU,3(*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3$R"CDP.3DY.#`X"C4Q,@HY,3DY.3<T-`HU,3(*.3(Y.3DV.#`*
+M-3$R"CDS.3DY-C$V"C4Q,@HY-#DY.34U,@HU,3(*.38P,#`P,#`*-3$R"CDV
+M.3DY.3,V"C4Q,@HY-SDY.3@W,@HU,3(*.3@Y.3DX,#@*,3DS"@``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````&$`````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!A````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````!A````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````!A````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``!A````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````!A````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````80``````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````80``````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````80``````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````80``````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````80``````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&$`````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````&$`````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````&$`````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````&$`````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````&$`````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````!A````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````!A````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````!A````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````!A````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````!A````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````80``````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````80``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````80``````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````80``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````80``
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````&$`````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````&$`````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````&$`````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````&$`````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````````````&$`
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````!A````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````!A````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````!A````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````!A````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````````````````````````!A
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````80``````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````80``````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````80``````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````80``````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M80``````````````````````````````````````````````````````````
+M`````````````````````````&$`````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````&$`````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`&$`````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````````````&$`````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````+B]0
+M87A(96%D97)S+C,X-C8S+VYO;BUS<&%R<V4`````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````#`P,#`V-#0`,#`P,3<U,``P,#`Q-S4P`#`P,#`P,#`P,#4P`#$P
+M-S,S,3`Q,30S`#`Q-#(U,P`@>```````````````````````````````````
+M````````````````````````````````````````````````````````````
+M``````````````````````````````````````!U<W1A<@`P,```````````
+M````````````````````````````````````````````````````````````
+M```````````````P,#`P,#`P`#`P,#`P,#``````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M```````````````````R,"!A=&EM93TQ,3DX,CDS-C`Q"C(P(&-T:6UE/3$Q
+M.3@R.3,V,#$*````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M`````````````````````````````````````````&YO;BUS<&%R<V4`````
+M````````````````````````````````````````````````````````````
+M```````````````````````````````````````````````````````P,#`P
+M-C0T`#`P,#$W-3``,#`P,3<U,``P,#`P,#`P,#`P,``Q,#<S,S$P,3$T,0`P
+M,3(U,#<`(#``````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````=7-T87(`,#!T:6T`````````````````````
+M`````````````````'1I;0``````````````````````````````````````
+M,#`P,#`P,``P,#`P,#`P````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+M````````````````````````````````````````````````````````````
+/````````````````````
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu
index cf8fd77cc0c..a9120a21af2 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu
@@ -1,3 +1,4 @@
+$FreeBSD: src/lib/libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu,v 1.2 2008/07/03 03:26:30 peter Exp $
begin 644 test_read_format_gtar_sparse_1_17_posix10_modified.tar
M+B]087A(96%D97)S+C,X-C8S+W-P87)S90``````````````````````````
M````````````````````````````````````````````````````````````
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso.iso.Z.uu
new file mode 100644
index 00000000000..989c11251ba
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso.iso.Z.uu
@@ -0,0 +1,26 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$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N^..01R[YY)17;OGEF&>N^>:<=^[Y
+MYZ"'+OKHI)=N^NFHIZ[ZZJRW[OKKL,<N^^RTUV[[[;CGKOONO/?N^^_`!R_\
+M\,07;_SQR">O_/+,-^_\\]!'+_WTU%=O_?789Z_]]MQW[_WWX(<O_OCDEV_^
+L^>BGK_[Z[+?O_OOPQR___/37;__]^.>O__[\]^___P`,H``'2,`"&O"`]`,`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c b/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c
index 92ada131d2c..822b969e335 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_gz.c
@@ -23,51 +23,30 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_iso_gz.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
-
-static unsigned char archive[] = {
-31,139,8,8,201,'R','p','C',0,3,'t','e','s','t','-','r','e','a','d','_','f',
-'o','r','m','a','t','.','i','s','o',0,237,219,223,'k',211,'@',28,0,240,212,
-23,'K','}',20,169,143,135,15,162,224,218,180,']','W',186,183,173,'I',183,
-206,254,144,'d',19,246,'$',5,';',24,'2',11,235,240,239,221,127,162,233,'f',
-17,29,219,24,12,'\'',243,243,'!',185,187,220,']',146,';',8,9,223,131,'D',
-17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'P',234,
-'%','q',220,'(','E',253,211,217,'l',';','O',194,'u','z','I','6',25,']',219,
-26,194,234,'z',241,'o',217,13,247,'-',182,229,30,149,203,'Q',229,178,170,
-242,252,'W',243,139,'e',242,'*',170,'^',30,'U',163,242,'2','+','G',199,207,
-158,'V','_',190,';',127,178,':',255,134,1,241,23,140,222,15,242,'I','?',15,
-'E',26,186,27,27,'q','}',183,'8',232,15,134,'i','~',152,239,167,163,176,'}',
-'0',24,'&','i',22,'^','/',159,159,180,'7',201,146,162,176,150,213,147,143,
-'E','!','K',183,246,'\'','Y','x',211,'{',27,26,221,'n','+',164,181,195,201,
-193,'x','\'',217,26,166,171,202,'N',216,171,'}','H',183,178,'|','2',174,239,
-213,242,222,238,'`','8',28,140,'w',30,'j',186,205,'8','n','7',26,'q',167,
-217,'j',174,183,';','q','|','~',165,'"',254,'C','t',165,'G',')','z',168,209,
-243,'o',184,143,215,'6',220,139,239,'?',191,255,0,192,255,163,136,224,194,
-'h',254,'5',140,231,223,'B',232,132,'f','k',179,185,190,217,238,'\\',132,
-':',149,147,'/',199,139,249,209,'"','4','k','q',173,21,214,230,225,'l',182,
-'8','[',';',157,'M','?',127,':',154,159,158,'L',207,'j','E','{',152,'>',244,
-28,0,128,187,')',']',172,177,139,255,1,0,0,224,'1',187,136,252,171,22,0,0,
-0,0,224,'1',187,253,31,187,'[','{','X',';',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,206,
-'~',0,137,'#',195,182,0,128,1,0};
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_iso_gz.c 201247 2009-12-30 05:59:21Z kientzle $");
DEFINE_TEST(test_read_format_iso_gz)
{
struct archive_entry *ae;
struct archive *a;
+ const char *name = "test_read_format_iso.iso.Z";
+
+ extract_reference_file(name);
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
- assert(archive_format(a) == ARCHIVE_FORMAT_ISO9660);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_filename(a, name, 512));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a),
+ ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet.iso.Z.uu
new file mode 100644
index 00000000000..4642fece1b7
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet.iso.Z.uu
@@ -0,0 +1,66 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_joliet.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_joliet.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$BQHL6+&#-JW,BQH\>/($.*'$FR
+MI,F3*%.J7,FRI<N7,&/*G$FSILV;.'/JW,FSI\^?0(,*'4JTJ-&C2),J7<JT
+MJ=.G4*-*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW<./*G4NW
+MKMV[>//JW<NWK]^_@`,+'DRXL.'#B!,K7LRXL>/'D"-+GDRYLN7+F#-KWLRY
+ML^?/H$.+'DVZM.G3J%.K7LVZM>O7L&/+GDV[MNW;N'/KWLV[M^_?P(,+'TZ\
+MN/'CR),K7\Z\N?/GT*-+GTZ]NO7KV+-KW\Z]N_?OX,.+'T^^O/GSZ-.K7\^^
+MO?OW\./+GT^_OOW[^//K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(F2.(F46(F6
+M>(F8F(F:N(F<V(F>^(F@&(JB.(JD6(JF>(JHF(JJN(JLV(JN^(JP&(NR.(NT
+M6(NV>(NXF(NZN(N\V(N^^(O`&(S".(S$6(S&>(S(F(S*N(S,V(S.^(S0&(W2
+M.(W46(W6>(W8F(W:N(W<V(W>^(W@&([B.([D6([F>([HF([JN([LV([N^([P
+(&(_R.(_T:!4`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu
new file mode 100644
index 00000000000..030dd3cb268
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu
@@ -0,0 +1,71 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_joliet_long.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_joliet_long.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$BQHL6+&#-JW,BQH\>/($.*'$FR
+MI,F3*%.J7,FRI<N7,&/*G$FSILV;.'/JW,FSI\^?0(,*'4JTJ-&C2),J7<JT
+MJ=.G4*-*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW<./*G4NW
+MKMV[>//JW<NWK]^_@`,+'DRXL.'#B!,K7LRXL>/'D"-+GDRYLN7+F#-KWLRY
+ML^?/H$.+'DVZM.G3J%.K7LVZM>O7L&/+GDV[MNW;N'/KWLV[M^_?P(,+'TZ\
+MN/'CR),K7\Z\N?/GT*-+GTZ]NO7KV+-KW\Z]N_?OX,.+'T^^O/GSZ-.K7\^^
+MO?OW\./+GT^_OOW[^//KW\^_O_^_`0Q!!`PPQ!```$;(44890DQ!!`@01BCA
+MA!1***`43S11X88<1GA0+@6!Z-&!``1`XH$((`"`!@5I0$%"%@PD`@`<%%2C
+MB@*I:$0``B10(@D"!'3B@1T6:>212":IY)),-NGDD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2
+M.(W46(W6>(W8F(W:N(W<V(W>^(W@&([B.([D6([F>([HF([JN([LV([N^([P
+M&(_R.(_T6(_V>(_XF(_ZN(_\V(_^^(\`&9`".9`$69`&>9`(F9`*N9`,V9`.
+M^9`0&9$2.9$469$6>9$8F9$:N9$<V9$>^9$@&9(B.9(D69(F>9(HF9(JN9(L
+MV9(N^9(P&9,R.9,T69,V>9,XF9,ZN9,\V9,^^9-`&91".91$691&>91(F91*
+MN91,V91.^910&952.9546956>958F95:N95<V95>^95@&99B.99D699F>99H
+MF99JN99LV99N^99P&9=R.9=T69=V>9=XF9=ZN9=\V9=^^9>`&9B".9B$69B&
+4>9B(F9B*N9B,V9B.^9B0&9F2J90`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu
new file mode 100644
index 00000000000..9f1dd09c70f
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu
@@ -0,0 +1,68 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_joliet_rockridge.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_joliet_rockridge.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$BQHL6+&#-JW,BQH\>/($.*'$FR
+MI,F3*%.J7,FRI<N7,&/*G$FSILV;.'/JW,FSI\^?0(,*'4JTJ-&C2),J7<JT
+MJ=.G4*-*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW<./*G4NW
+MKMV[>//JW<NWK]^_@`,+'DRXL.'#B!,K7LRXL>/'D"-+GDRYLN7+F#-KWLRY
+ML^?/H$.+'DVZM.G3J%.K7LVZM>O7L&/+GDV[MNW;N'/KWLV[M^_?P(,+'TZ\
+MN/'CR),K7\Z\N?/GT*-+GTZ]NO7KV+-KW\Z]N_?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^(>`&(B".(B$6(B&>(B(F(B*N(B,V(B.^(B0&(F2.(F46(F6
+M>(F8F(F:N(F<V(F>^(F@&(JB.(JD6(JF>(JHF(JJN(JLV(JN^(JP&(NR.(NT
+M6(NV>(NXF(NZN(N\V(N^^(O`&(S".(S$6(S&>(S(F(S*N(S,V(S.^(S0&(W2
+M.(W46(W6>(W8F(W:N(W<V(W>^(W@&([B.([D6([F>([HF([JN([LV([N^([P
+M&(_R.(_T6(_V>(_XF(_ZN(_\V(_^^(\`&9`".9`$69`&>9`(F9`*N9`,V9`.
+M^9`0&9$2.9$469$6>9$8F9$:N9$<V9$>^9$@&9(B.9(D69(F>9(HF9(JN9(L
+.V9(N^9(P&9,R.9,T^8(`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.c b/archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.c
new file mode 100644
index 00000000000..3ec472dab2b
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.c
@@ -0,0 +1,94 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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: head/lib/libarchive/test/test_read_format_iso_multi_extent.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+DEFINE_TEST(test_read_format_iso_multi_extent)
+{
+ const char *refname = "test_read_format_iso_multi_extent.iso.Z";
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+ int i;
+
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* Retrieve each of the 2 files on the ISO image and
+ * verify that each one is what we expect. */
+ for (i = 0; i < 2; ++i) {
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+
+ if (strcmp(".", archive_entry_pathname(ae)) == 0) {
+ /* '.' root directory. */
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+ } else if (strcmp("file", archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString("file", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(262280, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "head--head--head", 16);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else {
+ failure("Saw a file that shouldn't have been there");
+ assertEqualString(archive_entry_pathname(ae), "");
+ }
+ }
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu
new file mode 100644
index 00000000000..79100f077c9
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu
@@ -0,0 +1,67 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_multi_extent.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_multi_extent.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$BQHL6+&#-JW,BQH\>/($.*'$FR
+MI,F3*%.J7,FRI<N7,&/*G$FSILV;.'/JW,FSI\^?0(,*'4JTJ-&C2),J7<JT
+MJ=.G4*-*G4JUJM6K6+-JW<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N(`,V(`.^(`0&($2.($46($6>($8F($:N($<V($>
+M^($@&((B.((D6((F>((HF((JN((LV((N^((P&(,R.(,T6(,V>(,XF(,ZN(,\
+MV(,^^(-`&(1".(1$6(1&>(1(F(1*N(1,V(1.^(10&(52.(546(56>(58F(5:
+MN(5<V(5>^(5@&(9B.(9D6(9F>(9HF(9JN(9LV(9N^(9P&(=R.(=T6(=V>(=X
+MF(=ZN(=\V(=^^(>`&(B".(B$6(B&>(B(F(B*N(B,V(B.^(B0&(F2.(F46(F6
+M>(F8F(F:N(F<V(F>^(F@&(JB.(JD6(JF>(JHF(JJN(JLV(JN^(JP&(NR.(NT
+M6(NV>(NXF(NZN(N\V(N^^(O`&(S".(S$6(S&>(S(F(S*N(S,V(S.^(S0&(W2
+M.(W46(W6>(W8F(W:N(W<V(W>^(W@&([B.([D6([F>([HF([JN([LV([N^([P
+M&(_R.(_T6(_V>(_XF(_ZN(_\V(_^^(\`&9`".9`$69`&>9`(F9`*N9`,V9`.
+0^9`0&9$2.9$469$6>9%O"```
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge.iso.Z.uu
new file mode 100644
index 00000000000..5f06cb3ab44
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge.iso.Z.uu
@@ -0,0 +1,206 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_rockridge.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_rockridge.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$BQHL6+&#-JW,BQH\>/($.*'$FR
+MI,F3*%.J7,FRI<N7,&/*G$FSILV;.'/JW,FSI\^?0(,*'4JTJ-&C2),J7<JT
+MJ=.G4*-*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW<./*G4NW
+MKMV[>//JW<NWK]^_@`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_iso_rockridge_ce.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu
new file mode 100644
index 00000000000..00848957056
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu
@@ -0,0 +1,63 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_rockridge_ce.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_rockridge_ce.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$BQHL6+&#-JW,BQH\>/($.*'$FR
+MI,F3*%.J7,FRI<N7,&/*G$FSILV;.'/JW,FSI\^?0(,*'4JTJ-&C2),J7<JT
+MJ=.G4*-*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW<./*G4NW
+MKMV[>//JW<NWK]^_@`,+'DRXL.'#B!,K7LRXL>/'D"-+GDRYLN7+F#-KWLRY
+ML^?/H$.+'DVZM.G3J%.K7LVZM>O7L&/+GDV[MNW;N'/KWLV[M^_?P(,+'TZ\
+MN/'CR),K7\Z\N?/GT*-+GTZ]NO7KV+-KW\Z]N_?OX,.+'T^^O/GSZ-.K7\^^
+MO?OW\./+GT^_OOW[^//KW\^_O_^_`0Q!!`PPQ!```$;(44890DQ!!`@01BCA
+MA!1***`43S11X88<1GC0+06!Z-&!``1`XH$((`"`!059,$%"%0PD`@`7%%2C
+MB@*I:$0``B10(@D"!'3B@1T6:>212":IY)),-NGDDU!&*>645%9I991-+)'$
+M%$\8,04(6SX!0@XVV`##"TAX"8(123!1Q!193$%%$1H*446;1!0A!0@F@'!A
+M$4,\(<6#`K8@Q0M$6$&H%$4$086@(*`P1`H@Q)!##C.`4(0+63Q1A1-'$!&$
+MFY%.6NFE-X"@A`M0-"H%ETZ\L.H40R#1)A-)@'KEKKSN*@.!.<10H`PQR%##
+MKV;"0,*O,`0[;+''PI`L"016:^VU!`+`K+/%0HLL@200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3O.:V_SF.,^YSG?.
+M\Y[[_.=`#[K0AT[THAO]Z$A/NM*7SO2F._WI4(^ZU*=.]:I;_>I8S[K6M\[U
+MKGO]ZV`/N]C'3O:RF_WL:$^[VM?.]K:[_>UPC[O<YT[WNMO][GC/N][WSO>^
+M^_WO@`^\X`=/^,(;_O"(3[SB%\_XQCO^\9"/O.0G3_G*6_[RF,^\YC?/^<Y[
+M_O.@#[WH1T_ZTIO^]*A/O>I7S_K6N_[UL(^][&=/^]K;_O:XS[WN=\_[WOO^
+M]\`/OO"'3_SB&__XR$^^\I?/_.8[__G0C[[TIT_]ZEO_^MC/OO:WS_WN>__[
+MX`^_^,=/_O*;__SH3[_ZU\_^]KO__?"/O_SG3__ZV__^^,^__O?/__[[__\`
+M&(`".(`$6(`&>(`(F(`*N(`,V(`.^(`0&($2.($46($6>($8F($:N($<V($>
+M^($@&((B.((D6((F>((HF((JN((LV((N^((P&(,R.(,T6(,V>(,XF(,ZN(,\
+MV(,^^(-`&(1".(1$6(1&>(1(F(1*N(1,V(1.^(10&(52.(546(56>(58F(5:
+MN(5<V(5>^(5@&(9B.(9D6(9F>(9HF(9JN(9LV(9N^(9P&(=R.(=T6(=V>(=X
+MF(=ZN(=\V(=^^(>`&(B".(B$6(B&>(B(F(B*N(B,V(B.^(B0&(F2.(F46(F6
+(>(F8F(F:^!,`
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu
new file mode 100644
index 00000000000..3ef253b5b1c
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu
@@ -0,0 +1,208 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_rockridge_new.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_rockridge_new.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$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+M"[$A/L2(.!$KXD7,B!NQ(W[$D#@22^))3(DKL26^Q)@X$VOB3<R).[$G_L2@
+M.!2+XE%,BDNQ*3[%J#@5J^)5S(I;L2M^Q;`X%LOB64R+:[$MOL6X.!?KXEW,
+MBWNQ+_[%P#@8"^-A3(R+L3$^QL@X&2OC9<R,F[$S?L;0.!I+XVE,C:NQ-;[&
+DV#@;:^-MS(V[L3?^QN`X'(OC<4R.R[$Y/L?H.!VKXW7,CKDM
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu
new file mode 100644
index 00000000000..8ec91cc2d90
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu
@@ -0,0 +1,304 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_rockridge_rr_moved.iso.Z.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_iso_rockridge_rr_moved.iso.Z
+M'YV0``(*'$BPH,&#"!,J7,BPH<.'$"-*G$BQHL6+&#-JW,BQH\>/($.*'$FR
+MI,F3*%.J7,FRI<N7,&/*G$FSILV;.'/JW,FSI\^?0(,*'4JTJ-&C2),J7<JT
+MJ=.G4*-*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW<./*G4NW
+MKMV[>//JW<NWK]^_@`,+'DRXL.'#B!,K7LRXL>/'D"-+GDRYLN7+F#-KWLRY
+ML^?/H$.+'DVZM.G3J%.K7LVZM>O7L&/+GDV[MNW;N'/KWLV[M^_?P(,+'TZ\
+MN/'CR),K7\Z\N?/GT*-+GTZ]NO7KV+-KW\Z]N_?OX,.+'T^^O/GSZ-.K7\^^
+MO?OW\./+GT^_OOW[^//KW\^_O_^_`0Q!!`PPQ!```$;(44890DQ!!`@01BCA
+MA!1***`43S11X88<1G@0-2\,]`(U'QT(0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T&%T*!U.A]1A=6@=7H?887:H'6Z'W&%WZ!U^A^!A>"@>CH?D
+M87EH'IZ'Z&%ZJ!ZNA^QA>^@>OH?P87PH'\Z']&%]:!_>A_AA?J@?[H?\87_H
+M'_Z'`&*`*"`.B`1B@6@@'H@(8H*H("Z(#&*#Z"`^B!!BA"@A3H@48H5H(5Z(
+M&&*&J"%NB!QBA^@A?H@@8H@H(HZ()&*):"*>B"ABBJ@BKH@L8HOH(KZ(,&*,
+M*"/.B#1BC6@CWH@X8HZH(^Z(/&*/Z"/^B$!BD"@D#HE$8I%H)!Z)2&*2J"0N
+MB4QBD^@D/HE08I0H)4Z)5&*5:"5>B5ABEJ@E;HE<8I?H)7Z)8&*8*":.B61B
+MF6@FGHEH8IJH)JZ);&*;Z":^B7!BG"@GSHET8IUH)]Z)>&*>J"?NB7QBG^@G
+M_HF`8J`H*`Z*A&*A:"@>BHABHJ@H+HJ,8J/H*#Z*D&*D*"E.BI1BI6@I7HJ8
+M8J:H*6Z*G&*GZ"E^BJ!BJ"@JCHJD8JEH*IZ*J&*JJ"JNBJQBJ^@JOHJP8JPH
+M*\Z*M&*M:"O>BKABKJ@K[HJ\8J_H*_Z*P&*P*"P.B\1BL6@L'HO(8K*H+"Z+
+MS&*SZ"P^B]!BM"@M3HO48K5H+5Z+V&*VJ"UNB]QBM^@M?HO@8K@H+HZ+Y&*Y
+M:"Z>B^ABNJ@NKHOL8KOH+KZ+\&*\*"_.B_1BO6@OWHOX8KZH+^Z+_&*_Z"_^
+'BP!CP+@7`0``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_iso_zisofs.iso.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_iso_zisofs.iso.Z.uu
new file mode 100644
index 00000000000..ef54ca6c770
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_iso_zisofs.iso.Z.uu
@@ -0,0 +1,63 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_iso_zisofs.iso.Z.uu 201247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A/O>I7S_K6N_[UL(^][&=/^]K;_O:XS[WN=\_[WOO^
+M]\`/OO"'3_SB&__XR$^^\I?/_.8[__G0C[[TIT_]ZEO_^MC/OO:WS_WN>__[
+MX`^_^,=/_O*;__SH3[_ZU\_^]KO__?"/O_SG3__ZV__^^,^__O?/__[[__\`
+M&(`".(`$6(`&>(`(F(`*N(`,V(`.^(`0&($2.($46($6>($8F($:N($<V($>
+M^($@&((B.((D6((F>((HF((JN((LV((N^((P&(,R.(,T6(,V>(,XF(,ZN(,\
+MV(,^^(-`&(1".(1$6(1&>(1(F(1*N(1,V(1.^(10&(52.(546(56>(58F(5:
+MN(5<V(5>^(5@&(9B.(9D6(9F>(9HF(9JN(9LV(9N^(9P&(=R.(=T6(=V>(=X
+MF(=ZN(=\V(=^^(>`&(B".(B$6(B&>(B(F(B*N(B,V(B.^(B0&(F2.(F46(F6
+@>(F8F(F:N(F<V(F>^(F@&(JB.(JD6(JF>(JHF(JJN'``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_bz2.c
new file mode 100644
index 00000000000..a2c5307b7aa
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_bz2.c
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Based on libarchive/test/test_read_format_isorr_bz2.c with
+ * bugs introduced by Andreas Henriksson <andreas@fatal.se> for
+ * testing ISO9660 image with Joliet extension.
+ *
+ * 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: head/lib/libarchive/test/test_read_format_isojoliet_bz2.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+Execute the following to rebuild the data for this program:
+ tail -n +35 test_read_format_isojoliet_bz2.c | /bin/sh
+
+rm -rf /tmp/iso
+mkdir /tmp/iso
+mkdir /tmp/iso/dir
+echo "hello" >/tmp/iso/long-joliet-file-name.textfile
+ln /tmp/iso/long-joliet-file-name.textfile /tmp/iso/hardlink
+(cd /tmp/iso; ln -s long-joliet-file-name.textfile symlink)
+if [ "$(uname -s)" = "Linux" ]; then # gnu coreutils touch doesn't have -h
+TZ=utc touch -afm -t 197001020000.01 /tmp/iso /tmp/iso/long-joliet-file-name.textfile /tmp/iso/dir
+TZ=utc touch -afm -t 197001030000.02 /tmp/iso/symlink
+else
+TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/long-joliet-file-name.textfile /tmp/iso/dir
+TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
+fi
+F=test_read_format_iso_joliet.iso.Z
+mkhybrid -J -uid 1 -gid 2 /tmp/iso | compress > $F
+uuencode $F $F > $F.uu
+exit 1
+ */
+
+DEFINE_TEST(test_read_format_isojoliet_bz2)
+{
+ const char *refname = "test_read_format_iso_joliet.iso.Z";
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_set_options(a, "iso9660:!rockridge"));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* First entry is '.' root directory. */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString(".", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(86401, archive_entry_ctime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(0, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+
+ /* A directory. */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("dir", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+
+ /* A regular file with two names ("hardlink" gets returned
+ * first, so it's not marked as a hardlink). */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("long-joliet-file-name.textfile",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(6, archive_entry_size(ae));
+ assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(6, (int)size);
+ assertEqualInt(0, offset);
+ assertEqualInt(0, memcmp(p, "hello\n", 6));
+
+ /* Second name for the same regular file (this happens to be
+ * returned second, so does get marked as a hardlink). */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("hardlink", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualString("long-joliet-file-name.textfile",
+ archive_entry_hardlink(ae));
+ assert(!archive_entry_size_is_set(ae));
+
+ /* A symlink to the regular file. */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("symlink", archive_entry_pathname(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_long.c b/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_long.c
new file mode 100644
index 00000000000..765cf37f1c2
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_long.c
@@ -0,0 +1,141 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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: head/lib/libarchive/test/test_read_format_isojoliet_long.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+Execute the following to rebuild the data for this program:
+ tail -n +35 test_read_format_isojoliet_long.c | /bin/sh
+
+rm -rf /tmp/iso
+mkdir /tmp/iso
+num=0
+file="";
+while [ $num -lt 100 ]
+do
+ num=$((num+10))
+ file="${file}1234567890"
+done
+dir="${file}dir"
+mkdir /tmp/iso/${dir}
+file="${file}123"
+echo "hello" > /tmp/iso/${file}
+ln /tmp/iso/${file} /tmp/iso/hardlink
+if [ "$(uname -s)" = "Linux" ]; then # gnu coreutils touch doesn't have -h
+TZ=utc touch -afm -t 197001020000.01 /tmp/iso /tmp/iso/${file} /tmp/iso/${dir}
+else
+TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/${file} /tmp/iso/${dir}
+fi
+F=test_read_format_iso_joliet_long.iso.Z
+mkhybrid -J -joliet-long -uid 1 -gid 2 /tmp/iso | compress > $F
+uuencode $F $F > $F.uu
+rm -rf /tmp/iso
+exit 1
+ */
+
+DEFINE_TEST(test_read_format_isojoliet_long)
+{
+ const char *refname = "test_read_format_iso_joliet_long.iso.Z";
+ char pathname[104];
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+ int i;
+
+ for (i = 0; i < 100; i++)
+ pathname[i] = '0' + ((i+1) % 10);
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_set_options(a, "iso9660:!rockridge"));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* First entry is '.' root directory. */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString(".", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(86401, archive_entry_ctime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(0, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+
+ /* A directory. */
+ pathname[100] = 'd';
+ pathname[101] = 'i';
+ pathname[102] = 'r';
+ pathname[103] = '\0';
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString(pathname, archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+
+ /* A regular file with two names (pathname gets returned
+ * first, so it's not marked as a hardlink). */
+ pathname[100] = '1';
+ pathname[101] = '2';
+ pathname[102] = '3';
+ pathname[103] = '\0';
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString(pathname, archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(6, archive_entry_size(ae));
+ assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(6, (int)size);
+ assertEqualInt(0, offset);
+ assertEqualInt(0, memcmp(p, "hello\n", 6));
+
+ /* Second name for the same regular file (this happens to be
+ * returned second, so does get marked as a hardlink). */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("hardlink", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualString(pathname, archive_entry_hardlink(ae));
+ assert(!archive_entry_size_is_set(ae));
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_rr.c b/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_rr.c
new file mode 100644
index 00000000000..365f8e7a8de
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isojoliet_rr.c
@@ -0,0 +1,159 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Based on libarchive/test/test_read_format_isorr_bz2.c with
+ * bugs introduced by Andreas Henriksson <andreas@fatal.se> for
+ * testing ISO9660 image with Joliet extension.
+ *
+ * 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: head/lib/libarchive/test/test_read_format_isojoliet_rr.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+Execute the following to rebuild the data for this program:
+ tail -n +35 test_read_format_isojoliet_rr.c | /bin/sh
+
+rm -rf /tmp/iso
+mkdir /tmp/iso
+mkdir /tmp/iso/dir
+file="long-joliet-file-name.textfile"
+echo "hello" >/tmp/iso/$file
+ln /tmp/iso/$file /tmp/iso/hardlink
+(cd /tmp/iso; ln -s $file symlink)
+if [ "$(uname -s)" = "Linux" ]; then # gnu coreutils touch doesn't have -h
+TZ=utc touch -afm -t 197001020000.01 /tmp/iso/hardlink /tmp/iso/$file /tmp/iso/dir
+TZ=utc touch -afm -t 197001030000.02 /tmp/iso/symlink
+TZ=utc touch -afm -t 197001020000.01 /tmp/iso
+else
+TZ=utc touch -afhm -t 197001020000.01 /tmp/iso/hardlink /tmp/iso/$file /tmp/iso/dir
+TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
+TZ=utc touch -afhm -t 197001020000.01 /tmp/iso
+fi
+F=test_read_format_iso_joliet_rockridge.iso.Z
+mkhybrid -J -uid 1 -gid 2 /tmp/iso | compress > $F
+uuencode $F $F > $F.uu
+exit 1
+ */
+
+DEFINE_TEST(test_read_format_isojoliet_rr)
+{
+ const char *refname = "test_read_format_iso_joliet_rockridge.iso.Z";
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* First entry is '.' root directory. */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString(".", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+
+ /* A directory. */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("dir", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+
+ /* A regular file with two names ("hardlink" gets returned
+ * first, so it's not marked as a hardlink). */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("long-joliet-file-name.textfile",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(6, archive_entry_size(ae));
+ assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(6, (int)size);
+ assertEqualInt(0, offset);
+ assertEqualInt(0, memcmp(p, "hello\n", 6));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ /* mkisofs records their access time. */
+ /*assertEqualInt(86401, archive_entry_atime(ae));*/
+ /* TODO: Actually, libarchive should be able to
+ * compute nlinks correctly even without RR
+ * extensions. See comments in libarchive source. */
+ assertEqualInt(2, archive_entry_nlink(ae));
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+
+ /* Second name for the same regular file (this happens to be
+ * returned second, so does get marked as a hardlink). */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("hardlink", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualString("long-joliet-file-name.textfile",
+ archive_entry_hardlink(ae));
+ assert(!archive_entry_size_is_set(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ /* TODO: See above. */
+ assertEqualInt(2, archive_entry_nlink(ae));
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+
+ /* A symlink to the regular file. */
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+ assertEqualString("symlink", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("long-joliet-file-name.textfile",
+ archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_nlink(ae));
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c
index 5457c7fd96f..cb5a969d621 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c
@@ -23,119 +23,181 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_isorr_bz2.c,v 1.4 2008/06/21 19:11:51 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_isorr_bz2.c 201247 2009-12-30 05:59:21Z kientzle $");
/*
-Execute the following to rebuild the data for this program:
- tail -n +32 test_read_format_isorr_bz2.c | /bin/sh
+PLEASE use old cdrtools; mkisofs verion is 2.01.
+This version mkisofs made wrong "SL" System Use Entry of RRIP.
+
+Execute the following command to rebuild the data for this program:
+ tail -n +34 test_read_format_isorr_bz2.c | /bin/sh
rm -rf /tmp/iso
mkdir /tmp/iso
mkdir /tmp/iso/dir
echo "hello" >/tmp/iso/file
+dd if=/dev/zero count=1 bs=12345678 >>/tmp/iso/file
ln /tmp/iso/file /tmp/iso/hardlink
(cd /tmp/iso; ln -s file symlink)
+(cd /tmp/iso; ln -s /tmp/ symlink2)
+(cd /tmp/iso; ln -s /tmp/../ symlink3)
+(cd /tmp/iso; ln -s .././../tmp/ symlink4)
+(cd /tmp/iso; ln -s .///file symlink5)
+(cd /tmp/iso; ln -s /tmp//../ symlink6)
TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir
-TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
-mkhybrid -R -uid 1 -gid 2 /tmp/iso | bzip2 > test_read_format_isorr_bz2.iso.bz2
-F=test_read_format_isorr_bz2.iso.bz2
+TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink /tmp/iso/symlink5
+F=test_read_format_iso_rockridge.iso.Z
+mkhybrid -R -uid 1 -gid 2 /tmp/iso | compress > $F
uuencode $F $F > $F.uu
exit 1
*/
DEFINE_TEST(test_read_format_isorr_bz2)
{
- const char *refname = "test_read_format_isorr_bz2.iso.bz2";
+ const char *refname = "test_read_format_iso_rockridge.iso.Z";
struct archive_entry *ae;
struct archive *a;
const void *p;
size_t size;
off_t offset;
+ int i;
extract_reference_file(refname);
assert((a = archive_read_new()) != NULL);
assertEqualInt(0, archive_read_support_compression_all(a));
assertEqualInt(0, archive_read_support_format_all(a));
- assertEqualInt(0, archive_read_open_filename(a, refname, 10240));
-
- /* First entry is '.' root directory. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString(".", archive_entry_pathname(ae));
- assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
- assertEqualInt(2048, archive_entry_size(ae));
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(0, archive_entry_mtime_nsec(ae));
- assertEqualInt(86401, archive_entry_ctime(ae));
- assertEqualInt(0, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(0, archive_entry_uid(ae));
- assertEqualIntA(a, ARCHIVE_EOF,
- archive_read_data_block(a, &p, &size, &offset));
- assertEqualInt(size, 0);
-
- /* A directory. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString("dir", archive_entry_pathname(ae));
- assert(S_ISDIR(archive_entry_stat(ae)->st_mode));
- assertEqualInt(2048, archive_entry_size(ae));
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(86401, archive_entry_atime(ae));
- assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
-
- /* A regular file. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString("file", archive_entry_pathname(ae));
- assert(S_ISREG(archive_entry_stat(ae)->st_mode));
- assertEqualInt(6, archive_entry_size(ae));
- assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset));
- assertEqualInt(6, size);
- assertEqualInt(0, offset);
- assertEqualInt(0, memcmp(p, "hello\n", 6));
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(86401, archive_entry_atime(ae));
- assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
- /* A hardlink to the regular file. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString("hardlink", archive_entry_pathname(ae));
- assert(S_ISREG(archive_entry_stat(ae)->st_mode));
- assertEqualString("file", archive_entry_hardlink(ae));
- assertEqualInt(6, archive_entry_size(ae));
- assertEqualInt(86401, archive_entry_mtime(ae));
- assertEqualInt(86401, archive_entry_atime(ae));
- assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
+ /* Retrieve each of the 8 files on the ISO image and
+ * verify that each one is what we expect. */
+ for (i = 0; i < 10; ++i) {
+ assertEqualInt(0, archive_read_next_header(a, &ae));
- /* A symlink to the regular file. */
- assertEqualInt(0, archive_read_next_header(a, &ae));
- assertEqualString("symlink", archive_entry_pathname(ae));
- assert(S_ISLNK(archive_entry_stat(ae)->st_mode));
- assertEqualString("file", archive_entry_symlink(ae));
- assertEqualInt(0, archive_entry_size(ae));
- assertEqualInt(172802, archive_entry_mtime(ae));
- assertEqualInt(172802, archive_entry_atime(ae));
- assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
- assertEqualInt(1, archive_entry_uid(ae));
- assertEqualInt(2, archive_entry_gid(ae));
+ if (strcmp(".", archive_entry_pathname(ae)) == 0) {
+ /* '.' root directory. */
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ /* Now, we read timestamp recorded by RRIP "TF". */
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ /* Now, we read links recorded by RRIP "PX". */
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+ } else if (strcmp("dir", archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("hardlink", archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString("hardlink", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(12345684, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello\n", 6);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("file", archive_entry_pathname(ae)) == 0) {
+ /* A hardlink to the regular file. */
+ /* Note: If "hardlink" gets returned before "file",
+ * then "hardlink" will get returned as a regular file
+ * and "file" will get returned as the hardlink.
+ * This test should tolerate that, since it's a
+ * perfectly permissible thing for libarchive to do. */
+ assertEqualString("file", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualString("hardlink", archive_entry_hardlink(ae));
+ assertEqualInt(0, archive_entry_size_is_set(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("file", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink2", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp (an absolute path) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink3", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp/.. (with a ".." component) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp/..", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink4", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to a path with ".." and "." components */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(".././../tmp",
+ archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink5", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file with "/" components. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(".///file", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink6", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp//..
+ * (with "/" and ".." components) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp//..", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else {
+ failure("Saw a file that shouldn't have been there");
+ assertEqualString(archive_entry_pathname(ae), "");
+ }
+ }
/* End of archive. */
assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
/* Verify archive format. */
- assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
/* Close the archive. */
assertEqualInt(0, archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
assertEqualInt(0, archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_ce.c b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_ce.c
new file mode 100644
index 00000000000..71bce93dfe9
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_ce.c
@@ -0,0 +1,223 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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: head/lib/libarchive/test/test_read_format_isorr_ce.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+Execute the following command to rebuild the data for this program:
+ tail -n +32 test_read_format_isorr_ce.c | /bin/sh
+
+dirname=/tmp/iso
+#
+rm -rf $dirname
+mkdir $dirname
+#
+num=0
+file=""
+while [ $num -lt 150 ]
+do
+ num=$((num+1))
+ file="a$file"
+done
+#
+num=0
+while [ $num -lt 3 ]
+do
+ num=$((num+1))
+ file="a$file"
+ echo "hello $((num+150))" > $dirname/$file
+ dd if=/dev/zero count=1 bs=4080 >> $dirname/$file
+ (cd $dirname; ln -s $file sym$num)
+done
+#
+mkdir $dirname/dir
+#
+time1="197001020000.01"
+time2="197001030000.02"
+TZ=utc touch -afhm -t $time1 $dirname/dir $dirname/aaaa*
+TZ=utc touch -afhm -t $time2 $dirname/sym*
+TZ=utc touch -afhm -t $time1 $dirname
+#
+F=test_read_format_iso_rockridge_ce.iso.Z
+mkisofs -R -uid 1 -gid 2 $dirname | compress > $F
+uuencode $F $F > $F.uu
+rm -rf $dirname
+exit 1
+ */
+
+/*
+ * Test reading SUSP "CE" extension is works fine.
+ */
+
+static void
+mkpath(char *p, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ p[i] = 'a';
+ p[len] = '\0';
+}
+
+DEFINE_TEST(test_read_format_isorr_ce)
+{
+ const char *refname = "test_read_format_iso_rockridge_ce.iso.Z";
+ char path1[160];
+ char path2[160];
+ char path3[160];
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+ int i;
+
+ mkpath(path1, 151);
+ mkpath(path2, 152);
+ mkpath(path3, 153);
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* Retrieve each of the 8 files on the ISO image and
+ * verify that each one is what we expect. */
+ for (i = 0; i < 8; ++i) {
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+
+ if (strcmp(".", archive_entry_pathname(ae)) == 0) {
+ /* '.' root directory. */
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ /* Now, we read timestamp recorded by RRIP "TF". */
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ /* Now, we read links recorded by RRIP "PX". */
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+ } else if (strcmp("dir", archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp(path1, archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString(path1, archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(4090, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello 151\n", 10);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp(path2, archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString(path2, archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(4090, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello 152\n", 10);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp(path3, archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString(path3, archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(4090, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello 153\n", 10);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("sym1", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(path1, archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("sym2", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(path2, archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("sym3", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(path3, archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else {
+ failure("Saw a file that shouldn't have been there");
+ assertEqualString(archive_entry_pathname(ae), "");
+ }
+ }
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_new_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_new_bz2.c
new file mode 100644
index 00000000000..633959af96d
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_new_bz2.c
@@ -0,0 +1,204 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_isorr_new_bz2.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+
+/*
+PLEASE use latest cdrtools at least mkisofs version is 2.01.01a63 or later.
+Old version mkisofs made wrong "SL" System Use Entry of RRIP.
+
+Execute the following command to rebuild the data for this program:
+ tail -n +34 test_read_format_isorr_new_bz2.c | /bin/sh
+
+rm -rf /tmp/iso
+mkdir /tmp/iso
+mkdir /tmp/iso/dir
+echo "hello" >/tmp/iso/file
+dd if=/dev/zero count=1 bs=12345678 >>/tmp/iso/file
+ln /tmp/iso/file /tmp/iso/hardlink
+(cd /tmp/iso; ln -s file symlink)
+(cd /tmp/iso; ln -s /tmp/ symlink2)
+(cd /tmp/iso; ln -s /tmp/../ symlink3)
+(cd /tmp/iso; ln -s .././../tmp/ symlink4)
+(cd /tmp/iso; ln -s .///file symlink5)
+(cd /tmp/iso; ln -s /tmp//../ symlink6)
+TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir
+TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
+F=test_read_format_iso_rockridge_new.iso.Z
+mkhybrid -R -uid 1 -gid 2 /tmp/iso | compress > $F
+uuencode $F $F > $F.uu
+exit 1
+ */
+
+DEFINE_TEST(test_read_format_isorr_new_bz2)
+{
+ const char *refname = "test_read_format_iso_rockridge_new.iso.Z";
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+ int i;
+
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* Retrieve each of the 8 files on the ISO image and
+ * verify that each one is what we expect. */
+ for (i = 0; i < 10; ++i) {
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+
+ if (strcmp(".", archive_entry_pathname(ae)) == 0) {
+ /* '.' root directory. */
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ /* Now, we read timestamp recorded by RRIP "TF". */
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ /* Now, we read links recorded by RRIP "PX". */
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+ } else if (strcmp("dir", archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("hardlink", archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString("hardlink", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(12345684, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello\n", 6);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("file", archive_entry_pathname(ae)) == 0) {
+ /* A hardlink to the regular file. */
+ /* Note: If "hardlink" gets returned before "file",
+ * then "hardlink" will get returned as a regular file
+ * and "file" will get returned as the hardlink.
+ * This test should tolerate that, since it's a
+ * perfectly permissible thing for libarchive to do. */
+ assertEqualString("file", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualString("hardlink", archive_entry_hardlink(ae));
+ assertEqualInt(0, archive_entry_size_is_set(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("file", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink2", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp/ (an absolute path) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp/", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink3", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp/../ (with a ".." component) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp/../", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink4", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to a path with ".." and "." components */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(".././../tmp/",
+ archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink5", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file with "/" components. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(".///file", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink6", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp//../
+ * (with "/" and ".." components) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp//../", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else {
+ failure("Saw a file that shouldn't have been there");
+ assertEqualString(archive_entry_pathname(ae), "");
+ }
+ }
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_rr_moved.c b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_rr_moved.c
new file mode 100644
index 00000000000..d59b3464030
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_rr_moved.c
@@ -0,0 +1,270 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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: head/lib/libarchive/test/test_read_format_isorr_rr_moved.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+Execute the following command to rebuild the data for this program:
+ tail -n +32 test_read_format_isorr_rr_moved.c | /bin/sh
+
+dirname=/tmp/iso
+rm -rf $dirname
+mkdir -p $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10
+echo "hello" >$dirname/file
+dd if=/dev/zero count=1 bs=12345678 >>$dirname/file
+deepfile=$dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10/deep
+echo "hello" >$deepfile
+dd if=/dev/zero count=1 bs=12345678 >>$deepfile
+time="197001020000.01"
+TZ=utc touch -afhm -t $time $deepfile
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9/dir10
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8/dir9
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7/dir8
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6/dir7
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5/dir6
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4/dir5
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3/dir4
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2/dir3
+TZ=utc touch -afhm -t $time $dirname/dir1/dir2
+TZ=utc touch -afhm -t $time $dirname/dir1
+TZ=utc touch -afhm -t $time $dirname/file
+TZ=utc touch -afhm -t $time $dirname
+F=test_read_format_isorr_rockridge_moved.iso.Z
+mkhybrid -R -uid 1 -gid 2 $dirname | compress > $F
+uuencode $F $F > $F.uu
+exit 1
+ */
+
+DEFINE_TEST(test_read_format_isorr_rr_moved)
+{
+ const char *refname = "test_read_format_iso_rockridge_rr_moved.iso.Z";
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+ int i;
+
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* Retrieve each of the 8 files on the ISO image and
+ * verify that each one is what we expect. */
+ for (i = 0; i < 13; ++i) {
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+
+ if (strcmp(".", archive_entry_pathname(ae)) == 0) {
+ /* '.' root directory. */
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ /* Now, we read timestamp recorded by RRIP "TF". */
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ /* Now, we read links recorded by RRIP "PX". */
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+ } else if (strcmp("dir1", archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3/dir4",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4/dir5",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3/dir4/dir5",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8/dir9",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8/dir9",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8/dir9/dir10",
+ archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8/dir9/dir10",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("file", archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString("file", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(12345684, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello\n", 6);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8/dir9/dir10/deep",
+ archive_entry_pathname(ae)) == 0) {
+ /* A regular file. */
+ assertEqualString("dir1/dir2/dir3/dir4/dir5/dir6/dir7"
+ "/dir8/dir9/dir10/deep",
+ archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(12345684, archive_entry_size(ae));
+ assertEqualInt(0,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello\n", 6);
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else {
+ failure("Saw a file that shouldn't have been there");
+ assertEqualString(archive_entry_pathname(ae), "");
+ }
+ }
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isozisofs_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_isozisofs_bz2.c
new file mode 100644
index 00000000000..05271cdd89e
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_isozisofs_bz2.c
@@ -0,0 +1,187 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_isozisofs_bz2.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+Execute the following command to rebuild the data for this program:
+ tail -n +32 test_read_format_isozisofs_bz2.c | /bin/sh
+
+rm -rf /tmp/iso /tmp/ziso
+mkdir /tmp/iso
+mkdir /tmp/iso/dir
+echo "hello" >/tmp/iso/file
+dd if=/dev/zero count=1 bs=12345678 >>/tmp/iso/file
+ln /tmp/iso/file /tmp/iso/hardlink
+(cd /tmp/iso; ln -s file symlink)
+(cd /tmp/iso; ln -s /tmp/ symlink2)
+(cd /tmp/iso; ln -s /tmp/../ symlink3)
+(cd /tmp/iso; ln -s .././../tmp/ symlink4)
+TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir
+TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink
+mkzftree /tmp/iso /tmp/ziso
+TZ=utc touch -afhm -t 197001020000.01 /tmp/ziso /tmp/ziso/file /tmp/ziso/dir
+TZ=utc touch -afhm -t 197001030000.02 /tmp/ziso/symlink
+F=test_read_format_iso_zisofs.iso.Z
+mkhybrid -R -uid 1 -gid 2 -z /tmp/ziso | compress > $F
+uuencode $F $F > $F.uu
+exit 1
+
+ */
+
+DEFINE_TEST(test_read_format_isozisofs_bz2)
+{
+ const char *refname = "test_read_format_iso_zisofs.iso.Z";
+ struct archive_entry *ae;
+ struct archive *a;
+ const void *p;
+ size_t size;
+ off_t offset;
+ int i;
+
+ extract_reference_file(refname);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualInt(0, archive_read_support_compression_all(a));
+ assertEqualInt(0, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_filename(a, refname, 10240));
+
+ /* Retrieve each of the 8 files on the ISO image and
+ * verify that each one is what we expect. */
+ for (i = 0; i < 8; ++i) {
+ assertEqualInt(0, archive_read_next_header(a, &ae));
+
+ if (strcmp(".", archive_entry_pathname(ae)) == 0) {
+ /* '.' root directory. */
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ /* Now, we read timestamp recorded by RRIP "TF". */
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ /* Now, we read links recorded by RRIP "PX". */
+ assertEqualInt(3, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_data_block(a, &p, &size, &offset));
+ assertEqualInt((int)size, 0);
+ } else if (strcmp("dir", archive_entry_pathname(ae)) == 0) {
+ /* A directory. */
+ assertEqualString("dir", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
+ assertEqualInt(2048, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("hardlink", archive_entry_pathname(ae)) == 0) {
+ int r;
+ /* A regular file. */
+ assertEqualString("hardlink", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualInt(12345684, archive_entry_size(ae));
+ r = archive_read_data_block(a, &p, &size, &offset);
+ if (r == ARCHIVE_FAILED) {
+ skipping("Can't read body of ZISOFS entry.");
+ } else {
+ assertEqualInt(ARCHIVE_OK, r);
+ assertEqualInt(0, offset);
+ assertEqualMem(p, "hello\n", 6);
+ }
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("file", archive_entry_pathname(ae)) == 0) {
+ /* A hardlink to the regular file. */
+ /* Note: If "hardlink" gets returned before "file",
+ * then "hardlink" will get returned as a regular file
+ * and "file" will get returned as the hardlink.
+ * This test should tolerate that, since it's a
+ * perfectly permissible thing for libarchive to do. */
+ assertEqualString("file", archive_entry_pathname(ae));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
+ assertEqualString("hardlink", archive_entry_hardlink(ae));
+ assertEqualInt(0, archive_entry_size_is_set(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(86401, archive_entry_mtime(ae));
+ assertEqualInt(86401, archive_entry_atime(ae));
+ assertEqualInt(2, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to the regular file. */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("file", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(172802, archive_entry_mtime(ae));
+ assertEqualInt(172802, archive_entry_atime(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink2", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp (an absolute path) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink3", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to /tmp/.. (with a ".." component) */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString("/tmp/..", archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else if (strcmp("symlink4", archive_entry_pathname(ae)) == 0) {
+ /* A symlink to a path with ".." and "." components */
+ assertEqualInt(AE_IFLNK, archive_entry_filetype(ae));
+ assertEqualString(".././../tmp",
+ archive_entry_symlink(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualInt(1, archive_entry_stat(ae)->st_nlink);
+ assertEqualInt(1, archive_entry_uid(ae));
+ assertEqualInt(2, archive_entry_gid(ae));
+ } else {
+ failure("Saw a file that shouldn't have been there");
+ assertEqualString(archive_entry_pathname(ae), "");
+ }
+ }
+
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ /* Verify archive format. */
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE);
+
+ /* Close the archive. */
+ assertEqualInt(0, archive_read_close(a));
+ assertEqualInt(0, archive_read_finish(a));
+}
+
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c b/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c
index 954f0222ad1..ce6e92086dc 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c
@@ -23,58 +23,61 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_mtree.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $");
-
-/* Single entry with a hardlink. */
-static unsigned char archive[] = {
- "#mtree\n"
- "file type=file uid=18 mode=0123\n"
- "dir type=dir\n"
- " file\\040with\\040space type=file uid=18\n"
- " ..\n"
- "file\\04with\\040space type=file\n"
- "dir2 type=dir\n"
- " dir3a type=dir\n"
- " indir3a type=file\n"
- "dir2/fullindir2 type=file mode=0777\n"
- " ..\n"
- " indir2 type=file\n"
- " dir3b type=dir\n"
- " indir3b type=file\n"
- " ..\n"
- " ..\n"
- "notindir type=file\n"
- "dir2/fullindir2 mode=0644\n"
-};
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_mtree.c 201247 2009-12-30 05:59:21Z kientzle $");
-DEFINE_TEST(test_read_format_mtree)
+static void
+test_read_format_mtree1(void)
{
+ const char reffile[] = "test_read_format_mtree.mtree";
+ char buff[16];
struct archive_entry *ae;
struct archive *a;
+ FILE *f;
+
+ extract_reference_file(reffile);
+
+ /*
+ * An access error occurred on some platform when mtree
+ * format handling open a directory. It is for through
+ * the routine which open a directory that we create
+ * "dir" and "dir2" directories.
+ */
+ assertMakeDir("dir", 0775);
+ assertMakeDir("dir2", 0775);
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK,
archive_read_support_compression_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_support_format_all(a));
- assertEqualIntA(a, ARCHIVE_OK,
- archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_file(a, reffile, 11));
+
+ /*
+ * Read "file", whose data is available on disk.
+ */
+ f = fopen("file", "wb");
+ assert(f != NULL);
+ assertEqualInt(3, fwrite("hi\n", 1, 3, f));
+ fclose(f);
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
- assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE_V1);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE);
assertEqualString(archive_entry_pathname(ae), "file");
assertEqualInt(archive_entry_uid(ae), 18);
- assert(S_ISREG(archive_entry_mode(ae)));
+ assertEqualInt(AE_IFREG, archive_entry_filetype(ae));
assertEqualInt(archive_entry_mode(ae), AE_IFREG | 0123);
+ assertEqualInt(archive_entry_size(ae), 3);
+ assertEqualInt(3, archive_read_data(a, buff, 3));
+ assertEqualMem(buff, "hi\n", 3);
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir");
- assert(S_ISDIR(archive_entry_mode(ae)));
+ assertEqualInt(AE_IFDIR, archive_entry_filetype(ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir/file with space");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
- assertEqualString(archive_entry_pathname(ae), "file\\04with space");
+ assertEqualString(archive_entry_pathname(ae), "file with space");
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "dir2");
@@ -103,11 +106,38 @@ DEFINE_TEST(test_read_format_mtree)
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
}
+static void
+test_read_format_mtree2(void)
+{
+ static char archive[] =
+ "#mtree\n"
+ "d type=dir content=.\n";
+ struct archive_entry *ae;
+ struct archive *a;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_MTREE);
+ assertEqualString(archive_entry_pathname(ae), "d");
+ assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
+
+
+DEFINE_TEST(test_read_format_mtree)
+{
+ test_read_format_mtree1();
+ test_read_format_mtree2();
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_mtree.mtree.uu b/archivers/libarchive/files/libarchive/test/test_read_format_mtree.mtree.uu
new file mode 100644
index 00000000000..1634d0015f5
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_mtree.mtree.uu
@@ -0,0 +1,13 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_mtree.mtree.uu 201247 2009-12-30 05:59:21Z kientzle $
+
+begin 644 test_read_format_mtree.mtree
+M(VUT<F5E"F9I;&4@='EP93UF:6QE('5I9#TQ."!M;V1E/3`Q,C,@<VEZ93TS
+M"F1I<B!T>7!E/61I<@H@9FEL95PP-#!W:71H7#`T,'-P86-E('1Y<&4]9FEL
+M92!U:60],3@*("XN"F9I;&5<,#0P=VET:%PP-#!S<&%C92!T>7!E/69I;&4*
+M9&ER,B!T>7!E/61I<@H@9&ER,V$@='EP93UD:7(*("!I;F1I<C-A('1Y<&4]
+M9FEL90ID:7(R+V9U;&QI;F1I<C(@='EP93UF:6QE(&UO9&4],#<W-PH@("XN
+M"B!I;F1I<C(@='EP93UF:6QE"B!D:7(S8B!T>7!E/61I<@H@(&EN9&ER,V(@
+M='EP93UF:6QE"B`@+BX*("XN"FYO=&EN9&ER('1Y<&4]9FEL90ID:7(R+V9U
+3;&QI;F1I<C(@;6]D93TP-C0T"@``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c
index 186d5f9d5ba..af70b366308 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_pax_bz2.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_pax_bz2.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_pax_bz2.c 201247 2009-12-30 05:59:21Z kientzle $");
static unsigned char archive[] = {
'B','Z','h','9','1','A','Y','&','S','Y',152,180,30,185,0,0,140,127,176,212,
@@ -44,19 +44,23 @@ DEFINE_TEST(test_read_format_pax_bz2)
{
struct archive_entry *ae;
struct archive *a;
+ int r;
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
- assert(archive_format(a) == ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ r = archive_read_support_compression_bzip2(a);
+ if (r != ARCHIVE_OK) {
+ archive_read_close(a);
+ skipping("Bzip2 unavailable");
+ return;
+ }
+ assertEqualIntA(a,ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a,ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a,ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE);
+ assertEqualIntA(a,ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_raw.c b/archivers/libarchive/files/libarchive/test/test_read_format_raw.c
new file mode 100644
index 00000000000..cd5f00ee1bf
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_raw.c
@@ -0,0 +1,89 @@
+/*-
+ * Copyright (c) 2007 Kai Wang
+ * Copyright (c) 2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 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: head/lib/libarchive/test/test_read_format_raw.c 191594 2009-04-27 20:09:05Z kientzle $");
+
+DEFINE_TEST(test_read_format_raw)
+{
+ char buff[512];
+ struct archive_entry *ae;
+ struct archive *a;
+ const char *reffile1 = "test_read_format_raw.data";
+ const char *reffile2 = "test_read_format_raw.data.Z";
+
+ /* First, try pulling data out of an uninterpretable file. */
+ extract_reference_file(reffile1);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_raw(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_filename(a, reffile1, 512));
+
+ /* First (and only!) Entry */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualString("data", archive_entry_pathname(ae));
+ /* Most fields should be unset (unknown) */
+ assert(!archive_entry_size_is_set(ae));
+ assert(!archive_entry_atime_is_set(ae));
+ assert(!archive_entry_ctime_is_set(ae));
+ assert(!archive_entry_mtime_is_set(ae));
+ assertEqualInt(4, archive_read_data(a, buff, 32));
+ assertEqualMem(buff, "foo\n", 4);
+
+ /* Test EOF */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+
+ /* Second, try the same with a compressed file. */
+ extract_reference_file(reffile2);
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_raw(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_filename(a, reffile2, 1));
+
+ /* First (and only!) Entry */
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualString("data", archive_entry_pathname(ae));
+ /* Most fields should be unset (unknown) */
+ assert(!archive_entry_size_is_set(ae));
+ assert(!archive_entry_atime_is_set(ae));
+ assert(!archive_entry_ctime_is_set(ae));
+ assert(!archive_entry_mtime_is_set(ae));
+ assertEqualInt(4, archive_read_data(a, buff, 32));
+ assertEqualMem(buff, "foo\n", 4);
+
+ /* Test EOF */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_raw.data.Z.uu b/archivers/libarchive/files/libarchive/test/test_read_format_raw.data.Z.uu
new file mode 100644
index 00000000000..eff01d3799e
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_raw.data.Z.uu
@@ -0,0 +1,5 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_raw.data.Z.uu 191594 2009-04-27 20:09:05Z kientzle $
+begin 644 test_read_format_raw.data.Z
+('YV09MZ\40``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_raw.data.uu b/archivers/libarchive/files/libarchive/test/test_read_format_raw.data.uu
new file mode 100644
index 00000000000..e88da003fb4
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_raw.data.uu
@@ -0,0 +1,5 @@
+$FreeBSD: head/lib/libarchive/test/test_read_format_raw.data.uu 191594 2009-04-27 20:09:05Z kientzle $
+begin 644 test_read_format_raw.data
+$9F]O"@``
+`
+end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tar.c b/archivers/libarchive/files/libarchive/test/test_read_format_tar.c
index 1de08495ca9..9c197df0946 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_tar.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tar.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tar.c,v 1.3 2008/01/13 23:50:30 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tar.c 201247 2009-12-30 05:59:21Z kientzle $");
/*
* Each of these archives is a short archive with a single entry. The
@@ -71,14 +71,15 @@ static void verifyEmpty(void)
assertA(0 == archive_read_open_memory(a, archiveEmpty, 512));
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
+ assertEqualString(archive_compression_name(a), "none");
failure("512 zero bytes should be recognized as a tar archive.");
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
@@ -100,9 +101,9 @@ static unsigned char archive1[] = {
static void verify1(struct archive_entry *ae)
{
/* A hardlink is not a symlink. */
- assert(!S_ISLNK(archive_entry_mode(ae)));
+ assert(archive_entry_filetype(ae) != AE_IFLNK);
/* Nor is it a directory. */
- assert(!S_ISDIR(archive_entry_mode(ae)));
+ assert(archive_entry_filetype(ae) != AE_IFDIR);
assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
assertEqualInt(archive_entry_uid(ae), 1000);
assertEqualInt(archive_entry_gid(ae), 1000);
@@ -131,7 +132,7 @@ static unsigned char archive2[] = {
static void verify2(struct archive_entry *ae)
{
- assert(S_ISLNK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
assertEqualInt(archive_entry_uid(ae), 1000);
assertEqualInt(archive_entry_gid(ae), 1000);
@@ -160,7 +161,7 @@ static unsigned char archive3[] = {
static void verify3(struct archive_entry *ae)
{
- assert(S_ISCHR(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_filetype(ae), AE_IFCHR);
assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
assertEqualInt(archive_entry_uid(ae), 1000);
assertEqualInt(archive_entry_gid(ae), 1000);
@@ -189,7 +190,7 @@ static unsigned char archive4[] = {
static void verify4(struct archive_entry *ae)
{
- assert(S_ISBLK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_filetype(ae), AE_IFBLK);
assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
assertEqualInt(archive_entry_uid(ae), 1000);
assertEqualInt(archive_entry_gid(ae), 1000);
@@ -218,7 +219,7 @@ static unsigned char archive5[] = {
static void verify5(struct archive_entry *ae)
{
- assert(S_ISDIR(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
assertEqualInt(archive_entry_mtime(ae), 1131430878);
assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
assertEqualInt(archive_entry_uid(ae), 1000);
@@ -244,7 +245,7 @@ static unsigned char archive6[] = {
static void verify6(struct archive_entry *ae)
{
- assert(S_ISFIFO(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_filetype(ae), AE_IFIFO);
assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
assertEqualInt(archive_entry_uid(ae), 1000);
assertEqualInt(archive_entry_gid(ae), 1000);
@@ -315,7 +316,7 @@ static unsigned char archiveK[] = {
static void verifyK(struct archive_entry *ae)
{
- assert(S_ISLNK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
assertEqualInt(archive_entry_uid(ae), 1000);
assertEqualInt(archive_entry_gid(ae), 1000);
@@ -401,7 +402,7 @@ static unsigned char archivexL[] = {
static void verifyxL(struct archive_entry *ae)
{
- assert(S_ISLNK(archive_entry_mode(ae)));
+ assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
assertEqualInt(archive_entry_uid(ae), 1000);
assertEqualInt(archive_entry_gid(ae), 1000);
@@ -447,10 +448,10 @@ static void verify(unsigned char *d, size_t s,
f(ae);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
free(buff);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c b/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c
index d9ba69bd93c..8d917144448 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tar_empty_filename.c,v 1.2 2008/09/01 05:38:33 kientzle Exp $");
/*
* Tar entries with empty filenames are unusual, but shouldn't crash us.
@@ -58,9 +58,9 @@ DEFINE_TEST(test_read_format_tar_empty_filename)
assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu b/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu
index 7a34c82ca6b..f8a4f4f2f1b 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tar_empty_filename.tar.uu
@@ -1,3 +1,4 @@
+$FreeBSD: src/lib/libarchive/test/test_read_format_tar_empty_filename.tar.uu,v 1.2 2008/07/03 03:26:30 peter Exp $
begin 644 test_compat_tar_1.tar
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tbz.c b/archivers/libarchive/files/libarchive/test/test_read_format_tbz.c
index 3d135eb6df6..06d8cad4798 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_tbz.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tbz.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tbz.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tbz.c 201247 2009-12-30 05:59:21Z kientzle $");
static unsigned char archive[] = {
'B','Z','h','9','1','A','Y','&','S','Y',237,7,140,'W',0,0,27,251,144,208,
@@ -37,19 +37,23 @@ DEFINE_TEST(test_read_format_tbz)
{
struct archive_entry *ae;
struct archive *a;
+ int r;
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2);
- assert(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ r = archive_read_support_compression_bzip2(a);
+ if (r != ARCHIVE_OK) {
+ skipping("Bzip2 support");
+ archive_read_finish(a);
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tgz.c b/archivers/libarchive/files/libarchive/test/test_read_format_tgz.c
index ce61aa67971..f411b433802 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_tgz.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tgz.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tgz.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tgz.c 191183 2009-04-17 01:06:31Z kientzle $");
static unsigned char archive[] = {
31,139,8,0,222,'C','p','C',0,3,211,'c',160,'=','0','0','0','0','7','5','U',
@@ -36,19 +36,25 @@ DEFINE_TEST(test_read_format_tgz)
{
struct archive_entry *ae;
struct archive *a;
+ int r;
+
assert((a = archive_read_new()) != NULL);
- assert(0 == archive_read_support_compression_all(a));
- assert(0 == archive_read_support_format_all(a));
- assert(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assert(0 == archive_read_next_header(a, &ae));
- assert(archive_compression(a) == ARCHIVE_COMPRESSION_GZIP);
- assert(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ assertEqualInt(ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a),
+ ARCHIVE_COMPRESSION_GZIP);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK,archive_read_finish(a));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tlz.c b/archivers/libarchive/files/libarchive/test/test_read_format_tlz.c
new file mode 100644
index 00000000000..7dd09a0c518
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tlz.c
@@ -0,0 +1,60 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tlz.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+static unsigned char archive[] = {
+ 93, 0, 0,128, 0,255,255,255,255,255,255,255,255, 0, 23, 0,
+ 51, 80, 24,164,204,238, 45, 77, 28,191, 13,144, 8, 10, 70, 5,
+173,215, 47,132,237,145,162, 96, 6,131,168,152, 8,135,161,189,
+ 73,110,132, 27,195, 52,109,203, 22, 17,168,211, 18,181, 76, 93,
+120, 88,154,155,244,141,193,206,170,224, 80,137,134, 67, 1, 9,
+123,121,189, 74,137,197, 63,255,214, 55,119, 0
+};
+
+DEFINE_TEST(test_read_format_tlz)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ int r;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_lzma(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("lzma reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_LZMA);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_txz.c b/archivers/libarchive/files/libarchive/test/test_read_format_txz.c
new file mode 100644
index 00000000000..acff175c56f
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_txz.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_txz.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+static unsigned char archive[] = {
+253, 55,122, 88, 90, 0, 0, 4,230,214,180, 70, 2, 0, 33, 1,
+ 22, 0, 0, 0,116, 47,229,163,224, 5,255, 0, 73, 93, 0, 23,
+ 0, 51, 80, 24,164,204,238, 45, 77, 28,191, 13,144, 8, 10, 70,
+ 5,173,215, 47,132,237,145,162, 96, 6,131,168,152, 8,135,161,
+189, 73,110,132, 27,195, 52,109,203, 22, 17,168,211, 18,181, 76,
+ 93,120, 88,154,155,244,141,193,206,170,224, 80,137,134, 67, 1,
+ 9,123,121,188,247, 28,139, 0, 0, 0, 0, 0,112,184, 17, 5,
+103, 16, 8, 73, 0, 1,101,128, 12, 0, 0, 0, 30, 69, 92, 96,
+177,196,103,251, 2, 0, 0, 0, 0, 4, 89, 90
+};
+
+DEFINE_TEST(test_read_format_txz)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ int r;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_xz(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("xz reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_XZ);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_tz.c b/archivers/libarchive/files/libarchive/test/test_read_format_tz.c
index 337b96dfc17..eb066013842 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_tz.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_tz.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_tz.c,v 1.1 2007/03/03 07:37:37 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_tz.c 189381 2009-03-05 00:31:48Z kientzle $");
static unsigned char archive[] = {
31,157,144,'.',0,8,28,'H',176,160,193,131,8,19,'*','\\',200,176,'!','B',24,
@@ -39,17 +39,22 @@ DEFINE_TEST(test_read_format_tz)
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_open_memory(a, archive, sizeof(archive)));
- assertA(0 == archive_read_next_header(a, &ae));
- assertA(archive_compression(a) == ARCHIVE_COMPRESSION_COMPRESS);
- assertA(archive_format(a) == ARCHIVE_FORMAT_TAR_USTAR);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, archive, sizeof(archive)));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ failure("archive_compression_name(a)=\"%s\"",
+ archive_compression_name(a));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_COMPRESS);
+ failure("archive_format_name(a)=\"%s\"", archive_format_name(a));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_xar.c b/archivers/libarchive/files/libarchive/test/test_read_format_xar.c
new file mode 100644
index 00000000000..a6966776081
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_xar.c
@@ -0,0 +1,697 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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 UID 1001
+#define UNAME "cue"
+#define GID 1001
+#define GNAME "cue"
+
+/* Verify that a file records with hardlink.
+#How to make
+echo "hellohellohello" > f1
+chown $UNAME:$GNAME f1
+chmod 0644 f1
+ln f1 hardlink
+chown $UNAME:$GNAME hardlink
+chmod 0644 hardlink
+env TZ=utc touch -afm -t 197001020000.01 f1 hardlink
+xar -cf archive1.xar f1 hardlink
+od -t x1 archive1.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive1.xar.txt
+*/
+static unsigned char archive1[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xc6,
+0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x70,0x00,0x00,0x00,0x01,0x78,0xda,0xc4,0x54,
+0xc9,0x6e,0xdb,0x30,0x14,0xbc,0xe7,0x2b,0x08,0xdd,0x55,0xae,0xb6,0x45,0x83,0x56,
+0xd0,0x4b,0xd1,0x7b,0xd3,0x4b,0x6f,0x34,0x17,0x89,0x88,0x36,0x48,0x54,0xe0,0xe4,
+0xeb,0x4b,0x52,0x52,0x0c,0xa7,0x71,0x6f,0x45,0x01,0x01,0x1a,0x0e,0x87,0xa3,0xa7,
+0xf7,0x06,0x14,0x8f,0x97,0xb6,0x01,0x2f,0x66,0x9c,0x5c,0xdf,0x9d,0x32,0xfc,0x05,
+0x65,0xc0,0x74,0xaa,0xd7,0xae,0xab,0x4e,0xd9,0xcf,0xa7,0x6f,0x79,0x91,0x3d,0x96,
+0x0f,0xe2,0x22,0xc7,0xf2,0x01,0x08,0xdf,0xab,0xf0,0x02,0x42,0x8d,0x46,0xfa,0x70,
+0x22,0xf7,0xae,0x35,0x25,0x41,0x88,0xe7,0x98,0xe4,0x88,0x3c,0x61,0x7a,0xa4,0xe8,
+0x48,0xb9,0x80,0xb7,0x92,0x74,0xa8,0x36,0xea,0x79,0x9a,0x5b,0x30,0xf9,0xd7,0xc6,
+0x9c,0xb2,0xa9,0x96,0x38,0x8b,0x3b,0x40,0xf4,0xd6,0x4e,0xc6,0x97,0x48,0xc0,0x15,
+0x25,0x76,0x72,0x6f,0xd1,0x5c,0xc0,0x04,0xa2,0x05,0xdc,0x3c,0xd2,0xca,0xba,0xc6,
+0x00,0xa7,0x4f,0x19,0x59,0x6d,0xd4,0x9d,0x72,0xd8,0xaf,0x70,0x72,0xab,0x03,0x88,
+0x36,0x41,0xcc,0x0f,0x28,0x47,0x38,0xca,0x10,0x3a,0xc6,0x07,0x07,0x59,0x7b,0x95,
+0xc9,0x7b,0x3f,0x17,0x64,0xf2,0x2a,0xab,0xc6,0x7e,0x1e,0x4a,0x35,0x1b,0x01,0x17,
+0xb8,0xb0,0x4e,0x97,0x18,0x21,0x1c,0xc8,0x80,0x12,0x35,0x4f,0x66,0x5c,0x74,0x09,
+0x2d,0xdc,0xbb,0x6c,0xde,0x64,0x6d,0xaf,0x4d,0x89,0xf6,0x8c,0x85,0x62,0x22,0x4c,
+0xa4,0x7f,0x1d,0x0c,0x68,0x5c,0xf7,0x1c,0x66,0x94,0x95,0xb5,0x1c,0x75,0x5c,0x08,
+0x18,0xf9,0x45,0xd1,0xc9,0x50,0xd0,0x75,0x23,0x2d,0x53,0xcb,0x62,0x97,0x6e,0xdb,
+0xb5,0x75,0x5d,0x4b,0x2f,0x13,0x02,0xa2,0x31,0x5d,0xe5,0xeb,0x92,0x50,0x01,0x57,
+0xb8,0xf0,0xeb,0x38,0xc8,0xed,0x64,0xd6,0xd1,0xe0,0xfd,0x75,0x34,0x81,0xdb,0x72,
+0xb3,0xcd,0x57,0x0e,0x43,0xe3,0x54,0x0a,0x01,0xbc,0xe4,0xd5,0x9b,0x1b,0x32,0xb8,
+0x4a,0xe5,0xa8,0x6a,0xf7,0x62,0x74,0xfe,0x31,0x13,0x3f,0xbe,0x7f,0x0d,0xd5,0xd9,
+0x82,0x52,0x4d,0xac,0x56,0x98,0x53,0xc6,0xa9,0x3c,0xb3,0x82,0x4b,0x2d,0x09,0xb5,
+0x85,0x3d,0x70,0x6c,0xf7,0xc4,0x2a,0xba,0xe7,0x45,0x98,0xc3,0x47,0xa3,0xad,0x96,
+0x8b,0x1f,0xa5,0xf2,0x77,0xbf,0xb0,0xd3,0x07,0x76,0x56,0x67,0x75,0xe0,0x9a,0x5a,
+0x7e,0xb6,0x4c,0xda,0xe0,0xcd,0x8a,0xa2,0x40,0x86,0xed,0xc8,0x7e,0xc7,0xac,0x41,
+0x8a,0x87,0x1c,0xff,0xe9,0xb4,0x34,0x0f,0xbe,0x77,0xef,0x9f,0xc4,0xee,0x73,0xd9,
+0x7f,0x8c,0x5d,0x3f,0xba,0xca,0x75,0xb2,0xf9,0x4b,0xfa,0x2c,0xfe,0x24,0x77,0x41,
+0x15,0x2f,0x0d,0x01,0xd3,0x15,0xf2,0x1b,0x00,0x00,0xff,0xff,0x03,0x00,0x88,0x32,
+0x49,0x7b,0x67,0xbf,0xc6,0x01,0x29,0xf2,0x1c,0x40,0x05,0x3c,0x49,0x25,0x9f,0xab,
+0x7c,0x8e,0xc5,0xa5,0x79,0xe0,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,0x80,0x13,
+0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47
+};
+
+static void verify0(struct archive *a, struct archive_entry *ae)
+{
+ const void *p;
+ size_t size;
+ off_t offset;
+
+ assert(archive_entry_filetype(ae) == AE_IFREG);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+ assertEqualString(archive_entry_pathname(ae), "f1");
+ assert(archive_entry_hardlink(ae) == NULL);
+ assert(archive_entry_symlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 86401);
+ assertEqualInt(archive_entry_size(ae), 16);
+ assertEqualInt(archive_read_data_block(a, &p, &size, &offset), 0);
+ assertEqualInt((int)size, 16);
+ assertEqualInt((int)offset, 0);
+ assertEqualInt(memcmp(p, "hellohellohello\n", 16), 0);
+}
+
+static void verify1(struct archive *a, struct archive_entry *ae)
+{
+ (void)a; /* UNUSED */
+ /* A hardlink is not a symlink. */
+ assert(archive_entry_filetype(ae) != AE_IFLNK);
+ /* Nor is it a directory. */
+ assert(archive_entry_filetype(ae) != AE_IFDIR);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+ assertEqualString(archive_entry_pathname(ae), "hardlink");
+ assertEqualString(archive_entry_hardlink(ae), "f1");
+ assert(archive_entry_symlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 86401);
+ assertEqualInt(archive_entry_nlink(ae), 2);
+}
+
+/* Verify that symlinks are read correctly.
+#How to make
+echo "hellohellohello" > f1
+chown $UNAME:$GNAME f1
+chmod 0644 f1
+ln -s f1 symlink
+chown $UNAME:$GNAME symlink
+chmod 0644 symlink
+env TZ=utc touch -afm -t 197001020000.01 f1 symlink
+xar -cf archive2.xar f1 symlink
+od -t x1 archive2.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive2.xar.txt
+*/
+static unsigned char archive2[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,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0x66,0x45,0x4c,0xb7,0x28,0x45,0x38,0xd0,0x90,0x37,0x98,0x7f,0xf0,0x9a,0x15,
+0xd7,0x69,0xff,0xdd,0x8a,0x9b,0x3c,0xff,0x6c,0xc5,0xe0,0xae,0x24,0x18,0xaa,0x02,
+0xfd,0x68,0x6b,0xdb,0x89,0x06,0xf0,0x83,0x18,0xd5,0xaa,0xf9,0x82,0x4f,0xef,0x7c,
+0xe7,0x59,0xe1,0x22,0x61,0x30,0x5e,0x2b,0x7f,0x01,0x00,0x00,0xff,0xff,0x03,0x00,
+0x2b,0xab,0x4f,0xf9,0xbb,0xf7,0x90,0xb5,0x34,0x8f,0x7c,0xae,0x72,0xa0,0x80,0xd2,
+0x69,0xc7,0xa2,0xe7,0x44,0x53,0xeb,0x75,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,
+0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47
+};
+
+static void verify2(struct archive *a, struct archive_entry *ae)
+{
+ (void)a; /* UNUSED */
+ assertEqualInt(archive_entry_filetype(ae), AE_IFLNK);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+ assertEqualString(archive_entry_pathname(ae), "symlink");
+ assertEqualString(archive_entry_symlink(ae), "f1");
+ assert(archive_entry_hardlink(ae) == NULL);
+}
+
+/* Character device node.
+#How to make
+mknod devchar c 0 30
+chown $UNAME:$GNAME devchar
+chmod 0644 devchar
+env TZ=utc touch -afm -t 197001020000.01 devchar
+xar -cf archive3.xar devchar
+od -t x1 archive3.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive3.xar.txt
+*/
+static unsigned char archive3[] = {
+0x78,0x61,0x72,0x21,0x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c0,
+0x0e,0xde,0x8d,0x27,0x65,0x46,0x04,0x3e,0xc9,0xc9,0xb5,0x8d,0x92,0x42,0xc8,0x64,
+0x26,0x45,0xd6,0x18,0xd0,0x4f,0x1c,0xa9,0xc9,0xfb,0xc6,0xc6,0x3b,0xd6,0xbb,0x06,
+0x95,0x58,0x2d,0x16,0xa9,0x99,0x2c,0xc9,0x6c,0xf0,0x6c,0xcd,0xa4,0x13,0x61,0x07,
+0xe7,0xd5,0x3c,0x0d,0x66,0x52,0x37,0x57,0x1f,0x93,0xce,0x26,0x09,0x8a,0xf1,0x1f,
+0x39,0x88,0xd7,0x13,0x2a,0xd3,0x6a,0xaf,0x4d,0x44,0xcf,0xc2,0x09,0x8d,0xd5,0x1d,
+0x70,0xf2,0x89,0x18,0x74,0xba,0x54,0x8a,0x64,0x08,0x38,0xed,0x68,0xea,0x79,0xd0,
+0xf9,0xf9,0x39,0xbd,0x3f,0x70,0xfa,0x1b,0xbe,0x00,0x00,0x00,0xff,0xff,0x03,0x00,
+0xab,0x43,0xa3,0xac,0x76,0x40,0x1e,0x8b,0x95,0x0d,0x28,0x79,0x79,0x43,0x49,0x4e,
+0x16,0xa1,0x56,0x99,0x1f,0x83,0x77,0x41
+};
+
+static void verify3(struct archive *a, struct archive_entry *ae)
+{
+ (void)a; /* UNUSED */
+ assertEqualInt(archive_entry_filetype(ae), AE_IFCHR);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+ assertEqualString(archive_entry_pathname(ae), "devchar");
+ assert(archive_entry_symlink(ae) == NULL);
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 86401);
+}
+
+/* Block device node.
+#How to make
+mknod devblock b 0 30
+chown $UNAME:$GNAME devblock
+chmod 0644 devblock
+env TZ=utc touch -afm -t 197001020000.01 devblock
+xar -cf archive4.xar devblock
+od -t x1 archive4.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive4.xar.txt
+*/
+static unsigned char archive4[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x34,
+0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x38,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x92,
+0xc1,0x6e,0xc2,0x30,0x0c,0x86,0xef,0x3c,0x45,0xd4,0x7b,0x17,0x07,0xd0,0x0a,0x95,
+0x09,0xb7,0x3d,0x01,0xbb,0xec,0x96,0xa5,0x06,0x32,0xda,0xa6,0x6a,0x5a,0x04,0x7b,
+0xfa,0x25,0x2e,0x8c,0x4d,0x9a,0x26,0x55,0xea,0x97,0x3f,0x9f,0x2d,0x37,0x29,0x6e,
+0x2f,0x4d,0x2d,0xce,0xd4,0x07,0xe7,0xdb,0x4d,0xa6,0x9e,0x20,0x13,0xd4,0x5a,0x5f,
+0xb9,0xf6,0xb0,0xc9,0x5e,0x77,0x2f,0xf9,0x2a,0xdb,0xea,0x19,0x5e,0x4c,0xaf,0x67,
+0x02,0x07,0x6f,0xe3,0x4b,0xa0,0xed,0xc9,0x0c,0xb1,0x22,0x1f,0x5c,0x43,0x7a,0x0e,
+0xb0,0xce,0xd5,0x3c,0x87,0xf9,0x4e,0x41,0xb9,0x58,0x95,0xaa,0x40,0xf9,0x5b,0xe1,
+0xa2,0x23,0xd9,0x53,0x18,0x1b,0x11,0x86,0x6b,0x4d,0x9b,0x2c,0x1c,0x8d,0xca,0xd2,
+0x8e,0x40,0xbf,0xdf,0x07,0x1a,0x34,0xa0,0xbc,0x11,0xa7,0xc1,0x7d,0xa6,0xe6,0x28,
+0x19,0x52,0x0b,0x79,0xef,0xc1,0xab,0xbd,0xab,0x49,0xb8,0x2a,0x8e,0x7d,0x6b,0x63,
+0xff,0x1e,0x07,0x8a,0xb7,0x58,0x79,0x9f,0x43,0x60,0xc3,0xa8,0xd6,0x05,0xe4,0xa0,
+0x92,0x06,0x50,0xa6,0x47,0x45,0xad,0x79,0x68,0xe6,0x1f,0xcd,0x3c,0xb4,0x43,0xef,
+0xc7,0x4e,0xdb,0x91,0x50,0x4e,0x38,0xa5,0xae,0xd2,0x0a,0x40,0xc5,0x30,0x12,0x47,
+0x63,0xa0,0x7e,0xf2,0x98,0xa6,0xec,0x5b,0x1b,0xef,0x5a,0xe3,0x2b,0xd2,0xf0,0xbc,
+0x5c,0xc6,0x61,0x12,0x72,0x58,0xd1,0xd9,0xd9,0x89,0xa3,0xe1,0x5a,0xdf,0xeb,0x45,
+0x3c,0x98,0x89,0x6e,0xa9,0xf9,0x88,0x9c,0x42,0x06,0x2e,0x93,0x3f,0xea,0x70,0xb8,
+0x76,0xa4,0xdf,0x6b,0x6f,0x4f,0x22,0x74,0x64,0x9d,0xa9,0x51,0x72,0xc6,0xbb,0xad,
+0x89,0x1f,0x14,0x75,0x16,0x50,0xf2,0x92,0x8f,0x3c,0x9d,0x72,0xba,0x7b,0xc9,0x97,
+0x8f,0x92,0x7f,0x85,0x2f,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0xbe,0x66,0xa2,0x82,
+0x3a,0x54,0xd3,0x61,0xaa,0x8e,0x30,0x4c,0xc8,0x36,0x3b,0x7a,0xa4,0xb9,0xef,0xfc,
+0x7a,0x5d,0x21,0xde
+};
+
+static void verify4(struct archive *a, struct archive_entry *ae)
+{
+ (void)a; /* UNUSED */
+ assertEqualInt(archive_entry_filetype(ae), AE_IFBLK);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+ assertEqualString(archive_entry_pathname(ae), "devblock");
+ assert(archive_entry_symlink(ae) == NULL);
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 86401);
+}
+
+/* Directory.
+#How to make
+mkdir dir1
+chown $UNAME:$GNAME dir1
+chmod 0755 dir1
+env TZ=utc touch -afm -t 197001020000.01 dir1
+xar -cf archive5.xar dir1
+od -t x1 archive5.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive5.xar.txt
+*/
+static unsigned char archive5[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x16,
+0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xec,0x00,0x00,0x00,0x01,0x78,0xda,0x74,0x91,
+0xc1,0x6e,0xc2,0x30,0x0c,0x86,0xef,0x3c,0x45,0xd4,0x7b,0x17,0xa7,0x83,0x31,0xaa,
+0x34,0xdc,0xf6,0x04,0xec,0xb2,0x5b,0x95,0x1a,0x88,0x68,0x1a,0x94,0xa4,0x13,0xdd,
+0xd3,0x2f,0x71,0xe9,0xd0,0xa4,0x4d,0xaa,0xd4,0x3f,0xbf,0x3f,0xff,0xb2,0x6c,0xb9,
+0xbf,0xd9,0x9e,0x7d,0xa2,0x0f,0xc6,0x0d,0x4d,0x21,0x9e,0xa0,0x60,0x38,0x68,0xd7,
+0x99,0xe1,0xd4,0x14,0xef,0x87,0xb7,0xf2,0xb5,0xd8,0xab,0x95,0xbc,0xb5,0x5e,0xad,
+0x98,0x8c,0x4e,0xa7,0x1f,0x93,0xda,0x63,0x1b,0x53,0x47,0x19,0x8d,0x45,0x55,0x01,
+0xec,0x4a,0x51,0x95,0x50,0x1d,0x04,0xd4,0x6b,0x51,0xaf,0x37,0x92,0xff,0x46,0xa8,
+0xe9,0x8c,0xfa,0x12,0x46,0xcb,0x42,0x9c,0x7a,0x6c,0x8a,0x70,0x6e,0x45,0x91,0x2b,
+0x4c,0xba,0xe3,0x31,0x60,0x54,0x20,0xf9,0x5d,0x91,0x1b,0xcc,0x57,0x0e,0x97,0x9c,
+0x44,0x8e,0xe0,0x4b,0x06,0xbd,0x8e,0xa6,0x47,0x66,0xba,0x34,0xf6,0x3d,0x46,0xff,
+0x3d,0xce,0x33,0x7c,0xa4,0xce,0x65,0x0e,0x26,0x2d,0x49,0xb1,0xdb,0x42,0x09,0x22,
+0x63,0x00,0x75,0xfe,0x44,0xc2,0xec,0x03,0x6b,0xff,0x49,0x7b,0x49,0x58,0xfb,0xc0,
+0x4e,0xde,0x8d,0x57,0xa5,0x47,0x94,0x7c,0x96,0xb3,0x6b,0x3a,0x25,0x00,0x44,0x32,
+0x93,0x22,0x6b,0x0c,0xe8,0x67,0x8e,0xd4,0xec,0xfd,0x60,0xe3,0x82,0x59,0xd7,0xa1,
+0x82,0xed,0x26,0xed,0x90,0x24,0x99,0x71,0xba,0xa2,0xea,0x8c,0x47,0x1d,0x9d,0x9f,
+0x24,0xa7,0x37,0x55,0x86,0xd6,0x52,0x25,0x45,0x90,0xa4,0x35,0xe5,0xcd,0xe4,0x7b,
+0x71,0x3a,0x98,0xe4,0x74,0xbe,0x6f,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x23,0x7a,
+0x8c,0x2f,0x78,0xe9,0x69,0x28,0x93,0x14,0x72,0x68,0x8d,0xeb,0x42,0x7b,0xf6,0x0f,
+0x70,0x64,0xa3,0xff,0xb9,0x35
+};
+
+static void verify5(struct archive *a, struct archive_entry *ae)
+{
+ (void)a; /* UNUSED */
+ assertEqualInt(archive_entry_filetype(ae), AE_IFDIR);
+ assertEqualInt(archive_entry_mtime(ae), 86401);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+}
+
+/* fifo
+#How to make
+mkfifo -m 0755 fifo
+chown $UNAME:$GNAME fifo
+env TZ=utc touch -afm -t 197001020000.01 fifo
+xar -cf archive6.xar fifo
+od -t x1 archive6.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive6.xar.txt
+*/
+static unsigned char archive6[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0e,
+0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe7,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x91,
+0xc1,0x6e,0xc3,0x20,0x0c,0x86,0xef,0x7d,0x0a,0xc4,0x3d,0xc3,0x64,0xab,0xda,0x46,
+0x94,0xde,0xf6,0x04,0xdd,0x65,0x37,0x44,0x9c,0x16,0x2d,0x84,0x2a,0x90,0xa9,0xdd,
+0xd3,0x0f,0x9c,0x66,0xd5,0xa4,0x69,0x12,0x52,0xbe,0xfc,0x7c,0xb6,0x2c,0xac,0x0e,
+0x57,0xdf,0xb3,0x4f,0x1c,0xa3,0x0b,0xc3,0x9e,0xcb,0x27,0xe0,0x0c,0x07,0x1b,0x5a,
+0x37,0x9c,0xf6,0xfc,0xed,0xf8,0x5a,0x6d,0xf9,0x41,0xaf,0xd4,0xd5,0x8c,0x7a,0xc5,
+0x54,0x0a,0x36,0x7f,0x98,0xb2,0x23,0x9a,0x94,0x2b,0xaa,0xe4,0x3c,0xea,0x1a,0x60,
+0x57,0xc9,0xba,0x82,0xfa,0x28,0x65,0xf3,0x02,0x4d,0xbd,0x55,0xe2,0xb7,0x42,0x45,
+0x67,0xb4,0x1f,0x71,0xf2,0x2c,0xa6,0x5b,0x8f,0x7b,0x1e,0xcf,0x46,0xf2,0x72,0xc3,
+0x54,0xe8,0xba,0x88,0x49,0x83,0x12,0x77,0xa2,0x34,0xba,0xaf,0xd2,0x5c,0x09,0x82,
+0xd2,0x42,0x2c,0x3d,0xe8,0xaf,0x73,0x3d,0x32,0xd7,0xe6,0xb1,0xef,0x6d,0xec,0xdf,
+0xe3,0xc8,0xe7,0xf7,0x5c,0xb9,0xcc,0xc1,0x94,0x27,0x94,0xbb,0x0d,0x54,0x20,0x8b,
+0x06,0xd0,0x94,0x23,0xb3,0xe6,0x1f,0x9a,0xf9,0x47,0x33,0x0f,0xed,0x34,0x86,0xe9,
+0xa2,0xed,0x84,0x4a,0xcc,0x38,0xa7,0xae,0xd5,0x12,0x40,0xe6,0x30,0x13,0x45,0x53,
+0xc4,0x71,0xf6,0x88,0xe6,0xec,0x47,0x9b,0x16,0xcd,0x87,0x16,0x35,0x6c,0xd6,0xeb,
+0x3c,0x4c,0x41,0x0a,0xd3,0xed,0x82,0xba,0x73,0x5d,0x50,0x82,0x90,0xc2,0xc1,0xf8,
+0x25,0x24,0xa4,0x17,0x2a,0x8f,0x52,0x56,0x25,0x68,0x57,0x4a,0xd0,0xe6,0xbe,0x01,
+0x00,0x00,0xff,0xff,0x03,0x00,0x44,0x19,0x8a,0x2a,0x82,0xbc,0x8c,0xae,0x97,0xa7,
+0x7d,0x65,0xa5,0x82,0xdb,0xaa,0xc2,0xcb,0xbe,0xf0,0x1f,0xd1,0xf9,0x56
+};
+
+static void verify6(struct archive *a, struct archive_entry *ae)
+{
+ (void)a; /* UNUSED */
+ assertEqualInt(archive_entry_filetype(ae), AE_IFIFO);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0755);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+ assertEqualString(archive_entry_pathname(ae), "fifo");
+ assert(archive_entry_symlink(ae) == NULL);
+ assert(archive_entry_hardlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 86401);
+}
+
+/* Verify that a file records with directory name.
+#How to make
+mkdir dir1
+echo "hellohellohello" > dir1/f1
+chown $UNAME:$GNAME dir1/f1
+chmod 0644 dir1/f1
+env TZ=utc touch -afm -t 197001020000.01 dir1/f1
+xar -cf archive7.xar dir1/f1
+od -t x1 archive7.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive7.xar.txt
+*/
+
+static unsigned char archive7[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xbb,
+0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x8a,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x53,
+0xc9,0x6e,0xdb,0x30,0x14,0xbc,0xe7,0x2b,0x04,0xdd,0x55,0x2e,0xa2,0x16,0x1a,0xb4,
+0x82,0x5e,0x8a,0xdc,0x93,0x5e,0x7a,0xa3,0xb9,0xd8,0x44,0xb5,0x41,0xa2,0x02,0x3b,
+0x5f,0x5f,0x92,0xa2,0x1c,0xbb,0x59,0x00,0x01,0x1a,0x3e,0xce,0x1b,0x0d,0x9f,0x86,
+0xec,0xf1,0xdc,0xb5,0xc9,0xab,0x9a,0x66,0x33,0xf4,0xfb,0x14,0xfd,0x80,0x69,0xa2,
+0x7a,0x31,0x48,0xd3,0x1f,0xf7,0xe9,0xef,0x97,0x5f,0x59,0x9d,0x3e,0x36,0x0f,0xec,
+0xcc,0xa7,0xe6,0x21,0x61,0x76,0x10,0xee,0x95,0x30,0x31,0x29,0x6e,0x5d,0x47,0x66,
+0x4d,0xa7,0x1a,0x0c,0x21,0xcd,0x10,0xce,0x20,0x7e,0x41,0x68,0x57,0xe0,0x5d,0x51,
+0x31,0x70,0x4f,0x09,0x4d,0x27,0x25,0xfe,0xce,0x4b,0x97,0xcc,0xf6,0xd2,0xaa,0x7d,
+0x3a,0x9f,0x38,0x4a,0xfd,0x4e,0xc2,0x06,0xad,0x67,0x65,0x1b,0xc8,0x40,0x44,0xa1,
+0x3a,0x9b,0x37,0x2f,0xce,0x40,0x00,0x5e,0x02,0x6c,0x1a,0x61,0xa5,0x4d,0xab,0x12,
+0x23,0x9d,0xed,0x28,0x63,0x2f,0xa3,0x6a,0xa4,0x99,0x94,0xb0,0xc3,0x74,0x61,0x20,
+0xac,0xc3,0x4e,0xcf,0xbb,0xb0,0x83,0x18,0x08,0x30,0x14,0xaf,0xfd,0x78,0xed,0x4f,
+0x98,0xe4,0x96,0xaf,0x30,0x61,0xad,0xea,0x8f,0xf6,0xd4,0xe0,0x9c,0x81,0x08,0xe3,
+0x46,0xb4,0x88,0xef,0xdd,0x6e,0x7e,0x51,0xf9,0xee,0xd7,0x17,0xb7,0x69,0x6e,0xa7,
+0xe6,0xe3,0xd8,0x1a,0x11,0x46,0x03,0xce,0xd9,0xf1,0xcd,0x8c,0x29,0xd8,0xb8,0x7c,
+0x12,0x27,0xf3,0xaa,0x64,0xf6,0xff,0xa8,0x9e,0x9f,0x7e,0xba,0x33,0xea,0x3a,0xcf,
+0x25,0xd6,0x52,0x20,0x9a,0x13,0x9a,0xf3,0x03,0xa9,0x29,0x97,0x1c,0xe7,0xba,0xd6,
+0x15,0x45,0xba,0xc4,0x5a,0xe4,0x25,0xad,0x19,0xf8,0x20,0x74,0x75,0x73,0xb6,0x13,
+0x17,0xf6,0xcb,0x4f,0x14,0xb2,0x22,0x07,0x71,0x10,0x15,0x95,0xb9,0xa6,0x07,0x4d,
+0xb8,0x76,0xe2,0xa4,0xae,0x6b,0xa8,0x48,0x81,0xcb,0x82,0x68,0x05,0x05,0xa5,0x0c,
+0x7c,0x54,0x8a,0x33,0x04,0xef,0x43,0x64,0xe2,0xf3,0x7c,0x90,0xfa,0x8f,0xfb,0x95,
+0x5b,0x30,0x1c,0xaf,0x0b,0x18,0xd1,0x0a,0x66,0x10,0x79,0x1e,0x84,0x3b,0xff,0x20,
+0xc7,0xeb,0x6e,0x78,0xfc,0x1b,0x1e,0xbf,0xe1,0x1d,0xa7,0x61,0x19,0x1b,0xb1,0x28,
+0x06,0x56,0x18,0xcb,0x46,0x36,0x08,0x42,0x17,0x02,0x8f,0xd6,0xda,0x32,0xab,0x69,
+0x65,0x06,0x14,0x8b,0x57,0xe2,0x72,0x25,0x76,0x83,0x54,0x0d,0x2c,0x09,0x71,0x96,
+0x3c,0x5c,0xab,0x21,0x62,0x3e,0x48,0x37,0x69,0x8b,0x71,0xd3,0x77,0x61,0x03,0x9e,
+0xb4,0x86,0x38,0x22,0xd7,0xe1,0xaf,0x13,0x03,0xe1,0x72,0xfd,0x03,0x00,0x00,0xff,
+0xff,0x03,0x00,0x8d,0xb1,0x06,0x76,0xa6,0x7a,0xc3,0xbb,0x13,0x3d,0x45,0xe2,0x2b,
+0x3b,0xd0,0x88,0xc7,0x58,0x7b,0xbd,0x30,0x9d,0x01,0x44,0x78,0xda,0xca,0x48,0xcd,
+0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,
+0x06,0x47
+};
+
+static void verify7(struct archive *a, struct archive_entry *ae)
+{
+ (void)a; /* UNUSED */
+ assert(archive_entry_filetype(ae) == AE_IFREG);
+ assertEqualInt(archive_entry_mode(ae) & 0777, 0644);
+ assertEqualInt(archive_entry_uid(ae), UID);
+ assertEqualInt(archive_entry_gid(ae), GID);
+ assertEqualString(archive_entry_uname(ae), UNAME);
+ assertEqualString(archive_entry_gname(ae), GNAME);
+ assertEqualString(archive_entry_pathname(ae), "dir1/f1");
+ assert(archive_entry_hardlink(ae) == NULL);
+ assert(archive_entry_symlink(ae) == NULL);
+ assertEqualInt(archive_entry_mtime(ae), 86401);
+}
+
+/* Verify that a file records with bzip2 compression
+#How to make
+echo "hellohellohello" > f1
+chown $UNAME:$GNAME f1
+chmod 0644 f1
+env TZ=utc touch -afm -t 197001020000.01 f1
+xar --compression bzip2 -cf archive8.xar f1
+od -t x1 archive8.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive8.xar.txt
+*/
+
+static unsigned char archive8[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xb1,
+0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x42,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x53,
+0xcb,0x6e,0xdc,0x20,0x14,0xdd,0xe7,0x2b,0x90,0xf7,0x0e,0x60,0xe3,0x07,0x23,0x86,
+0xa8,0x9b,0xa8,0xfb,0x4e,0x37,0xdd,0x61,0x1e,0x63,0x14,0xbf,0x64,0xe3,0x68,0x92,
+0xaf,0x2f,0x60,0x3b,0xa3,0x34,0x6d,0x25,0x4b,0x3e,0x1c,0x0e,0xe7,0x5e,0xee,0xe5,
+0xb2,0xa7,0x5b,0xdf,0x81,0x57,0x3d,0x2f,0x76,0x1c,0xce,0x09,0x7e,0x44,0x09,0xd0,
+0x83,0x1c,0x95,0x1d,0xae,0xe7,0xe4,0xe7,0xe5,0x39,0xad,0x93,0x27,0xfe,0xc0,0x6e,
+0x62,0xe6,0x0f,0x80,0xb9,0x51,0xfa,0x1f,0x60,0x72,0xd6,0xc2,0xf9,0x13,0xa9,0xb3,
+0xbd,0xe6,0x19,0x42,0x34,0xc5,0x59,0x8a,0xc8,0x05,0xd1,0x13,0xc6,0x27,0x9c,0x33,
+0xf8,0x59,0x12,0x0f,0xb5,0x5a,0xbe,0x2c,0x6b,0x0f,0x16,0xf7,0xd6,0xe9,0x73,0xb2,
+0xb4,0x02,0x27,0x61,0x07,0xb0,0xd1,0x98,0x45,0x3b,0x8e,0x18,0xdc,0x51,0x64,0x17,
+0xfb,0x1e,0xcc,0x19,0x8c,0x20,0x58,0xc0,0xc3,0x23,0xae,0x8c,0xed,0x34,0xb0,0xca,
+0xa7,0xbd,0xdb,0x28,0xe1,0x44,0x44,0x80,0x75,0x7a,0xb8,0xba,0x96,0x13,0xc2,0xe0,
+0x0e,0x37,0x7e,0xf7,0xcf,0x3e,0x87,0xda,0x63,0xe1,0xf2,0x1e,0xcb,0x73,0x47,0x21,
+0x8e,0x84,0xc5,0x34,0x75,0x56,0xc6,0x5b,0xc1,0x5b,0xda,0xbc,0xdb,0x29,0x4b,0xe0,
+0xae,0x15,0xb3,0x6c,0xed,0xab,0x56,0xe9,0x9f,0xb7,0xfc,0xf1,0xfd,0x9b,0x4f,0xcf,
+0xe4,0xa4,0x28,0x4a,0x94,0xcb,0x3a,0xcf,0x9b,0x26,0x93,0xaa,0x92,0xba,0x29,0xa8,
+0x2a,0x89,0x29,0xa8,0x50,0x22,0x97,0x45,0xa1,0x71,0xe5,0xeb,0xf6,0xc5,0xe8,0x48,
+0xe6,0xe6,0x66,0x21,0xdd,0x3f,0x23,0x14,0xaa,0x22,0x8d,0x6c,0x64,0x45,0x55,0x6e,
+0x68,0x63,0x88,0x30,0xa6,0x36,0xa4,0xae,0x6b,0xa4,0x49,0x91,0x95,0x05,0x31,0x1a,
+0x49,0x4a,0x19,0xfc,0xea,0xb4,0x55,0x0f,0x7e,0x94,0x8f,0xc9,0xbf,0xf7,0x15,0xd5,
+0xbf,0x7c,0x0b,0x8e,0x86,0x02,0xd6,0x47,0x88,0x69,0x85,0x52,0x84,0x53,0x94,0x5d,
+0x10,0x3a,0x85,0x0f,0x7b,0x59,0x7f,0x97,0x89,0xff,0xc8,0xc4,0x5d,0x76,0x9d,0xc7,
+0x75,0xe2,0x72,0xd5,0x0c,0x6e,0x70,0x63,0xad,0xe2,0x18,0x21,0xec,0x49,0x8f,0x22,
+0xb5,0x2e,0x7a,0xde,0x74,0x11,0x6d,0xdc,0x87,0x6c,0x3d,0x64,0xfd,0xa8,0x34,0x47,
+0x65,0x78,0x02,0x11,0x46,0xd2,0xbd,0x4d,0x1a,0x74,0x76,0x78,0x39,0x27,0xe3,0x6c,
+0xaf,0x76,0x10,0x5d,0xc2,0x5b,0x31,0xab,0xc0,0x31,0x18,0xb6,0x37,0xe1,0x20,0x7c,
+0x5e,0xc6,0xfb,0x45,0x10,0x1f,0x5f,0x78,0x6f,0x61,0x0a,0x60,0x1c,0x03,0x06,0xe3,
+0x50,0xfc,0x06,0x00,0x00,0xff,0xff,0x03,0x00,0x19,0xcf,0xf5,0xc0,0xf9,0x65,0xe8,
+0x78,0xc3,0xfa,0x5f,0x0a,0xf6,0x09,0x17,0xd8,0xb0,0x54,0xb9,0x02,0x8d,0x91,0x31,
+0x9c,0x42,0x5a,0x68,0x39,0x31,0x41,0x59,0x26,0x53,0x59,0xc1,0x52,0x36,0xf7,0x00,
+0x00,0x03,0x41,0x00,0x00,0x10,0x02,0x44,0xa0,0x00,0x21,0xb4,0x01,0x9a,0x0d,0x46,
+0xa5,0x32,0x38,0xbb,0x92,0x29,0xc2,0x84,0x86,0x0a,0x91,0xb7,0xb8
+};
+
+/* Verify that a file records with no compression
+#How to make
+echo "hellohellohello" > f1
+chown $UNAME:$GNAME f1
+chmod 0644 f1
+env TZ=utc touch -afm -t 197001020000.01 f1
+xar --compression none -cf archive9.xar f1
+od -t x1 archive9.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive9.xar.txt
+*/
+
+static unsigned char archive9[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x98,
+0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x47,0x00,0x00,0x00,0x01,0x78,0xda,0xa4,0x53,
+0x4d,0x6f,0xe3,0x20,0x14,0xbc,0xf7,0x57,0x20,0xee,0x5e,0xc0,0x25,0x89,0x1d,0x11,
+0xaa,0x5e,0xaa,0xbd,0x6f,0xf6,0xb2,0x37,0x02,0x8f,0x18,0xc5,0x1f,0x11,0xc6,0x55,
+0xba,0xbf,0x7e,0x01,0xdb,0xad,0xba,0x55,0x7b,0xa9,0x64,0xc9,0xe3,0x61,0xde,0x78,
+0x78,0xf0,0xc4,0xc3,0xad,0x6b,0xd1,0x33,0xf8,0xd1,0x0d,0xfd,0x01,0xb3,0x1f,0x14,
+0x23,0xe8,0xf5,0x60,0x5c,0x7f,0x3e,0xe0,0xdf,0xc7,0xa7,0xa2,0xc2,0x0f,0xf2,0x4e,
+0xdc,0x94,0x97,0x77,0x48,0x84,0x41,0xc7,0x17,0x12,0xda,0x83,0x0a,0xb1,0xa2,0x08,
+0xae,0x03,0x59,0x52,0x5a,0x17,0xac,0x2c,0x28,0x3f,0xd2,0x7a,0xcf,0xaa,0x3d,0xaf,
+0x05,0x79,0x2f,0xc9,0x45,0x0d,0xe8,0xcb,0x38,0x75,0x68,0x0c,0x2f,0x2d,0x1c,0xf0,
+0xd8,0x28,0x86,0xd3,0x0a,0x12,0x83,0xb5,0x23,0x04,0x49,0x05,0x59,0x50,0x66,0x47,
+0xf7,0x37,0x99,0x0b,0x92,0x41,0xb2,0x20,0xab,0x47,0xfe,0xb2,0xae,0x05,0xe4,0x4c,
+0x8c,0xbd,0xd8,0x18,0x15,0x54,0x46,0x48,0xb4,0xd0,0x9f,0x43,0x23,0xd9,0x56,0x90,
+0x05,0xce,0xfc,0xba,0xb9,0x35,0x84,0xba,0x5e,0x5b,0xa7,0x73,0x52,0x32,0xe8,0x00,
+0xa1,0x18,0x43,0x4c,0xde,0x61,0xb2,0x14,0x2c,0x81,0xca,0xf7,0xd9,0x96,0x70,0xc9,
+0x7e,0x0d,0x17,0x39,0xe5,0x75,0xe3,0x9e,0xc1,0x14,0xff,0x6f,0xf5,0xd7,0xcf,0xc7,
+0x98,0x71,0x63,0x76,0xfc,0xa4,0x4f,0x7a,0x57,0x9b,0x7b,0x5b,0x9f,0x2c,0x57,0xd6,
+0x56,0x96,0x57,0x55,0x45,0x81,0x6f,0xca,0xed,0x86,0x5b,0xa0,0xba,0x8e,0xcd,0xfb,
+0x60,0xb4,0xa6,0xbf,0x05,0xaf,0x62,0xca,0xef,0xff,0xe1,0xa3,0xd3,0xdc,0x42,0xf2,
+0xda,0x43,0xa1,0x3f,0x39,0xdc,0xed,0x9f,0x78,0x0e,0xeb,0xa9,0x22,0xd1,0x65,0xc8,
+0xea,0x1d,0x2d,0x28,0x2b,0x68,0x79,0xa4,0x74,0x9f,0x1e,0x16,0x65,0xdd,0x9b,0x4c,
+0x7d,0x21,0x53,0x6f,0xb2,0xb3,0x1f,0xa6,0xab,0xd4,0x13,0x08,0x32,0xc3,0x99,0x75,
+0x46,0x32,0x4a,0x59,0x24,0x23,0xca,0xd4,0x34,0x82,0x9f,0x75,0x19,0xcd,0xdc,0xab,
+0x6c,0x5a,0x65,0xdd,0x60,0x40,0xd2,0x2d,0xe7,0x31,0x4c,0x82,0x99,0x0c,0x2f,0x57,
+0x40,0xad,0xeb,0x2f,0x07,0x3c,0x78,0x77,0x76,0xbd,0x6a,0xb1,0x6c,0x94,0x37,0x89,
+0x13,0x24,0x2d,0xcf,0xc2,0x5e,0xc5,0x5c,0x36,0xfa,0x65,0x90,0x6f,0x60,0xba,0x74,
+0x69,0x14,0x48,0x9e,0x05,0x41,0xf2,0x64,0xfc,0x03,0x00,0x00,0xff,0xff,0x03,0x00,
+0xee,0x8e,0xf8,0x75,0xa1,0xaf,0x74,0x71,0x3f,0x40,0x08,0xab,0x13,0x7d,0xc0,0x82,
+0x3a,0x56,0xeb,0x4e,0x35,0xf1,0x35,0xb7,0x68,0x65,0x6c,0x6c,0x6f,0x68,0x65,0x6c,
+0x6c,0x6f,0x68,0x65,0x6c,0x6c,0x6f,0x0a
+};
+
+/* Verify that a file records with md5 hashing algorithm
+#How to make
+echo "hellohellohello" > f1
+chown $UNAME:$GNAME f1
+chmod 0644 f1
+env TZ=utc touch -afm -t 197001020000.01 f1
+xar --toc-cksum md5 -cf archive10.xar f1
+od -t x1 archive10.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive10.xar.txt
+*/
+
+static unsigned char archive10[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xaf,
+0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x40,0x00,0x00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0xb7,0x18,
+0xe8,0x34,0x20,0x06,0x5c,0x66,0x9a,0x43,0x26,0xe7,0x94,0x78,0xda,0xca,0x48,0xcd,
+0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,
+0x06,0x47
+};
+
+/* Verify that a file records with no hashing algorithm
+#How to make
+echo "hellohellohello" > f1
+chown $UNAME:$GNAME f1
+chmod 0644 f1
+env TZ=utc touch -afm -t 197001020000.01 f1
+xar --toc-cksum none -cf archive11.xar f1
+od -t x1 archive11.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive11.xar.txt
+*/
+
+static unsigned char archive11[] = {
+0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x98,
+0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xef,0x00,0x00,0x00,0x00,0x78,0xda,0x7c,0x52,
+0xcb,0x6e,0xeb,0x20,0x14,0xdc,0xf7,0x2b,0x10,0x7b,0x17,0xb0,0x89,0x63,0x22,0x42,
+0x75,0x37,0x55,0xf7,0xcd,0xdd,0x74,0x47,0x78,0x38,0xa8,0x7e,0xc9,0xc6,0x55,0xda,
+0xaf,0xbf,0x3c,0xe2,0x56,0x55,0xd5,0x2b,0x21,0x79,0x3c,0xcc,0x39,0x67,0x74,0x18,
+0xfe,0x70,0xed,0x3b,0xf0,0x66,0xe6,0xc5,0x8d,0xc3,0x11,0x92,0x7b,0x0c,0x81,0x19,
+0xd4,0xa8,0xdd,0xd0,0x1e,0xe1,0xdf,0xd3,0x63,0xd1,0xc0,0x07,0x71,0xc7,0xaf,0x72,
+0x16,0x77,0x80,0xfb,0x51,0x85,0x0f,0xe0,0x6a,0x36,0xd2,0x87,0x8a,0xc2,0xbb,0xde,
+0x88,0x12,0x63,0x56,0x90,0xb2,0xc0,0xf4,0x44,0xf0,0x81,0x54,0x07,0x5a,0x73,0xf4,
+0x5d,0x12,0x8b,0xac,0xeb,0x0c,0x70,0x3a,0x4c,0x81,0xf1,0x1f,0x70,0x2d,0xbd,0x4c,
+0x08,0xf0,0xce,0x0c,0xad,0xbf,0x88,0xb2,0xe2,0xe8,0x06,0x33,0x3f,0x5a,0xbb,0x18,
+0x2f,0x30,0x47,0x37,0x94,0xe9,0xc5,0x7d,0x18,0x41,0xc2,0x94,0x04,0x32,0xb7,0xd9,
+0x06,0x8b,0x7f,0xef,0xcc,0x11,0xca,0x69,0xea,0x9c,0x4a,0x1e,0xd0,0xb5,0x68,0x3f,
+0xdc,0x04,0xd1,0x4d,0x2a,0x67,0x75,0x71,0x6f,0x46,0x17,0xea,0x62,0xd4,0xeb,0xb2,
+0xf6,0x5b,0xcd,0xf3,0xd3,0x9f,0x60,0xce,0x36,0x55,0xa5,0x4b,0xab,0x15,0x61,0x15,
+0x65,0x95,0x3c,0xd3,0x86,0x49,0x2d,0xcb,0xca,0x36,0x76,0xcf,0x88,0xad,0x4b,0xab,
+0xaa,0x9a,0x35,0x1c,0xfd,0x68,0xb4,0x79,0xb9,0xfa,0x59,0x2a,0xff,0xeb,0x84,0x9d,
+0xde,0xd3,0xb3,0x3a,0xab,0x3d,0xd3,0x95,0x65,0x67,0x4b,0xa5,0x0d,0xbd,0x69,0xd3,
+0x34,0xd8,0xd0,0x5d,0x59,0xef,0xa8,0x35,0x58,0x31,0xc6,0xd1,0xcf,0x4e,0x79,0x77,
+0xe8,0x73,0x79,0x5c,0xfd,0xf2,0x08,0xe4,0x25,0xbc,0xc2,0xb6,0x7d,0xc0,0xfb,0x04,
+0x09,0xdb,0xe3,0x02,0x93,0x02,0x97,0x27,0x8c,0x0f,0xf1,0x44,0x59,0xff,0x25,0x93,
+0xff,0x91,0xc9,0x2f,0x59,0x3b,0x8f,0xeb,0x24,0xd4,0x6a,0x38,0xca,0x30,0xb3,0x4e,
+0x0b,0x82,0x31,0x09,0x64,0x40,0x89,0x5a,0x17,0x33,0x67,0x5d,0x42,0x99,0xfb,0x94,
+0xad,0x9b,0xac,0x1f,0xb5,0x11,0xb8,0xa6,0x34,0x98,0x89,0x30,0x91,0xfe,0x7d,0x32,
+0xa0,0x73,0xc3,0xeb,0x11,0x8e,0xb3,0x6b,0xdd,0x20,0x3b,0x28,0x2e,0x72,0xd6,0x91,
+0xe3,0x28,0x5e,0x67,0xe1,0x20,0x83,0x2f,0x1b,0xfa,0x25,0x10,0xc3,0x86,0x62,0xda,
+0x62,0x64,0x51,0xca,0x2c,0x47,0x29,0xc1,0xff,0x00,0x00,0x00,0xff,0xff,0x03,0x00,
+0xf1,0x18,0xdc,0x71,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,
+0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47
+};
+
+enum enc {
+ GZIP,
+ BZIP2
+};
+
+static void verify(unsigned char *d, size_t s,
+ void (*f1)(struct archive *, struct archive_entry *),
+ void (*f2)(struct archive *, struct archive_entry *),
+ enum enc etype)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ unsigned char *buff;
+ int r;
+
+ assert((a = archive_read_new()) != NULL);
+ switch (etype) {
+ case BZIP2:
+ /* This is only check whether bzip is supported or not.
+ * This filter won't be used this test. */
+ if (ARCHIVE_OK != archive_read_support_compression_bzip2(a)) {
+ skipping("Unsupported bzip2");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ break;
+ case GZIP:
+ /* This gzip must be needed. archive_read_support_format_xar()
+ * will return a warning if gzip is unsupported. */
+ break;
+ }
+ assertA(0 == archive_read_support_compression_all(a));
+ r = archive_read_support_format_xar(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("xar reading not fully supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assert((buff = malloc(100000)) != NULL);
+ if (buff == NULL)
+ return;
+ memcpy(buff, d, s);
+ memset(buff + s, 0, 2048);
+
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_open_memory(a, buff, s + 1024));
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR);
+ /* Verify the only entry. */
+ f1(a, ae);
+ if (f2) {
+ assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE);
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR);
+ /* Verify the only entry. */
+ f2(a, ae);
+ }
+ /* End of archive. */
+ assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae));
+
+ assertA(0 == archive_read_close(a));
+ assertA(0 == archive_read_finish(a));
+ free(buff);
+}
+
+DEFINE_TEST(test_read_format_xar)
+{
+ verify(archive1, sizeof(archive1), verify0, verify1, GZIP);
+ verify(archive2, sizeof(archive2), verify0, verify2, GZIP);
+ verify(archive3, sizeof(archive3), verify3, NULL, GZIP);
+ verify(archive4, sizeof(archive4), verify4, NULL, GZIP);
+ verify(archive5, sizeof(archive5), verify5, NULL, GZIP);
+ verify(archive6, sizeof(archive6), verify6, NULL, GZIP);
+ verify(archive7, sizeof(archive7), verify7, NULL, GZIP);
+ verify(archive8, sizeof(archive8), verify0, NULL, BZIP2);
+ verify(archive9, sizeof(archive9), verify0, NULL, GZIP);
+ verify(archive10, sizeof(archive10), verify0, NULL, GZIP);
+ verify(archive11, sizeof(archive11), verify0, NULL, GZIP);
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_zip.c b/archivers/libarchive/files/libarchive/test/test_read_format_zip.c
index 50e522bb4d5..680e7ede360 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_zip.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_zip.c
@@ -23,7 +23,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_zip.c,v 1.3 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_format_zip.c 189482 2009-03-07 03:30:35Z kientzle $");
+
+/*
+ * The reference file for this has been manually tweaked so that:
+ * * file2 has length-at-end but file1 does not
+ * * file2 has an invalid CRC
+ */
DEFINE_TEST(test_read_format_zip)
{
@@ -34,6 +40,7 @@ DEFINE_TEST(test_read_format_zip)
const void *pv;
size_t s;
off_t o;
+ int r;
extract_reference_file(refname);
assert((a = archive_read_new()) != NULL);
@@ -46,26 +53,39 @@ DEFINE_TEST(test_read_format_zip)
assertEqualInt(0, archive_entry_size(ae));
assertEqualIntA(a, ARCHIVE_EOF,
archive_read_data_block(a, &pv, &s, &o));
- assertEqualInt(s, 0);
+ assertEqualInt((int)s, 0);
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("file1", archive_entry_pathname(ae));
assertEqualInt(1179604289, archive_entry_mtime(ae));
assertEqualInt(18, archive_entry_size(ae));
- assertEqualInt(18, archive_read_data(a, buff, 18));
+ failure("archive_read_data() returns number of bytes read");
+ r = archive_read_data(a, buff, 19);
+ if (r < ARCHIVE_OK) {
+ if (strcmp(archive_error_string(a),
+ "libarchive compiled without deflate support (no libz)") == 0) {
+ skipping("Skipping ZIP compression check: %s",
+ archive_error_string(a));
+ goto finish;
+ }
+ }
+ assertEqualInt(18, r);
assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("file2", archive_entry_pathname(ae));
assertEqualInt(1179605932, archive_entry_mtime(ae));
- assertEqualInt(18, archive_entry_size(ae));
- assertEqualInt(18, archive_read_data(a, buff, 18));
+ failure("file2 has length-at-end, so we shouldn't see a valid size");
+ assertEqualInt(0, archive_entry_size_is_set(ae));
+ failure("file2 has a bad CRC, so reading to end should fail");
+ assertEqualInt(ARCHIVE_WARN, archive_read_data(a, buff, 19));
assert(0 == memcmp(buff, "hello\nhello\nhello\n", 18));
assertA(archive_compression(a) == ARCHIVE_COMPRESSION_NONE);
assertA(archive_format(a) == ARCHIVE_FORMAT_ZIP);
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+finish:
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu b/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu
index f61340e2f93..b1f04c4fea0 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu
+++ b/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu
@@ -1,13 +1,14 @@
-$FreeBSD$
-begin 645 test_read_format_zip.zip
-M4$L#!`H``````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1AE5
-M3T95>`0`Z`/H`U!+`P04````"`!O9K,V.C=F/0H````2````!0`5`&9I;&4Q
-M550)``-!54]&K%M/1E5X!`#H`^@#RTC-R<GGRD`B`5!+`P04````"`!::K,V
-M.C=F/0H````2````!0`5`&9I;&4R550)``.L6T]&K%M/1E5X!`#H`^@#RTC-
-MR<GGRD`B`5!+`0(7`PH``````%EFLS8````````````````$``T`````````
-M$`#M00````!D:7(O550%``,954]&57@``%!+`0(7`Q0````(`&]FLS8Z-V8]
-M"@```!(````%``T```````$```"D@3<```!F:6QE,554!0`#055/1E5X``!0
-M2P$"%P,4````"`!::K,V.C=F/0H````2````!0`-```````!````I(%Y````
-H9FEL93)55`4``ZQ;3T95>```4$L%!@`````#``,`OP```+L`````````
+$FreeBSD: src/lib/libarchive/test/test_read_format_zip.zip.uu,v 1.3 2008/10/21 05:08:35 kientzle Exp $
+begin 644 test_read_format_zip.zip
+M4$L#!`H`"````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1M19
+M_4A5>`0`Z`/H`U!+!P@```````````````!02P,$%`````@`;V:S-CHW9CT*
+M````$@````4`%0!F:6QE,554"0`#055/1L!9_4A5>`0`Z`/H`\M(S<G)Y\I`
+M(@%02P,$%``(``@`6FJS-@``````````$@````4`%0!F:6QE,E54"0`#K%M/
+M1L!9_4A5>`0`Z`/H`\M(S<G)Y\I`(@%02P<(.C=F$@H````2````4$L!`A<#
+M"@`(````66:S-@````````````````0`#0`````````0`.U!`````&1I<B]5
+M5`4``QE53T95>```4$L!`A<#%``(``@`;V:S-CHW9CT*````$@````4`#0``
+M`````0```.V!1P```&9I;&4Q550%``-!54]&57@``%!+`0(7`Q0`"``(`%IJ
+MLS8Z-V8]"@```!(````%``T```````$```#M@8D```!F:6QE,E54!0`#K%M/
+;1E5X``!02P4&``````,``P"_````VP``````
`
end
diff --git a/archivers/libarchive/files/libarchive/test/test_read_large.c b/archivers/libarchive/files/libarchive/test/test_read_large.c
index d0342407cd8..a2be6017865 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_large.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_large.c
@@ -23,21 +23,27 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_large.c,v 1.3 2007/05/29 01:00:21 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_large.c 201247 2009-12-30 05:59:21Z kientzle $");
static unsigned char testdata[10 * 1024 * 1024];
static unsigned char testdatacopy[10 * 1024 * 1024];
static unsigned char buff[11 * 1024 * 1024];
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define open _open
+#define close _close
+#endif
+
/* Check correct behavior on large reads. */
DEFINE_TEST(test_read_large)
{
unsigned int i;
int tmpfilefd;
- char tmpfilename[] = "/tmp/test-read_large.XXXXXX";
+ char tmpfilename[] = "test-read_large.XXXXXX";
size_t used;
struct archive *a;
struct archive_entry *entry;
+ FILE *f;
for (i = 0; i < sizeof(testdata); i++)
testdata[i] = (unsigned char)(rand());
@@ -51,12 +57,8 @@ DEFINE_TEST(test_read_large)
archive_entry_set_pathname(entry, "test");
assertA(0 == archive_write_header(a, entry));
archive_entry_free(entry);
- assertA(sizeof(testdata) == archive_write_data(a, testdata, sizeof(testdata)));
-#if ARCHIVE_API_VERSION > 1
+ assertA((int)sizeof(testdata) == archive_write_data(a, testdata, sizeof(testdata)));
assertA(0 == archive_write_finish(a));
-#else
- archive_write_finish(a);
-#endif
assert(NULL != (a = archive_read_new()));
assertA(0 == archive_read_support_format_all(a));
@@ -64,11 +66,7 @@ DEFINE_TEST(test_read_large)
assertA(0 == archive_read_open_memory(a, buff, sizeof(buff)));
assertA(0 == archive_read_next_header(a, &entry));
assertA(0 == archive_read_data_into_buffer(a, testdatacopy, sizeof(testdatacopy)));
-#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
assert(0 == memcmp(testdata, testdatacopy, sizeof(testdata)));
@@ -77,18 +75,19 @@ DEFINE_TEST(test_read_large)
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_open_memory(a, buff, sizeof(buff)));
assertA(0 == archive_read_next_header(a, &entry));
- assert(0 < (tmpfilefd = mkstemp(tmpfilename)));
- assertA(0 == archive_read_data_into_fd(a, tmpfilefd));
- close(tmpfilefd);
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_read_finish(a));
+#if defined(__BORLANDC__)
+ tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY);
#else
- archive_read_finish(a);
+ tmpfilefd = open(tmpfilename, O_WRONLY | O_CREAT | O_BINARY, 0755);
#endif
- tmpfilefd = open(tmpfilename, O_RDONLY);
- read(tmpfilefd, testdatacopy, sizeof(testdatacopy));
+ assert(0 < tmpfilefd);
+ assertA(0 == archive_read_data_into_fd(a, tmpfilefd));
close(tmpfilefd);
- assert(0 == memcmp(testdata, testdatacopy, sizeof(testdata)));
+ assertA(0 == archive_read_finish(a));
- unlink(tmpfilename);
+ f = fopen(tmpfilename, "rb");
+ assertEqualInt(sizeof(testdatacopy),
+ fread(testdatacopy, 1, sizeof(testdatacopy), f));
+ fclose(f);
+ assert(0 == memcmp(testdata, testdatacopy, sizeof(testdata)));
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c b/archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c
index 5e2c9c536b4..4e2a8134ec2 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_pax_truncated.c
@@ -23,15 +23,14 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_pax_truncated.c,v 1.2 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_pax_truncated.c 189483 2009-03-07 03:34:34Z kientzle $");
DEFINE_TEST(test_read_pax_truncated)
{
struct archive_entry *ae;
struct archive *a;
- ssize_t used, i;
- size_t buff_size = 1000000;
- ssize_t filedata_size = 100000;
+ size_t used, i, buff_size = 1000000;
+ size_t filedata_size = 100000;
char *buff = malloc(buff_size);
char *buff2 = malloc(buff_size);
char *filedata = malloc(filedata_size);
@@ -40,7 +39,8 @@ DEFINE_TEST(test_read_pax_truncated)
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_pax(a));
assertA(0 == archive_write_set_compression_none(a));
- assertA(0 == archive_write_open_memory(a, buff, buff_size, &used));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_open_memory(a, buff, buff_size, &used));
/*
* Write a file to it.
@@ -56,14 +56,15 @@ DEFINE_TEST(test_read_pax_truncated)
archive_entry_set_size(ae, filedata_size);
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
- assertA(filedata_size == archive_write_data(a, filedata, filedata_size));
+ assertA((ssize_t)filedata_size
+ == archive_write_data(a, filedata, filedata_size));
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/* Now, read back a truncated version of the archive and
@@ -72,7 +73,7 @@ DEFINE_TEST(test_read_pax_truncated)
assert((a = archive_read_new()) != NULL);
assertA(0 == archive_read_support_format_all(a));
assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == read_open_memory(a, buff, i, 13));
+ assertA(0 == read_open_memory2(a, buff, i, 13));
if (i < 1536) {
assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
@@ -98,16 +99,20 @@ DEFINE_TEST(test_read_pax_truncated)
* does not return an error if it can't consume
* it.) */
if (i < 1536 + 512*((filedata_size + 511)/512) + 512) {
- assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
+ failure("i=%d minsize=%d", i,
+ 1536 + 512*((filedata_size + 511)/512) + 512);
+ assertEqualIntA(a, ARCHIVE_FATAL,
+ archive_read_next_header(a, &ae));
} else {
- assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_next_header(a, &ae));
}
wrap_up:
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
@@ -141,16 +146,18 @@ DEFINE_TEST(test_read_pax_truncated)
* does not return an error if it can't consume
* it.) */
if (i < 1536 + 512*((filedata_size + 511)/512) + 512) {
- assertA(ARCHIVE_FATAL == archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_FATAL,
+ archive_read_next_header(a, &ae));
} else {
- assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_EOF,
+ archive_read_next_header(a, &ae));
}
wrap_up2:
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
@@ -167,10 +174,10 @@ DEFINE_TEST(test_read_pax_truncated)
assertA(0 == archive_read_open_memory(a, buff2, used));
assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/* Damage the size field in the pax attributes. */
@@ -182,10 +189,10 @@ DEFINE_TEST(test_read_pax_truncated)
assertA(0 == archive_read_open_memory(a, buff2, used));
assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/* Damage the size field in the pax attributes. */
@@ -199,10 +206,10 @@ DEFINE_TEST(test_read_pax_truncated)
assertA(0 == archive_read_open_memory(a, buff2, used));
assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/* Damage the size field in the pax attributes. */
@@ -217,10 +224,10 @@ DEFINE_TEST(test_read_pax_truncated)
assertA(0 == archive_read_open_memory(a, buff2, used));
assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/* Damage the size field in the pax attributes. */
@@ -233,10 +240,10 @@ DEFINE_TEST(test_read_pax_truncated)
assertA(0 == archive_read_open_memory(a, buff2, used));
assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/* Damage the size field in the pax attributes. */
@@ -248,10 +255,10 @@ DEFINE_TEST(test_read_pax_truncated)
assertA(0 == archive_read_open_memory(a, buff2, used));
assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/* Damage the ustar header. */
@@ -263,10 +270,10 @@ DEFINE_TEST(test_read_pax_truncated)
assertA(0 == archive_read_open_memory(a, buff2, used));
assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
/*
diff --git a/archivers/libarchive/files/libarchive/test/test_read_position.c b/archivers/libarchive/files/libarchive/test/test_read_position.c
index 3675e11a4b9..85b79672142 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_position.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_position.c
@@ -23,10 +23,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_position.c,v 1.3 2007/05/29 01:00:21 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_read_position.c 189389 2009-03-05 02:19:42Z kientzle $");
-static unsigned char nulls[10000000];
-static unsigned char buff[10000000];
+static unsigned char nulls[10000];
+static unsigned char buff[10000000];
/* Check that header_position tracks correctly on read. */
DEFINE_TEST(test_read_position)
@@ -34,42 +34,61 @@ DEFINE_TEST(test_read_position)
struct archive *a;
struct archive_entry *ae;
size_t write_pos;
- const size_t data_size = 1000000;
+ intmax_t read_position;
+ size_t i, j;
+ size_t data_sizes[] = {0, 5, 511, 512, 513};
- /* Create a simple archive_entry. */
- assert((ae = archive_entry_new()) != NULL);
- archive_entry_set_pathname(ae, "testfile");
- archive_entry_set_mode(ae, S_IFREG);
- archive_entry_set_size(ae, data_size);
+ /* Sanity test */
+ assert(sizeof(nulls) + 512 + 1024 <= sizeof(buff));
+ /* Create an archive. */
assert(NULL != (a = archive_write_new()));
assertA(0 == archive_write_set_format_pax_restricted(a));
assertA(0 == archive_write_set_bytes_per_block(a, 512));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &write_pos));
- assertA(0 == archive_write_header(a, ae));
- archive_entry_free(ae);
- assertA(data_size == (size_t)archive_write_data(a, nulls, sizeof(nulls)));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+
+ for (i = 0; i < sizeof(data_sizes)/sizeof(data_sizes[0]); ++i) {
+ /* Create a simple archive_entry. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_pathname(ae, "testfile");
+ archive_entry_set_mode(ae, S_IFREG);
+ archive_entry_set_size(ae, data_sizes[i]);
+ assertA(0 == archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertA(data_sizes[i]
+ == (size_t)archive_write_data(a, nulls, sizeof(nulls)));
+ }
assertA(0 == archive_write_close(a));
- archive_write_finish(a);
-#endif
- /* 512-byte header + data_size (rounded up) + 1024 end-of-archive */
- assert(write_pos == ((512 + data_size + 1024 + 511)/512)*512);
+ assertA(0 == archive_write_finish(a));
/* Read the archive back. */
assert(NULL != (a = archive_read_new()));
assertA(0 == archive_read_support_format_tar(a));
assertA(0 == archive_read_open_memory2(a, buff, sizeof(buff), 512));
- assert((intmax_t)0 == (intmax_t)archive_read_header_position(a));
- assertA(0 == archive_read_next_header(a, &ae));
- assert((intmax_t)0 == (intmax_t)archive_read_header_position(a));
- assertA(0 == archive_read_data_skip(a));
- assert((intmax_t)0 == (intmax_t)archive_read_header_position(a));
+
+ read_position = 0;
+ /* Initial header position is zero. */
+ assert(read_position == (intmax_t)archive_read_header_position(a));
+ for (j = 0; j < i; ++j) {
+ assertA(0 == archive_read_next_header(a, &ae));
+ assert(read_position
+ == (intmax_t)archive_read_header_position(a));
+ /* Every other entry: read, then skip */
+ if (j & 1)
+ assertEqualInt(ARCHIVE_OK,
+ archive_read_data_into_buffer(a, buff, 1));
+ assertA(0 == archive_read_data_skip(a));
+ /* read_data_skip() doesn't change header_position */
+ assert(read_position
+ == (intmax_t)archive_read_header_position(a));
+
+ read_position += 512; /* Size of header. */
+ read_position += (data_sizes[j] + 511) & ~511;
+ }
+
assertA(1 == archive_read_next_header(a, &ae));
- assert((intmax_t)((data_size + 511 + 512)/512)*512 == (intmax_t)archive_read_header_position(a));
+ assert(read_position == (intmax_t)archive_read_header_position(a));
assertA(0 == archive_read_close(a));
- assert((intmax_t)((data_size + 511 + 512)/512)*512 == (intmax_t)archive_read_header_position(a));
+ assert(read_position == (intmax_t)archive_read_header_position(a));
archive_read_finish(a);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_truncated.c b/archivers/libarchive/files/libarchive/test/test_read_truncated.c
index 726984c58c4..9b26b59818a 100644
--- a/archivers/libarchive/files/libarchive/test/test_read_truncated.c
+++ b/archivers/libarchive/files/libarchive/test/test_read_truncated.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_truncated.c,v 1.3 2007/05/29 01:00:21 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_truncated.c,v 1.4 2008/09/01 05:38:33 kientzle Exp $");
char buff[1000000];
char buff2[100000];
@@ -52,14 +52,14 @@ DEFINE_TEST(test_read_truncated)
archive_entry_set_size(ae, sizeof(buff2));
assertA(0 == archive_write_header(a, ae));
archive_entry_free(ae);
- assertA(sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2)));
+ assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2)));
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/* Now, read back a truncated version of the archive and
@@ -81,7 +81,7 @@ DEFINE_TEST(test_read_truncated)
assertA(ARCHIVE_FATAL == archive_read_data(a, buff2, sizeof(buff2)));
goto wrap_up;
} else {
- assertA(sizeof(buff2) == archive_read_data(a, buff2, sizeof(buff2)));
+ assertA((int)sizeof(buff2) == archive_read_data(a, buff2, sizeof(buff2)));
}
/* Verify the end of the archive. */
@@ -97,10 +97,10 @@ DEFINE_TEST(test_read_truncated)
}
wrap_up:
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
@@ -140,10 +140,10 @@ DEFINE_TEST(test_read_truncated)
}
wrap_up2:
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
}
diff --git a/archivers/libarchive/files/libarchive/test/test_read_uu.c b/archivers/libarchive/files/libarchive/test/test_read_uu.c
new file mode 100644
index 00000000000..a5de09af740
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_read_uu.c
@@ -0,0 +1,134 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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: head/lib/libarchive/test/test_read_uu.c 201248 2009-12-30 06:12:03Z kientzle $");
+
+static const char archive[] = {
+"begin 644 test_read_uu.Z\n"
+"M'YV0+@`('$BPH,&#\"!,J7,BP(4(8$&_4J`$\"`,08$F%4O)AQ(\\2/(#7&@#%C\n"
+"M!@T8-##.L`$\"QL@:-F(``%'#H<V;.'/J!%!G#ITP<BS\"H).FS<Z$1(T>/1A2\n"
+"IHU\"0%9=*G4JUJM6K6+-JW<JUJ]>O8,.*'4NVK-FS:-.J7<NVK=NW9P$`\n"
+"`\n"
+"end\n"
+};
+
+static const char archive64[] = {
+"begin-base64 644 test_read_uu.Z\n"
+"H52QLgAIHEiwoMGDCBMqXMiwIUIYEG/UqAECAMQYEmFUvJhxI8SPIDXGgDFjBg0YNDDOsAECxsga\n"
+"NmIAAFHDoc2bOHPqBFBnDp0wcizCoJOmzc6ERI0ePRhSo1CQFZdKnUq1qtWrWLNq3cq1q9evYMOK\n"
+"HUu2rNmzaNOqXcu2rdu3ZwE=\n"
+"====\n"
+};
+
+static const char extradata[] = {
+"From uudecode@libarchive Mon Jun 2 03:03:31 2008\n"
+"Return-Path: <uudecode@libarchive>\n"
+"Received: from libarchive (localhost [127.0.0.1])\n"
+" by libarchive (8.14.2/8.14.2) with ESMTP id m5233UT1006448\n"
+" for <uudecode@libarchive>; Mon, 2 Jun 2008 03:03:31 GMT\n"
+" (envelope-from uudecode@libarchive)\n"
+"Received: (from uudecode@localhost)\n"
+" by libarchive (8.14.2/8.14.2/Submit) id m5233U3e006406\n"
+" for uudecode; Mon, 2 Jun 2008 03:03:30 GMT\n"
+" (envelope-from root)\n"
+"Date: Mon, 2 Jun 2008 03:03:30 GMT\n"
+"From: Libarchive Test <uudecode@libarchive>\n"
+"Message-Id: <200806020303.m5233U3e006406@libarchive>\n"
+"To: uudecode@libarchive\n"
+"Subject: Libarchive uudecode test\n"
+"\n"
+"* Redistribution and use in source and binary forms, with or without\n"
+"* modification, are permitted provided that the following conditions\n"
+"* are met:\n"
+"\n"
+"01234567890abcdeghijklmnopqrstuvwxyz\n"
+"01234567890ABCEFGHIJKLMNOPQRSTUVWXYZ\n"
+"\n"
+};
+
+static void
+test_read_uu_sub(const char *uudata, size_t uusize)
+{
+ struct archive_entry *ae;
+ struct archive *a;
+ char *buff;
+ int extra;
+
+ assert(NULL != (buff = malloc(uusize + 64 * 1024)));
+ if (buff == NULL)
+ return;
+ for (extra = 0; extra <= 64; extra = extra==0?1:extra*2) {
+ size_t size = extra * 1024;
+ char *p = buff;
+
+ /* Add extra text size of which is from 1K bytes to
+ * 64Kbytes before uuencoded data. */
+ while (size) {
+ if (size > sizeof(extradata)-1) {
+ memcpy(p, extradata, sizeof(extradata)-1);
+ p += sizeof(extradata)-1;
+ size -= sizeof(extradata)-1;
+ } else {
+ memcpy(p, extradata, size-1);
+ p += size-1;
+ *p++ = '\n';/* the last of extra text must have
+ * '\n' character. */
+ break;
+ }
+ }
+ memcpy(p, uudata, uusize);
+ size = extra * 1024 + uusize;
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ read_open_memory(a, buff, size, 2));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae));
+ failure("archive_compression_name(a)=\"%s\"",
+ archive_compression_name(a));
+ assertEqualInt(archive_compression(a),
+ ARCHIVE_COMPRESSION_COMPRESS);
+ failure("archive_format_name(a)=\"%s\"",
+ archive_format_name(a));
+ assertEqualInt(archive_format(a), ARCHIVE_FORMAT_TAR_USTAR);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ }
+ free(buff);
+}
+
+DEFINE_TEST(test_read_uu)
+{
+ /* Read the traditional uuencoded data. */
+ test_read_uu_sub(archive, sizeof(archive)-1);
+ /* Read the Base64 uuencoded data. */
+ test_read_uu_sub(archive64, sizeof(archive64)-1);
+}
+
diff --git a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c b/archivers/libarchive/files/libarchive/test/test_tar_filenames.c
index e863fbd23cd..b08373819df 100644
--- a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c
+++ b/archivers/libarchive/files/libarchive/test/test_tar_filenames.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_filenames.c,v 1.9 2008/05/26 17:00:24 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_filenames.c,v 1.10 2008/09/01 05:38:33 kientzle Exp $");
/*
* Exercise various lengths of filenames in tar archives,
@@ -101,10 +101,10 @@ test_filename(const char *prefix, int dlen, int flen)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/*
@@ -117,7 +117,7 @@ test_filename(const char *prefix, int dlen, int flen)
/* Read the file and check the filename. */
assertA(0 == archive_read_next_header(a, &ae));
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("Leading '/' preserved on long filenames");
#else
assertEqualString(filename, archive_entry_pathname(ae));
@@ -133,7 +133,7 @@ test_filename(const char *prefix, int dlen, int flen)
* here.
*/
assertA(0 == archive_read_next_header(a, &ae));
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("Trailing '/' preserved on dirnames");
#else
assertEqualString(dirname, archive_entry_pathname(ae));
@@ -141,7 +141,7 @@ test_filename(const char *prefix, int dlen, int flen)
assert((S_IFDIR | 0755) == archive_entry_mode(ae));
assertA(0 == archive_read_next_header(a, &ae));
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("Trailing '/' added to dir names");
#else
assertEqualString(dirname, archive_entry_pathname(ae));
@@ -151,10 +151,10 @@ test_filename(const char *prefix, int dlen, int flen)
/* Verify the end of the archive. */
assert(1 == archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_tar_large.c b/archivers/libarchive/files/libarchive/test/test_tar_large.c
index df8a1399ad9..adc81551cec 100644
--- a/archivers/libarchive/files/libarchive/test/test_tar_large.c
+++ b/archivers/libarchive/files/libarchive/test/test_tar_large.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_large.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_tar_large.c 201247 2009-12-30 05:59:21Z kientzle $");
#include <errno.h>
#include <stdlib.h>
@@ -53,7 +53,7 @@ struct memblock {
struct memblock *next;
size_t size;
void *buff;
- off_t filebytes;
+ int64_t filebytes;
};
/*
@@ -61,19 +61,19 @@ struct memblock {
* some accounting overhead.
*/
struct memdata {
- off_t filebytes;
+ int64_t filebytes;
void *buff;
struct memblock *first;
struct memblock *last;
};
/* The following size definitions simplify things below. */
-#define KB ((off_t)1024)
-#define MB ((off_t)1024 * KB)
-#define GB ((off_t)1024 * MB)
-#define TB ((off_t)1024 * GB)
+#define KB ((int64_t)1024)
+#define MB ((int64_t)1024 * KB)
+#define GB ((int64_t)1024 * MB)
+#define TB ((int64_t)1024 * GB)
-#if ARCHIVE_API_VERSION < 2
+#if ARCHIVE_VERSION_NUMBER < 2000000
static ssize_t memory_read_skip(struct archive *, void *, size_t request);
#else
static off_t memory_read_skip(struct archive *, void *, off_t request);
@@ -100,7 +100,7 @@ memory_write(struct archive *a, void *_private, const void *buff, size_t size)
if ((const char *)filedata <= (const char *)buff
&& (const char *)buff < (const char *)filedata + filedatasize) {
/* We don't need to store a block of file data. */
- private->last->filebytes += size;
+ private->last->filebytes += (int64_t)size;
} else {
/* Yes, we're assuming the very first write is metadata. */
/* It's header or metadata, copy and save it. */
@@ -117,7 +117,7 @@ memory_write(struct archive *a, void *_private, const void *buff, size_t size)
}
block->next = NULL;
}
- return (size);
+ return ((long)size);
}
static ssize_t
@@ -140,8 +140,8 @@ memory_read(struct archive *a, void *_private, const void **buff)
* We're returning file bytes, simulate it by
* passing blocks from the template data.
*/
- if (private->filebytes > (off_t)filedatasize)
- size = filedatasize;
+ if (private->filebytes > (int64_t)filedatasize)
+ size = (ssize_t)filedatasize;
else
size = (ssize_t)private->filebytes;
private->filebytes -= size;
@@ -152,7 +152,7 @@ memory_read(struct archive *a, void *_private, const void **buff)
*/
block = private->first;
private->first = block->next;
- size = block->size;
+ size = (ssize_t)block->size;
if (block->buff != NULL) {
private->buff = block->buff;
*buff = block->buff;
@@ -167,7 +167,7 @@ memory_read(struct archive *a, void *_private, const void **buff)
}
-#if ARCHIVE_API_VERSION < 2
+#if ARCHIVE_VERSION_NUMBER < 2000000
static ssize_t
memory_read_skip(struct archive *a, void *private, size_t skip)
{
@@ -179,7 +179,6 @@ memory_read_skip(struct archive *a, void *private, size_t skip)
#else
static off_t
memory_read_skip(struct archive *a, void *_private, off_t skip)
-#endif
{
struct memdata *private = _private;
@@ -191,18 +190,19 @@ memory_read_skip(struct archive *a, void *_private, off_t skip)
}
if (private->filebytes > 0) {
if (private->filebytes < skip)
- skip = private->filebytes;
+ skip = (off_t)private->filebytes;
private->filebytes -= skip;
} else {
skip = 0;
}
return (skip);
}
+#endif
DEFINE_TEST(test_tar_large)
{
/* The sizes of the entries we're going to generate. */
- static off_t tests[] = {
+ static int64_t tests[] = {
/* Test for 32-bit signed overflow. */
2 * GB - 1, 2 * GB, 2 * GB + 1,
/* Test for 32-bit unsigned overflow. */
@@ -218,9 +218,10 @@ DEFINE_TEST(test_tar_large)
struct memdata memdata;
struct archive_entry *ae;
struct archive *a;
- off_t filesize, writesize;
+ int64_t filesize;
+ size_t writesize;
- filedatasize = 1 * MB;
+ filedatasize = (size_t)(1 * MB);
filedata = malloc(filedatasize);
memset(filedata, 0xAA, filedatasize);
memset(&memdata, 0, sizeof(memdata));
@@ -236,17 +237,13 @@ DEFINE_TEST(test_tar_large)
/*
* Write a series of large files to it.
*/
- for (i = 0; tests[i] > 0; i++) {
+ for (i = 0; tests[i] != 0; i++) {
assert((ae = archive_entry_new()) != NULL);
sprintf(namebuff, "file_%d", i);
archive_entry_copy_pathname(ae, namebuff);
archive_entry_set_mode(ae, S_IFREG | 0755);
filesize = tests[i];
- if (filesize < 0) {
- skipping("32-bit off_t doesn't permit testing of very large files.");
- return;
- }
archive_entry_set_size(ae, filesize);
assertA(0 == archive_write_header(a, ae));
@@ -257,9 +254,10 @@ DEFINE_TEST(test_tar_large)
*/
while (filesize > 0) {
writesize = filedatasize;
- if (writesize > filesize)
- writesize = filesize;
- assertA(writesize == archive_write_data(a, filedata, writesize));
+ if ((int64_t)writesize > filesize)
+ writesize = (size_t)filesize;
+ assertA((int)writesize
+ == archive_write_data(a, filedata, writesize));
filesize -= writesize;
}
}
@@ -273,10 +271,10 @@ DEFINE_TEST(test_tar_large)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/*
@@ -303,10 +301,10 @@ DEFINE_TEST(test_tar_large)
/* Close out the archive. */
assertA(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertA(0 == archive_read_finish(a));
#endif
free(memdata.buff);
diff --git a/archivers/libarchive/files/libarchive/test/test_ustar_filenames.c b/archivers/libarchive/files/libarchive/test/test_ustar_filenames.c
index 88b4b2c4ac4..e3ebf3c92f0 100644
--- a/archivers/libarchive/files/libarchive/test/test_ustar_filenames.c
+++ b/archivers/libarchive/files/libarchive/test/test_ustar_filenames.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_ustar_filenames.c 189308 2009-03-03 17:02:51Z kientzle $");
/*
* Exercise various lengths of filenames in ustar archives.
@@ -43,7 +43,7 @@ test_filename(const char *prefix, int dlen, int flen)
if (prefix != NULL) {
strcpy(filename, prefix);
- i = strlen(prefix);
+ i = (int)strlen(prefix);
}
if (dlen > 0) {
for (; i < dlen; i++)
@@ -53,7 +53,7 @@ test_filename(const char *prefix, int dlen, int flen)
}
for (; i < dlen + flen + separator; i++)
filename[i] = 'b';
- filename[i++] = '\0';
+ filename[i] = '\0';
strcpy(dirname, filename);
@@ -111,7 +111,11 @@ test_filename(const char *prefix, int dlen, int flen)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
- assertA(0 == archive_write_finish(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_write_finish(a);
+#else
+ assertEqualInt(0, archive_write_finish(a));
+#endif
/*
* Now, read the data back.
@@ -153,7 +157,11 @@ test_filename(const char *prefix, int dlen, int flen)
failure("This fails if entries were written that should not have been written. dlen=%d, flen=%d", dlen, flen);
assertEqualInt(1, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
- assert(0 == archive_read_finish(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_read_finish(a);
+#else
+ assertEqualInt(0, archive_read_finish(a));
+#endif
}
DEFINE_TEST(test_ustar_filenames)
diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress.c b/archivers/libarchive/files/libarchive/test/test_write_compress.c
index 6f8ef3565fe..aa590de8a91 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_compress.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_compress.c
@@ -25,7 +25,7 @@
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_compress.c,v 1.2 2008/03/15 11:05:49 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_compress.c 189308 2009-03-03 17:02:51Z kientzle $");
/*
* A basic exercise of compress reading and writing.
@@ -68,10 +68,10 @@ DEFINE_TEST(test_write_compress)
archive_write_close(a);
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assert(0 == archive_write_finish(a));
#endif
/*
@@ -85,16 +85,16 @@ DEFINE_TEST(test_write_compress)
for (i = 0; i < 100; i++) {
sprintf(path, "file%03d", i);
- assertEqualInt(0, archive_read_next_header(a, &ae));
+ if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
+ break;
assertEqualString(path, archive_entry_pathname(ae));
- assertEqualInt(datasize, archive_entry_size(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
}
-
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
free(data);
diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_bzip2.c b/archivers/libarchive/files/libarchive/test/test_write_compress_bzip2.c
new file mode 100644
index 00000000000..ee6954022aa
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_compress_bzip2.c
@@ -0,0 +1,228 @@
+/*-
+ * Copyright (c) 2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 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: head/lib/libarchive/test/test_write_compress_bzip2.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+/*
+ * A basic exercise of bzip2 reading and writing.
+ *
+ * TODO: Add a reference file and make sure we can decompress that.
+ */
+
+DEFINE_TEST(test_write_compress_bzip2)
+{
+ struct archive_entry *ae;
+ struct archive* a;
+ char *buff, *data;
+ size_t buffsize, datasize;
+ char path[16];
+ size_t used1, used2;
+ int i, r;
+
+ buffsize = 2000000;
+ assert(NULL != (buff = (char *)malloc(buffsize)));
+
+ datasize = 10000;
+ assert(NULL != (data = (char *)malloc(datasize)));
+ memset(data, 0, datasize);
+
+ /*
+ * Write a 100 files and read them all back.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ r = archive_write_set_compression_bzip2(a);
+ if (r == ARCHIVE_FATAL) {
+ skipping("bzip2 writing not supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertEqualInt(ARCHIVE_COMPRESSION_BZIP2, archive_compression(a));
+ assertEqualString("bzip2", archive_compression_name(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+ assertEqualInt(ARCHIVE_COMPRESSION_BZIP2, archive_compression(a));
+ assertEqualString("bzip2", archive_compression_name(a));
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ archive_entry_set_size(ae, datasize);
+ for (i = 0; i < 999; i++) {
+ sprintf(path, "file%03d", i);
+ archive_entry_copy_pathname(ae, path);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize
+ == (size_t)archive_write_data(a, data, datasize));
+ }
+ archive_entry_free(ae);
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ assertA(0 == archive_read_open_memory(a, buff, used1));
+ for (i = 0; i < 999; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assert(0 == archive_read_close(a));
+ assert(0 == archive_read_finish(a));
+
+ /*
+ * Repeat the cycle again, this time setting some compression
+ * options.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_bzip2(a));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "nonexistent-option=0"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=abc"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=99"));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=9"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 999; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize == (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ /* Curiously, this test fails; the test data above compresses
+ * better at default compression than at level 9. */
+ /*
+ failure("compression-level=9 wrote %d bytes, default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 < used1);
+ */
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ assertA(0 == archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 999; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assert(0 == archive_read_close(a));
+ assert(0 == archive_read_finish(a));
+
+ /*
+ * Repeat again, with much lower compression.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_bzip2(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=1"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 999; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ failure("Writing file %s", path);
+ assertEqualIntA(a, datasize,
+ (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ /* Level 0 really does result in larger data. */
+ failure("Compression-level=0 wrote %d bytes; default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 > used1);
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ assertA(0 == archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 999; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assert(0 == archive_read_close(a));
+ assert(0 == archive_read_finish(a));
+
+ /*
+ * Test various premature shutdown scenarios to make sure we
+ * don't crash or leak memory.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_bzip2(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ * Clean up.
+ */
+ free(data);
+ free(buff);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_gzip.c b/archivers/libarchive/files/libarchive/test/test_write_compress_gzip.c
new file mode 100644
index 00000000000..ec55c8db646
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_compress_gzip.c
@@ -0,0 +1,252 @@
+/*-
+ * Copyright (c) 2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 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: head/lib/libarchive/test/test_write_compress_gzip.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+/*
+ * A basic exercise of gzip reading and writing.
+ *
+ * TODO: Add a reference file and make sure we can decompress that.
+ */
+
+DEFINE_TEST(test_write_compress_gzip)
+{
+ struct archive_entry *ae;
+ struct archive* a;
+ char *buff, *data;
+ size_t buffsize, datasize;
+ char path[16];
+ size_t used1, used2;
+ int i, r;
+
+ buffsize = 2000000;
+ assert(NULL != (buff = (char *)malloc(buffsize)));
+
+ datasize = 10000;
+ assert(NULL != (data = (char *)malloc(datasize)));
+ memset(data, 0, datasize);
+
+ /*
+ * Write a 100 files and read them all back.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ r = archive_write_set_compression_gzip(a);
+ if (r == ARCHIVE_FATAL) {
+ skipping("gzip writing not supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertEqualInt(ARCHIVE_COMPRESSION_GZIP, archive_compression(a));
+ assertEqualString("gzip", archive_compression_name(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+ assertEqualInt(ARCHIVE_COMPRESSION_GZIP, archive_compression(a));
+ assertEqualString("gzip", archive_compression_name(a));
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ archive_entry_set_size(ae, datasize);
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ archive_entry_copy_pathname(ae, path);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize
+ == (size_t)archive_write_data(a, data, datasize));
+ }
+ archive_entry_free(ae);
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("Can't verify gzip writing by reading back;"
+ " gzip reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used1));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Repeat the cycle again, this time setting some compression
+ * options.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_gzip(a));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "nonexistent-option=0"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=abc"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=99"));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=9"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize == (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ /* Curiously, this test fails; the test data above compresses
+ * better at default compression than at level 9. */
+ /*
+ failure("compression-level=9 wrote %d bytes, default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 < used1);
+ */
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Repeat again, with much lower compression.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_gzip(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=0"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ failure("Writing file %s", path);
+ assertEqualIntA(a, datasize,
+ (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ /* Level 0 really does result in larger data. */
+ failure("Compression-level=0 wrote %d bytes; default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 > used1);
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ r = archive_read_support_compression_gzip(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("gzip reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Test various premature shutdown scenarios to make sure we
+ * don't crash or leak memory.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_gzip(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ * Clean up.
+ */
+ free(data);
+ free(buff);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_lzma.c b/archivers/libarchive/files/libarchive/test/test_write_compress_lzma.c
new file mode 100644
index 00000000000..0b456910dae
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_compress_lzma.c
@@ -0,0 +1,245 @@
+/*-
+ * Copyright (c) 2007-2009 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
+ * in this position and unchanged.
+ * 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: head/lib/libarchive/test/test_write_compress_lzma.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+/*
+ * A basic exercise of lzma reading and writing.
+ *
+ */
+
+DEFINE_TEST(test_write_compress_lzma)
+{
+ struct archive_entry *ae;
+ struct archive* a;
+ char *buff, *data;
+ size_t buffsize, datasize;
+ char path[16];
+ size_t used1, used2;
+ int i, r;
+
+ buffsize = 2000000;
+ assert(NULL != (buff = (char *)malloc(buffsize)));
+
+ datasize = 10000;
+ assert(NULL != (data = (char *)malloc(datasize)));
+ memset(data, 0, datasize);
+
+ /*
+ * Write a 100 files and read them all back.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ r = archive_write_set_compression_lzma(a);
+ if (r == ARCHIVE_FATAL) {
+ skipping("lzma writing not supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertEqualInt(ARCHIVE_COMPRESSION_LZMA, archive_compression(a));
+ assertEqualString("lzma", archive_compression_name(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+ assertEqualInt(ARCHIVE_COMPRESSION_LZMA, archive_compression(a));
+ assertEqualString("lzma", archive_compression_name(a));
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ archive_entry_set_size(ae, datasize);
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ archive_entry_copy_pathname(ae, path);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize
+ == (size_t)archive_write_data(a, data, datasize));
+ }
+ archive_entry_free(ae);
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ r = archive_read_support_compression_lzma(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("Can't verify lzma writing by reading back;"
+ " lzma reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used1));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Repeat the cycle again, this time setting some compression
+ * options.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_lzma(a));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "nonexistent-option=0"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=abc"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=99"));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=9"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize == (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ r = archive_read_support_compression_lzma(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("lzma reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ failure("Trying to read %s", path);
+ if (!assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Repeat again, with much lower compression.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_lzma(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=0"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ failure("Writing file %s", path);
+ assertEqualIntA(a, datasize,
+ (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ /* Level 0 really does result in larger data. */
+ failure("Compression-level=0 wrote %d bytes; default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 > used1);
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ r = archive_read_support_compression_lzma(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("lzma reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Test various premature shutdown scenarios to make sure we
+ * don't crash or leak memory.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_lzma(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ * Clean up.
+ */
+ free(data);
+ free(buff);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_program.c b/archivers/libarchive/files/libarchive/test/test_write_compress_program.c
index 666bbf9231d..bae77e5341b 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_compress_program.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_compress_program.c
@@ -23,26 +23,38 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_compress_program.c,v 1.2 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_compress_program.c 201247 2009-12-30 05:59:21Z kientzle $");
char buff[1000000];
char buff2[64];
DEFINE_TEST(test_write_compress_program)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("archive_write_set_compress_program()");
#else
struct archive_entry *ae;
struct archive *a;
size_t used;
int blocksize = 1024;
+ int r;
+
+ if (!canGzip()) {
+ skipping("Cannot run 'gzip'");
+ return;
+ }
/* Create a new archive in memory. */
/* Write it through an external "gzip" program. */
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
- assertA(0 == archive_write_set_compression_program(a, "gzip"));
+ r = archive_write_set_compression_program(a, "gzip");
+ if (r == ARCHIVE_FATAL) {
+ skipping("Write compression via external "
+ "program unsupported on this platform");
+ archive_write_finish(a);
+ return;
+ }
assertA(0 == archive_write_set_bytes_per_block(a, blocksize));
assertA(0 == archive_write_set_bytes_in_last_block(a, blocksize));
assertA(blocksize == archive_write_get_bytes_in_last_block(a));
@@ -64,38 +76,43 @@ DEFINE_TEST(test_write_compress_program)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
assertA(0 == archive_write_finish(a));
-#else
- archive_write_finish(a);
-#endif
/*
* Now, read the data back through the built-in gzip support.
*/
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_open_memory(a, buff, used));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ r = archive_read_support_compression_gzip(a);
+ /* The compression_gzip() handler will fall back to gunzip
+ * automatically, but if we know gunzip isn't available, then
+ * skip the rest. */
+ if (r != ARCHIVE_OK && !canGunzip()) {
+ skipping("No libz and no gunzip program, "
+ "unable to verify gzip compression");
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
- assertA(0 == archive_read_next_header(a, &ae));
+ if (!assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae))) {
+ archive_read_finish(a);
+ return;
+ }
- assert(1 == archive_entry_mtime(ae));
- assert(0 == archive_entry_atime(ae));
- assert(0 == archive_entry_ctime(ae));
+ assertEqualInt(1, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_atime(ae));
+ assertEqualInt(0, archive_entry_ctime(ae));
assertEqualString("file", archive_entry_pathname(ae));
- assert((S_IFREG | 0755) == archive_entry_mode(ae));
- assert(8 == archive_entry_size(ae));
- assertA(8 == archive_read_data(a, buff2, 10));
- assert(0 == memcmp(buff2, "12345678", 8));
+ assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+ assertEqualMem(buff2, "12345678", 8);
/* Verify the end of the archive. */
- assert(1 == archive_read_next_header(a, &ae));
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
- archive_read_finish(a);
-#endif
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_compress_xz.c b/archivers/libarchive/files/libarchive/test/test_write_compress_xz.c
new file mode 100644
index 00000000000..88db2e66898
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_compress_xz.c
@@ -0,0 +1,253 @@
+/*-
+ * Copyright (c) 2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 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: head/lib/libarchive/test/test_write_compress_xz.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+/*
+ * A basic exercise of xz reading and writing.
+ *
+ * TODO: Add a reference file and make sure we can decompress that.
+ */
+
+DEFINE_TEST(test_write_compress_xz)
+{
+ struct archive_entry *ae;
+ struct archive* a;
+ char *buff, *data;
+ size_t buffsize, datasize;
+ char path[16];
+ size_t used1, used2;
+ int i, r;
+
+ buffsize = 2000000;
+ assert(NULL != (buff = (char *)malloc(buffsize)));
+
+ datasize = 10000;
+ assert(NULL != (data = (char *)malloc(datasize)));
+ memset(data, 0, datasize);
+
+ /*
+ * Write a 100 files and read them all back.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ r = archive_write_set_compression_xz(a);
+ if (r == ARCHIVE_FATAL) {
+ skipping("xz writing not supported on this platform");
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+ return;
+ }
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertEqualInt(ARCHIVE_COMPRESSION_XZ, archive_compression(a));
+ assertEqualString("xz", archive_compression_name(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used1));
+ assertEqualInt(ARCHIVE_COMPRESSION_XZ, archive_compression(a));
+ assertEqualString("xz", archive_compression_name(a));
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ archive_entry_set_size(ae, datasize);
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ archive_entry_copy_pathname(ae, path);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize
+ == (size_t)archive_write_data(a, data, datasize));
+ }
+ archive_entry_free(ae);
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ r = archive_read_support_compression_xz(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("Can't verify xz writing by reading back;"
+ " xz reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used1));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Repeat the cycle again, this time setting some compression
+ * options.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_xz(a));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "nonexistent-option=0"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=abc"));
+ assertEqualIntA(a, ARCHIVE_WARN,
+ archive_write_set_compressor_options(a, "compression-level=99"));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=9"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ assertA(datasize == (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ /* Curiously, this test fails; the test data above compresses
+ * better at default compression than at level 9. */
+ /*
+ failure("compression-level=9 wrote %d bytes, default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 < used1);
+ */
+
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ r = archive_read_support_compression_xz(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("xz reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ failure("Trying to read %s", path);
+ if (!assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Repeat again, with much lower compression.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_bytes_per_block(a, 10));
+ assertA(0 == archive_write_set_compression_xz(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_compressor_options(a, "compression-level=0"));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, path);
+ archive_entry_set_size(ae, datasize);
+ archive_entry_set_filetype(ae, AE_IFREG);
+ assertA(0 == archive_write_header(a, ae));
+ failure("Writing file %s", path);
+ assertEqualIntA(a, datasize,
+ (size_t)archive_write_data(a, data, datasize));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+ assert(0 == archive_write_finish(a));
+
+ /* Level 0 really does result in larger data. */
+ failure("Compression-level=0 wrote %d bytes; default wrote %d bytes",
+ (int)used2, (int)used1);
+ assert(used2 > used1);
+
+ assert((a = archive_read_new()) != NULL);
+ assertA(0 == archive_read_support_format_all(a));
+ assertA(0 == archive_read_support_compression_all(a));
+ r = archive_read_support_compression_xz(a);
+ if (r == ARCHIVE_WARN) {
+ skipping("xz reading not fully supported on this platform");
+ } else {
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used2));
+ for (i = 0; i < 100; i++) {
+ sprintf(path, "file%03d", i);
+ if (!assertEqualInt(ARCHIVE_OK,
+ archive_read_next_header(a, &ae)))
+ break;
+ assertEqualString(path, archive_entry_pathname(ae));
+ assertEqualInt((int)datasize, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ }
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+
+ /*
+ * Test various premature shutdown scenarios to make sure we
+ * don't crash or leak memory.
+ */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ustar(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_xz(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used2));
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ * Clean up.
+ */
+ free(data);
+ free(buff);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk.c b/archivers/libarchive/files/libarchive/test/test_write_disk.c
index fe44a4538e2..169f4f23996 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_disk.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk.c
@@ -23,11 +23,19 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk.c,v 1.9 2008/06/15 10:35:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk.c 201247 2009-12-30 05:59:21Z kientzle $");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
#define UMASK 022
+/*
+ * When comparing mode values, ignore high-order bits
+ * that are set on some OSes. This should cover the bits
+ * we're interested in (standard mode bits + file type bits)
+ * while ignoring extra markers such as Haiku/BeOS index
+ * flags.
+ */
+#define MODE_MASK 0777777
static void create(struct archive_entry *ae, const char *msg)
{
@@ -39,30 +47,33 @@ static void create(struct archive_entry *ae, const char *msg)
failure("%s", msg);
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_API_VERSION > 1
- assertEqualInt(0, archive_write_finish(ad));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(ad);
+#else
+ assertEqualInt(0, archive_write_finish(ad));
#endif
/* Test the entries on disk. */
assert(0 == stat(archive_entry_pathname(ae), &st));
- failure("st.st_mode=%o archive_entry_mode(ae)=%o",
- st.st_mode, archive_entry_mode(ae));
+ failure("%s", msg);
+
+#if !defined(_WIN32) || defined(__CYGWIN__)
/* When verifying a dir, ignore the S_ISGID bit, as some systems set
* that automatically. */
if (archive_entry_filetype(ae) == AE_IFDIR)
st.st_mode &= ~S_ISGID;
- assertEqualInt(st.st_mode, archive_entry_mode(ae) & ~UMASK);
+ assertEqualInt(st.st_mode & MODE_MASK,
+ archive_entry_mode(ae) & ~UMASK & MODE_MASK);
+#endif
}
static void create_reg_file(struct archive_entry *ae, const char *msg)
{
static const char data[]="abcdefghijklmnopqrstuvwxyz";
struct archive *ad;
- struct stat st;
/* Write the entry to disk. */
assert((ad = archive_write_disk_new()) != NULL);
+ archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME);
failure("%s", msg);
/*
* A touchy API design issue: archive_write_data() does (as of
@@ -82,30 +93,30 @@ static void create_reg_file(struct archive_entry *ae, const char *msg)
* the entry being a maximum size.
*/
archive_entry_set_size(ae, sizeof(data));
+ archive_entry_set_mtime(ae, 123456789, 0);
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_API_VERSION > 1
- assertEqualInt(0, archive_write_finish(ad));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(ad);
+#else
+ assertEqualInt(0, archive_write_finish(ad));
#endif
/* Test the entries on disk. */
- assert(0 == stat(archive_entry_pathname(ae), &st));
- failure("st.st_mode=%o archive_entry_mode(ae)=%o",
- st.st_mode, archive_entry_mode(ae));
- assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
- assertEqualInt(st.st_size, sizeof(data));
+ assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777);
+ assertFileSize(archive_entry_pathname(ae), sizeof(data));
+ /* test_write_disk_times has more detailed tests of this area. */
+ assertFileMtime(archive_entry_pathname(ae), 123456789, 0);
+ failure("No atime given, so atime should get set to current time");
+ assertFileAtimeRecent(archive_entry_pathname(ae));
}
static void create_reg_file2(struct archive_entry *ae, const char *msg)
{
const int datasize = 100000;
char *data;
- char *compare;
struct archive *ad;
- struct stat st;
- int i, fd;
+ int i;
data = malloc(datasize);
for (i = 0; i < datasize; i++)
@@ -125,37 +136,124 @@ static void create_reg_file2(struct archive_entry *ae, const char *msg)
archive_write_data_block(ad, data + i, 1000, i));
}
assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_API_VERSION > 1
assertEqualInt(0, archive_write_finish(ad));
+
+ /* Test the entries on disk. */
+ assertIsReg(archive_entry_pathname(ae), archive_entry_mode(ae) & 0777);
+ assertFileSize(archive_entry_pathname(ae), i);
+ assertFileContents(data, datasize, archive_entry_pathname(ae));
+ free(data);
+}
+
+static void create_reg_file3(struct archive_entry *ae, const char *msg)
+{
+ static const char data[]="abcdefghijklmnopqrstuvwxyz";
+ struct archive *ad;
+ struct stat st;
+
+ /* Write the entry to disk. */
+ assert((ad = archive_write_disk_new()) != NULL);
+ failure("%s", msg);
+ /* Set the size smaller than the data and verify the truncation. */
+ archive_entry_set_size(ae, 5);
+ assertEqualIntA(ad, 0, archive_write_header(ad, ae));
+ assertEqualInt(5, archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_write_finish(ad);
#else
+ assertEqualInt(0, archive_write_finish(ad));
+#endif
+ /* Test the entry on disk. */
+ assert(0 == stat(archive_entry_pathname(ae), &st));
+ failure("st.st_mode=%o archive_entry_mode(ae)=%o",
+ st.st_mode, archive_entry_mode(ae));
+#if !defined(_WIN32) || defined(__CYGWIN__)
+ assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
+#endif
+ assertEqualInt(st.st_size, 5);
+}
+
+
+static void create_reg_file4(struct archive_entry *ae, const char *msg)
+{
+ static const char data[]="abcdefghijklmnopqrstuvwxyz";
+ struct archive *ad;
+ struct stat st;
+
+ /* Write the entry to disk. */
+ assert((ad = archive_write_disk_new()) != NULL);
+ /* Leave the size unset. The data should not be truncated. */
+ assertEqualIntA(ad, 0, archive_write_header(ad, ae));
+ assertEqualInt(ARCHIVE_OK,
+ archive_write_data_block(ad, data, sizeof(data), 0));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(ad);
+#else
+ assertEqualInt(0, archive_write_finish(ad));
#endif
- /* Test the entries on disk. */
+ /* Test the entry on disk. */
assert(0 == stat(archive_entry_pathname(ae), &st));
failure("st.st_mode=%o archive_entry_mode(ae)=%o",
st.st_mode, archive_entry_mode(ae));
+#if !defined(_WIN32) || defined(__CYGWIN__)
assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
- assertEqualInt(st.st_size, i);
-
- compare = malloc(datasize);
- fd = open(archive_entry_pathname(ae), O_RDONLY);
- assertEqualInt(datasize, read(fd, compare, datasize));
- close(fd);
- assert(memcmp(compare, data, datasize) == 0);
- free(compare);
- free(data);
+#endif
+ failure(msg);
+ assertEqualInt(st.st_size, sizeof(data));
+}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static void create_reg_file_win(struct archive_entry *ae, const char *msg)
+{
+ static const char data[]="abcdefghijklmnopqrstuvwxyz";
+ struct archive *ad;
+ struct stat st;
+ char *p, *fname;
+ size_t l;
+
+ /* Write the entry to disk. */
+ assert((ad = archive_write_disk_new()) != NULL);
+ archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME);
+ failure("%s", msg);
+ archive_entry_set_size(ae, sizeof(data));
+ archive_entry_set_mtime(ae, 123456789, 0);
+ assertEqualIntA(ad, 0, archive_write_header(ad, ae));
+ assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_write_finish(ad);
+#else
+ assertEqualInt(0, archive_write_finish(ad));
+#endif
+ /* Test the entries on disk. */
+ l = strlen(archive_entry_pathname(ae));
+ fname = malloc(l + 1);
+ assert(NULL != fname);
+ strcpy(fname, archive_entry_pathname(ae));
+ /* Replace unusable characters in Windows to '_' */
+ for (p = fname; *p != '\0'; p++)
+ if (*p == ':' || *p == '*' || *p == '?' ||
+ *p == '"' || *p == '<' || *p == '>' || *p == '|')
+ *p = '_';
+ assert(0 == stat(fname, &st));
+ failure("st.st_mode=%o archive_entry_mode(ae)=%o",
+ st.st_mode, archive_entry_mode(ae));
+ assertEqualInt(st.st_size, sizeof(data));
}
+#endif /* _WIN32 && !__CYGWIN__ */
#endif
DEFINE_TEST(test_write_disk)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("archive_write_disk interface");
#else
struct archive_entry *ae;
/* Force the umask to something predictable. */
- umask(UMASK);
+ assertUmask(UMASK);
/* A regular file. */
assert((ae = archive_entry_new()) != NULL);
@@ -171,6 +269,20 @@ DEFINE_TEST(test_write_disk)
create_reg_file2(ae, "Test creating another regular file");
archive_entry_free(ae);
+ /* A regular file with a size restriction */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file3");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ create_reg_file3(ae, "Regular file with size restriction");
+ archive_entry_free(ae);
+
+ /* A regular file with an unspecified size */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file3");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ create_reg_file4(ae, "Regular file with unspecified size");
+ archive_entry_free(ae);
+
/* A regular file over an existing file */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "file");
@@ -198,5 +310,23 @@ DEFINE_TEST(test_write_disk)
archive_entry_set_mode(ae, S_IFREG | 0744);
create(ae, "Test creating a file over an existing dir.");
archive_entry_free(ae);
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* A file with unusable characters in its file name. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "f:i*l?e\"f<i>l|e");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ create_reg_file_win(ae, "Test creating a regular file"
+ " with unusable characters in its file name");
+ archive_entry_free(ae);
+
+ /* A file with unusable characters in its directory name. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "d:i*r?e\"c<t>o|ry/file1");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ create_reg_file_win(ae, "Test creating a regular file"
+ " with unusable characters in its file name");
+ archive_entry_free(ae);
+#endif /* _WIN32 && !__CYGWIN__ */
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_failures.c b/archivers/libarchive/files/libarchive/test/test_write_disk_failures.c
new file mode 100644
index 00000000000..991fa3d4fe6
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_failures.c
@@ -0,0 +1,72 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_failures.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+#if ARCHIVE_VERSION_NUMBER >= 1009000
+
+#define UMASK 022
+
+
+#endif
+
+DEFINE_TEST(test_write_disk_failures)
+{
+#if ARCHIVE_VERSION_NUMBER < 1009000 || (defined(_WIN32) && !defined(__CYGWIN__))
+ skipping("archive_write_disk interface");
+#else
+ struct archive_entry *ae;
+ struct archive *a;
+ int fd;
+
+ /* Force the umask to something predictable. */
+ assertUmask(UMASK);
+
+ /* A directory that we can't write to. */
+ assertMakeDir("dir", 0555);
+
+ /* Can we? */
+ fd = open("dir/testfile", O_WRONLY | O_CREAT | O_BINARY, 0777);
+ if (fd >= 0) {
+ /* Apparently, we can, so the test below won't work. */
+ close(fd);
+ skipping("Can't test writing to non-writable directory");
+ return;
+ }
+
+ /* Try to extract a regular file into the directory above. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "dir/file");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ archive_entry_set_size(ae, 8);
+ assert((a = archive_write_disk_new()) != NULL);
+ archive_write_disk_set_options(a, ARCHIVE_EXTRACT_TIME);
+ archive_entry_set_mtime(ae, 123456789, 0);
+ assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae));
+ assertEqualIntA(a, 0, archive_write_finish_entry(a));
+ assertEqualInt(0, archive_write_finish(a));
+ archive_entry_free(ae);
+#endif
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c b/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c
index dda384a85a1..934aa08d578 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c
@@ -23,9 +23,16 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_hardlink.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_hardlink.c 201247 2009-12-30 05:59:21Z kientzle $");
+#if defined(_WIN32) && !defined(__CYGWIN__)
+/* Execution bits, Group members bits and others bits do not work. */
+#define UMASK 0177
+#define E_MASK (~0177)
+#else
#define UMASK 022
+#define E_MASK (~0)
+#endif
/*
* Exercise hardlink recreation.
@@ -36,16 +43,16 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_hardlink.c,v 1.2 200
*/
DEFINE_TEST(test_write_disk_hardlink)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
- skipping("archive_write_disk_hardlink tests");
+#if defined(__HAIKU__)
+ skipping("archive_write_disk_hardlink; hardlinks are not supported on bfs");
#else
static const char data[]="abcdefghijklmnopqrstuvwxyz";
struct archive *ad;
struct archive_entry *ae;
- struct stat st, st2;
+ int r;
/* Force the umask to something predictable. */
- umask(UMASK);
+ assertUmask(UMASK);
/* Write entries to disk. */
assert((ad = archive_write_disk_new()) != NULL);
@@ -61,21 +68,55 @@ DEFINE_TEST(test_write_disk_hardlink)
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, sizeof(data));
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
- assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
+ assertEqualInt(sizeof(data),
+ archive_write_data(ad, data, sizeof(data)));
assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
archive_entry_free(ae);
- /* Link. */
+ /* Link. Size of zero means this doesn't carry data. */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "link1b");
- archive_entry_set_mode(ae, S_IFREG | 0600);
+ archive_entry_set_mode(ae, S_IFREG | 0642);
archive_entry_set_size(ae, 0);
archive_entry_copy_hardlink(ae, "link1a");
+ assertEqualIntA(ad, 0, r = archive_write_header(ad, ae));
+ if (r >= ARCHIVE_WARN) {
+ assertEqualInt(ARCHIVE_WARN,
+ archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ }
+ archive_entry_free(ae);
+
+ /*
+ * Repeat tar approach test, but use unset to mark the
+ * hardlink as having no data.
+ */
+
+ /* Regular file. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link2a");
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ archive_entry_set_size(ae, sizeof(data));
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
- assertEqualInt(0, archive_write_data(ad, data, sizeof(data)));
+ assertEqualInt(sizeof(data),
+ archive_write_data(ad, data, sizeof(data)));
assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
archive_entry_free(ae);
+ /* Link. Unset size means this doesn't carry data. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link2b");
+ archive_entry_set_mode(ae, S_IFREG | 0642);
+ archive_entry_unset_size(ae);
+ archive_entry_copy_hardlink(ae, "link2a");
+ assertEqualIntA(ad, 0, r = archive_write_header(ad, ae));
+ if (r >= ARCHIVE_WARN) {
+ assertEqualInt(ARCHIVE_WARN,
+ archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ }
+ archive_entry_free(ae);
+
/*
* Second, try an old-cpio-like approach; a regular file, then
* another identical one (which has been marked hardlink).
@@ -83,7 +124,7 @@ DEFINE_TEST(test_write_disk_hardlink)
/* Regular file. */
assert((ae = archive_entry_new()) != NULL);
- archive_entry_copy_pathname(ae, "link2a");
+ archive_entry_copy_pathname(ae, "link3a");
archive_entry_set_mode(ae, S_IFREG | 0600);
archive_entry_set_size(ae, sizeof(data));
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
@@ -93,13 +134,16 @@ DEFINE_TEST(test_write_disk_hardlink)
/* Link. */
assert((ae = archive_entry_new()) != NULL);
- archive_entry_copy_pathname(ae, "link2b");
+ archive_entry_copy_pathname(ae, "link3b");
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, sizeof(data));
- archive_entry_copy_hardlink(ae, "link2a");
- assertEqualIntA(ad, 0, archive_write_header(ad, ae));
- assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ archive_entry_copy_hardlink(ae, "link3a");
+ assertEqualIntA(ad, 0, r = archive_write_header(ad, ae));
+ if (r > ARCHIVE_WARN) {
+ assertEqualInt(sizeof(data),
+ archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ }
archive_entry_free(ae);
/*
@@ -109,7 +153,7 @@ DEFINE_TEST(test_write_disk_hardlink)
/* Regular file. */
assert((ae = archive_entry_new()) != NULL);
- archive_entry_copy_pathname(ae, "link3a");
+ archive_entry_copy_pathname(ae, "link4a");
archive_entry_set_mode(ae, S_IFREG | 0600);
archive_entry_set_size(ae, 0);
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
@@ -123,51 +167,53 @@ DEFINE_TEST(test_write_disk_hardlink)
/* Link. */
assert((ae = archive_entry_new()) != NULL);
- archive_entry_copy_pathname(ae, "link3b");
+ archive_entry_copy_pathname(ae, "link4b");
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, sizeof(data));
- archive_entry_copy_hardlink(ae, "link3a");
- assertEqualIntA(ad, 0, archive_write_header(ad, ae));
- assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
- assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ archive_entry_copy_hardlink(ae, "link4a");
+ assertEqualIntA(ad, 0, r = archive_write_header(ad, ae));
+ if (r > ARCHIVE_FAILED) {
+ assertEqualInt(sizeof(data),
+ archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ }
archive_entry_free(ae);
assertEqualInt(0, archive_write_finish(ad));
/* Test the entries on disk. */
- assert(0 == stat("link1a", &st));
- assertEqualInt(st.st_mode, (S_IFREG | 0755) & ~UMASK);
- assertEqualInt(st.st_size, sizeof(data));
- assertEqualInt(st.st_nlink, 2);
-
- assert(0 == stat("link1b", &st2));
- assertEqualInt(st2.st_mode, (S_IFREG | 0755) & ~UMASK);
- assertEqualInt(st2.st_size, sizeof(data));
- assertEqualInt(st2.st_nlink, 2);
- assertEqualInt(st.st_ino, st2.st_ino);
- assertEqualInt(st.st_dev, st2.st_dev);
-
- assert(0 == stat("link2a", &st));
- assertEqualInt(st.st_mode, (S_IFREG | 0755) & ~UMASK);
- assertEqualInt(st.st_size, sizeof(data));
- assertEqualInt(st.st_nlink, 2);
-
- assert(0 == stat("link2b", &st2));
- assertEqualInt(st2.st_mode, (S_IFREG | 0755) & ~UMASK);
- assertEqualInt(st2.st_size, sizeof(data));
- assertEqualInt(st2.st_nlink, 2);
- assertEqualInt(st.st_ino, st2.st_ino);
- assertEqualInt(st.st_dev, st2.st_dev);
-
- assert(0 == stat("link3a", &st));
- assertEqualInt(st.st_mode, (S_IFREG | 0755) & ~UMASK);
- assertEqualInt(st.st_size, sizeof(data));
- assertEqualInt(st.st_nlink, 2);
-
- assert(0 == stat("link3b", &st2));
- assertEqualInt(st2.st_mode, (S_IFREG | 0755) & ~UMASK);
- assertEqualInt(st2.st_size, sizeof(data));
- assertEqualInt(st2.st_nlink, 2);
- assertEqualInt(st.st_ino, st2.st_ino);
- assertEqualInt(st.st_dev, st2.st_dev);
+
+ /* Test #1 */
+ /* If the hardlink was successfully created and the archive
+ * doesn't carry data for it, we consider it to be
+ * non-authoritive for meta data as well. This is consistent
+ * with GNU tar and BSD pax. */
+ assertIsReg("link1a", 0755 & ~UMASK);
+ assertFileSize("link1a", sizeof(data));
+ assertFileNLinks("link1a", 2);
+ assertIsHardlink("link1a", "link1b");
+
+ /* Test #2: Should produce identical results to test #1 */
+ /* Note that marking a hardlink with size = 0 is treated the
+ * same as having an unset size. This is partly for backwards
+ * compatibility (we used to not have unset tracking, so
+ * relied on size == 0) and partly to match the model used by
+ * common file formats that store a size of zero for
+ * hardlinks. */
+ assertIsReg("link2a", 0755 & ~UMASK);
+ assertFileSize("link2a", sizeof(data));
+ assertFileNLinks("link2a", 2);
+ assertIsHardlink("link2a", "link2b");
+
+ /* Test #3 */
+ assertIsReg("link3a", 0755 & ~UMASK);
+ assertFileSize("link3a", sizeof(data));
+ assertFileNLinks("link3a", 2);
+ assertIsHardlink("link3a", "link3b");
+
+ /* Test #4 */
+ assertIsReg("link4a", 0755 & ~UMASK);
+ assertFileNLinks("link4a", 2);
+ assertFileSize("link4a", sizeof(data));
+ assertIsHardlink("link4a", "link4b");
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c b/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c
index 2e872a1e359..207444833e7 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c
@@ -23,9 +23,9 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_perms.c,v 1.9 2008/06/15 10:35:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_perms.c 201247 2009-12-30 05:59:21Z kientzle $");
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000 && (!defined(_WIN32) || defined(__CYGWIN__))
#define UMASK 022
@@ -60,7 +60,7 @@ searchgid(void)
_searched = 1;
/* Create a file on disk in the current default dir. */
- fd = open("test_gid", O_CREAT, 0664);
+ fd = open("test_gid", O_CREAT | O_BINARY, 0664);
failure("Couldn't create a file for gid testing.");
assert(fd > 0);
@@ -125,13 +125,15 @@ defaultgid(void)
DEFINE_TEST(test_write_disk_perms)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000 || (defined(_WIN32) && !defined(__CYGWIN__))
skipping("archive_write_disk interface");
#else
struct archive *a;
struct archive_entry *ae;
struct stat st;
+ assertUmask(UMASK);
+
/*
* Set ownership of the current directory to the group of this
* process. Otherwise, the SGID tests below fail if the
@@ -182,7 +184,7 @@ DEFINE_TEST(test_write_disk_perms)
/* Overwrite an existing dir. */
/* For dir, the first perms should get left. */
- assert(mkdir("dir_overwrite_0744", 0744) == 0);
+ assertMakeDir("dir_overwrite_0744", 0744);
/* Check original perms. */
assert(0 == stat("dir_overwrite_0744", &st));
failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode);
@@ -272,7 +274,7 @@ DEFINE_TEST(test_write_disk_perms)
* Current user must belong to at least two groups or
* else we can't test setting the GID to another group.
*/
- printf("Current user can't test gid restore: must belong to more than one group.\n");
+ skipping("Current user can't test gid restore: must belong to more than one group.");
} else {
/*
* Write a regular file with ARCHIVE_EXTRACT_PERM & SGID bit
@@ -363,10 +365,10 @@ DEFINE_TEST(test_write_disk_perms)
assertEqualIntA(a,ARCHIVE_WARN,archive_write_finish_entry(a));
}
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assert(0 == archive_write_finish(a));
#endif
archive_entry_free(ae);
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c b/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c
index 2bcc95762c3..c14dadccfa6 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_secure.c,v 1.4 2008/06/15 10:35:22 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_secure.c 201247 2009-12-30 05:59:21Z kientzle $");
#define UMASK 022
@@ -34,15 +34,15 @@ __FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_secure.c,v 1.4 2008/
DEFINE_TEST(test_write_disk_secure)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("archive_write_disk interface");
-#else
+#elif !defined(_WIN32) || defined(__CYGWIN__)
struct archive *a;
struct archive_entry *ae;
struct stat st;
/* Start with a known umask. */
- umask(UMASK);
+ assertUmask(UMASK);
/* Create an archive_write_disk object. */
assert((a = archive_write_disk_new()) != NULL);
@@ -80,7 +80,7 @@ DEFINE_TEST(test_write_disk_secure)
archive_entry_set_mode(ae, S_IFREG | 0777);
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
failure("Extracting a file through a symlink should fail here.");
- assertEqualInt(ARCHIVE_WARN, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
archive_entry_free(ae);
assert(0 == archive_write_finish_entry(a));
@@ -105,12 +105,80 @@ DEFINE_TEST(test_write_disk_secure)
archive_entry_free(ae);
assert(0 == archive_write_finish_entry(a));
+ /*
+ * Without security checks, extracting a dir over a link to a
+ * dir should follow the link.
+ */
+ /* Create a symlink to a dir. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link_to_dir3");
+ archive_entry_set_mode(ae, S_IFLNK | 0777);
+ archive_entry_set_symlink(ae, "dir");
+ archive_write_disk_set_options(a, 0);
+ assert(0 == archive_write_header(a, ae));
+ assert(0 == archive_write_finish_entry(a));
+ /* Extract a dir whose name matches the symlink. */
+ assert(archive_entry_clear(ae) != NULL);
+ archive_entry_copy_pathname(ae, "link_to_dir3");
+ archive_entry_set_mode(ae, S_IFDIR | 0777);
+ assert(0 == archive_write_header(a, ae));
+ assert(0 == archive_write_finish_entry(a));
+ /* Verify link was followed. */
+ assertEqualInt(0, lstat("link_to_dir3", &st));
+ assert(S_ISLNK(st.st_mode));
+ archive_entry_free(ae);
+
+ /*
+ * As above, but a broken link, so the link should get replaced.
+ */
+ /* Create a symlink to a dir. */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link_to_dir4");
+ archive_entry_set_mode(ae, S_IFLNK | 0777);
+ archive_entry_set_symlink(ae, "nonexistent_dir");
+ archive_write_disk_set_options(a, 0);
+ assert(0 == archive_write_header(a, ae));
+ assert(0 == archive_write_finish_entry(a));
+ /* Extract a dir whose name matches the symlink. */
+ assert(archive_entry_clear(ae) != NULL);
+ archive_entry_copy_pathname(ae, "link_to_dir4");
+ archive_entry_set_mode(ae, S_IFDIR | 0777);
+ assert(0 == archive_write_header(a, ae));
+ assert(0 == archive_write_finish_entry(a));
+ /* Verify link was replaced. */
+ assertEqualInt(0, lstat("link_to_dir4", &st));
+ assert(S_ISDIR(st.st_mode));
+ archive_entry_free(ae);
+
+ /*
+ * As above, but a link to a non-dir, so the link should get replaced.
+ */
+ /* Create a regular file and a symlink to it */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "non_dir");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_write_disk_set_options(a, 0);
+ assert(0 == archive_write_header(a, ae));
+ assert(0 == archive_write_finish_entry(a));
+ /* Create symlink to the file. */
+ archive_entry_copy_pathname(ae, "link_to_dir5");
+ archive_entry_set_mode(ae, S_IFLNK | 0777);
+ archive_entry_set_symlink(ae, "non_dir");
+ archive_write_disk_set_options(a, 0);
+ assert(0 == archive_write_header(a, ae));
+ assert(0 == archive_write_finish_entry(a));
+ /* Extract a dir whose name matches the symlink. */
+ assert(archive_entry_clear(ae) != NULL);
+ archive_entry_copy_pathname(ae, "link_to_dir5");
+ archive_entry_set_mode(ae, S_IFDIR | 0777);
+ assert(0 == archive_write_header(a, ae));
+ assert(0 == archive_write_finish_entry(a));
+ /* Verify link was replaced. */
+ assertEqualInt(0, lstat("link_to_dir5", &st));
+ assert(S_ISDIR(st.st_mode));
+ archive_entry_free(ae);
-#if ARCHIVE_API_VERSION > 1
assert(0 == archive_write_finish(a));
-#else
- archive_write_finish(a);
-#endif
/* Test the entries on disk. */
assert(0 == lstat("dir", &st));
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_sparse.c b/archivers/libarchive/files/libarchive/test/test_write_disk_sparse.c
new file mode 100644
index 00000000000..638f0a4b26d
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_sparse.c
@@ -0,0 +1,280 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_sparse.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+ * Write a file using archive_write_data call, read the file
+ * back and verify the contents. The data written includes large
+ * blocks of nulls, so it should exercise the sparsification logic
+ * if ARCHIVE_EXTRACT_SPARSE is enabled.
+ */
+static void
+verify_write_data(struct archive *a, int sparse)
+{
+ static const char data[]="abcdefghijklmnopqrstuvwxyz";
+ struct stat st;
+ struct archive_entry *ae;
+ size_t buff_size = 64 * 1024;
+ char *buff, *p;
+ const char *msg = sparse ? "sparse" : "non-sparse";
+ FILE *f;
+
+ buff = malloc(buff_size);
+ assert(buff != NULL);
+
+ ae = archive_entry_new();
+ assert(ae != NULL);
+ archive_entry_set_size(ae, 8 * buff_size);
+ archive_entry_set_pathname(ae, "test_write_data");
+ archive_entry_set_mode(ae, AE_IFREG | 0755);
+ assertEqualIntA(a, 0, archive_write_header(a, ae));
+
+ /* Use archive_write_data() to write three relatively sparse blocks. */
+
+ /* First has non-null data at beginning. */
+ memset(buff, 0, buff_size);
+ memcpy(buff, data, sizeof(data));
+ failure("%s", msg);
+ assertEqualInt(buff_size, archive_write_data(a, buff, buff_size));
+
+ /* Second has non-null data in the middle. */
+ memset(buff, 0, buff_size);
+ memcpy(buff + buff_size / 2 - 3, data, sizeof(data));
+ failure("%s", msg);
+ assertEqualInt(buff_size, archive_write_data(a, buff, buff_size));
+
+ /* Third has non-null data at the end. */
+ memset(buff, 0, buff_size);
+ memcpy(buff + buff_size - sizeof(data), data, sizeof(data));
+ failure("%s", msg);
+ assertEqualInt(buff_size, archive_write_data(a, buff, buff_size));
+
+ failure("%s", msg);
+ assertEqualIntA(a, 0, archive_write_finish_entry(a));
+
+ /* Test the entry on disk. */
+ assert(0 == stat(archive_entry_pathname(ae), &st));
+ assertEqualInt(st.st_size, 8 * buff_size);
+ f = fopen(archive_entry_pathname(ae), "rb");
+ if (!assert(f != NULL))
+ return;
+
+ /* Check first block. */
+ assertEqualInt(buff_size, fread(buff, 1, buff_size, f));
+ failure("%s", msg);
+ assertEqualMem(buff, data, sizeof(data));
+ for (p = buff + sizeof(data); p < buff + buff_size; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+
+ /* Check second block. */
+ assertEqualInt(buff_size, fread(buff, 1, buff_size, f));
+ for (p = buff; p < buff + buff_size; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (p == buff + buff_size / 2 - 3) {
+ assertEqualMem(p, data, sizeof(data));
+ p += sizeof(data);
+ } else if (!assertEqualInt(0, *p))
+ break;
+ }
+
+ /* Check third block. */
+ assertEqualInt(buff_size, fread(buff, 1, buff_size, f));
+ for (p = buff; p < buff + buff_size - sizeof(data); ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+ failure("%s", msg);
+ assertEqualMem(buff + buff_size - sizeof(data), data, sizeof(data));
+
+ /* XXX more XXX */
+
+ assertEqualInt(0, fclose(f));
+ archive_entry_free(ae);
+ free(buff);
+}
+
+/*
+ * As above, but using the archive_write_data_block() call.
+ */
+static void
+verify_write_data_block(struct archive *a, int sparse)
+{
+ static const char data[]="abcdefghijklmnopqrstuvwxyz";
+ struct stat st;
+ struct archive_entry *ae;
+ size_t buff_size = 64 * 1024;
+ char *buff, *p;
+ const char *msg = sparse ? "sparse" : "non-sparse";
+ FILE *f;
+
+ buff = malloc(buff_size);
+ assert(buff != NULL);
+
+ ae = archive_entry_new();
+ assert(ae != NULL);
+ archive_entry_set_size(ae, 8 * buff_size);
+ archive_entry_set_pathname(ae, "test_write_data_block");
+ archive_entry_set_mode(ae, AE_IFREG | 0755);
+ assertEqualIntA(a, 0, archive_write_header(a, ae));
+
+ /* Use archive_write_data_block() to write three
+ relatively sparse blocks. */
+
+ /* First has non-null data at beginning. */
+ memset(buff, 0, buff_size);
+ memcpy(buff, data, sizeof(data));
+ failure("%s", msg);
+ assertEqualInt(ARCHIVE_OK,
+ archive_write_data_block(a, buff, buff_size, 100));
+
+ /* Second has non-null data in the middle. */
+ memset(buff, 0, buff_size);
+ memcpy(buff + buff_size / 2 - 3, data, sizeof(data));
+ failure("%s", msg);
+ assertEqualInt(ARCHIVE_OK,
+ archive_write_data_block(a, buff, buff_size, buff_size + 200));
+
+ /* Third has non-null data at the end. */
+ memset(buff, 0, buff_size);
+ memcpy(buff + buff_size - sizeof(data), data, sizeof(data));
+ failure("%s", msg);
+ assertEqualInt(ARCHIVE_OK,
+ archive_write_data_block(a, buff, buff_size, buff_size * 2 + 300));
+
+ failure("%s", msg);
+ assertEqualIntA(a, 0, archive_write_finish_entry(a));
+
+ /* Test the entry on disk. */
+ assert(0 == stat(archive_entry_pathname(ae), &st));
+ assertEqualInt(st.st_size, 8 * buff_size);
+ f = fopen(archive_entry_pathname(ae), "rb");
+ if (!assert(f != NULL))
+ return;
+
+ /* Check 100-byte gap at beginning */
+ assertEqualInt(100, fread(buff, 1, 100, f));
+ failure("%s", msg);
+ for (p = buff; p < buff + 100; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+
+ /* Check first block. */
+ assertEqualInt(buff_size, fread(buff, 1, buff_size, f));
+ failure("%s", msg);
+ assertEqualMem(buff, data, sizeof(data));
+ for (p = buff + sizeof(data); p < buff + buff_size; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+
+ /* Check 100-byte gap */
+ assertEqualInt(100, fread(buff, 1, 100, f));
+ failure("%s", msg);
+ for (p = buff; p < buff + 100; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+
+ /* Check second block. */
+ assertEqualInt(buff_size, fread(buff, 1, buff_size, f));
+ for (p = buff; p < buff + buff_size; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (p == buff + buff_size / 2 - 3) {
+ assertEqualMem(p, data, sizeof(data));
+ p += sizeof(data);
+ } else if (!assertEqualInt(0, *p))
+ break;
+ }
+
+ /* Check 100-byte gap */
+ assertEqualInt(100, fread(buff, 1, 100, f));
+ failure("%s", msg);
+ for (p = buff; p < buff + 100; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+
+ /* Check third block. */
+ assertEqualInt(buff_size, fread(buff, 1, buff_size, f));
+ for (p = buff; p < buff + buff_size - sizeof(data); ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+ failure("%s", msg);
+ assertEqualMem(buff + buff_size - sizeof(data), data, sizeof(data));
+
+ /* Check another block size beyond last we wrote. */
+ assertEqualInt(buff_size, fread(buff, 1, buff_size, f));
+ failure("%s", msg);
+ for (p = buff; p < buff + buff_size; ++p) {
+ failure("offset: %d, %s", (int)(p - buff), msg);
+ if (!assertEqualInt(0, *p))
+ break;
+ }
+
+
+ /* XXX more XXX */
+
+ assertEqualInt(0, fclose(f));
+ free(buff);
+ archive_entry_free(ae);
+}
+
+DEFINE_TEST(test_write_disk_sparse)
+{
+ struct archive *ad;
+
+
+ /*
+ * The return values, etc, of the write data functions
+ * shouldn't change regardless of whether we've requested
+ * sparsification. (The performance and pattern of actual
+ * write calls to the disk should vary, of course, but the
+ * client program shouldn't see any difference.)
+ */
+ assert((ad = archive_write_disk_new()) != NULL);
+ archive_write_disk_set_options(ad, 0);
+ verify_write_data(ad, 0);
+ verify_write_data_block(ad, 0);
+ assertEqualInt(0, archive_write_finish(ad));
+
+ assert((ad = archive_write_disk_new()) != NULL);
+ archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_SPARSE);
+ verify_write_data(ad, 1);
+ verify_write_data_block(ad, 1);
+ assertEqualInt(0, archive_write_finish(ad));
+
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_symlink.c b/archivers/libarchive/files/libarchive/test/test_write_disk_symlink.c
new file mode 100644
index 00000000000..60d0bdcbb0e
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_symlink.c
@@ -0,0 +1,117 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_disk_symlink.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+ * Exercise symlink recreation.
+ */
+DEFINE_TEST(test_write_disk_symlink)
+{
+ static const char data[]="abcdefghijklmnopqrstuvwxyz";
+ struct archive *ad;
+ struct archive_entry *ae;
+ int r;
+
+ if (!canSymlink()) {
+ skipping("Symlinks not supported");
+ return;
+ }
+
+ /* Write entries to disk. */
+ assert((ad = archive_write_disk_new()) != NULL);
+
+ /*
+ * First, create a regular file then a symlink to that file.
+ */
+
+ /* Regular file: link1a */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link1a");
+ archive_entry_set_mode(ae, AE_IFREG | 0755);
+ archive_entry_set_size(ae, sizeof(data));
+ assertEqualIntA(ad, 0, archive_write_header(ad, ae));
+ assertEqualInt(sizeof(data),
+ archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ archive_entry_free(ae);
+
+ /* Symbolic Link: link1b -> link1a */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link1b");
+ archive_entry_set_mode(ae, AE_IFLNK | 0642);
+ archive_entry_set_size(ae, 0);
+ archive_entry_copy_symlink(ae, "link1a");
+ assertEqualIntA(ad, 0, r = archive_write_header(ad, ae));
+ if (r >= ARCHIVE_WARN)
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ archive_entry_free(ae);
+
+ /*
+ * We should be able to do this in the other order as well,
+ * of course.
+ */
+
+ /* Symbolic link: link2b -> link2a */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link2b");
+ archive_entry_set_mode(ae, AE_IFLNK | 0642);
+ archive_entry_unset_size(ae);
+ archive_entry_copy_symlink(ae, "link2a");
+ assertEqualIntA(ad, 0, r = archive_write_header(ad, ae));
+ if (r >= ARCHIVE_WARN) {
+ assertEqualInt(ARCHIVE_WARN,
+ archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ }
+ archive_entry_free(ae);
+
+ /* File: link2a */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "link2a");
+ archive_entry_set_mode(ae, AE_IFREG | 0755);
+ archive_entry_set_size(ae, sizeof(data));
+ assertEqualIntA(ad, 0, archive_write_header(ad, ae));
+ assertEqualInt(sizeof(data),
+ archive_write_data(ad, data, sizeof(data)));
+ assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
+ archive_entry_free(ae);
+
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(ad));
+
+ /* Test the entries on disk. */
+
+ /* Test #1 */
+ assertIsReg("link1a", -1);
+ assertFileSize("link1a", sizeof(data));
+ assertFileNLinks("link1a", 1);
+ assertIsSymlink("link1b", "link1a");
+
+ /* Test #2: Should produce identical results to test #1 */
+ assertIsReg("link2a", -1);
+ assertFileSize("link2a", sizeof(data));
+ assertFileNLinks("link2a", 1);
+ assertIsSymlink("link2b", "link2a");
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_times.c b/archivers/libarchive/files/libarchive/test/test_write_disk_times.c
new file mode 100644
index 00000000000..9ecbff69b56
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_disk_times.c
@@ -0,0 +1,167 @@
+/*-
+ * Copyright (c) 2003-2008 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: head/lib/libarchive/test/test_write_disk_times.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+/*
+ * Exercise time restores in archive_write_disk(), including
+ * correct handling of omitted time values.
+ * On FreeBSD, we also test birthtime and high-res time restores.
+ */
+
+DEFINE_TEST(test_write_disk_times)
+{
+ struct archive *a;
+ struct archive_entry *ae;
+
+ /* Create an archive_write_disk object. */
+ assert((a = archive_write_disk_new()) != NULL);
+ assertEqualInt(ARCHIVE_OK,
+ archive_write_disk_set_options(a, ARCHIVE_EXTRACT_TIME));
+
+ /*
+ * Easy case: mtime and atime both specified.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file1");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_entry_set_atime(ae, 123456, 0);
+ archive_entry_set_mtime(ae, 234567, 0);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ /* Verify */
+ assertFileAtime("file1", 123456, 0);
+ assertFileMtime("file1", 234567, 0);
+
+ /*
+ * mtime specified, but not atime
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file2");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_entry_set_mtime(ae, 234567, 0);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ assertFileMtime("file2", 234567, 0);
+ assertFileAtimeRecent("file2");
+
+ /*
+ * atime specified, but not mtime
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file3");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_entry_set_atime(ae, 345678, 0);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ /* Verify: Current mtime and atime as specified. */
+ assertFileAtime("file3", 345678, 0);
+ assertFileMtimeRecent("file3");
+
+ /*
+ * Neither atime nor mtime specified.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file4");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ /* Verify: Current mtime and atime. */
+ assertFileAtimeRecent("file4");
+ assertFileMtimeRecent("file4");
+
+#if defined(__FreeBSD__)
+ /*
+ * High-res mtime and atime on FreeBSD.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file10");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_entry_set_atime(ae, 1234567, 23456);
+ archive_entry_set_mtime(ae, 2345678, 4567);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ /* Verify */
+ assertFileMtime("file10", 2345678, 4567);
+ assertFileAtime("file10", 1234567, 23456);
+
+ /*
+ * Birthtime, mtime and atime on FreeBSD
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file11");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_entry_set_atime(ae, 1234567, 23456);
+ archive_entry_set_birthtime(ae, 3456789, 12345);
+ /* mtime must be later than birthtime! */
+ archive_entry_set_mtime(ae, 12345678, 4567);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ /* Verify */
+ assertFileAtime("file11", 1234567, 23456);
+ assertFileBirthtime("file11", 3456789, 12345);
+ assertFileMtime("file11", 12345678, 4567);
+
+ /*
+ * Birthtime only on FreeBSD.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file12");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_entry_set_birthtime(ae, 3456789, 12345);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ /* Verify */
+ assertFileAtimeRecent("file12");
+ assertFileBirthtime("file12", 3456789, 12345);
+ assertFileMtimeRecent("file12");
+
+ /*
+ * mtime only on FreeBSD.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_copy_pathname(ae, "file13");
+ archive_entry_set_mode(ae, S_IFREG | 0777);
+ archive_entry_set_mtime(ae, 4567890, 23456);
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish_entry(a));
+ archive_entry_free(ae);
+ /* Verify */
+ assertFileAtimeRecent("file13");
+ assertFileBirthtime("file13", 4567890, 23456);
+ assertFileMtime("file13", 4567890, 23456);
+#else
+ skipping("Platform-specific time restore tests");
+#endif
+
+ archive_write_finish(a);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c b/archivers/libarchive/files/libarchive/test/test_write_format_ar.c
index a60a0cd8800..5822b3f3817 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_ar.c
@@ -26,7 +26,7 @@
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_ar.c,v 1.7 2008/05/26 17:00:24 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_ar.c 189308 2009-03-03 17:02:51Z kientzle $");
char buff[4096];
char buff2[64];
@@ -34,7 +34,7 @@ static char strtab[] = "abcdefghijklmn.o/\nggghhhjjjrrrttt.o/\niiijjjdddsssppp.o
DEFINE_TEST(test_write_format_ar)
{
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
skipping("ar write support");
#else
struct archive_entry *ae;
@@ -46,7 +46,6 @@ DEFINE_TEST(test_write_format_ar)
*/
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ar_svr4(a));
- assertA(0 == archive_write_set_compression_gzip(a));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
/* write the filename table */
@@ -73,8 +72,8 @@ DEFINE_TEST(test_write_format_ar)
archive_entry_copy_pathname(ae, "ggghhhjjjrrrttt.o");
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, 7);
- assertA(0 == archive_write_header(a, ae));
- assertA(7 == archive_write_data(a, "7777777", 7));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualIntA(a, 7, archive_write_data(a, "7777777", 7));
archive_entry_free(ae);
/* test full pathname */
@@ -82,8 +81,8 @@ DEFINE_TEST(test_write_format_ar)
archive_entry_copy_pathname(ae, "/usr/home/xx/iiijjjdddsssppp.o");
archive_entry_set_mode(ae, S_IFREG | 0755);
archive_entry_set_size(ae, 8);
- assertA(0 == archive_write_header(a, ae));
- assertA(8 == archive_write_data(a, "88877766", 8));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualIntA(a, 8, archive_write_data(a, "88877766", 8));
archive_entry_free(ae);
/* trailing "/" should be rejected */
@@ -102,49 +101,49 @@ DEFINE_TEST(test_write_format_ar)
archive_entry_free(ae);
archive_write_close(a);
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertEqualInt(0, archive_write_finish(a));
#endif
/*
* Now, read the data back.
*/
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_open_memory(a, buff, used));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
- assertA(0 == archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualInt(0, archive_entry_mtime(ae));
assertEqualString("//", archive_entry_pathname(ae));
assertEqualInt(0, archive_entry_size(ae));
- assertA(0 == archive_read_next_header(a, &ae));
- assert(1 == archive_entry_mtime(ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(1, archive_entry_mtime(ae));
assertEqualString("abcdefghijklmn.o", archive_entry_pathname(ae));
- assert(8 == archive_entry_size(ae));
- assertA(8 == archive_read_data(a, buff2, 10));
- assert(0 == memcmp(buff2, "87654321", 8));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+ assertEqualMem(buff2, "87654321", 8);
- assert(0 == archive_read_next_header(a, &ae));
+ assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("ggghhhjjjrrrttt.o", archive_entry_pathname(ae));
- assert(7 == archive_entry_size(ae));
- assertA(7 == archive_read_data(a, buff2, 11));
- assert(0 == memcmp(buff2, "7777777", 7));
+ assertEqualInt(7, archive_entry_size(ae));
+ assertEqualIntA(a, 7, archive_read_data(a, buff2, 11));
+ assertEqualMem(buff2, "7777777", 7);
- assert(0 == archive_read_next_header(a, &ae));
+ assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualString("iiijjjdddsssppp.o", archive_entry_pathname(ae));
- assert(8 == archive_entry_size(ae));
- assertA(8 == archive_read_data(a, buff2, 17));
- assert(0 == memcmp(buff2, "88877766", 8));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff2, 17));
+ assertEqualMem(buff2, "88877766", 8);
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+ assertEqualIntA(a, 0, archive_read_close(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(0, archive_read_finish(a));
#endif
/*
@@ -152,18 +151,17 @@ DEFINE_TEST(test_write_format_ar)
*/
memset(buff, 0, sizeof(buff));
assert((a = archive_write_new()) != NULL);
- assertA(0 == archive_write_set_format_ar_bsd(a));
- assertA(0 == archive_write_set_compression_bzip2(a));
- assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_ar_bsd(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, sizeof(buff), &used));
/* write a entry need long name extension */
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, "ttttyyyyuuuuiiii.o");
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, 5);
- assertA(0 == archive_write_header(a, ae));
- assertA(5 == archive_entry_size(ae));
- assertA(5 == archive_write_data(a, "12345", 7));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualInt(5, archive_entry_size(ae));
+ assertEqualIntA(a, 5, archive_write_data(a, "12345", 7));
archive_entry_free(ae);
/* write a entry with a short name */
@@ -171,41 +169,41 @@ DEFINE_TEST(test_write_format_ar)
archive_entry_copy_pathname(ae, "ttyy.o");
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, 6);
- assertA(0 == archive_write_header(a, ae));
- assertA(6 == archive_write_data(a, "555555", 7));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ assertEqualIntA(a, 6, archive_write_data(a, "555555", 7));
archive_entry_free(ae);
archive_write_close(a);
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertEqualInt(0, archive_write_finish(a));
#endif
/* Now, Read the data back */
assert((a = archive_read_new()) != NULL);
- assertA(0 == archive_read_support_format_all(a));
- assertA(0 == archive_read_support_compression_all(a));
- assertA(0 == archive_read_open_memory(a, buff, used));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualString("ttttyyyyuuuuiiii.o", archive_entry_pathname(ae));
assertEqualInt(5, archive_entry_size(ae));
- assertA(5 == archive_read_data(a, buff2, 10));
- assert(0 == memcmp(buff2, "12345", 5));
+ assertEqualIntA(a, 5, archive_read_data(a, buff2, 10));
+ assertEqualMem(buff2, "12345", 5);
- assert(0 == archive_read_next_header(a, &ae));
+ assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
assertEqualString("ttyy.o", archive_entry_pathname(ae));
- assert(6 == archive_entry_size(ae));
- assertA(6 == archive_read_data(a, buff2, 10));
- assert(0 == memcmp(buff2, "555555", 6));
+ assertEqualInt(6, archive_entry_size(ae));
+ assertEqualIntA(a, 6, archive_read_data(a, buff2, 10));
+ assertEqualMem(buff2, "555555", 6);
/* Test EOF */
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
- assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+ assertEqualIntA(a, 0, archive_read_close(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assertEqualInt(0, archive_read_finish(a));
#endif
#endif
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio.c
index dbb9775597a..7bf2a41a528 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_cpio.c
@@ -23,10 +23,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_cpio.c,v 1.4 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio.c 185672 2008-12-06 06:02:26Z kientzle $");
/* The version stamp macro was introduced after cpio write support. */
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
static void
test_format(int (*set_format)(struct archive *))
{
@@ -104,14 +104,16 @@ test_format(int (*set_format)(struct archive *))
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/*
* Damage the second entry to test the search-ahead recovery.
+ * TODO: Move the damage-recovery checking to a separate test;
+ * it doesn't really belong in this write test.
*/
{
int i;
@@ -124,7 +126,7 @@ test_format(int (*set_format)(struct archive *))
}
}
failure("Unable to locate the second header for damage-recovery test.");
- assert(damaged = 1);
+ assert(damaged == 1);
/*
* Now, read the data back.
@@ -134,7 +136,10 @@ test_format(int (*set_format)(struct archive *))
assertA(0 == archive_read_support_compression_all(a));
assertA(0 == archive_read_open_memory(a, buff, used));
- assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+ if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae))) {
+ archive_read_finish(a);
+ return;
+ }
assertEqualInt(1, archive_entry_mtime(ae));
/* Not the same as above: cpio doesn't store hi-res times. */
@@ -148,28 +153,14 @@ test_format(int (*set_format)(struct archive *))
assert(0 == memcmp(filedata, "12345678", 8));
/*
- * Read the second file back.
+ * The second file can't be read because we damaged its header.
*/
- if (!damaged) {
- assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
- assertEqualInt(1, archive_entry_mtime(ae));
- /* Not the same as above: cpio doesn't store hi-res times. */
- assert(0 == archive_entry_mtime_nsec(ae));
- assert(0 == archive_entry_atime(ae));
- assert(0 == archive_entry_ctime(ae));
- assertEqualString("file2", archive_entry_pathname(ae));
- assert((S_IFREG | 0755) == archive_entry_mode(ae));
- assertEqualInt(4, archive_entry_size(ae));
- assertEqualIntA(a, 4, archive_read_data(a, filedata, 10));
- assert(0 == memcmp(filedata, "1234", 4));
- }
/*
* Read the dir entry back.
+ * ARCHIVE_WARN here because the damaged entry was skipped.
*/
- assertEqualIntA(a,
- damaged ? ARCHIVE_WARN : ARCHIVE_OK,
- archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae));
assertEqualInt(11, archive_entry_mtime(ae));
assert(0 == archive_entry_mtime_nsec(ae));
assert(0 == archive_entry_atime(ae));
@@ -182,10 +173,10 @@ test_format(int (*set_format)(struct archive *))
/* Verify the end of the archive. */
assertEqualIntA(a, 1, archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
free(buff);
@@ -194,7 +185,7 @@ test_format(int (*set_format)(struct archive *))
DEFINE_TEST(test_write_format_cpio)
{
-#if ARCHIVE_VERSION_STAMP >= 1009000
+#if ARCHIVE_VERSION_NUMBER >= 1009000
test_format(archive_write_set_format_cpio);
test_format(archive_write_set_format_cpio_newc);
#else
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c
index 61c49211d07..131ac24617d 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_empty.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_cpio_empty.c,v 1.2 2007/05/29 01:00:21 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio_empty.c 201247 2009-12-30 05:59:21Z kientzle $");
/*
* Check that an "empty" cpio archive is correctly created.
@@ -62,14 +62,14 @@ DEFINE_TEST(test_write_format_cpio_empty)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
failure("Empty cpio archive should be exactly 87 bytes, was %d.", used);
assert(used == 87);
failure("Empty cpio archive is incorrectly formatted.");
- assert(memcmp(buff, ref, 87) == 0);
+ assertEqualMem(buff, ref, 87);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c
index 431097b2476..1c3c330b0e9 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_newc.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_cpio_newc.c,v 1.2 2008/01/23 05:43:26 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio_newc.c 201247 2009-12-30 05:59:21Z kientzle $");
static int
@@ -52,7 +52,7 @@ DEFINE_TEST(test_write_format_cpio_newc)
{
struct archive *a;
struct archive_entry *entry;
- char *buff, *e;
+ char *buff, *e, *file;
size_t buffsize = 100000;
size_t used;
@@ -99,7 +99,8 @@ DEFINE_TEST(test_write_format_cpio_newc)
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 3, 30);
archive_entry_set_pathname(entry, "lnk");
- archive_entry_set_mode(entry, S_IFLNK | 0664);
+ archive_entry_set_mode(entry, 0664);
+ archive_entry_set_filetype(entry, AE_IFLNK);
archive_entry_set_size(entry, 0);
archive_entry_set_uid(entry, 83);
archive_entry_set_gid(entry, 93);
@@ -111,10 +112,10 @@ DEFINE_TEST(test_write_format_cpio_newc)
archive_entry_free(entry);
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assert(0 == archive_write_finish(a));
#endif
/*
@@ -123,9 +124,10 @@ DEFINE_TEST(test_write_format_cpio_newc)
e = buff;
/* First entry is "file" */
+ file = e;
assert(is_hex(e, 110)); /* Entire header is hex digits. */
assertEqualMem(e + 0, "070701", 6); /* Magic */
- assertEqualMem(e + 6, "00000059", 8); /* ino */
+ assert(memcmp(e + 6, "00000000", 8) != 0); /* ino != 0 */
assertEqualMem(e + 14, "000081b4", 8); /* Mode */
assertEqualMem(e + 22, "00000050", 8); /* uid */
assertEqualMem(e + 30, "0000005a", 8); /* gid */
@@ -166,7 +168,8 @@ DEFINE_TEST(test_write_format_cpio_newc)
/* Third entry is "lnk" */
assert(is_hex(e, 110)); /* Entire header is hex digits. */
assertEqualMem(e + 0, "070701", 6); /* Magic */
- assertEqualMem(e + 6, "00000058", 8); /* ino */
+ assert(memcmp(e + 6, file + 6, 8) != 0); /* ino != file ino */
+ assert(memcmp(e + 6, "00000000", 8) != 0); /* ino != 0 */
assertEqualMem(e + 14, "0000a1b4", 8); /* Mode */
assertEqualMem(e + 22, "00000053", 8); /* uid */
assertEqualMem(e + 30, "0000005d", 8); /* gid */
@@ -205,7 +208,7 @@ DEFINE_TEST(test_write_format_cpio_newc)
assertEqualMem(e + 121, "\0\0\0", 3); /* Pad to multiple of 4 bytes */
e += 124; /* Must be multiple of four here! */
- assertEqualInt(used, e - buff);
+ assertEqualInt((int)used, e - buff);
free(buff);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c
index e6ed7eed778..e2136f87cfb 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_cpio_odc.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_cpio_odc.c,v 1.1 2008/01/01 22:28:04 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_cpio_odc.c 201247 2009-12-30 05:59:21Z kientzle $");
static int
@@ -46,7 +46,7 @@ DEFINE_TEST(test_write_format_cpio_odc)
{
struct archive *a;
struct archive_entry *entry;
- char *buff, *e;
+ char *buff, *e, *file;
size_t buffsize = 100000;
size_t used;
@@ -109,7 +109,8 @@ DEFINE_TEST(test_write_format_cpio_odc)
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 3, 30);
archive_entry_set_pathname(entry, "symlink");
- archive_entry_set_mode(entry, S_IFLNK | 0664);
+ archive_entry_set_mode(entry, 0664);
+ archive_entry_set_filetype(entry, AE_IFLNK);
archive_entry_set_symlink(entry,"file");
archive_entry_set_size(entry, 0);
archive_entry_set_uid(entry, 88);
@@ -122,22 +123,37 @@ DEFINE_TEST(test_write_format_cpio_odc)
/* Write of data to symlink should fail == zero bytes get written. */
assertEqualIntA(a, 0, archive_write_data(a, "1234567890", 10));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assert(0 == archive_write_finish(a));
#endif
/*
* Verify the archive format.
+ *
+ * Notes on the ino validation: cpio does not actually require
+ * that the ino values written to the archive match those read
+ * from disk. It really requires that:
+ * * matching non-zero ino values be written as matching
+ * non-zero values
+ * * non-matching non-zero ino values be written as non-matching
+ * non-zero values
+ * Libarchive further ensures that zero ino values get written
+ * as zeroes. This allows the cpio writer to generate
+ * synthetic ino values for the archive that may be different
+ * than those on disk in order to avoid problems due to truncation.
+ * This is especially needed for odc (POSIX format) that
+ * only supports 18-bit ino values.
*/
e = buff;
/* "file" */
+ file = e; /* Remember where this starts... */
assert(is_octal(e, 76)); /* Entire header is octal digits. */
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000014", 6); /* dev */
- assertEqualMem(e + 12, "000131", 6); /* ino */
+ assert(memcmp(e + 12, "000000", 6) != 0); /* ino must be != 0 */
assertEqualMem(e + 18, "100664", 6); /* Mode */
assertEqualMem(e + 24, "000120", 6); /* uid */
assertEqualMem(e + 30, "000132", 6); /* gid */
@@ -154,7 +170,7 @@ DEFINE_TEST(test_write_format_cpio_odc)
assert(is_octal(e, 76)); /* Entire header is octal digits. */
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000014", 6); /* dev */
- assertEqualMem(e + 12, "000131", 6); /* ino */
+ assertEqualMem(e + 12, file + 12, 6); /* ino must match above */
assertEqualMem(e + 18, "100664", 6); /* Mode */
assertEqualMem(e + 24, "000120", 6); /* uid */
assertEqualMem(e + 30, "000132", 6); /* gid */
@@ -187,7 +203,8 @@ DEFINE_TEST(test_write_format_cpio_odc)
assert(is_octal(e, 76)); /* Entire header is octal digits. */
assertEqualMem(e + 0, "070707", 6); /* Magic */
assertEqualMem(e + 6, "000014", 6); /* dev */
- assertEqualMem(e + 12, "000132", 6); /* ino */
+ assert(memcmp(e + 12, file + 12, 6) != 0); /* ino must != file ino */
+ assert(memcmp(e + 12, "000000", 6) != 0); /* ino must != 0 */
assertEqualMem(e + 18, "120664", 6); /* Mode */
assertEqualMem(e + 24, "000130", 6); /* uid */
assertEqualMem(e + 30, "000142", 6); /* gid */
@@ -218,7 +235,7 @@ DEFINE_TEST(test_write_format_cpio_odc)
assertEqualMem(e + 76, "TRAILER!!!\0", 11); /* Name */
e += 87;
- assertEqualInt(used, e - buff);
+ assertEqualInt((int)used, e - buff);
free(buff);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_mtree.c b/archivers/libarchive/files/libarchive/test/test_write_format_mtree.c
new file mode 100644
index 00000000000..e0b78f55716
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_mtree.c
@@ -0,0 +1,155 @@
+/*-
+ * Copyright (c) 2009 Michihiro NAKAJIMA
+ * 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
+ * in this position and unchanged.
+ * 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: head/lib/libarchive/test/test_write_format_mtree.c 191183 2009-04-17 01:06:31Z kientzle $");
+
+static char buff[4096];
+static struct {
+ const char *path;
+ mode_t mode;
+ time_t mtime;
+ uid_t uid;
+ gid_t gid;
+} entries[] = {
+ { "./Makefile", S_IFREG | 0644, 1233041050, 1001, 1001 },
+ { "./NEWS", S_IFREG | 0644, 1231975636, 1001, 1001 },
+ { "./PROJECTS", S_IFREG | 0644, 1231975636, 1001, 1001 },
+ { "./README", S_IFREG | 0644, 1231975636, 1001, 1001 },
+ { "./COPYING", S_IFREG | 0644, 1231975636, 1001, 1001 },
+ { "./subdir", S_IFDIR | 0755, 1233504586, 1001, 1001 },
+ { "./subdir/README", S_IFREG | 0664, 1231975636, 1002, 1001 },
+ { "./subdir/config", S_IFREG | 0664, 1232266273, 1003, 1003 },
+ { "./subdir2", S_IFDIR | 0755, 1233504586, 1001, 1001 },
+ { "./subdir3", S_IFDIR | 0755, 1233504586, 1001, 1001 },
+ { "./subdir3/mtree", S_IFREG | 0664, 1232266273, 1003, 1003 },
+ { NULL, 0, 0, 0, 0 }
+};
+
+static void
+test_write_format_mtree_sub(int use_set, int dironly)
+{
+ struct archive_entry *ae;
+ struct archive* a;
+ size_t used;
+ int i;
+
+ /* Create a mtree format archive. */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_mtree(a));
+ if (use_set)
+ assertA(0 == archive_write_set_options(a, "use-set"));
+ if (dironly)
+ assertA(0 == archive_write_set_options(a, "dironly"));
+ assertA(0 == archive_write_open_memory(a, buff, sizeof(buff)-1, &used));
+
+ /* Write entries */
+ for (i = 0; entries[i].path != NULL; i++) {
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_mtime(ae, entries[i].mtime, 0);
+ assert(entries[i].mtime == archive_entry_mtime(ae));
+ archive_entry_set_mode(ae, entries[i].mode);
+ assert(entries[i].mode == archive_entry_mode(ae));
+ archive_entry_set_uid(ae, entries[i].uid);
+ assert(entries[i].uid == archive_entry_uid(ae));
+ archive_entry_set_gid(ae, entries[i].gid);
+ assert(entries[i].gid == archive_entry_gid(ae));
+ archive_entry_copy_pathname(ae, entries[i].path);
+ if ((entries[i].mode & AE_IFMT) != S_IFDIR)
+ archive_entry_set_size(ae, 8);
+ assertA(0 == archive_write_header(a, ae));
+ if ((entries[i].mode & AE_IFMT) != S_IFDIR)
+ assertA(8 == archive_write_data(a, "Hello012", 15));
+ archive_entry_free(ae);
+ }
+ archive_write_close(a);
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_write_finish(a);
+#else
+ assertEqualInt(0, archive_write_finish(a));
+#endif
+ if (use_set) {
+ const char *p;
+
+ buff[used] = '\0';
+ assert(NULL != (p = strstr(buff, "\n/set ")));
+ if (p != NULL) {
+ char *r;
+ const char *o;
+ p++;
+ r = strchr(p, '\n');
+ if (r != NULL)
+ *r = '\0';
+ if (dironly)
+ o = "/set type=dir uid=1001 gid=1001 mode=755";
+ else
+ o = "/set type=file uid=1001 gid=1001 mode=644";
+ assertEqualString(o, p);
+ if (r != NULL)
+ *r = '\n';
+ }
+ }
+
+ /*
+ * Read the data and check it.
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used));
+
+ /* Read entries */
+ for (i = 0; entries[i].path != NULL; i++) {
+ if (dironly && (entries[i].mode & AE_IFMT) != S_IFDIR)
+ continue;
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(entries[i].mtime, archive_entry_mtime(ae));
+ assertEqualInt(entries[i].mode, archive_entry_mode(ae));
+ assertEqualInt(entries[i].uid, archive_entry_uid(ae));
+ assertEqualInt(entries[i].gid, archive_entry_gid(ae));
+ assertEqualString(entries[i].path, archive_entry_pathname(ae));
+ if ((entries[i].mode & AE_IFMT) != S_IFDIR)
+ assertEqualInt(8, archive_entry_size(ae));
+ }
+ assertEqualIntA(a, 0, archive_read_close(a));
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_read_finish(a);
+#else
+ assertEqualInt(0, archive_read_finish(a));
+#endif
+}
+
+DEFINE_TEST(test_write_format_mtree)
+{
+ /* Default setting */
+ test_write_format_mtree_sub(0, 0);
+ /* Directory only */
+ test_write_format_mtree_sub(0, 1);
+ /* Use /set keyword */
+ test_write_format_mtree_sub(1, 0);
+ /* Use /set keyword with directory only */
+ test_write_format_mtree_sub(1, 1);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_pax.c b/archivers/libarchive/files/libarchive/test/test_write_format_pax.c
new file mode 100644
index 00000000000..06cfca6fe99
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_pax.c
@@ -0,0 +1,146 @@
+/*-
+ * Copyright (c) 2003-2008 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$");
+
+char buff2[64];
+
+DEFINE_TEST(test_write_format_pax)
+{
+ size_t buffsize = 1000000;
+ char *buff;
+ struct archive_entry *ae;
+ struct archive *a;
+ size_t used;
+
+ buff = malloc(buffsize); /* million bytes of work area */
+ assert(buff != NULL);
+
+ /* Create a new archive in memory. */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_pax(a));
+ assertA(0 == archive_write_set_compression_none(a));
+ assertA(0 == archive_write_open_memory(a, buff, buffsize, &used));
+
+ /*
+ * "file" has a bunch of attributes and 8 bytes of data.
+ */
+ 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, "file");
+ 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));
+
+ /*
+ * "file2" is similar but has birthtime later than mtime.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_atime(ae, 2, 20);
+ archive_entry_set_birthtime(ae, 8, 80);
+ archive_entry_set_ctime(ae, 4, 40);
+ archive_entry_set_mtime(ae, 5, 50);
+ archive_entry_copy_pathname(ae, "file2");
+ 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));
+
+ /*
+ * XXX TODO XXX Archive directory, other file types.
+ * Archive extended attributes, ACLs, other metadata.
+ * Verify they get read back correctly.
+ */
+
+ /* Close out the archive. */
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ *
+ * Now, read the data back.
+ *
+ */
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, 0, archive_read_support_format_all(a));
+ assertEqualIntA(a, 0, archive_read_support_compression_all(a));
+ assertEqualIntA(a, 0, archive_read_open_memory(a, buff, used));
+
+ /*
+ * Read "file"
+ */
+ assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+ assertEqualInt(2, archive_entry_atime(ae));
+ assertEqualInt(20, archive_entry_atime_nsec(ae));
+ assertEqualInt(3, archive_entry_birthtime(ae));
+ assertEqualInt(30, archive_entry_birthtime_nsec(ae));
+ assertEqualInt(4, archive_entry_ctime(ae));
+ assertEqualInt(40, archive_entry_ctime_nsec(ae));
+ assertEqualInt(5, archive_entry_mtime(ae));
+ assertEqualInt(50, archive_entry_mtime_nsec(ae));
+ assertEqualString("file", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+ assertEqualMem(buff2, "12345678", 8);
+
+ /*
+ * Read "file2"
+ */
+ assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
+ assert(archive_entry_atime_is_set(ae));
+ assertEqualInt(2, archive_entry_atime(ae));
+ assertEqualInt(20, archive_entry_atime_nsec(ae));
+ /* Birthtime > mtime above, so it doesn't get stored at all. */
+ assert(!archive_entry_birthtime_is_set(ae));
+ assertEqualInt(0, archive_entry_birthtime(ae));
+ assertEqualInt(0, archive_entry_birthtime_nsec(ae));
+ assert(archive_entry_ctime_is_set(ae));
+ assertEqualInt(4, archive_entry_ctime(ae));
+ assertEqualInt(40, archive_entry_ctime_nsec(ae));
+ assert(archive_entry_mtime_is_set(ae));
+ assertEqualInt(5, archive_entry_mtime(ae));
+ assertEqualInt(50, archive_entry_mtime_nsec(ae));
+ assertEqualString("file2", archive_entry_pathname(ae));
+ assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(8, archive_entry_size(ae));
+ assertEqualIntA(a, 8, archive_read_data(a, buff2, 10));
+ assertEqualMem(buff2, "12345678", 8);
+
+ /*
+ * Verify the end of the archive.
+ */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_finish(a));
+
+ free(buff);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c b/archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c
index c43e23b3c56..14ee3889a36 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_shar_empty.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_shar_empty.c,v 1.2 2007/05/29 01:00:21 kientzle Exp $");
+__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_shar_empty.c,v 1.3 2008/09/01 05:38:33 kientzle Exp $");
/*
* Check that an "empty" shar archive is correctly created as an empty file.
@@ -47,10 +47,10 @@ DEFINE_TEST(test_write_format_shar_empty)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
failure("Empty shar archive should be exactly 0 bytes, was %d.", used);
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_tar.c b/archivers/libarchive/files/libarchive/test/test_write_format_tar.c
index a23d05ca209..372fef1f023 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_tar.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_tar.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_tar.c,v 1.3 2007/05/29 01:00:21 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_tar.c 189308 2009-03-03 17:02:51Z kientzle $");
char buff[1000000];
char buff2[64];
@@ -42,8 +42,8 @@ DEFINE_TEST(test_write_format_tar)
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
assertA(0 == archive_write_set_compression_none(a));
- assertA(0 == archive_write_set_bytes_per_block(a, blocksize));
- assertA(0 == archive_write_set_bytes_in_last_block(a, blocksize));
+ assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize));
+ assertA(0 == archive_write_set_bytes_in_last_block(a, (int)blocksize));
assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a));
assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
assertA(blocksize == (size_t)archive_write_get_bytes_in_last_block(a));
@@ -72,10 +72,10 @@ DEFINE_TEST(test_write_format_tar)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
/* This calculation gives "the smallest multiple of
* the block size that is at least 2048 bytes". */
@@ -105,10 +105,10 @@ DEFINE_TEST(test_write_format_tar)
/* Verify the end of the archive. */
assert(1 == archive_read_next_header(a, &ae));
assert(0 == archive_read_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_read_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_read_finish(a);
+#else
+ assert(0 == archive_read_finish(a));
#endif
}
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c b/archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c
index 1d4d35449d5..6b40f0767f3 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_tar_empty.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_tar_empty.c,v 1.3 2007/07/06 15:43:11 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_tar_empty.c 189308 2009-03-03 17:02:51Z kientzle $");
/*
* Check that an "empty" tar archive is correctly created.
@@ -46,13 +46,13 @@ DEFINE_TEST(test_write_format_tar_empty)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
/* Earlier versions wrote 0-length files for empty tar archives. */
skipping("empty tar archive size");
#else
@@ -73,17 +73,17 @@ DEFINE_TEST(test_write_format_tar_empty)
/* Close out the archive. */
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assertA(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assertA(0 == archive_write_finish(a));
#endif
-#if ARCHIVE_VERSION_STAMP < 1009000
+#if ARCHIVE_VERSION_NUMBER < 1009000
/* Earlier versions wrote 0-length files for empty tar archives. */
skipping("empty tar archive size");
#else
- assertEqualInt(used, 1024);
+ assertEqualInt((int)used, 1024);
#endif
for (i = 0; i < used; i++) {
failure("Empty tar archive should be all nulls.");
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c b/archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c
index 53eb07cf7d9..29968dfb331 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_tar_ustar.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_tar_ustar.c 201247 2009-12-30 05:59:21Z kientzle $");
static int
is_null(const char *p, size_t l)
@@ -133,7 +133,8 @@ DEFINE_TEST(test_write_format_tar_ustar)
assert((entry = archive_entry_new()) != NULL);
archive_entry_set_mtime(entry, 3, 30);
archive_entry_set_pathname(entry, "symlink");
- archive_entry_set_mode(entry, S_IFLNK | 0664);
+ archive_entry_set_mode(entry, 0664);
+ archive_entry_set_filetype(entry, AE_IFLNK);
archive_entry_set_symlink(entry,"file");
archive_entry_set_size(entry, 0);
archive_entry_set_uid(entry, 88);
@@ -188,7 +189,11 @@ DEFINE_TEST(test_write_format_tar_ustar)
assertEqualIntA(a, 0, archive_write_header(a, entry));
archive_entry_free(entry);
+#if ARCHIVE_VERSION_NUMBER < 2000000
+ archive_write_finish(a);
+#else
assert(0 == archive_write_finish(a));
+#endif
/*
* Verify the archive format.
@@ -336,7 +341,7 @@ DEFINE_TEST(test_write_format_tar_ustar)
assert(is_null(e, 1024));
e += 1024;
- assertEqualInt(used, e - buff);
+ assertEqualInt((int)used, e - buff);
free(buff);
}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_zip.c b/archivers/libarchive/files/libarchive/test/test_write_format_zip.c
new file mode 100644
index 00000000000..250ddba9131
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_zip.c
@@ -0,0 +1,180 @@
+/*-
+ * Copyright (c) 2003-2008 Tim Kientzle
+ * Copyright (c) 2008 Anselm Strauss
+ * 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.
+ */
+
+/*
+ * Development supported by Google Summer of Code 2008.
+ */
+
+/* TODO: reader does not yet restore permissions. */
+
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_zip.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+DEFINE_TEST(test_write_format_zip)
+{
+ char filedata[64];
+ struct archive_entry *ae;
+ struct archive *a;
+ size_t used;
+ size_t buffsize = 1000000;
+ char *buff;
+ const char *compression_type;
+
+ buff = malloc(buffsize);
+
+ /* Create a new archive in memory. */
+ assert((a = archive_write_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_format_zip(a));
+#ifdef HAVE_ZLIB_H
+ compression_type = "zip:compression=deflate";
+#else
+ compression_type = "zip:compression=store";
+#endif
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_set_format_options(a, compression_type));
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_set_compression_none(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_write_open_memory(a, buff, buffsize, &used));
+
+ /*
+ * Write a file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_mtime(ae, 1, 10);
+ assertEqualInt(1, archive_entry_mtime(ae));
+ assertEqualInt(10, archive_entry_mtime_nsec(ae));
+ archive_entry_copy_pathname(ae, "file");
+ assertEqualString("file", archive_entry_pathname(ae));
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
+ archive_entry_set_size(ae, 8);
+
+ assertEqualInt(0, archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertEqualInt(8, archive_write_data(a, "12345678", 9));
+ assertEqualInt(0, archive_write_data(a, "1", 1));
+
+ /*
+ * Write another file to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_mtime(ae, 1, 10);
+ assertEqualInt(1, archive_entry_mtime(ae));
+ assertEqualInt(10, archive_entry_mtime_nsec(ae));
+ archive_entry_copy_pathname(ae, "file2");
+ assertEqualString("file2", archive_entry_pathname(ae));
+ archive_entry_set_mode(ae, S_IFREG | 0755);
+ assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
+ archive_entry_set_size(ae, 4);
+
+ assertEqualInt(ARCHIVE_OK, archive_write_header(a, ae));
+ archive_entry_free(ae);
+ assertEqualInt(4, archive_write_data(a, "1234", 5));
+
+ /*
+ * Write a directory to it.
+ */
+ assert((ae = archive_entry_new()) != NULL);
+ archive_entry_set_mtime(ae, 11, 110);
+ archive_entry_copy_pathname(ae, "dir");
+ archive_entry_set_mode(ae, S_IFDIR | 0755);
+ archive_entry_set_size(ae, 512);
+
+ assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
+ failure("size should be zero so that applications know not to write");
+ assertEqualInt(0, archive_entry_size(ae));
+ archive_entry_free(ae);
+ assertEqualIntA(a, 0, archive_write_data(a, "12345678", 9));
+
+ /* Close out the archive. */
+ assertEqualInt(ARCHIVE_OK, archive_write_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_write_finish(a));
+
+ /*
+ * Now, read the data back.
+ */
+ ae = NULL;
+ assert((a = archive_read_new()) != NULL);
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_support_compression_all(a));
+ assertEqualIntA(a, ARCHIVE_OK,
+ archive_read_open_memory(a, buff, used));
+
+ /*
+ * Read and verify first file.
+ */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(1, archive_entry_mtime(ae));
+ /* Zip doesn't store high-resolution mtime. */
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(0, archive_entry_atime(ae));
+ assertEqualInt(0, archive_entry_ctime(ae));
+ assertEqualString("file", archive_entry_pathname(ae));
+ //assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualIntA(a, 8,
+ archive_read_data(a, filedata, sizeof(filedata)));
+ assertEqualMem(filedata, "12345678", 8);
+
+
+ /*
+ * Read the second file back.
+ */
+ if (!assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae))){
+ free(buff);
+ return;
+ }
+ assertEqualInt(1, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(0, archive_entry_atime(ae));
+ assertEqualInt(0, archive_entry_ctime(ae));
+ assertEqualString("file2", archive_entry_pathname(ae));
+ //assert((S_IFREG | 0755) == archive_entry_mode(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualIntA(a, 4,
+ archive_read_data(a, filedata, sizeof(filedata)));
+ assertEqualMem(filedata, "1234", 4);
+
+ /*
+ * Read the dir entry back.
+ */
+ assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+ assertEqualInt(11, archive_entry_mtime(ae));
+ assertEqualInt(0, archive_entry_mtime_nsec(ae));
+ assertEqualInt(0, archive_entry_atime(ae));
+ assertEqualInt(0, archive_entry_ctime(ae));
+ assertEqualString("dir/", archive_entry_pathname(ae));
+ //assertEqualInt((S_IFDIR | 0755), archive_entry_mode(ae));
+ assertEqualInt(0, archive_entry_size(ae));
+ assertEqualIntA(a, 0, archive_read_data(a, filedata, 10));
+
+ /* Verify the end of the archive. */
+ assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
+ assertEqualInt(ARCHIVE_OK, archive_read_close(a));
+ assertEqualInt(ARCHIVE_OK, archive_read_finish(a));
+ free(buff);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_zip_empty.c b/archivers/libarchive/files/libarchive/test/test_write_format_zip_empty.c
new file mode 100644
index 00000000000..459664e2347
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_zip_empty.c
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2008 Anselm Strauss
+ * 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.
+ */
+
+/*
+ * Development supported by Google Summer of Code 2008.
+ */
+
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_zip_empty.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+DEFINE_TEST(test_write_format_zip_empty)
+{
+ struct archive *a;
+ char buff[256];
+ size_t used;
+
+ /* Zip format: Create a new archive in memory. */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_zip(a));
+ assertA(0 == archive_write_set_compression_none(a));
+ assertA(0 == archive_write_set_bytes_per_block(a, 1));
+ assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
+ assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+ /* Close out the archive without writing anything. */
+ assertA(0 == archive_write_close(a));
+ assertA(0 == archive_write_finish(a));
+
+ /* Verify the correct format for an empy Zip archive. */
+ assertEqualInt(used, 22);
+ assertEqualMem(buff,
+ "PK\005\006\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
+ 22);
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_zip_no_compression.c b/archivers/libarchive/files/libarchive/test/test_write_format_zip_no_compression.c
new file mode 100644
index 00000000000..4a61a76eb6a
--- /dev/null
+++ b/archivers/libarchive/files/libarchive/test/test_write_format_zip_no_compression.c
@@ -0,0 +1,304 @@
+/*-
+ * Copyright (c) 2008 Anselm Strauss
+ * 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.
+ */
+
+/*
+ * Development supported by Google Summer of Code 2008.
+ */
+
+#include "test.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_format_zip_no_compression.c 201247 2009-12-30 05:59:21Z kientzle $");
+
+static unsigned long
+bitcrc32(unsigned long c, void *_p, size_t s)
+{
+ /* This is a drop-in replacement for crc32() from zlib.
+ * Libarchive should be able to correctly generate
+ * uncompressed zip archives (including correct CRCs) even
+ * when zlib is unavailable, and this function helps us verify
+ * that. Yes, this is very, very slow and unsuitable for
+ * production use, but it's correct, compact, and works well
+ * enough for this particular usage. Libarchive internally
+ * uses a much more efficient implementation. */
+ const unsigned char *p = _p;
+ int bitctr;
+
+ if (p == NULL)
+ return (0);
+
+ for (; s > 0; --s) {
+ c ^= *p++;
+ for (bitctr = 8; bitctr > 0; --bitctr) {
+ if (c & 1) c = (c >> 1);
+ else c = (c >> 1) ^ 0xedb88320;
+ c ^= 0x80000000;
+ }
+ }
+ return (c);
+}
+
+/* Quick and dirty: Read 2-byte and 4-byte integers from Zip file. */
+static int i2(const char *p) { return ((p[0] & 0xff) | ((p[1] & 0xff) << 8)); }
+static int i4(const char *p) { return (i2(p) | (i2(p + 2) << 16)); }
+
+DEFINE_TEST(test_write_format_zip_no_compression)
+{
+ /* Buffer data */
+ struct archive *a;
+ struct archive_entry *entry;
+ char buff[100000];
+ const char *buffend;
+ /* p is the pointer to walk over the central directory,
+ * q walks over the local headers, the data and the data descriptors. */
+ const char *p, *q;
+ size_t used;
+
+ /* File data */
+ char file_name[] = "file";
+ char file_data1[] = {'1', '2', '3', '4', '5'};
+ char file_data2[] = {'6', '7', '8', '9', '0'};
+ int file_perm = 00644;
+ short file_uid = 10;
+ short file_gid = 20;
+
+ /* Folder data */
+ char folder_name[] = "folder/";
+ int folder_perm = 00755;
+ short folder_uid = 30;
+ short folder_gid = 40;
+
+ /* Time data */
+ time_t t = time(NULL);
+ struct tm *tm = localtime(&t);
+
+ /* Misc variables */
+ unsigned long crc;
+
+ /* Create new ZIP archive in memory without padding. */
+ assert((a = archive_write_new()) != NULL);
+ assertA(0 == archive_write_set_format_zip(a));
+ assertA(0 == archive_write_set_format_options(a, "zip:compression=store"));
+ assertA(0 == archive_write_set_compression_none(a));
+ assertA(0 == archive_write_set_bytes_per_block(a, 1));
+ assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
+ assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
+
+ /* Write entries. */
+
+ /* Regular file */
+ assert((entry = archive_entry_new()) != NULL);
+ archive_entry_set_pathname(entry, file_name);
+ archive_entry_set_mode(entry, S_IFREG | 0644);
+ archive_entry_set_size(entry, sizeof(file_data1) + sizeof(file_data2));
+ archive_entry_set_uid(entry, file_uid);
+ archive_entry_set_gid(entry, file_gid);
+ archive_entry_set_mtime(entry, t, 0);
+ archive_entry_set_atime(entry, t, 0);
+ archive_entry_set_ctime(entry, t, 0);
+ assertEqualIntA(a, 0, archive_write_header(a, entry));
+ assertEqualIntA(a, sizeof(file_data1), archive_write_data(a, file_data1, sizeof(file_data1)));
+ assertEqualIntA(a, sizeof(file_data2), archive_write_data(a, file_data2, sizeof(file_data2)));
+ archive_entry_free(entry);
+
+ /* Folder */
+ assert((entry = archive_entry_new()) != NULL);
+ archive_entry_set_pathname(entry, folder_name);
+ archive_entry_set_mode(entry, S_IFDIR | folder_perm);
+ archive_entry_set_size(entry, 0);
+ archive_entry_set_uid(entry, folder_uid);
+ archive_entry_set_gid(entry, folder_gid);
+ archive_entry_set_mtime(entry, t, 0);
+ archive_entry_set_atime(entry, t, 0);
+ archive_entry_set_ctime(entry, t, 0);
+ assertEqualIntA(a, 0, archive_write_header(a, entry));
+ archive_entry_free(entry);
+
+ /* Close the archive . */
+ assertA(0 == archive_write_close(a));
+ assertA(0 == archive_write_finish(a));
+
+ /* Remember the end of the archive in memory. */
+ buffend = buff + used;
+
+ /* Verify "End of Central Directory" record. */
+ /* Get address of end-of-central-directory record. */
+ p = buffend - 22; /* Assumes there is no zip comment field. */
+ failure("End-of-central-directory begins with PK\\005\\006 signature");
+ assertEqualMem(p, "PK\005\006", 4);
+ failure("This must be disk 0");
+ assertEqualInt(i2(p + 4), 0);
+ failure("Central dir must start on disk 0");
+ assertEqualInt(i2(p + 6), 0);
+ failure("All central dir entries are on this disk");
+ assertEqualInt(i2(p + 8), i2(p + 10));
+ failure("CD start (%d) + CD length (%d) should == archive size - 22",
+ i4(p + 12), i4(p + 16));
+ assertEqualInt(i4(p + 12) + i4(p + 16), used - 22);
+ failure("no zip comment");
+ assertEqualInt(i2(p + 20), 0);
+
+ /* Get address of first entry in central directory. */
+ p = buff + i4(buffend - 6);
+ failure("Central file record at offset %d should begin with"
+ " PK\\001\\002 signature",
+ i4(buffend - 10));
+
+ /* Verify file entry in central directory. */
+ assertEqualMem(p, "PK\001\002", 4); /* Signature */
+ assertEqualInt(i2(p + 4), 3 * 256 + 20); /* Version made by */
+ assertEqualInt(i2(p + 6), 20); /* Version needed to extract */
+ assertEqualInt(i2(p + 8), 8); /* Flags */
+ assertEqualInt(i2(p + 10), 0); /* Compression method */
+ assertEqualInt(i2(p + 12), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
+ assertEqualInt(i2(p + 14), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
+ crc = bitcrc32(0, file_data1, sizeof(file_data1));
+ crc = bitcrc32(crc, file_data2, sizeof(file_data2));
+ assertEqualInt(i4(p + 16), crc); /* CRC-32 */
+ assertEqualInt(i4(p + 20), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */
+ assertEqualInt(i4(p + 24), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */
+ assertEqualInt(i2(p + 28), strlen(file_name)); /* Pathname length */
+ assertEqualInt(i2(p + 30), 13); /* Extra field length */
+ assertEqualInt(i2(p + 32), 0); /* File comment length */
+ assertEqualInt(i2(p + 34), 0); /* Disk number start */
+ assertEqualInt(i2(p + 36), 0); /* Internal file attrs */
+ assertEqualInt(i4(p + 38) >> 16 & 01777, file_perm); /* External file attrs */
+ assertEqualInt(i4(p + 42), 0); /* Offset of local header */
+ assertEqualMem(p + 46, file_name, strlen(file_name)); /* Pathname */
+ p = p + 46 + strlen(file_name);
+ assertEqualInt(i2(p), 0x5455); /* 'UT' extension header */
+ assertEqualInt(i2(p + 2), 5); /* 'UT' size */
+ assertEqualInt(p[4], 7); /* 'UT' flags */
+ assertEqualInt(i4(p + 5), t); /* 'UT' mtime */
+ p = p + 9;
+ assertEqualInt(i2(p), 0x7855); /* 'Ux' extension header */
+ assertEqualInt(i2(p + 2), 0); /* 'Ux' size */
+ p = p + 4;
+
+ /* Verify local header of file entry. */
+ q = buff;
+ assertEqualMem(q, "PK\003\004", 4); /* Signature */
+ assertEqualInt(i2(q + 4), 20); /* Version needed to extract */
+ assertEqualInt(i2(q + 6), 8); /* Flags */
+ assertEqualInt(i2(q + 8), 0); /* Compression method */
+ assertEqualInt(i2(q + 10), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
+ assertEqualInt(i2(q + 12), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
+ assertEqualInt(i4(q + 14), 0); /* CRC-32 */
+ assertEqualInt(i4(q + 18), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */
+ assertEqualInt(i4(q + 22), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */
+ assertEqualInt(i2(q + 26), strlen(file_name)); /* Pathname length */
+ assertEqualInt(i2(q + 28), 25); /* Extra field length */
+ assertEqualMem(q + 30, file_name, strlen(file_name)); /* Pathname */
+ q = q + 30 + strlen(file_name);
+ assertEqualInt(i2(q), 0x5455); /* 'UT' extension header */
+ assertEqualInt(i2(q + 2), 13); /* 'UT' size */
+ assertEqualInt(q[4], 7); /* 'UT' flags */
+ assertEqualInt(i4(q + 5), t); /* 'UT' mtime */
+ assertEqualInt(i4(q + 9), t); /* 'UT' atime */
+ assertEqualInt(i4(q + 13), t); /* 'UT' ctime */
+ q = q + 17;
+ assertEqualInt(i2(q), 0x7855); /* 'Ux' extension header */
+ assertEqualInt(i2(q + 2), 4); /* 'Ux' size */
+ assertEqualInt(i2(q + 4), file_uid); /* 'Ux' UID */
+ assertEqualInt(i2(q + 6), file_gid); /* 'Ux' GID */
+ q = q + 8;
+
+ /* Verify data of file entry. */
+ assertEqualMem(q, file_data1, sizeof(file_data1));
+ assertEqualMem(q + sizeof(file_data1), file_data2, sizeof(file_data2));
+ q = q + sizeof(file_data1) + sizeof(file_data2);
+
+ /* Verify data descriptor of file entry. */
+ assertEqualMem(q, "PK\007\010", 4); /* Signature */
+ assertEqualInt(i4(q + 4), crc); /* CRC-32 */
+ assertEqualInt(i4(q + 8), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */
+ assertEqualInt(i4(q + 12), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */
+ q = q + 16;
+
+ /* Verify folder entry in central directory. */
+ assertEqualMem(p, "PK\001\002", 4); /* Signature */
+ assertEqualInt(i2(p + 4), 3 * 256 + 20); /* Version made by */
+ assertEqualInt(i2(p + 6), 20); /* Version needed to extract */
+ assertEqualInt(i2(p + 8), 8); /* Flags */
+ assertEqualInt(i2(p + 10), 0); /* Compression method */
+ assertEqualInt(i2(p + 12), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
+ assertEqualInt(i2(p + 14), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
+ crc = 0;
+ assertEqualInt(i4(p + 16), crc); /* CRC-32 */
+ assertEqualInt(i4(p + 20), 0); /* Compressed size */
+ assertEqualInt(i4(p + 24), 0); /* Uncompressed size */
+ assertEqualInt(i2(p + 28), strlen(folder_name)); /* Pathname length */
+ assertEqualInt(i2(p + 30), 13); /* Extra field length */
+ assertEqualInt(i2(p + 32), 0); /* File comment length */
+ assertEqualInt(i2(p + 34), 0); /* Disk number start */
+ assertEqualInt(i2(p + 36), 0); /* Internal file attrs */
+ assertEqualInt(i4(p + 38) >> 16 & 01777, folder_perm); /* External file attrs */
+ assertEqualInt(i4(p + 42), q - buff); /* Offset of local header */
+ assertEqualMem(p + 46, folder_name, strlen(folder_name)); /* Pathname */
+ p = p + 46 + strlen(folder_name);
+ assertEqualInt(i2(p), 0x5455); /* 'UT' extension header */
+ assertEqualInt(i2(p + 2), 5); /* 'UT' size */
+ assertEqualInt(p[4], 7); /* 'UT' flags */
+ assertEqualInt(i4(p + 5), t); /* 'UT' mtime */
+ p = p + 9;
+ assertEqualInt(i2(p), 0x7855); /* 'Ux' extension header */
+ assertEqualInt(i2(p + 2), 0); /* 'Ux' size */
+ p = p + 4;
+
+ /* Verify local header of folder entry. */
+ assertEqualMem(q, "PK\003\004", 4); /* Signature */
+ assertEqualInt(i2(q + 4), 20); /* Version needed to extract */
+ assertEqualInt(i2(q + 6), 8); /* Flags */
+ assertEqualInt(i2(q + 8), 0); /* Compression method */
+ assertEqualInt(i2(q + 10), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */
+ assertEqualInt(i2(q + 12), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */
+ assertEqualInt(i4(q + 14), 0); /* CRC-32 */
+ assertEqualInt(i4(q + 18), 0); /* Compressed size */
+ assertEqualInt(i4(q + 22), 0); /* Uncompressed size */
+ assertEqualInt(i2(q + 26), strlen(folder_name)); /* Pathname length */
+ assertEqualInt(i2(q + 28), 25); /* Extra field length */
+ assertEqualMem(q + 30, folder_name, strlen(folder_name)); /* Pathname */
+ q = q + 30 + strlen(folder_name);
+ assertEqualInt(i2(q), 0x5455); /* 'UT' extension header */
+ assertEqualInt(i2(q + 2), 13); /* 'UT' size */
+ assertEqualInt(q[4], 7); /* 'UT' flags */
+ assertEqualInt(i4(q + 5), t); /* 'UT' mtime */
+ assertEqualInt(i4(q + 9), t); /* 'UT' atime */
+ assertEqualInt(i4(q + 13), t); /* 'UT' ctime */
+ q = q + 17;
+ assertEqualInt(i2(q), 0x7855); /* 'Ux' extension header */
+ assertEqualInt(i2(q + 2), 4); /* 'Ux' size */
+ assertEqualInt(i2(q + 4), folder_uid); /* 'Ux' UID */
+ assertEqualInt(i2(q + 6), folder_gid); /* 'Ux' GID */
+ q = q + 8;
+
+ /* There should not be any data in the folder entry,
+ * meaning next is the data descriptor header. */
+
+ /* Verify data descriptor of folder entry. */
+ assertEqualMem(q, "PK\007\010", 4); /* Signature */
+ assertEqualInt(i4(q + 4), crc); /* CRC-32 */
+ assertEqualInt(i4(q + 8), 0); /* Compressed size */
+ assertEqualInt(i4(q + 12), 0); /* Uncompressed size */
+ q = q + 16;
+}
diff --git a/archivers/libarchive/files/libarchive/test/test_write_open_memory.c b/archivers/libarchive/files/libarchive/test/test_write_open_memory.c
index 2e58fff4af5..696db6c963a 100644
--- a/archivers/libarchive/files/libarchive/test/test_write_open_memory.c
+++ b/archivers/libarchive/files/libarchive/test/test_write_open_memory.c
@@ -23,7 +23,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "test.h"
-__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_open_memory.c,v 1.3 2007/05/29 01:00:21 kientzle Exp $");
+__FBSDID("$FreeBSD: head/lib/libarchive/test/test_write_open_memory.c 189308 2009-03-03 17:02:51Z kientzle $");
/* Try to force archive_write_open_memory.c to write past the end of an array. */
static unsigned char buff[16384];
@@ -50,7 +50,7 @@ DEFINE_TEST(test_write_open_memory)
assert((a = archive_write_new()) != NULL);
assertA(0 == archive_write_set_format_ustar(a));
assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
- assertA(0 == archive_write_set_bytes_per_block(a, blocksize));
+ assertA(0 == archive_write_set_bytes_per_block(a, (int)blocksize));
buff[i] = 0xAE;
assertA(0 == archive_write_open_memory(a, buff, i, &s));
/* If buffer is smaller than a tar header, this should fail. */
@@ -64,10 +64,10 @@ DEFINE_TEST(test_write_open_memory)
assertA(ARCHIVE_FATAL == archive_write_close(a));
else
assertA(0 == archive_write_close(a));
-#if ARCHIVE_API_VERSION > 1
- assert(0 == archive_write_finish(a));
-#else
+#if ARCHIVE_VERSION_NUMBER < 2000000
archive_write_finish(a);
+#else
+ assert(0 == archive_write_finish(a));
#endif
assert(buff[i] == 0xAE);
assert(s <= i);