libarchive-static 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (296) hide show
  1. checksums.yaml +5 -5
  2. data/ext/extconf.rb +2 -9
  3. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.c +6 -6
  4. data/ext/libarchive-0.1.1/ext/archive_read_support_compression.o +0 -0
  5. data/ext/libarchive-0.1.1/ext/archive_read_support_format.o +0 -0
  6. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.c +1 -1
  7. data/ext/libarchive-0.1.1/ext/archive_write_open_rb_str.o +0 -0
  8. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.c +5 -5
  9. data/ext/libarchive-0.1.1/ext/archive_write_set_compression.o +0 -0
  10. data/ext/libarchive-0.1.1/ext/config.h +23 -0
  11. data/ext/libarchive-0.1.1/ext/config.log +230 -0
  12. data/ext/libarchive-0.1.1/ext/config.status +671 -0
  13. data/ext/libarchive-0.1.1/ext/libarchive.c +1 -1
  14. data/ext/libarchive-0.1.1/ext/libarchive.o +0 -0
  15. data/ext/libarchive-0.1.1/ext/libarchive_archive.c +7 -7
  16. data/ext/libarchive-0.1.1/ext/libarchive_archive.o +0 -0
  17. data/ext/libarchive-0.1.1/ext/libarchive_entry.c +6 -0
  18. data/ext/libarchive-0.1.1/ext/libarchive_entry.o +0 -0
  19. data/ext/libarchive-0.1.1/ext/libarchive_internal.h +0 -1
  20. data/ext/libarchive-0.1.1/ext/libarchive_reader.c +6 -4
  21. data/ext/libarchive-0.1.1/ext/libarchive_reader.o +0 -0
  22. data/ext/libarchive-0.1.1/ext/libarchive_ruby.so +0 -0
  23. data/ext/libarchive-0.1.1/ext/libarchive_win32.h +1 -1
  24. data/ext/libarchive-0.1.1/ext/libarchive_writer.c +2 -2
  25. data/ext/libarchive-0.1.1/ext/libarchive_writer.o +0 -0
  26. data/ext/libarchive-3.6.2/Makefile.in +16892 -0
  27. data/ext/libarchive-3.6.2/build/autoconf/ax_append_compile_flags.m4 +67 -0
  28. data/ext/libarchive-3.6.2/build/autoconf/ax_append_flag.m4 +71 -0
  29. data/ext/libarchive-3.6.2/build/autoconf/ax_check_compile_flag.m4 +74 -0
  30. data/ext/libarchive-3.6.2/build/autoconf/ax_require_defined.m4 +37 -0
  31. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/check_stdcall_func.m4 +0 -0
  32. data/ext/libarchive-3.6.2/build/autoconf/compile +348 -0
  33. data/ext/libarchive-3.6.2/build/autoconf/config.guess +1754 -0
  34. data/ext/libarchive-3.6.2/build/autoconf/config.rpath +696 -0
  35. data/ext/libarchive-3.6.2/build/autoconf/config.sub +1890 -0
  36. data/ext/libarchive-3.6.2/build/autoconf/depcomp +791 -0
  37. data/ext/libarchive-3.6.2/build/autoconf/iconv.m4 +271 -0
  38. data/ext/libarchive-3.6.2/build/autoconf/install-sh +541 -0
  39. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/la_uid_t.m4 +0 -0
  40. data/ext/libarchive-3.6.2/build/autoconf/lib-ld.m4 +109 -0
  41. data/ext/libarchive-3.6.2/build/autoconf/lib-link.m4 +777 -0
  42. data/ext/libarchive-3.6.2/build/autoconf/lib-prefix.m4 +224 -0
  43. data/ext/libarchive-3.6.2/build/autoconf/ltmain.sh +11251 -0
  44. data/ext/libarchive-3.6.2/build/autoconf/m4_ax_compile_check_sizeof.m4 +115 -0
  45. data/ext/libarchive-3.6.2/build/autoconf/missing +215 -0
  46. data/ext/libarchive-3.6.2/build/autoconf/test-driver +153 -0
  47. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/pkgconfig/libarchive.pc.in +4 -1
  48. data/ext/libarchive-3.6.2/config.h.in +1504 -0
  49. data/ext/libarchive-3.6.2/configure +25558 -0
  50. data/ext/libarchive-3.6.2/libarchive/archive.h +1212 -0
  51. data/ext/libarchive-3.6.2/libarchive/archive_acl.c +2097 -0
  52. data/ext/libarchive-3.6.2/libarchive/archive_acl_private.h +83 -0
  53. data/ext/libarchive-3.6.2/libarchive/archive_blake2.h +197 -0
  54. data/ext/libarchive-3.6.2/libarchive/archive_blake2_impl.h +161 -0
  55. data/ext/libarchive-3.6.2/libarchive/archive_blake2s_ref.c +369 -0
  56. data/ext/libarchive-3.6.2/libarchive/archive_blake2sp_ref.c +361 -0
  57. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_check_magic.c +63 -22
  58. data/ext/libarchive-3.6.2/libarchive/archive_cmdline.c +227 -0
  59. data/ext/libarchive-3.6.2/libarchive/archive_cmdline_private.h +47 -0
  60. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_crc32.h +17 -0
  61. data/ext/libarchive-3.6.2/libarchive/archive_cryptor.c +534 -0
  62. data/ext/libarchive-3.6.2/libarchive/archive_cryptor_private.h +188 -0
  63. data/ext/libarchive-3.6.2/libarchive/archive_digest.c +1505 -0
  64. data/ext/libarchive-3.6.2/libarchive/archive_digest_private.h +416 -0
  65. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_darwin.c +559 -0
  66. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_freebsd.c +712 -0
  67. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_linux.c +760 -0
  68. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_sunos.c +824 -0
  69. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_endian.h +48 -15
  70. data/ext/libarchive-3.6.2/libarchive/archive_entry.c +2149 -0
  71. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry.h +305 -106
  72. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_bhfi.c +5 -4
  73. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_stat.c +9 -3
  74. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_link_resolver.c +104 -62
  75. data/ext/libarchive-3.6.2/libarchive/archive_entry_locale.h +92 -0
  76. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_private.h +65 -49
  77. data/ext/libarchive-3.6.2/libarchive/archive_entry_sparse.c +156 -0
  78. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_stat.c +6 -6
  79. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_strmode.c +1 -1
  80. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_xattr.c +4 -6
  81. data/ext/libarchive-3.6.2/libarchive/archive_getdate.c +1165 -0
  82. data/ext/libarchive-3.6.2/libarchive/archive_getdate.h +39 -0
  83. data/ext/libarchive-3.6.2/libarchive/archive_hmac.c +334 -0
  84. data/ext/libarchive-3.6.2/libarchive/archive_hmac_private.h +117 -0
  85. data/ext/libarchive-3.6.2/libarchive/archive_match.c +1875 -0
  86. data/ext/libarchive-3.6.2/libarchive/archive_openssl_evp_private.h +53 -0
  87. data/ext/libarchive-3.6.2/libarchive/archive_openssl_hmac_private.h +54 -0
  88. data/ext/libarchive-3.6.2/libarchive/archive_options.c +218 -0
  89. data/ext/libarchive-3.6.2/libarchive/archive_options_private.h +51 -0
  90. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.c +337 -0
  91. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.h +49 -0
  92. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.c +463 -0
  93. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.h +52 -0
  94. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_platform.h +77 -9
  95. data/ext/libarchive-3.6.2/libarchive/archive_platform_acl.h +55 -0
  96. data/ext/libarchive-3.6.2/libarchive/archive_platform_xattr.h +47 -0
  97. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7.c +1168 -0
  98. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7_private.h +119 -0
  99. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8.c +1287 -0
  100. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8_private.h +148 -0
  101. data/ext/libarchive-3.6.2/libarchive/archive_ppmd_private.h +151 -0
  102. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_private.h +74 -18
  103. data/ext/libarchive-3.6.2/libarchive/archive_random.c +272 -0
  104. data/ext/libarchive-3.6.2/libarchive/archive_random_private.h +36 -0
  105. data/ext/libarchive-3.6.2/libarchive/archive_rb.c +709 -0
  106. data/ext/libarchive-3.6.2/libarchive/archive_rb.h +113 -0
  107. data/ext/libarchive-3.6.2/libarchive/archive_read.c +1756 -0
  108. data/ext/libarchive-3.6.2/libarchive/archive_read_add_passphrase.c +190 -0
  109. data/ext/libarchive-3.6.2/libarchive/archive_read_append_filter.c +204 -0
  110. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_data_into_fd.c +64 -18
  111. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_entry_from_file.c +1086 -0
  112. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_posix.c +2732 -0
  113. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_private.h +40 -4
  114. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_set_standard_lookup.c +21 -11
  115. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_windows.c +2479 -0
  116. data/ext/libarchive-3.6.2/libarchive/archive_read_extract.c +60 -0
  117. data/ext/{libarchive-2.8.4/libarchive/archive_read_extract.c → libarchive-3.6.2/libarchive/archive_read_extract2.c} +34 -61
  118. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_fd.c +70 -49
  119. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_file.c +38 -23
  120. data/ext/libarchive-3.6.2/libarchive/archive_read_open_filename.c +586 -0
  121. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_memory.c +58 -28
  122. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_private.h +127 -59
  123. data/ext/libarchive-3.6.2/libarchive/archive_read_set_format.c +117 -0
  124. data/ext/libarchive-3.6.2/libarchive/archive_read_set_options.c +133 -0
  125. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_all.c → libarchive-3.6.2/libarchive/archive_read_support_filter_all.c} +35 -10
  126. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_by_code.c +83 -0
  127. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_bzip2.c → libarchive-3.6.2/libarchive/archive_read_support_filter_bzip2.c} +38 -26
  128. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_compress.c → libarchive-3.6.2/libarchive/archive_read_support_filter_compress.c} +52 -44
  129. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_grzip.c +112 -0
  130. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_gzip.c → libarchive-3.6.2/libarchive/archive_read_support_filter_gzip.c} +108 -37
  131. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lrzip.c +122 -0
  132. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lz4.c +742 -0
  133. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lzop.c +499 -0
  134. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_none.c → libarchive-3.6.2/libarchive/archive_read_support_filter_none.c} +15 -3
  135. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_program.c → libarchive-3.6.2/libarchive/archive_read_support_filter_program.c} +114 -77
  136. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_rpm.c → libarchive-3.6.2/libarchive/archive_read_support_filter_rpm.c} +31 -31
  137. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_uu.c → libarchive-3.6.2/libarchive/archive_read_support_filter_uu.c} +141 -85
  138. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_compression_xz.c → libarchive-3.6.2/libarchive/archive_read_support_filter_xz.c} +369 -284
  139. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_zstd.c +297 -0
  140. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_7zip.c +3900 -0
  141. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_all.c +89 -0
  142. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_ar.c +126 -72
  143. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_by_code.c +92 -0
  144. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cab.c +3228 -0
  145. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cpio.c +1104 -0
  146. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_empty.c +14 -11
  147. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_iso9660.c +990 -541
  148. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_lha.c +2916 -0
  149. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_mtree.c +2150 -0
  150. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar.c +3797 -0
  151. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar5.c +4251 -0
  152. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_raw.c +38 -31
  153. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_tar.c +1157 -629
  154. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_warc.c +848 -0
  155. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_xar.c +439 -258
  156. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_zip.c +4270 -0
  157. data/ext/libarchive-3.6.2/libarchive/archive_string.c +4240 -0
  158. data/ext/libarchive-3.6.2/libarchive/archive_string.h +243 -0
  159. data/ext/libarchive-3.6.2/libarchive/archive_string_composition.h +2292 -0
  160. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_string_sprintf.c +44 -16
  161. data/ext/libarchive-3.6.2/libarchive/archive_util.c +655 -0
  162. data/ext/libarchive-3.6.2/libarchive/archive_version_details.c +151 -0
  163. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_virtual.c +85 -16
  164. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.c +214 -541
  165. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.h +74 -106
  166. data/ext/libarchive-3.6.2/libarchive/archive_write.c +828 -0
  167. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter.c +72 -0
  168. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_b64encode.c +304 -0
  169. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_by_name.c +77 -0
  170. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_bzip2.c +401 -0
  171. data/ext/{libarchive-2.8.4/libarchive/archive_write_set_compression_compress.c → libarchive-3.6.2/libarchive/archive_write_add_filter_compress.c} +86 -131
  172. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_grzip.c +135 -0
  173. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_gzip.c +442 -0
  174. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lrzip.c +197 -0
  175. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lz4.c +700 -0
  176. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lzop.c +478 -0
  177. data/ext/{libarchive-2.8.4/libarchive/archive_read_support_format_all.c → libarchive-3.6.2/libarchive/archive_write_add_filter_none.c} +11 -11
  178. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_program.c +391 -0
  179. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_uuencode.c +295 -0
  180. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_xz.c +545 -0
  181. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_zstd.c +418 -0
  182. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_posix.c +4711 -0
  183. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_private.h +9 -2
  184. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_set_standard_lookup.c +30 -29
  185. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_windows.c +2842 -0
  186. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_fd.c +15 -10
  187. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_file.c +15 -9
  188. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_filename.c +128 -20
  189. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_memory.c +7 -18
  190. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_private.h +72 -29
  191. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format.c +56 -3
  192. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_7zip.c +2322 -0
  193. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ar.c +54 -34
  194. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_by_name.c +20 -2
  195. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio.c +11 -0
  196. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_binary.c +610 -0
  197. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_newc.c +457 -0
  198. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_odc.c +500 -0
  199. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_filter_by_ext.c +142 -0
  200. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_gnutar.c +755 -0
  201. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_iso9660.c +8165 -0
  202. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_mtree.c +2217 -0
  203. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_pax.c +1049 -387
  204. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_private.h +42 -0
  205. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_raw.c +125 -0
  206. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_shar.c +62 -47
  207. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ustar.c +279 -108
  208. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_v7tar.c +638 -0
  209. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_warc.c +453 -0
  210. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_xar.c +3259 -0
  211. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_zip.c +1704 -0
  212. data/ext/libarchive-3.6.2/libarchive/archive_write_set_options.c +130 -0
  213. data/ext/libarchive-3.6.2/libarchive/archive_write_set_passphrase.c +95 -0
  214. data/ext/libarchive-3.6.2/libarchive/archive_xxhash.h +48 -0
  215. data/ext/libarchive-3.6.2/libarchive/config_freebsd.h +271 -0
  216. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/filter_fork.h +10 -5
  217. data/ext/{libarchive-2.8.4/libarchive/filter_fork.c → libarchive-3.6.2/libarchive/filter_fork_posix.c} +98 -19
  218. data/ext/libarchive-3.6.2/libarchive/filter_fork_windows.c +236 -0
  219. data/ext/libarchive-3.6.2/libarchive/xxhash.c +525 -0
  220. data/ext/libarchive-static-makefile +144 -80
  221. data/ext/libarchive-static-wrapper-makefile +1 -1
  222. data/ext/zlib-1.2.13/Makefile.in +404 -0
  223. data/ext/{zlib-1.2.5 → zlib-1.2.13}/adler32.c +51 -34
  224. data/ext/{zlib-1.2.5 → zlib-1.2.13}/compress.c +27 -21
  225. data/ext/zlib-1.2.13/configure +922 -0
  226. data/ext/zlib-1.2.13/crc32.c +1125 -0
  227. data/ext/zlib-1.2.13/crc32.h +9446 -0
  228. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.c +842 -459
  229. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.h +37 -33
  230. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzclose.c +0 -0
  231. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzguts.h +103 -16
  232. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzlib.c +155 -53
  233. data/ext/zlib-1.2.13/gzread.c +650 -0
  234. data/ext/zlib-1.2.13/gzwrite.c +677 -0
  235. data/ext/{zlib-1.2.5 → zlib-1.2.13}/infback.c +24 -12
  236. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.c +49 -66
  237. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.h +0 -0
  238. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffixed.h +3 -3
  239. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.c +209 -94
  240. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.h +9 -5
  241. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.c +24 -50
  242. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.h +1 -1
  243. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.c +135 -198
  244. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.h +0 -0
  245. data/ext/zlib-1.2.13/uncompr.c +93 -0
  246. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zconf.h +182 -63
  247. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zlib.h +617 -295
  248. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.c +50 -41
  249. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.h +83 -82
  250. metadata +244 -137
  251. data/ext/libarchive-0.1.1/libarchive.c +0 -1762
  252. data/ext/libarchive-2.8.4/Makefile.in +0 -7076
  253. data/ext/libarchive-2.8.4/build/autoconf/compile +0 -143
  254. data/ext/libarchive-2.8.4/build/autoconf/config.guess +0 -1502
  255. data/ext/libarchive-2.8.4/build/autoconf/config.sub +0 -1708
  256. data/ext/libarchive-2.8.4/build/autoconf/depcomp +0 -630
  257. data/ext/libarchive-2.8.4/build/autoconf/install-sh +0 -291
  258. data/ext/libarchive-2.8.4/build/autoconf/ltmain.sh +0 -8406
  259. data/ext/libarchive-2.8.4/build/autoconf/missing +0 -376
  260. data/ext/libarchive-2.8.4/config.h.in +0 -772
  261. data/ext/libarchive-2.8.4/configure +0 -17916
  262. data/ext/libarchive-2.8.4/libarchive/archive.h +0 -741
  263. data/ext/libarchive-2.8.4/libarchive/archive_entry.c +0 -2202
  264. data/ext/libarchive-2.8.4/libarchive/archive_hash.h +0 -281
  265. data/ext/libarchive-2.8.4/libarchive/archive_read.c +0 -1249
  266. data/ext/libarchive-2.8.4/libarchive/archive_read_disk.c +0 -198
  267. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_entry_from_file.c +0 -570
  268. data/ext/libarchive-2.8.4/libarchive/archive_read_open_filename.c +0 -272
  269. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_cpio.c +0 -777
  270. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_mtree.c +0 -1304
  271. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_zip.c +0 -903
  272. data/ext/libarchive-2.8.4/libarchive/archive_string.c +0 -453
  273. data/ext/libarchive-2.8.4/libarchive/archive_string.h +0 -148
  274. data/ext/libarchive-2.8.4/libarchive/archive_util.c +0 -391
  275. data/ext/libarchive-2.8.4/libarchive/archive_write.c +0 -466
  276. data/ext/libarchive-2.8.4/libarchive/archive_write_disk.c +0 -2628
  277. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_bzip2.c +0 -408
  278. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_gzip.c +0 -477
  279. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_none.c +0 -257
  280. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_program.c +0 -347
  281. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_xz.c +0 -438
  282. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio.c +0 -344
  283. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio_newc.c +0 -295
  284. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_mtree.c +0 -1050
  285. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_zip.c +0 -667
  286. data/ext/libarchive-2.8.4/libarchive/config_freebsd.h +0 -154
  287. data/ext/libarchive-2.8.4/libarchive/filter_fork_windows.c +0 -113
  288. data/ext/zlib-1.2.5/Makefile.in +0 -257
  289. data/ext/zlib-1.2.5/configure +0 -596
  290. data/ext/zlib-1.2.5/crc32.c +0 -442
  291. data/ext/zlib-1.2.5/crc32.h +0 -441
  292. data/ext/zlib-1.2.5/example.c +0 -565
  293. data/ext/zlib-1.2.5/gzread.c +0 -653
  294. data/ext/zlib-1.2.5/gzwrite.c +0 -531
  295. data/ext/zlib-1.2.5/minigzip.c +0 -440
  296. data/ext/zlib-1.2.5/uncompr.c +0 -59
@@ -0,0 +1,742 @@
1
+ /*-
2
+ * Copyright (c) 2014 Michihiro NAKAJIMA
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ * 2. Redistributions in binary form must reproduce the above copyright
11
+ * notice, this list of conditions and the following disclaimer in the
12
+ * documentation and/or other materials provided with the distribution.
13
+ *
14
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
+ */
25
+
26
+ #include "archive_platform.h"
27
+
28
+ __FBSDID("$FreeBSD$");
29
+
30
+ #ifdef HAVE_ERRNO_H
31
+ #include <errno.h>
32
+ #endif
33
+ #include <stdio.h>
34
+ #ifdef HAVE_STDLIB_H
35
+ #include <stdlib.h>
36
+ #endif
37
+ #ifdef HAVE_STRING_H
38
+ #include <string.h>
39
+ #endif
40
+ #ifdef HAVE_UNISTD_H
41
+ #include <unistd.h>
42
+ #endif
43
+ #ifdef HAVE_LZ4_H
44
+ #include <lz4.h>
45
+ #endif
46
+
47
+ #include "archive.h"
48
+ #include "archive_endian.h"
49
+ #include "archive_private.h"
50
+ #include "archive_read_private.h"
51
+ #include "archive_xxhash.h"
52
+
53
+ #define LZ4_MAGICNUMBER 0x184d2204
54
+ #define LZ4_SKIPPABLED 0x184d2a50
55
+ #define LZ4_LEGACY 0x184c2102
56
+
57
+ #if defined(HAVE_LIBLZ4)
58
+ struct private_data {
59
+ enum { SELECT_STREAM,
60
+ READ_DEFAULT_STREAM,
61
+ READ_DEFAULT_BLOCK,
62
+ READ_LEGACY_STREAM,
63
+ READ_LEGACY_BLOCK,
64
+ } stage;
65
+ struct {
66
+ unsigned block_independence:1;
67
+ unsigned block_checksum:3;
68
+ unsigned stream_size:1;
69
+ unsigned stream_checksum:1;
70
+ unsigned preset_dictionary:1;
71
+ int block_maximum_size;
72
+ } flags;
73
+ int64_t stream_size;
74
+ uint32_t dict_id;
75
+ char *out_block;
76
+ size_t out_block_size;
77
+
78
+ /* Bytes read but not yet consumed via __archive_read_consume() */
79
+ size_t unconsumed;
80
+ size_t decoded_size;
81
+ void *xxh32_state;
82
+
83
+ char valid; /* True = decompressor is initialized */
84
+ char eof; /* True = found end of compressed data. */
85
+ };
86
+
87
+ #define LEGACY_BLOCK_SIZE (8 * 1024 * 1024)
88
+
89
+ /* Lz4 filter */
90
+ static ssize_t lz4_filter_read(struct archive_read_filter *, const void **);
91
+ static int lz4_filter_close(struct archive_read_filter *);
92
+ #endif
93
+
94
+ /*
95
+ * Note that we can detect lz4 archives even if we can't decompress
96
+ * them. (In fact, we like detecting them because we can give better
97
+ * error messages.) So the bid framework here gets compiled even
98
+ * if liblz4 is unavailable.
99
+ */
100
+ static int lz4_reader_bid(struct archive_read_filter_bidder *, struct archive_read_filter *);
101
+ static int lz4_reader_init(struct archive_read_filter *);
102
+ #if defined(HAVE_LIBLZ4)
103
+ static ssize_t lz4_filter_read_default_stream(struct archive_read_filter *,
104
+ const void **);
105
+ static ssize_t lz4_filter_read_legacy_stream(struct archive_read_filter *,
106
+ const void **);
107
+ #endif
108
+
109
+ static const struct archive_read_filter_bidder_vtable
110
+ lz4_bidder_vtable = {
111
+ .bid = lz4_reader_bid,
112
+ .init = lz4_reader_init,
113
+ };
114
+
115
+ int
116
+ archive_read_support_filter_lz4(struct archive *_a)
117
+ {
118
+ struct archive_read *a = (struct archive_read *)_a;
119
+
120
+ if (__archive_read_register_bidder(a, NULL, "lz4",
121
+ &lz4_bidder_vtable) != ARCHIVE_OK)
122
+ return (ARCHIVE_FATAL);
123
+
124
+ #if defined(HAVE_LIBLZ4)
125
+ return (ARCHIVE_OK);
126
+ #else
127
+ archive_set_error(_a, ARCHIVE_ERRNO_MISC,
128
+ "Using external lz4 program");
129
+ return (ARCHIVE_WARN);
130
+ #endif
131
+ }
132
+
133
+ /*
134
+ * Test whether we can handle this data.
135
+ *
136
+ * This logic returns zero if any part of the signature fails. It
137
+ * also tries to Do The Right Thing if a very short buffer prevents us
138
+ * from verifying as much as we would like.
139
+ */
140
+ static int
141
+ lz4_reader_bid(struct archive_read_filter_bidder *self,
142
+ struct archive_read_filter *filter)
143
+ {
144
+ const unsigned char *buffer;
145
+ ssize_t avail;
146
+ int bits_checked;
147
+ uint32_t number;
148
+
149
+ (void)self; /* UNUSED */
150
+
151
+ /* Minimal lz4 archive is 11 bytes. */
152
+ buffer = __archive_read_filter_ahead(filter, 11, &avail);
153
+ if (buffer == NULL)
154
+ return (0);
155
+
156
+ /* First four bytes must be LZ4 magic numbers. */
157
+ bits_checked = 0;
158
+ if ((number = archive_le32dec(buffer)) == LZ4_MAGICNUMBER) {
159
+ unsigned char flag, BD;
160
+
161
+ bits_checked += 32;
162
+ /* Next follows a stream descriptor. */
163
+ /* Descriptor Flags. */
164
+ flag = buffer[4];
165
+ /* A version number must be "01". */
166
+ if (((flag & 0xc0) >> 6) != 1)
167
+ return (0);
168
+ /* A reserved bit must be "0". */
169
+ if (flag & 2)
170
+ return (0);
171
+ bits_checked += 8;
172
+ BD = buffer[5];
173
+ /* A block maximum size should be more than 3. */
174
+ if (((BD & 0x70) >> 4) < 4)
175
+ return (0);
176
+ /* Reserved bits must be "0". */
177
+ if (BD & ~0x70)
178
+ return (0);
179
+ bits_checked += 8;
180
+ } else if (number == LZ4_LEGACY) {
181
+ bits_checked += 32;
182
+ }
183
+
184
+ return (bits_checked);
185
+ }
186
+
187
+ #if !defined(HAVE_LIBLZ4)
188
+
189
+ /*
190
+ * If we don't have the library on this system, we can't actually do the
191
+ * decompression. We can, however, still detect compressed archives
192
+ * and emit a useful message.
193
+ */
194
+ static int
195
+ lz4_reader_init(struct archive_read_filter *self)
196
+ {
197
+ int r;
198
+
199
+ r = __archive_read_program(self, "lz4 -d -q");
200
+ /* Note: We set the format here even if __archive_read_program()
201
+ * above fails. We do, after all, know what the format is
202
+ * even if we weren't able to read it. */
203
+ self->code = ARCHIVE_FILTER_LZ4;
204
+ self->name = "lz4";
205
+ return (r);
206
+ }
207
+
208
+
209
+ #else
210
+
211
+ static const struct archive_read_filter_vtable
212
+ lz4_reader_vtable = {
213
+ .read = lz4_filter_read,
214
+ .close = lz4_filter_close,
215
+ };
216
+
217
+ /*
218
+ * Setup the callbacks.
219
+ */
220
+ static int
221
+ lz4_reader_init(struct archive_read_filter *self)
222
+ {
223
+ struct private_data *state;
224
+
225
+ self->code = ARCHIVE_FILTER_LZ4;
226
+ self->name = "lz4";
227
+
228
+ state = (struct private_data *)calloc(sizeof(*state), 1);
229
+ if (state == NULL) {
230
+ archive_set_error(&self->archive->archive, ENOMEM,
231
+ "Can't allocate data for lz4 decompression");
232
+ return (ARCHIVE_FATAL);
233
+ }
234
+
235
+ self->data = state;
236
+ state->stage = SELECT_STREAM;
237
+ self->vtable = &lz4_reader_vtable;
238
+
239
+ return (ARCHIVE_OK);
240
+ }
241
+
242
+ static int
243
+ lz4_allocate_out_block(struct archive_read_filter *self)
244
+ {
245
+ struct private_data *state = (struct private_data *)self->data;
246
+ size_t out_block_size = state->flags.block_maximum_size;
247
+ void *out_block;
248
+
249
+ if (!state->flags.block_independence)
250
+ out_block_size += 64 * 1024;
251
+ if (state->out_block_size < out_block_size) {
252
+ free(state->out_block);
253
+ out_block = (unsigned char *)malloc(out_block_size);
254
+ state->out_block_size = out_block_size;
255
+ if (out_block == NULL) {
256
+ archive_set_error(&self->archive->archive, ENOMEM,
257
+ "Can't allocate data for lz4 decompression");
258
+ return (ARCHIVE_FATAL);
259
+ }
260
+ state->out_block = out_block;
261
+ }
262
+ if (!state->flags.block_independence)
263
+ memset(state->out_block, 0, 64 * 1024);
264
+ return (ARCHIVE_OK);
265
+ }
266
+
267
+ static int
268
+ lz4_allocate_out_block_for_legacy(struct archive_read_filter *self)
269
+ {
270
+ struct private_data *state = (struct private_data *)self->data;
271
+ size_t out_block_size = LEGACY_BLOCK_SIZE;
272
+ void *out_block;
273
+
274
+ if (state->out_block_size < out_block_size) {
275
+ free(state->out_block);
276
+ out_block = (unsigned char *)malloc(out_block_size);
277
+ state->out_block_size = out_block_size;
278
+ if (out_block == NULL) {
279
+ archive_set_error(&self->archive->archive, ENOMEM,
280
+ "Can't allocate data for lz4 decompression");
281
+ return (ARCHIVE_FATAL);
282
+ }
283
+ state->out_block = out_block;
284
+ }
285
+ return (ARCHIVE_OK);
286
+ }
287
+
288
+ /*
289
+ * Return the next block of decompressed data.
290
+ */
291
+ static ssize_t
292
+ lz4_filter_read(struct archive_read_filter *self, const void **p)
293
+ {
294
+ struct private_data *state = (struct private_data *)self->data;
295
+ ssize_t ret;
296
+
297
+ if (state->eof) {
298
+ *p = NULL;
299
+ return (0);
300
+ }
301
+
302
+ __archive_read_filter_consume(self->upstream, state->unconsumed);
303
+ state->unconsumed = 0;
304
+
305
+ switch (state->stage) {
306
+ case SELECT_STREAM:
307
+ break;
308
+ case READ_DEFAULT_STREAM:
309
+ case READ_LEGACY_STREAM:
310
+ /* Reading a lz4 stream already failed. */
311
+ archive_set_error(&self->archive->archive,
312
+ ARCHIVE_ERRNO_MISC, "Invalid sequence.");
313
+ return (ARCHIVE_FATAL);
314
+ case READ_DEFAULT_BLOCK:
315
+ ret = lz4_filter_read_default_stream(self, p);
316
+ if (ret != 0 || state->stage != SELECT_STREAM)
317
+ return ret;
318
+ break;
319
+ case READ_LEGACY_BLOCK:
320
+ ret = lz4_filter_read_legacy_stream(self, p);
321
+ if (ret != 0 || state->stage != SELECT_STREAM)
322
+ return ret;
323
+ break;
324
+ default:
325
+ archive_set_error(&self->archive->archive,
326
+ ARCHIVE_ERRNO_MISC, "Program error.");
327
+ return (ARCHIVE_FATAL);
328
+ break;
329
+ }
330
+
331
+ while (state->stage == SELECT_STREAM) {
332
+ const char *read_buf;
333
+
334
+ /* Read a magic number. */
335
+ read_buf = __archive_read_filter_ahead(self->upstream, 4,
336
+ NULL);
337
+ if (read_buf == NULL) {
338
+ state->eof = 1;
339
+ *p = NULL;
340
+ return (0);
341
+ }
342
+ uint32_t number = archive_le32dec(read_buf);
343
+ __archive_read_filter_consume(self->upstream, 4);
344
+ if (number == LZ4_MAGICNUMBER)
345
+ return lz4_filter_read_default_stream(self, p);
346
+ else if (number == LZ4_LEGACY)
347
+ return lz4_filter_read_legacy_stream(self, p);
348
+ else if ((number & ~0xF) == LZ4_SKIPPABLED) {
349
+ read_buf = __archive_read_filter_ahead(
350
+ self->upstream, 4, NULL);
351
+ if (read_buf == NULL) {
352
+ archive_set_error(
353
+ &self->archive->archive,
354
+ ARCHIVE_ERRNO_MISC,
355
+ "Malformed lz4 data");
356
+ return (ARCHIVE_FATAL);
357
+ }
358
+ uint32_t skip_bytes = archive_le32dec(read_buf);
359
+ __archive_read_filter_consume(self->upstream,
360
+ 4 + skip_bytes);
361
+ } else {
362
+ /* Ignore following unrecognized data. */
363
+ state->eof = 1;
364
+ *p = NULL;
365
+ return (0);
366
+ }
367
+ }
368
+ state->eof = 1;
369
+ *p = NULL;
370
+ return (0);
371
+ }
372
+
373
+ static int
374
+ lz4_filter_read_descriptor(struct archive_read_filter *self)
375
+ {
376
+ struct private_data *state = (struct private_data *)self->data;
377
+ const char *read_buf;
378
+ ssize_t bytes_remaining;
379
+ ssize_t descriptor_bytes;
380
+ unsigned char flag, bd;
381
+ unsigned int chsum, chsum_verifier;
382
+
383
+ /* Make sure we have 2 bytes for flags. */
384
+ read_buf = __archive_read_filter_ahead(self->upstream, 2,
385
+ &bytes_remaining);
386
+ if (read_buf == NULL) {
387
+ archive_set_error(&self->archive->archive,
388
+ ARCHIVE_ERRNO_MISC,
389
+ "truncated lz4 input");
390
+ return (ARCHIVE_FATAL);
391
+ }
392
+
393
+ /*
394
+ Parse flags.
395
+ */
396
+ flag = (unsigned char)read_buf[0];
397
+ /* Verify version number. */
398
+ if ((flag & 0xc0) != 1<<6)
399
+ goto malformed_error;
400
+ /* A reserved bit must be zero. */
401
+ if (flag & 0x02)
402
+ goto malformed_error;
403
+ state->flags.block_independence = (flag & 0x20) != 0;
404
+ state->flags.block_checksum = (flag & 0x10)?4:0;
405
+ state->flags.stream_size = (flag & 0x08) != 0;
406
+ state->flags.stream_checksum = (flag & 0x04) != 0;
407
+ state->flags.preset_dictionary = (flag & 0x01) != 0;
408
+
409
+ /* BD */
410
+ bd = (unsigned char)read_buf[1];
411
+ /* Reserved bits must be zero. */
412
+ if (bd & 0x8f)
413
+ goto malformed_error;
414
+ /* Get a maximum block size. */
415
+ switch (read_buf[1] >> 4) {
416
+ case 4: /* 64 KB */
417
+ state->flags.block_maximum_size = 64 * 1024;
418
+ break;
419
+ case 5: /* 256 KB */
420
+ state->flags.block_maximum_size = 256 * 1024;
421
+ break;
422
+ case 6: /* 1 MB */
423
+ state->flags.block_maximum_size = 1024 * 1024;
424
+ break;
425
+ case 7: /* 4 MB */
426
+ state->flags.block_maximum_size = 4 * 1024 * 1024;
427
+ break;
428
+ default:
429
+ goto malformed_error;
430
+ }
431
+
432
+ /* Read the whole descriptor in a stream block. */
433
+ descriptor_bytes = 3;
434
+ if (state->flags.stream_size)
435
+ descriptor_bytes += 8;
436
+ if (state->flags.preset_dictionary)
437
+ descriptor_bytes += 4;
438
+ if (bytes_remaining < descriptor_bytes) {
439
+ read_buf = __archive_read_filter_ahead(self->upstream,
440
+ descriptor_bytes, &bytes_remaining);
441
+ if (read_buf == NULL) {
442
+ archive_set_error(&self->archive->archive,
443
+ ARCHIVE_ERRNO_MISC,
444
+ "truncated lz4 input");
445
+ return (ARCHIVE_FATAL);
446
+ }
447
+ }
448
+ /* Check if a descriptor is corrupted */
449
+ chsum = __archive_xxhash.XXH32(read_buf, (int)descriptor_bytes -1, 0);
450
+ chsum = (chsum >> 8) & 0xff;
451
+ chsum_verifier = read_buf[descriptor_bytes-1] & 0xff;
452
+ if (chsum != chsum_verifier)
453
+ #ifndef DONT_FAIL_ON_CRC_ERROR
454
+ goto malformed_error;
455
+ #endif
456
+
457
+ __archive_read_filter_consume(self->upstream, descriptor_bytes);
458
+
459
+ /* Make sure we have a large enough buffer for uncompressed data. */
460
+ if (lz4_allocate_out_block(self) != ARCHIVE_OK)
461
+ return (ARCHIVE_FATAL);
462
+ if (state->flags.stream_checksum)
463
+ state->xxh32_state = __archive_xxhash.XXH32_init(0);
464
+
465
+ state->decoded_size = 0;
466
+ /* Success */
467
+ return (ARCHIVE_OK);
468
+ malformed_error:
469
+ archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
470
+ "malformed lz4 data");
471
+ return (ARCHIVE_FATAL);
472
+ }
473
+
474
+ static ssize_t
475
+ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
476
+ {
477
+ struct private_data *state = (struct private_data *)self->data;
478
+ ssize_t compressed_size;
479
+ const char *read_buf;
480
+ ssize_t bytes_remaining;
481
+ int checksum_size;
482
+ ssize_t uncompressed_size;
483
+ size_t prefix64k;
484
+
485
+ *p = NULL;
486
+
487
+ /* Make sure we have 4 bytes for a block size. */
488
+ read_buf = __archive_read_filter_ahead(self->upstream, 4,
489
+ &bytes_remaining);
490
+ if (read_buf == NULL)
491
+ goto truncated_error;
492
+ compressed_size = archive_le32dec(read_buf);
493
+ if ((compressed_size & 0x7fffffff) > state->flags.block_maximum_size)
494
+ goto malformed_error;
495
+ /* A compressed size == 0 means the end of stream blocks. */
496
+ if (compressed_size == 0) {
497
+ __archive_read_filter_consume(self->upstream, 4);
498
+ return 0;
499
+ }
500
+
501
+ checksum_size = state->flags.block_checksum;
502
+ /* Check if the block is uncompressed. */
503
+ if (compressed_size & 0x80000000U) {
504
+ compressed_size &= 0x7fffffff;
505
+ uncompressed_size = compressed_size;
506
+ } else
507
+ uncompressed_size = 0;/* Unknown yet. */
508
+
509
+ /*
510
+ Unfortunately, lz4 decompression API requires a whole block
511
+ for its decompression speed, so we read a whole block and allocate
512
+ a huge buffer used for decoded data.
513
+ */
514
+ read_buf = __archive_read_filter_ahead(self->upstream,
515
+ 4 + compressed_size + checksum_size, &bytes_remaining);
516
+ if (read_buf == NULL)
517
+ goto truncated_error;
518
+
519
+ /* Optional processing, checking a block sum. */
520
+ if (checksum_size) {
521
+ unsigned int chsum = __archive_xxhash.XXH32(
522
+ read_buf + 4, (int)compressed_size, 0);
523
+ unsigned int chsum_block =
524
+ archive_le32dec(read_buf + 4 + compressed_size);
525
+ if (chsum != chsum_block)
526
+ #ifndef DONT_FAIL_ON_CRC_ERROR
527
+ goto malformed_error;
528
+ #endif
529
+ }
530
+
531
+
532
+ /* If the block is uncompressed, there is nothing to do. */
533
+ if (uncompressed_size) {
534
+ /* Prepare a prefix 64k block for next block. */
535
+ if (!state->flags.block_independence) {
536
+ prefix64k = 64 * 1024;
537
+ if (uncompressed_size < (ssize_t)prefix64k) {
538
+ memcpy(state->out_block
539
+ + prefix64k - uncompressed_size,
540
+ read_buf + 4,
541
+ uncompressed_size);
542
+ memset(state->out_block, 0,
543
+ prefix64k - uncompressed_size);
544
+ } else {
545
+ memcpy(state->out_block,
546
+ read_buf + 4
547
+ + uncompressed_size - prefix64k,
548
+ prefix64k);
549
+ }
550
+ state->decoded_size = 0;
551
+ }
552
+ state->unconsumed = 4 + uncompressed_size + checksum_size;
553
+ *p = read_buf + 4;
554
+ return uncompressed_size;
555
+ }
556
+
557
+ /*
558
+ Decompress a block data.
559
+ */
560
+ if (state->flags.block_independence) {
561
+ prefix64k = 0;
562
+ uncompressed_size = LZ4_decompress_safe(read_buf + 4,
563
+ state->out_block, (int)compressed_size,
564
+ state->flags.block_maximum_size);
565
+ } else {
566
+ prefix64k = 64 * 1024;
567
+ if (state->decoded_size) {
568
+ if (state->decoded_size < prefix64k) {
569
+ memmove(state->out_block
570
+ + prefix64k - state->decoded_size,
571
+ state->out_block + prefix64k,
572
+ state->decoded_size);
573
+ memset(state->out_block, 0,
574
+ prefix64k - state->decoded_size);
575
+ } else {
576
+ memmove(state->out_block,
577
+ state->out_block + state->decoded_size,
578
+ prefix64k);
579
+ }
580
+ }
581
+ #if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
582
+ uncompressed_size = LZ4_decompress_safe_usingDict(
583
+ read_buf + 4,
584
+ state->out_block + prefix64k, (int)compressed_size,
585
+ state->flags.block_maximum_size,
586
+ state->out_block,
587
+ prefix64k);
588
+ #else
589
+ uncompressed_size = LZ4_decompress_safe_withPrefix64k(
590
+ read_buf + 4,
591
+ state->out_block + prefix64k, (int)compressed_size,
592
+ state->flags.block_maximum_size);
593
+ #endif
594
+ }
595
+
596
+ /* Check if an error occurred in the decompression process. */
597
+ if (uncompressed_size < 0) {
598
+ archive_set_error(&(self->archive->archive),
599
+ ARCHIVE_ERRNO_MISC, "lz4 decompression failed");
600
+ return (ARCHIVE_FATAL);
601
+ }
602
+
603
+ state->unconsumed = 4 + compressed_size + checksum_size;
604
+ *p = state->out_block + prefix64k;
605
+ state->decoded_size = uncompressed_size;
606
+ return uncompressed_size;
607
+
608
+ malformed_error:
609
+ archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
610
+ "malformed lz4 data");
611
+ return (ARCHIVE_FATAL);
612
+ truncated_error:
613
+ archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
614
+ "truncated lz4 input");
615
+ return (ARCHIVE_FATAL);
616
+ }
617
+
618
+ static ssize_t
619
+ lz4_filter_read_default_stream(struct archive_read_filter *self, const void **p)
620
+ {
621
+ struct private_data *state = (struct private_data *)self->data;
622
+ const char *read_buf;
623
+ ssize_t bytes_remaining;
624
+ ssize_t ret;
625
+
626
+ if (state->stage == SELECT_STREAM) {
627
+ state->stage = READ_DEFAULT_STREAM;
628
+ /* First, read a descriptor. */
629
+ if((ret = lz4_filter_read_descriptor(self)) != ARCHIVE_OK)
630
+ return (ret);
631
+ state->stage = READ_DEFAULT_BLOCK;
632
+ }
633
+ /* Decompress a block. */
634
+ ret = lz4_filter_read_data_block(self, p);
635
+
636
+ /* If the end of block is detected, change the filter status
637
+ to read next stream. */
638
+ if (ret == 0 && *p == NULL)
639
+ state->stage = SELECT_STREAM;
640
+
641
+ /* Optional processing, checking a stream sum. */
642
+ if (state->flags.stream_checksum) {
643
+ if (state->stage == SELECT_STREAM) {
644
+ unsigned int checksum;
645
+ unsigned int checksum_stream;
646
+ read_buf = __archive_read_filter_ahead(self->upstream,
647
+ 4, &bytes_remaining);
648
+ if (read_buf == NULL) {
649
+ archive_set_error(&self->archive->archive,
650
+ ARCHIVE_ERRNO_MISC, "truncated lz4 input");
651
+ return (ARCHIVE_FATAL);
652
+ }
653
+ checksum = archive_le32dec(read_buf);
654
+ __archive_read_filter_consume(self->upstream, 4);
655
+ checksum_stream = __archive_xxhash.XXH32_digest(
656
+ state->xxh32_state);
657
+ state->xxh32_state = NULL;
658
+ if (checksum != checksum_stream) {
659
+ #ifndef DONT_FAIL_ON_CRC_ERROR
660
+ archive_set_error(&self->archive->archive,
661
+ ARCHIVE_ERRNO_MISC,
662
+ "lz4 stream checksum error");
663
+ return (ARCHIVE_FATAL);
664
+ #endif
665
+ }
666
+ } else if (ret > 0)
667
+ __archive_xxhash.XXH32_update(state->xxh32_state,
668
+ *p, (int)ret);
669
+ }
670
+ return (ret);
671
+ }
672
+
673
+ static ssize_t
674
+ lz4_filter_read_legacy_stream(struct archive_read_filter *self, const void **p)
675
+ {
676
+ struct private_data *state = (struct private_data *)self->data;
677
+ uint32_t compressed;
678
+ const char *read_buf;
679
+ ssize_t ret;
680
+
681
+ *p = NULL;
682
+ ret = lz4_allocate_out_block_for_legacy(self);
683
+ if (ret != ARCHIVE_OK)
684
+ return ret;
685
+
686
+ /* Make sure we have 4 bytes for a block size. */
687
+ read_buf = __archive_read_filter_ahead(self->upstream, 4, NULL);
688
+ if (read_buf == NULL) {
689
+ if (state->stage == SELECT_STREAM) {
690
+ state->stage = READ_LEGACY_STREAM;
691
+ archive_set_error(&self->archive->archive,
692
+ ARCHIVE_ERRNO_MISC,
693
+ "truncated lz4 input");
694
+ return (ARCHIVE_FATAL);
695
+ }
696
+ state->stage = SELECT_STREAM;
697
+ return 0;
698
+ }
699
+ state->stage = READ_LEGACY_BLOCK;
700
+ compressed = archive_le32dec(read_buf);
701
+ if (compressed > LZ4_COMPRESSBOUND(LEGACY_BLOCK_SIZE)) {
702
+ state->stage = SELECT_STREAM;
703
+ return 0;
704
+ }
705
+
706
+ /* Make sure we have a whole block. */
707
+ read_buf = __archive_read_filter_ahead(self->upstream,
708
+ 4 + compressed, NULL);
709
+ if (read_buf == NULL) {
710
+ archive_set_error(&(self->archive->archive),
711
+ ARCHIVE_ERRNO_MISC, "truncated lz4 input");
712
+ return (ARCHIVE_FATAL);
713
+ }
714
+ ret = LZ4_decompress_safe(read_buf + 4, state->out_block,
715
+ compressed, (int)state->out_block_size);
716
+ if (ret < 0) {
717
+ archive_set_error(&(self->archive->archive),
718
+ ARCHIVE_ERRNO_MISC, "lz4 decompression failed");
719
+ return (ARCHIVE_FATAL);
720
+ }
721
+ *p = state->out_block;
722
+ state->unconsumed = 4 + compressed;
723
+ return ret;
724
+ }
725
+
726
+ /*
727
+ * Clean up the decompressor.
728
+ */
729
+ static int
730
+ lz4_filter_close(struct archive_read_filter *self)
731
+ {
732
+ struct private_data *state;
733
+ int ret = ARCHIVE_OK;
734
+
735
+ state = (struct private_data *)self->data;
736
+ free(state->xxh32_state);
737
+ free(state->out_block);
738
+ free(state);
739
+ return (ret);
740
+ }
741
+
742
+ #endif /* HAVE_LIBLZ4 */