libarchive-static 1.0.6 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. checksums.yaml +4 -4
  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_reader.c +6 -4
  20. data/ext/libarchive-0.1.1/ext/libarchive_reader.o +0 -0
  21. data/ext/libarchive-0.1.1/ext/libarchive_ruby.so +0 -0
  22. data/ext/libarchive-0.1.1/ext/libarchive_win32.h +1 -1
  23. data/ext/libarchive-0.1.1/ext/libarchive_writer.c +2 -2
  24. data/ext/libarchive-0.1.1/ext/libarchive_writer.o +0 -0
  25. data/ext/libarchive-3.6.2/Makefile.in +16892 -0
  26. data/ext/libarchive-3.6.2/build/autoconf/ax_append_compile_flags.m4 +67 -0
  27. data/ext/libarchive-3.6.2/build/autoconf/ax_append_flag.m4 +71 -0
  28. data/ext/libarchive-3.6.2/build/autoconf/ax_check_compile_flag.m4 +74 -0
  29. data/ext/libarchive-3.6.2/build/autoconf/ax_require_defined.m4 +37 -0
  30. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/check_stdcall_func.m4 +0 -0
  31. data/ext/libarchive-3.6.2/build/autoconf/compile +348 -0
  32. data/ext/libarchive-3.6.2/build/autoconf/config.guess +1754 -0
  33. data/ext/libarchive-3.6.2/build/autoconf/config.rpath +696 -0
  34. data/ext/libarchive-3.6.2/build/autoconf/config.sub +1890 -0
  35. data/ext/libarchive-3.6.2/build/autoconf/depcomp +791 -0
  36. data/ext/libarchive-3.6.2/build/autoconf/iconv.m4 +271 -0
  37. data/ext/libarchive-3.6.2/build/autoconf/install-sh +541 -0
  38. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/autoconf/la_uid_t.m4 +0 -0
  39. data/ext/libarchive-3.6.2/build/autoconf/lib-ld.m4 +109 -0
  40. data/ext/libarchive-3.6.2/build/autoconf/lib-link.m4 +777 -0
  41. data/ext/libarchive-3.6.2/build/autoconf/lib-prefix.m4 +224 -0
  42. data/ext/libarchive-3.6.2/build/autoconf/ltmain.sh +11251 -0
  43. data/ext/libarchive-3.6.2/build/autoconf/m4_ax_compile_check_sizeof.m4 +115 -0
  44. data/ext/libarchive-3.6.2/build/autoconf/missing +215 -0
  45. data/ext/libarchive-3.6.2/build/autoconf/test-driver +153 -0
  46. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/build/pkgconfig/libarchive.pc.in +4 -1
  47. data/ext/libarchive-3.6.2/config.h.in +1504 -0
  48. data/ext/libarchive-3.6.2/configure +25558 -0
  49. data/ext/libarchive-3.6.2/libarchive/archive.h +1212 -0
  50. data/ext/libarchive-3.6.2/libarchive/archive_acl.c +2097 -0
  51. data/ext/libarchive-3.6.2/libarchive/archive_acl_private.h +83 -0
  52. data/ext/libarchive-3.6.2/libarchive/archive_blake2.h +197 -0
  53. data/ext/libarchive-3.6.2/libarchive/archive_blake2_impl.h +161 -0
  54. data/ext/libarchive-3.6.2/libarchive/archive_blake2s_ref.c +369 -0
  55. data/ext/libarchive-3.6.2/libarchive/archive_blake2sp_ref.c +361 -0
  56. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_check_magic.c +63 -22
  57. data/ext/libarchive-3.6.2/libarchive/archive_cmdline.c +227 -0
  58. data/ext/libarchive-3.6.2/libarchive/archive_cmdline_private.h +47 -0
  59. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_crc32.h +17 -0
  60. data/ext/libarchive-3.6.2/libarchive/archive_cryptor.c +534 -0
  61. data/ext/libarchive-3.6.2/libarchive/archive_cryptor_private.h +188 -0
  62. data/ext/libarchive-3.6.2/libarchive/archive_digest.c +1505 -0
  63. data/ext/libarchive-3.6.2/libarchive/archive_digest_private.h +416 -0
  64. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_darwin.c +559 -0
  65. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_freebsd.c +712 -0
  66. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_linux.c +760 -0
  67. data/ext/libarchive-3.6.2/libarchive/archive_disk_acl_sunos.c +824 -0
  68. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_endian.h +48 -15
  69. data/ext/libarchive-3.6.2/libarchive/archive_entry.c +2149 -0
  70. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry.h +305 -106
  71. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_bhfi.c +5 -4
  72. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_copy_stat.c +9 -3
  73. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_link_resolver.c +104 -62
  74. data/ext/libarchive-3.6.2/libarchive/archive_entry_locale.h +92 -0
  75. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_private.h +65 -49
  76. data/ext/libarchive-3.6.2/libarchive/archive_entry_sparse.c +156 -0
  77. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_stat.c +6 -6
  78. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_strmode.c +1 -1
  79. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_entry_xattr.c +4 -6
  80. data/ext/libarchive-3.6.2/libarchive/archive_getdate.c +1165 -0
  81. data/ext/libarchive-3.6.2/libarchive/archive_getdate.h +39 -0
  82. data/ext/libarchive-3.6.2/libarchive/archive_hmac.c +334 -0
  83. data/ext/libarchive-3.6.2/libarchive/archive_hmac_private.h +117 -0
  84. data/ext/libarchive-3.6.2/libarchive/archive_match.c +1875 -0
  85. data/ext/libarchive-3.6.2/libarchive/archive_openssl_evp_private.h +53 -0
  86. data/ext/libarchive-3.6.2/libarchive/archive_openssl_hmac_private.h +54 -0
  87. data/ext/libarchive-3.6.2/libarchive/archive_options.c +218 -0
  88. data/ext/libarchive-3.6.2/libarchive/archive_options_private.h +51 -0
  89. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.c +337 -0
  90. data/ext/libarchive-3.6.2/libarchive/archive_pack_dev.h +49 -0
  91. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.c +463 -0
  92. data/ext/libarchive-3.6.2/libarchive/archive_pathmatch.h +52 -0
  93. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_platform.h +77 -9
  94. data/ext/libarchive-3.6.2/libarchive/archive_platform_acl.h +55 -0
  95. data/ext/libarchive-3.6.2/libarchive/archive_platform_xattr.h +47 -0
  96. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7.c +1168 -0
  97. data/ext/libarchive-3.6.2/libarchive/archive_ppmd7_private.h +119 -0
  98. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8.c +1287 -0
  99. data/ext/libarchive-3.6.2/libarchive/archive_ppmd8_private.h +148 -0
  100. data/ext/libarchive-3.6.2/libarchive/archive_ppmd_private.h +151 -0
  101. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_private.h +74 -18
  102. data/ext/libarchive-3.6.2/libarchive/archive_random.c +272 -0
  103. data/ext/libarchive-3.6.2/libarchive/archive_random_private.h +36 -0
  104. data/ext/libarchive-3.6.2/libarchive/archive_rb.c +709 -0
  105. data/ext/libarchive-3.6.2/libarchive/archive_rb.h +113 -0
  106. data/ext/libarchive-3.6.2/libarchive/archive_read.c +1756 -0
  107. data/ext/libarchive-3.6.2/libarchive/archive_read_add_passphrase.c +190 -0
  108. data/ext/libarchive-3.6.2/libarchive/archive_read_append_filter.c +204 -0
  109. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_data_into_fd.c +64 -18
  110. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_entry_from_file.c +1086 -0
  111. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_posix.c +2732 -0
  112. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_private.h +40 -4
  113. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_disk_set_standard_lookup.c +21 -11
  114. data/ext/libarchive-3.6.2/libarchive/archive_read_disk_windows.c +2479 -0
  115. data/ext/libarchive-3.6.2/libarchive/archive_read_extract.c +60 -0
  116. data/ext/{libarchive-2.8.4/libarchive/archive_read_extract.c → libarchive-3.6.2/libarchive/archive_read_extract2.c} +34 -61
  117. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_fd.c +70 -49
  118. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_file.c +38 -23
  119. data/ext/libarchive-3.6.2/libarchive/archive_read_open_filename.c +586 -0
  120. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_open_memory.c +58 -28
  121. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_private.h +127 -59
  122. data/ext/libarchive-3.6.2/libarchive/archive_read_set_format.c +117 -0
  123. data/ext/libarchive-3.6.2/libarchive/archive_read_set_options.c +133 -0
  124. 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
  125. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_by_code.c +83 -0
  126. 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
  127. 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
  128. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_grzip.c +112 -0
  129. 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
  130. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lrzip.c +122 -0
  131. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lz4.c +742 -0
  132. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_lzop.c +499 -0
  133. 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
  134. 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
  135. 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
  136. 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
  137. 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
  138. data/ext/libarchive-3.6.2/libarchive/archive_read_support_filter_zstd.c +297 -0
  139. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_7zip.c +3900 -0
  140. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_all.c +89 -0
  141. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_ar.c +126 -72
  142. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_by_code.c +92 -0
  143. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cab.c +3228 -0
  144. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_cpio.c +1104 -0
  145. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_empty.c +14 -11
  146. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_iso9660.c +990 -541
  147. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_lha.c +2916 -0
  148. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_mtree.c +2150 -0
  149. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar.c +3797 -0
  150. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_rar5.c +4251 -0
  151. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_raw.c +38 -31
  152. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_tar.c +1157 -629
  153. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_warc.c +848 -0
  154. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_read_support_format_xar.c +439 -258
  155. data/ext/libarchive-3.6.2/libarchive/archive_read_support_format_zip.c +4270 -0
  156. data/ext/libarchive-3.6.2/libarchive/archive_string.c +4240 -0
  157. data/ext/libarchive-3.6.2/libarchive/archive_string.h +243 -0
  158. data/ext/libarchive-3.6.2/libarchive/archive_string_composition.h +2292 -0
  159. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_string_sprintf.c +44 -16
  160. data/ext/libarchive-3.6.2/libarchive/archive_util.c +655 -0
  161. data/ext/libarchive-3.6.2/libarchive/archive_version_details.c +151 -0
  162. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_virtual.c +85 -16
  163. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.c +214 -541
  164. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_windows.h +74 -106
  165. data/ext/libarchive-3.6.2/libarchive/archive_write.c +828 -0
  166. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter.c +72 -0
  167. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_b64encode.c +304 -0
  168. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_by_name.c +77 -0
  169. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_bzip2.c +401 -0
  170. 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
  171. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_grzip.c +135 -0
  172. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_gzip.c +442 -0
  173. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lrzip.c +197 -0
  174. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lz4.c +700 -0
  175. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_lzop.c +478 -0
  176. 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
  177. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_program.c +391 -0
  178. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_uuencode.c +295 -0
  179. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_xz.c +545 -0
  180. data/ext/libarchive-3.6.2/libarchive/archive_write_add_filter_zstd.c +418 -0
  181. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_posix.c +4711 -0
  182. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_private.h +9 -2
  183. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_disk_set_standard_lookup.c +30 -29
  184. data/ext/libarchive-3.6.2/libarchive/archive_write_disk_windows.c +2842 -0
  185. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_fd.c +15 -10
  186. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_file.c +15 -9
  187. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_filename.c +128 -20
  188. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_open_memory.c +7 -18
  189. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_private.h +72 -29
  190. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format.c +56 -3
  191. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_7zip.c +2322 -0
  192. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ar.c +54 -34
  193. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_by_name.c +20 -2
  194. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio.c +11 -0
  195. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_binary.c +610 -0
  196. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_newc.c +457 -0
  197. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_cpio_odc.c +500 -0
  198. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_filter_by_ext.c +142 -0
  199. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_gnutar.c +755 -0
  200. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_iso9660.c +8165 -0
  201. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_mtree.c +2217 -0
  202. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_pax.c +1049 -387
  203. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_private.h +42 -0
  204. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_raw.c +125 -0
  205. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_shar.c +62 -47
  206. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/archive_write_set_format_ustar.c +279 -108
  207. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_v7tar.c +638 -0
  208. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_warc.c +453 -0
  209. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_xar.c +3259 -0
  210. data/ext/libarchive-3.6.2/libarchive/archive_write_set_format_zip.c +1704 -0
  211. data/ext/libarchive-3.6.2/libarchive/archive_write_set_options.c +130 -0
  212. data/ext/libarchive-3.6.2/libarchive/archive_write_set_passphrase.c +95 -0
  213. data/ext/libarchive-3.6.2/libarchive/archive_xxhash.h +48 -0
  214. data/ext/libarchive-3.6.2/libarchive/config_freebsd.h +271 -0
  215. data/ext/{libarchive-2.8.4 → libarchive-3.6.2}/libarchive/filter_fork.h +10 -5
  216. data/ext/{libarchive-2.8.4/libarchive/filter_fork.c → libarchive-3.6.2/libarchive/filter_fork_posix.c} +98 -19
  217. data/ext/libarchive-3.6.2/libarchive/filter_fork_windows.c +236 -0
  218. data/ext/libarchive-3.6.2/libarchive/xxhash.c +525 -0
  219. data/ext/libarchive-static-makefile +144 -80
  220. data/ext/libarchive-static-wrapper-makefile +1 -1
  221. data/ext/zlib-1.2.13/Makefile.in +404 -0
  222. data/ext/{zlib-1.2.5 → zlib-1.2.13}/adler32.c +51 -34
  223. data/ext/{zlib-1.2.5 → zlib-1.2.13}/compress.c +27 -21
  224. data/ext/zlib-1.2.13/configure +922 -0
  225. data/ext/zlib-1.2.13/crc32.c +1125 -0
  226. data/ext/zlib-1.2.13/crc32.h +9446 -0
  227. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.c +842 -459
  228. data/ext/{zlib-1.2.5 → zlib-1.2.13}/deflate.h +37 -33
  229. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzclose.c +0 -0
  230. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzguts.h +103 -16
  231. data/ext/{zlib-1.2.5 → zlib-1.2.13}/gzlib.c +155 -53
  232. data/ext/zlib-1.2.13/gzread.c +650 -0
  233. data/ext/zlib-1.2.13/gzwrite.c +677 -0
  234. data/ext/{zlib-1.2.5 → zlib-1.2.13}/infback.c +24 -12
  235. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.c +49 -66
  236. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffast.h +0 -0
  237. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inffixed.h +3 -3
  238. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.c +209 -94
  239. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inflate.h +9 -5
  240. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.c +24 -50
  241. data/ext/{zlib-1.2.5 → zlib-1.2.13}/inftrees.h +1 -1
  242. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.c +135 -198
  243. data/ext/{zlib-1.2.5 → zlib-1.2.13}/trees.h +0 -0
  244. data/ext/zlib-1.2.13/uncompr.c +93 -0
  245. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zconf.h +182 -63
  246. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zlib.h +617 -295
  247. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.c +50 -41
  248. data/ext/{zlib-1.2.5 → zlib-1.2.13}/zutil.h +83 -82
  249. metadata +241 -133
  250. data/ext/libarchive-0.1.1/libarchive.c +0 -1762
  251. data/ext/libarchive-2.8.4/Makefile.in +0 -7076
  252. data/ext/libarchive-2.8.4/build/autoconf/compile +0 -143
  253. data/ext/libarchive-2.8.4/build/autoconf/config.guess +0 -1502
  254. data/ext/libarchive-2.8.4/build/autoconf/config.sub +0 -1708
  255. data/ext/libarchive-2.8.4/build/autoconf/depcomp +0 -630
  256. data/ext/libarchive-2.8.4/build/autoconf/install-sh +0 -291
  257. data/ext/libarchive-2.8.4/build/autoconf/ltmain.sh +0 -8406
  258. data/ext/libarchive-2.8.4/build/autoconf/missing +0 -376
  259. data/ext/libarchive-2.8.4/config.h.in +0 -772
  260. data/ext/libarchive-2.8.4/configure +0 -17916
  261. data/ext/libarchive-2.8.4/libarchive/archive.h +0 -741
  262. data/ext/libarchive-2.8.4/libarchive/archive_entry.c +0 -2202
  263. data/ext/libarchive-2.8.4/libarchive/archive_hash.h +0 -281
  264. data/ext/libarchive-2.8.4/libarchive/archive_read.c +0 -1249
  265. data/ext/libarchive-2.8.4/libarchive/archive_read_disk.c +0 -198
  266. data/ext/libarchive-2.8.4/libarchive/archive_read_disk_entry_from_file.c +0 -570
  267. data/ext/libarchive-2.8.4/libarchive/archive_read_open_filename.c +0 -272
  268. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_cpio.c +0 -777
  269. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_mtree.c +0 -1304
  270. data/ext/libarchive-2.8.4/libarchive/archive_read_support_format_zip.c +0 -903
  271. data/ext/libarchive-2.8.4/libarchive/archive_string.c +0 -453
  272. data/ext/libarchive-2.8.4/libarchive/archive_string.h +0 -148
  273. data/ext/libarchive-2.8.4/libarchive/archive_util.c +0 -391
  274. data/ext/libarchive-2.8.4/libarchive/archive_write.c +0 -466
  275. data/ext/libarchive-2.8.4/libarchive/archive_write_disk.c +0 -2628
  276. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_bzip2.c +0 -408
  277. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_gzip.c +0 -477
  278. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_none.c +0 -257
  279. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_program.c +0 -347
  280. data/ext/libarchive-2.8.4/libarchive/archive_write_set_compression_xz.c +0 -438
  281. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio.c +0 -344
  282. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_cpio_newc.c +0 -295
  283. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_mtree.c +0 -1050
  284. data/ext/libarchive-2.8.4/libarchive/archive_write_set_format_zip.c +0 -667
  285. data/ext/libarchive-2.8.4/libarchive/config_freebsd.h +0 -154
  286. data/ext/libarchive-2.8.4/libarchive/filter_fork_windows.c +0 -113
  287. data/ext/zlib-1.2.5/Makefile.in +0 -257
  288. data/ext/zlib-1.2.5/configure +0 -596
  289. data/ext/zlib-1.2.5/crc32.c +0 -442
  290. data/ext/zlib-1.2.5/crc32.h +0 -441
  291. data/ext/zlib-1.2.5/example.c +0 -565
  292. data/ext/zlib-1.2.5/gzread.c +0 -653
  293. data/ext/zlib-1.2.5/gzwrite.c +0 -531
  294. data/ext/zlib-1.2.5/minigzip.c +0 -440
  295. data/ext/zlib-1.2.5/uncompr.c +0 -59
@@ -0,0 +1,1104 @@
1
+ /*-
2
+ * Copyright (c) 2003-2007 Tim Kientzle
3
+ * Copyright (c) 2010-2012 Michihiro NAKAJIMA
4
+ * All rights reserved.
5
+ *
6
+ * Redistribution and use in source and binary forms, with or without
7
+ * modification, are permitted provided that the following conditions
8
+ * are met:
9
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
16
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
19
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ */
26
+
27
+ #include "archive_platform.h"
28
+ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_cpio.c 201163 2009-12-29 05:50:34Z kientzle $");
29
+
30
+ #ifdef HAVE_ERRNO_H
31
+ #include <errno.h>
32
+ #endif
33
+ /* #include <stdint.h> */ /* See archive_platform.h */
34
+ #ifdef HAVE_STDLIB_H
35
+ #include <stdlib.h>
36
+ #endif
37
+ #ifdef HAVE_STRING_H
38
+ #include <string.h>
39
+ #endif
40
+
41
+ #include "archive.h"
42
+ #include "archive_entry.h"
43
+ #include "archive_entry_locale.h"
44
+ #include "archive_private.h"
45
+ #include "archive_read_private.h"
46
+
47
+ #define bin_magic_offset 0
48
+ #define bin_magic_size 2
49
+ #define bin_dev_offset 2
50
+ #define bin_dev_size 2
51
+ #define bin_ino_offset 4
52
+ #define bin_ino_size 2
53
+ #define bin_mode_offset 6
54
+ #define bin_mode_size 2
55
+ #define bin_uid_offset 8
56
+ #define bin_uid_size 2
57
+ #define bin_gid_offset 10
58
+ #define bin_gid_size 2
59
+ #define bin_nlink_offset 12
60
+ #define bin_nlink_size 2
61
+ #define bin_rdev_offset 14
62
+ #define bin_rdev_size 2
63
+ #define bin_mtime_offset 16
64
+ #define bin_mtime_size 4
65
+ #define bin_namesize_offset 20
66
+ #define bin_namesize_size 2
67
+ #define bin_filesize_offset 22
68
+ #define bin_filesize_size 4
69
+ #define bin_header_size 26
70
+
71
+ #define odc_magic_offset 0
72
+ #define odc_magic_size 6
73
+ #define odc_dev_offset 6
74
+ #define odc_dev_size 6
75
+ #define odc_ino_offset 12
76
+ #define odc_ino_size 6
77
+ #define odc_mode_offset 18
78
+ #define odc_mode_size 6
79
+ #define odc_uid_offset 24
80
+ #define odc_uid_size 6
81
+ #define odc_gid_offset 30
82
+ #define odc_gid_size 6
83
+ #define odc_nlink_offset 36
84
+ #define odc_nlink_size 6
85
+ #define odc_rdev_offset 42
86
+ #define odc_rdev_size 6
87
+ #define odc_mtime_offset 48
88
+ #define odc_mtime_size 11
89
+ #define odc_namesize_offset 59
90
+ #define odc_namesize_size 6
91
+ #define odc_filesize_offset 65
92
+ #define odc_filesize_size 11
93
+ #define odc_header_size 76
94
+
95
+ #define newc_magic_offset 0
96
+ #define newc_magic_size 6
97
+ #define newc_ino_offset 6
98
+ #define newc_ino_size 8
99
+ #define newc_mode_offset 14
100
+ #define newc_mode_size 8
101
+ #define newc_uid_offset 22
102
+ #define newc_uid_size 8
103
+ #define newc_gid_offset 30
104
+ #define newc_gid_size 8
105
+ #define newc_nlink_offset 38
106
+ #define newc_nlink_size 8
107
+ #define newc_mtime_offset 46
108
+ #define newc_mtime_size 8
109
+ #define newc_filesize_offset 54
110
+ #define newc_filesize_size 8
111
+ #define newc_devmajor_offset 62
112
+ #define newc_devmajor_size 8
113
+ #define newc_devminor_offset 70
114
+ #define newc_devminor_size 8
115
+ #define newc_rdevmajor_offset 78
116
+ #define newc_rdevmajor_size 8
117
+ #define newc_rdevminor_offset 86
118
+ #define newc_rdevminor_size 8
119
+ #define newc_namesize_offset 94
120
+ #define newc_namesize_size 8
121
+ #define newc_checksum_offset 102
122
+ #define newc_checksum_size 8
123
+ #define newc_header_size 110
124
+
125
+ /*
126
+ * An afio large ASCII header, which they named itself.
127
+ * afio utility uses this header, if a file size is larger than 2G bytes
128
+ * or inode/uid/gid is bigger than 65535(0xFFFF) or mtime is bigger than
129
+ * 0x7fffffff, which we cannot record to odc header because of its limit.
130
+ * If not, uses odc header.
131
+ */
132
+ #define afiol_magic_offset 0
133
+ #define afiol_magic_size 6
134
+ #define afiol_dev_offset 6
135
+ #define afiol_dev_size 8 /* hex */
136
+ #define afiol_ino_offset 14
137
+ #define afiol_ino_size 16 /* hex */
138
+ #define afiol_ino_m_offset 30 /* 'm' */
139
+ #define afiol_mode_offset 31
140
+ #define afiol_mode_size 6 /* oct */
141
+ #define afiol_uid_offset 37
142
+ #define afiol_uid_size 8 /* hex */
143
+ #define afiol_gid_offset 45
144
+ #define afiol_gid_size 8 /* hex */
145
+ #define afiol_nlink_offset 53
146
+ #define afiol_nlink_size 8 /* hex */
147
+ #define afiol_rdev_offset 61
148
+ #define afiol_rdev_size 8 /* hex */
149
+ #define afiol_mtime_offset 69
150
+ #define afiol_mtime_size 16 /* hex */
151
+ #define afiol_mtime_n_offset 85 /* 'n' */
152
+ #define afiol_namesize_offset 86
153
+ #define afiol_namesize_size 4 /* hex */
154
+ #define afiol_flag_offset 90
155
+ #define afiol_flag_size 4 /* hex */
156
+ #define afiol_xsize_offset 94
157
+ #define afiol_xsize_size 4 /* hex */
158
+ #define afiol_xsize_s_offset 98 /* 's' */
159
+ #define afiol_filesize_offset 99
160
+ #define afiol_filesize_size 16 /* hex */
161
+ #define afiol_filesize_c_offset 115 /* ':' */
162
+ #define afiol_header_size 116
163
+
164
+
165
+ struct links_entry {
166
+ struct links_entry *next;
167
+ struct links_entry *previous;
168
+ unsigned int links;
169
+ dev_t dev;
170
+ int64_t ino;
171
+ char *name;
172
+ };
173
+
174
+ #define CPIO_MAGIC 0x13141516
175
+ struct cpio {
176
+ int magic;
177
+ int (*read_header)(struct archive_read *, struct cpio *,
178
+ struct archive_entry *, size_t *, size_t *);
179
+ struct links_entry *links_head;
180
+ int64_t entry_bytes_remaining;
181
+ int64_t entry_bytes_unconsumed;
182
+ int64_t entry_offset;
183
+ int64_t entry_padding;
184
+
185
+ struct archive_string_conv *opt_sconv;
186
+ struct archive_string_conv *sconv_default;
187
+ int init_default_conversion;
188
+
189
+ int option_pwb;
190
+ };
191
+
192
+ static int64_t atol16(const char *, unsigned);
193
+ static int64_t atol8(const char *, unsigned);
194
+ static int archive_read_format_cpio_bid(struct archive_read *, int);
195
+ static int archive_read_format_cpio_options(struct archive_read *,
196
+ const char *, const char *);
197
+ static int archive_read_format_cpio_cleanup(struct archive_read *);
198
+ static int archive_read_format_cpio_read_data(struct archive_read *,
199
+ const void **, size_t *, int64_t *);
200
+ static int archive_read_format_cpio_read_header(struct archive_read *,
201
+ struct archive_entry *);
202
+ static int archive_read_format_cpio_skip(struct archive_read *);
203
+ static int64_t be4(const unsigned char *);
204
+ static int find_odc_header(struct archive_read *);
205
+ static int find_newc_header(struct archive_read *);
206
+ static int header_bin_be(struct archive_read *, struct cpio *,
207
+ struct archive_entry *, size_t *, size_t *);
208
+ static int header_bin_le(struct archive_read *, struct cpio *,
209
+ struct archive_entry *, size_t *, size_t *);
210
+ static int header_newc(struct archive_read *, struct cpio *,
211
+ struct archive_entry *, size_t *, size_t *);
212
+ static int header_odc(struct archive_read *, struct cpio *,
213
+ struct archive_entry *, size_t *, size_t *);
214
+ static int header_afiol(struct archive_read *, struct cpio *,
215
+ struct archive_entry *, size_t *, size_t *);
216
+ static int is_octal(const char *, size_t);
217
+ static int is_hex(const char *, size_t);
218
+ static int64_t le4(const unsigned char *);
219
+ static int record_hardlink(struct archive_read *a,
220
+ struct cpio *cpio, struct archive_entry *entry);
221
+
222
+ int
223
+ archive_read_support_format_cpio(struct archive *_a)
224
+ {
225
+ struct archive_read *a = (struct archive_read *)_a;
226
+ struct cpio *cpio;
227
+ int r;
228
+
229
+ archive_check_magic(_a, ARCHIVE_READ_MAGIC,
230
+ ARCHIVE_STATE_NEW, "archive_read_support_format_cpio");
231
+
232
+ cpio = (struct cpio *)calloc(1, sizeof(*cpio));
233
+ if (cpio == NULL) {
234
+ archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
235
+ return (ARCHIVE_FATAL);
236
+ }
237
+ cpio->magic = CPIO_MAGIC;
238
+
239
+ r = __archive_read_register_format(a,
240
+ cpio,
241
+ "cpio",
242
+ archive_read_format_cpio_bid,
243
+ archive_read_format_cpio_options,
244
+ archive_read_format_cpio_read_header,
245
+ archive_read_format_cpio_read_data,
246
+ archive_read_format_cpio_skip,
247
+ NULL,
248
+ archive_read_format_cpio_cleanup,
249
+ NULL,
250
+ NULL);
251
+
252
+ if (r != ARCHIVE_OK)
253
+ free(cpio);
254
+ return (ARCHIVE_OK);
255
+ }
256
+
257
+
258
+ static int
259
+ archive_read_format_cpio_bid(struct archive_read *a, int best_bid)
260
+ {
261
+ const unsigned char *p;
262
+ struct cpio *cpio;
263
+ int bid;
264
+
265
+ (void)best_bid; /* UNUSED */
266
+
267
+ cpio = (struct cpio *)(a->format->data);
268
+
269
+ if ((p = __archive_read_ahead(a, 6, NULL)) == NULL)
270
+ return (-1);
271
+
272
+ bid = 0;
273
+ if (memcmp(p, "070707", 6) == 0) {
274
+ /* ASCII cpio archive (odc, POSIX.1) */
275
+ cpio->read_header = header_odc;
276
+ bid += 48;
277
+ /*
278
+ * XXX TODO: More verification; Could check that only octal
279
+ * digits appear in appropriate header locations. XXX
280
+ */
281
+ } else if (memcmp(p, "070727", 6) == 0) {
282
+ /* afio large ASCII cpio archive */
283
+ cpio->read_header = header_odc;
284
+ bid += 48;
285
+ /*
286
+ * XXX TODO: More verification; Could check that almost hex
287
+ * digits appear in appropriate header locations. XXX
288
+ */
289
+ } else if (memcmp(p, "070701", 6) == 0) {
290
+ /* ASCII cpio archive (SVR4 without CRC) */
291
+ cpio->read_header = header_newc;
292
+ bid += 48;
293
+ /*
294
+ * XXX TODO: More verification; Could check that only hex
295
+ * digits appear in appropriate header locations. XXX
296
+ */
297
+ } else if (memcmp(p, "070702", 6) == 0) {
298
+ /* ASCII cpio archive (SVR4 with CRC) */
299
+ /* XXX TODO: Flag that we should check the CRC. XXX */
300
+ cpio->read_header = header_newc;
301
+ bid += 48;
302
+ /*
303
+ * XXX TODO: More verification; Could check that only hex
304
+ * digits appear in appropriate header locations. XXX
305
+ */
306
+ } else if (p[0] * 256 + p[1] == 070707) {
307
+ /* big-endian binary cpio archives */
308
+ cpio->read_header = header_bin_be;
309
+ bid += 16;
310
+ /* Is more verification possible here? */
311
+ } else if (p[0] + p[1] * 256 == 070707) {
312
+ /* little-endian binary cpio archives */
313
+ cpio->read_header = header_bin_le;
314
+ bid += 16;
315
+ /* Is more verification possible here? */
316
+ } else
317
+ return (ARCHIVE_WARN);
318
+
319
+ return (bid);
320
+ }
321
+
322
+ static int
323
+ archive_read_format_cpio_options(struct archive_read *a,
324
+ const char *key, const char *val)
325
+ {
326
+ struct cpio *cpio;
327
+ int ret = ARCHIVE_FAILED;
328
+
329
+ cpio = (struct cpio *)(a->format->data);
330
+ if (strcmp(key, "compat-2x") == 0) {
331
+ /* Handle filenames as libarchive 2.x */
332
+ cpio->init_default_conversion = (val != NULL)?1:0;
333
+ return (ARCHIVE_OK);
334
+ } else if (strcmp(key, "hdrcharset") == 0) {
335
+ if (val == NULL || val[0] == 0)
336
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
337
+ "cpio: hdrcharset option needs a character-set name");
338
+ else {
339
+ cpio->opt_sconv =
340
+ archive_string_conversion_from_charset(
341
+ &a->archive, val, 0);
342
+ if (cpio->opt_sconv != NULL)
343
+ ret = ARCHIVE_OK;
344
+ else
345
+ ret = ARCHIVE_FATAL;
346
+ }
347
+ return (ret);
348
+ } else if (strcmp(key, "pwb") == 0) {
349
+ if (val != NULL && val[0] != 0)
350
+ cpio->option_pwb = 1;
351
+ return (ARCHIVE_OK);
352
+ }
353
+
354
+ /* Note: The "warn" return is just to inform the options
355
+ * supervisor that we didn't handle it. It will generate
356
+ * a suitable error if no one used this option. */
357
+ return (ARCHIVE_WARN);
358
+ }
359
+
360
+ static int
361
+ archive_read_format_cpio_read_header(struct archive_read *a,
362
+ struct archive_entry *entry)
363
+ {
364
+ struct cpio *cpio;
365
+ const void *h, *hl;
366
+ struct archive_string_conv *sconv;
367
+ size_t namelength;
368
+ size_t name_pad;
369
+ int r;
370
+
371
+ cpio = (struct cpio *)(a->format->data);
372
+ sconv = cpio->opt_sconv;
373
+ if (sconv == NULL) {
374
+ if (!cpio->init_default_conversion) {
375
+ cpio->sconv_default =
376
+ archive_string_default_conversion_for_read(
377
+ &(a->archive));
378
+ cpio->init_default_conversion = 1;
379
+ }
380
+ sconv = cpio->sconv_default;
381
+ }
382
+
383
+ r = (cpio->read_header(a, cpio, entry, &namelength, &name_pad));
384
+
385
+ if (r < ARCHIVE_WARN)
386
+ return (r);
387
+
388
+ /* Read name from buffer. */
389
+ h = __archive_read_ahead(a, namelength + name_pad, NULL);
390
+ if (h == NULL)
391
+ return (ARCHIVE_FATAL);
392
+ if (archive_entry_copy_pathname_l(entry,
393
+ (const char *)h, namelength, sconv) != 0) {
394
+ if (errno == ENOMEM) {
395
+ archive_set_error(&a->archive, ENOMEM,
396
+ "Can't allocate memory for Pathname");
397
+ return (ARCHIVE_FATAL);
398
+ }
399
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
400
+ "Pathname can't be converted from %s to current locale.",
401
+ archive_string_conversion_charset_name(sconv));
402
+ r = ARCHIVE_WARN;
403
+ }
404
+ cpio->entry_offset = 0;
405
+
406
+ __archive_read_consume(a, namelength + name_pad);
407
+
408
+ /* If this is a symlink, read the link contents. */
409
+ if (archive_entry_filetype(entry) == AE_IFLNK) {
410
+ if (cpio->entry_bytes_remaining > 1024 * 1024) {
411
+ archive_set_error(&a->archive, ENOMEM,
412
+ "Rejecting malformed cpio archive: symlink contents exceed 1 megabyte");
413
+ return (ARCHIVE_FATAL);
414
+ }
415
+ hl = __archive_read_ahead(a,
416
+ (size_t)cpio->entry_bytes_remaining, NULL);
417
+ if (hl == NULL)
418
+ return (ARCHIVE_FATAL);
419
+ if (archive_entry_copy_symlink_l(entry, (const char *)hl,
420
+ (size_t)cpio->entry_bytes_remaining, sconv) != 0) {
421
+ if (errno == ENOMEM) {
422
+ archive_set_error(&a->archive, ENOMEM,
423
+ "Can't allocate memory for Linkname");
424
+ return (ARCHIVE_FATAL);
425
+ }
426
+ archive_set_error(&a->archive,
427
+ ARCHIVE_ERRNO_FILE_FORMAT,
428
+ "Linkname can't be converted from %s to "
429
+ "current locale.",
430
+ archive_string_conversion_charset_name(sconv));
431
+ r = ARCHIVE_WARN;
432
+ }
433
+ __archive_read_consume(a, cpio->entry_bytes_remaining);
434
+ cpio->entry_bytes_remaining = 0;
435
+ }
436
+
437
+ /* XXX TODO: If the full mode is 0160200, then this is a Solaris
438
+ * ACL description for the following entry. Read this body
439
+ * and parse it as a Solaris-style ACL, then read the next
440
+ * header. XXX */
441
+
442
+ /* Compare name to "TRAILER!!!" to test for end-of-archive. */
443
+ if (namelength == 11 && strncmp((const char *)h, "TRAILER!!!",
444
+ 11) == 0) {
445
+ /* TODO: Store file location of start of block. */
446
+ archive_clear_error(&a->archive);
447
+ return (ARCHIVE_EOF);
448
+ }
449
+
450
+ /* Detect and record hardlinks to previously-extracted entries. */
451
+ if (record_hardlink(a, cpio, entry) != ARCHIVE_OK) {
452
+ return (ARCHIVE_FATAL);
453
+ }
454
+
455
+ return (r);
456
+ }
457
+
458
+ static int
459
+ archive_read_format_cpio_read_data(struct archive_read *a,
460
+ const void **buff, size_t *size, int64_t *offset)
461
+ {
462
+ ssize_t bytes_read;
463
+ struct cpio *cpio;
464
+
465
+ cpio = (struct cpio *)(a->format->data);
466
+
467
+ if (cpio->entry_bytes_unconsumed) {
468
+ __archive_read_consume(a, cpio->entry_bytes_unconsumed);
469
+ cpio->entry_bytes_unconsumed = 0;
470
+ }
471
+
472
+ if (cpio->entry_bytes_remaining > 0) {
473
+ *buff = __archive_read_ahead(a, 1, &bytes_read);
474
+ if (bytes_read <= 0)
475
+ return (ARCHIVE_FATAL);
476
+ if (bytes_read > cpio->entry_bytes_remaining)
477
+ bytes_read = (ssize_t)cpio->entry_bytes_remaining;
478
+ *size = bytes_read;
479
+ cpio->entry_bytes_unconsumed = bytes_read;
480
+ *offset = cpio->entry_offset;
481
+ cpio->entry_offset += bytes_read;
482
+ cpio->entry_bytes_remaining -= bytes_read;
483
+ return (ARCHIVE_OK);
484
+ } else {
485
+ if (cpio->entry_padding !=
486
+ __archive_read_consume(a, cpio->entry_padding)) {
487
+ return (ARCHIVE_FATAL);
488
+ }
489
+ cpio->entry_padding = 0;
490
+ *buff = NULL;
491
+ *size = 0;
492
+ *offset = cpio->entry_offset;
493
+ return (ARCHIVE_EOF);
494
+ }
495
+ }
496
+
497
+ static int
498
+ archive_read_format_cpio_skip(struct archive_read *a)
499
+ {
500
+ struct cpio *cpio = (struct cpio *)(a->format->data);
501
+ int64_t to_skip = cpio->entry_bytes_remaining + cpio->entry_padding +
502
+ cpio->entry_bytes_unconsumed;
503
+
504
+ if (to_skip != __archive_read_consume(a, to_skip)) {
505
+ return (ARCHIVE_FATAL);
506
+ }
507
+ cpio->entry_bytes_remaining = 0;
508
+ cpio->entry_padding = 0;
509
+ cpio->entry_bytes_unconsumed = 0;
510
+ return (ARCHIVE_OK);
511
+ }
512
+
513
+ /*
514
+ * Skip forward to the next cpio newc header by searching for the
515
+ * 07070[12] string. This should be generalized and merged with
516
+ * find_odc_header below.
517
+ */
518
+ static int
519
+ is_hex(const char *p, size_t len)
520
+ {
521
+ while (len-- > 0) {
522
+ if ((*p >= '0' && *p <= '9')
523
+ || (*p >= 'a' && *p <= 'f')
524
+ || (*p >= 'A' && *p <= 'F'))
525
+ ++p;
526
+ else
527
+ return (0);
528
+ }
529
+ return (1);
530
+ }
531
+
532
+ static int
533
+ find_newc_header(struct archive_read *a)
534
+ {
535
+ const void *h;
536
+ const char *p, *q;
537
+ size_t skip, skipped = 0;
538
+ ssize_t bytes;
539
+
540
+ for (;;) {
541
+ h = __archive_read_ahead(a, newc_header_size, &bytes);
542
+ if (h == NULL)
543
+ return (ARCHIVE_FATAL);
544
+ p = h;
545
+ q = p + bytes;
546
+
547
+ /* Try the typical case first, then go into the slow search.*/
548
+ if (memcmp("07070", p, 5) == 0
549
+ && (p[5] == '1' || p[5] == '2')
550
+ && is_hex(p, newc_header_size))
551
+ return (ARCHIVE_OK);
552
+
553
+ /*
554
+ * Scan ahead until we find something that looks
555
+ * like a newc header.
556
+ */
557
+ while (p + newc_header_size <= q) {
558
+ switch (p[5]) {
559
+ case '1':
560
+ case '2':
561
+ if (memcmp("07070", p, 5) == 0
562
+ && is_hex(p, newc_header_size)) {
563
+ skip = p - (const char *)h;
564
+ __archive_read_consume(a, skip);
565
+ skipped += skip;
566
+ if (skipped > 0) {
567
+ archive_set_error(&a->archive,
568
+ 0,
569
+ "Skipped %d bytes before "
570
+ "finding valid header",
571
+ (int)skipped);
572
+ return (ARCHIVE_WARN);
573
+ }
574
+ return (ARCHIVE_OK);
575
+ }
576
+ p += 2;
577
+ break;
578
+ case '0':
579
+ p++;
580
+ break;
581
+ default:
582
+ p += 6;
583
+ break;
584
+ }
585
+ }
586
+ skip = p - (const char *)h;
587
+ __archive_read_consume(a, skip);
588
+ skipped += skip;
589
+ }
590
+ }
591
+
592
+ static int
593
+ header_newc(struct archive_read *a, struct cpio *cpio,
594
+ struct archive_entry *entry, size_t *namelength, size_t *name_pad)
595
+ {
596
+ const void *h;
597
+ const char *header;
598
+ int r;
599
+
600
+ r = find_newc_header(a);
601
+ if (r < ARCHIVE_WARN)
602
+ return (r);
603
+
604
+ /* Read fixed-size portion of header. */
605
+ h = __archive_read_ahead(a, newc_header_size, NULL);
606
+ if (h == NULL)
607
+ return (ARCHIVE_FATAL);
608
+
609
+ /* Parse out hex fields. */
610
+ header = (const char *)h;
611
+
612
+ if (memcmp(header + newc_magic_offset, "070701", 6) == 0) {
613
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_SVR4_NOCRC;
614
+ a->archive.archive_format_name = "ASCII cpio (SVR4 with no CRC)";
615
+ } else if (memcmp(header + newc_magic_offset, "070702", 6) == 0) {
616
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_SVR4_CRC;
617
+ a->archive.archive_format_name = "ASCII cpio (SVR4 with CRC)";
618
+ } else {
619
+ /* TODO: Abort here? */
620
+ }
621
+
622
+ archive_entry_set_devmajor(entry,
623
+ (dev_t)atol16(header + newc_devmajor_offset, newc_devmajor_size));
624
+ archive_entry_set_devminor(entry,
625
+ (dev_t)atol16(header + newc_devminor_offset, newc_devminor_size));
626
+ archive_entry_set_ino(entry, atol16(header + newc_ino_offset, newc_ino_size));
627
+ archive_entry_set_mode(entry,
628
+ (mode_t)atol16(header + newc_mode_offset, newc_mode_size));
629
+ archive_entry_set_uid(entry, atol16(header + newc_uid_offset, newc_uid_size));
630
+ archive_entry_set_gid(entry, atol16(header + newc_gid_offset, newc_gid_size));
631
+ archive_entry_set_nlink(entry,
632
+ (unsigned int)atol16(header + newc_nlink_offset, newc_nlink_size));
633
+ archive_entry_set_rdevmajor(entry,
634
+ (dev_t)atol16(header + newc_rdevmajor_offset, newc_rdevmajor_size));
635
+ archive_entry_set_rdevminor(entry,
636
+ (dev_t)atol16(header + newc_rdevminor_offset, newc_rdevminor_size));
637
+ archive_entry_set_mtime(entry, atol16(header + newc_mtime_offset, newc_mtime_size), 0);
638
+ *namelength = (size_t)atol16(header + newc_namesize_offset, newc_namesize_size);
639
+ /* Pad name to 2 more than a multiple of 4. */
640
+ *name_pad = (2 - *namelength) & 3;
641
+
642
+ /* Make sure that the padded name length fits into size_t. */
643
+ if (*name_pad > SIZE_MAX - *namelength) {
644
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
645
+ "cpio archive has invalid namelength");
646
+ return (ARCHIVE_FATAL);
647
+ }
648
+
649
+ /*
650
+ * Note: entry_bytes_remaining is at least 64 bits and
651
+ * therefore guaranteed to be big enough for a 33-bit file
652
+ * size.
653
+ */
654
+ cpio->entry_bytes_remaining =
655
+ atol16(header + newc_filesize_offset, newc_filesize_size);
656
+ archive_entry_set_size(entry, cpio->entry_bytes_remaining);
657
+ /* Pad file contents to a multiple of 4. */
658
+ cpio->entry_padding = 3 & -cpio->entry_bytes_remaining;
659
+ __archive_read_consume(a, newc_header_size);
660
+ return (r);
661
+ }
662
+
663
+ /*
664
+ * Skip forward to the next cpio odc header by searching for the
665
+ * 070707 string. This is a hand-optimized search that could
666
+ * probably be easily generalized to handle all character-based
667
+ * cpio variants.
668
+ */
669
+ static int
670
+ is_octal(const char *p, size_t len)
671
+ {
672
+ while (len-- > 0) {
673
+ if (*p < '0' || *p > '7')
674
+ return (0);
675
+ ++p;
676
+ }
677
+ return (1);
678
+ }
679
+
680
+ static int
681
+ is_afio_large(const char *h, size_t len)
682
+ {
683
+ if (len < afiol_header_size)
684
+ return (0);
685
+ if (h[afiol_ino_m_offset] != 'm'
686
+ || h[afiol_mtime_n_offset] != 'n'
687
+ || h[afiol_xsize_s_offset] != 's'
688
+ || h[afiol_filesize_c_offset] != ':')
689
+ return (0);
690
+ if (!is_hex(h + afiol_dev_offset, afiol_ino_m_offset - afiol_dev_offset))
691
+ return (0);
692
+ if (!is_hex(h + afiol_mode_offset, afiol_mtime_n_offset - afiol_mode_offset))
693
+ return (0);
694
+ if (!is_hex(h + afiol_namesize_offset, afiol_xsize_s_offset - afiol_namesize_offset))
695
+ return (0);
696
+ if (!is_hex(h + afiol_filesize_offset, afiol_filesize_size))
697
+ return (0);
698
+ return (1);
699
+ }
700
+
701
+ static int
702
+ find_odc_header(struct archive_read *a)
703
+ {
704
+ const void *h;
705
+ const char *p, *q;
706
+ size_t skip, skipped = 0;
707
+ ssize_t bytes;
708
+
709
+ for (;;) {
710
+ h = __archive_read_ahead(a, odc_header_size, &bytes);
711
+ if (h == NULL)
712
+ return (ARCHIVE_FATAL);
713
+ p = h;
714
+ q = p + bytes;
715
+
716
+ /* Try the typical case first, then go into the slow search.*/
717
+ if (memcmp("070707", p, 6) == 0 && is_octal(p, odc_header_size))
718
+ return (ARCHIVE_OK);
719
+ if (memcmp("070727", p, 6) == 0 && is_afio_large(p, bytes)) {
720
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_AFIO_LARGE;
721
+ return (ARCHIVE_OK);
722
+ }
723
+
724
+ /*
725
+ * Scan ahead until we find something that looks
726
+ * like an odc header.
727
+ */
728
+ while (p + odc_header_size <= q) {
729
+ switch (p[5]) {
730
+ case '7':
731
+ if ((memcmp("070707", p, 6) == 0
732
+ && is_octal(p, odc_header_size))
733
+ || (memcmp("070727", p, 6) == 0
734
+ && is_afio_large(p, q - p))) {
735
+ skip = p - (const char *)h;
736
+ __archive_read_consume(a, skip);
737
+ skipped += skip;
738
+ if (p[4] == '2')
739
+ a->archive.archive_format =
740
+ ARCHIVE_FORMAT_CPIO_AFIO_LARGE;
741
+ if (skipped > 0) {
742
+ archive_set_error(&a->archive,
743
+ 0,
744
+ "Skipped %d bytes before "
745
+ "finding valid header",
746
+ (int)skipped);
747
+ return (ARCHIVE_WARN);
748
+ }
749
+ return (ARCHIVE_OK);
750
+ }
751
+ p += 2;
752
+ break;
753
+ case '0':
754
+ p++;
755
+ break;
756
+ default:
757
+ p += 6;
758
+ break;
759
+ }
760
+ }
761
+ skip = p - (const char *)h;
762
+ __archive_read_consume(a, skip);
763
+ skipped += skip;
764
+ }
765
+ }
766
+
767
+ static int
768
+ header_odc(struct archive_read *a, struct cpio *cpio,
769
+ struct archive_entry *entry, size_t *namelength, size_t *name_pad)
770
+ {
771
+ const void *h;
772
+ int r;
773
+ const char *header;
774
+
775
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
776
+ a->archive.archive_format_name = "POSIX octet-oriented cpio";
777
+
778
+ /* Find the start of the next header. */
779
+ r = find_odc_header(a);
780
+ if (r < ARCHIVE_WARN)
781
+ return (r);
782
+
783
+ if (a->archive.archive_format == ARCHIVE_FORMAT_CPIO_AFIO_LARGE) {
784
+ int r2 = (header_afiol(a, cpio, entry, namelength, name_pad));
785
+ if (r2 == ARCHIVE_OK)
786
+ return (r);
787
+ else
788
+ return (r2);
789
+ }
790
+
791
+ /* Read fixed-size portion of header. */
792
+ h = __archive_read_ahead(a, odc_header_size, NULL);
793
+ if (h == NULL)
794
+ return (ARCHIVE_FATAL);
795
+
796
+ /* Parse out octal fields. */
797
+ header = (const char *)h;
798
+
799
+ archive_entry_set_dev(entry,
800
+ (dev_t)atol8(header + odc_dev_offset, odc_dev_size));
801
+ archive_entry_set_ino(entry, atol8(header + odc_ino_offset, odc_ino_size));
802
+ archive_entry_set_mode(entry,
803
+ (mode_t)atol8(header + odc_mode_offset, odc_mode_size));
804
+ archive_entry_set_uid(entry, atol8(header + odc_uid_offset, odc_uid_size));
805
+ archive_entry_set_gid(entry, atol8(header + odc_gid_offset, odc_gid_size));
806
+ archive_entry_set_nlink(entry,
807
+ (unsigned int)atol8(header + odc_nlink_offset, odc_nlink_size));
808
+ archive_entry_set_rdev(entry,
809
+ (dev_t)atol8(header + odc_rdev_offset, odc_rdev_size));
810
+ archive_entry_set_mtime(entry, atol8(header + odc_mtime_offset, odc_mtime_size), 0);
811
+ *namelength = (size_t)atol8(header + odc_namesize_offset, odc_namesize_size);
812
+ *name_pad = 0; /* No padding of filename. */
813
+
814
+ /*
815
+ * Note: entry_bytes_remaining is at least 64 bits and
816
+ * therefore guaranteed to be big enough for a 33-bit file
817
+ * size.
818
+ */
819
+ cpio->entry_bytes_remaining =
820
+ atol8(header + odc_filesize_offset, odc_filesize_size);
821
+ archive_entry_set_size(entry, cpio->entry_bytes_remaining);
822
+ cpio->entry_padding = 0;
823
+ __archive_read_consume(a, odc_header_size);
824
+ return (r);
825
+ }
826
+
827
+ /*
828
+ * NOTE: if a filename suffix is ".z", it is the file gziped by afio.
829
+ * it would be nice that we can show uncompressed file size and we can
830
+ * uncompressed file contents automatically, unfortunately we have nothing
831
+ * to get a uncompressed file size while reading each header. It means
832
+ * we also cannot uncompress file contents under our framework.
833
+ */
834
+ static int
835
+ header_afiol(struct archive_read *a, struct cpio *cpio,
836
+ struct archive_entry *entry, size_t *namelength, size_t *name_pad)
837
+ {
838
+ const void *h;
839
+ const char *header;
840
+
841
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_AFIO_LARGE;
842
+ a->archive.archive_format_name = "afio large ASCII";
843
+
844
+ /* Read fixed-size portion of header. */
845
+ h = __archive_read_ahead(a, afiol_header_size, NULL);
846
+ if (h == NULL)
847
+ return (ARCHIVE_FATAL);
848
+
849
+ /* Parse out octal fields. */
850
+ header = (const char *)h;
851
+
852
+ archive_entry_set_dev(entry,
853
+ (dev_t)atol16(header + afiol_dev_offset, afiol_dev_size));
854
+ archive_entry_set_ino(entry, atol16(header + afiol_ino_offset, afiol_ino_size));
855
+ archive_entry_set_mode(entry,
856
+ (mode_t)atol8(header + afiol_mode_offset, afiol_mode_size));
857
+ archive_entry_set_uid(entry, atol16(header + afiol_uid_offset, afiol_uid_size));
858
+ archive_entry_set_gid(entry, atol16(header + afiol_gid_offset, afiol_gid_size));
859
+ archive_entry_set_nlink(entry,
860
+ (unsigned int)atol16(header + afiol_nlink_offset, afiol_nlink_size));
861
+ archive_entry_set_rdev(entry,
862
+ (dev_t)atol16(header + afiol_rdev_offset, afiol_rdev_size));
863
+ archive_entry_set_mtime(entry, atol16(header + afiol_mtime_offset, afiol_mtime_size), 0);
864
+ *namelength = (size_t)atol16(header + afiol_namesize_offset, afiol_namesize_size);
865
+ *name_pad = 0; /* No padding of filename. */
866
+
867
+ cpio->entry_bytes_remaining =
868
+ atol16(header + afiol_filesize_offset, afiol_filesize_size);
869
+ archive_entry_set_size(entry, cpio->entry_bytes_remaining);
870
+ cpio->entry_padding = 0;
871
+ __archive_read_consume(a, afiol_header_size);
872
+ return (ARCHIVE_OK);
873
+ }
874
+
875
+
876
+ static int
877
+ header_bin_le(struct archive_read *a, struct cpio *cpio,
878
+ struct archive_entry *entry, size_t *namelength, size_t *name_pad)
879
+ {
880
+ const void *h;
881
+ const unsigned char *header;
882
+
883
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_BIN_LE;
884
+ a->archive.archive_format_name = "cpio (little-endian binary)";
885
+
886
+ /* Read fixed-size portion of header. */
887
+ h = __archive_read_ahead(a, bin_header_size, NULL);
888
+ if (h == NULL) {
889
+ archive_set_error(&a->archive, 0,
890
+ "End of file trying to read next cpio header");
891
+ return (ARCHIVE_FATAL);
892
+ }
893
+
894
+ /* Parse out binary fields. */
895
+ header = (const unsigned char *)h;
896
+
897
+ archive_entry_set_dev(entry, header[bin_dev_offset] + header[bin_dev_offset + 1] * 256);
898
+ archive_entry_set_ino(entry, header[bin_ino_offset] + header[bin_ino_offset + 1] * 256);
899
+ archive_entry_set_mode(entry, header[bin_mode_offset] + header[bin_mode_offset + 1] * 256);
900
+ if (cpio->option_pwb) {
901
+ /* turn off random bits left over from V6 inode */
902
+ archive_entry_set_mode(entry, archive_entry_mode(entry) & 067777);
903
+ if ((archive_entry_mode(entry) & AE_IFMT) == 0)
904
+ archive_entry_set_mode(entry, archive_entry_mode(entry) | AE_IFREG);
905
+ }
906
+ archive_entry_set_uid(entry, header[bin_uid_offset] + header[bin_uid_offset + 1] * 256);
907
+ archive_entry_set_gid(entry, header[bin_gid_offset] + header[bin_gid_offset + 1] * 256);
908
+ archive_entry_set_nlink(entry, header[bin_nlink_offset] + header[bin_nlink_offset + 1] * 256);
909
+ archive_entry_set_rdev(entry, header[bin_rdev_offset] + header[bin_rdev_offset + 1] * 256);
910
+ archive_entry_set_mtime(entry, le4(header + bin_mtime_offset), 0);
911
+ *namelength = header[bin_namesize_offset] + header[bin_namesize_offset + 1] * 256;
912
+ *name_pad = *namelength & 1; /* Pad to even. */
913
+
914
+ cpio->entry_bytes_remaining = le4(header + bin_filesize_offset);
915
+ archive_entry_set_size(entry, cpio->entry_bytes_remaining);
916
+ cpio->entry_padding = cpio->entry_bytes_remaining & 1; /* Pad to even. */
917
+ __archive_read_consume(a, bin_header_size);
918
+ return (ARCHIVE_OK);
919
+ }
920
+
921
+ static int
922
+ header_bin_be(struct archive_read *a, struct cpio *cpio,
923
+ struct archive_entry *entry, size_t *namelength, size_t *name_pad)
924
+ {
925
+ const void *h;
926
+ const unsigned char *header;
927
+
928
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_BIN_BE;
929
+ a->archive.archive_format_name = "cpio (big-endian binary)";
930
+
931
+ /* Read fixed-size portion of header. */
932
+ h = __archive_read_ahead(a, bin_header_size, NULL);
933
+ if (h == NULL) {
934
+ archive_set_error(&a->archive, 0,
935
+ "End of file trying to read next cpio header");
936
+ return (ARCHIVE_FATAL);
937
+ }
938
+
939
+ /* Parse out binary fields. */
940
+ header = (const unsigned char *)h;
941
+
942
+ archive_entry_set_dev(entry, header[bin_dev_offset] * 256 + header[bin_dev_offset + 1]);
943
+ archive_entry_set_ino(entry, header[bin_ino_offset] * 256 + header[bin_ino_offset + 1]);
944
+ archive_entry_set_mode(entry, header[bin_mode_offset] * 256 + header[bin_mode_offset + 1]);
945
+ if (cpio->option_pwb) {
946
+ /* turn off random bits left over from V6 inode */
947
+ archive_entry_set_mode(entry, archive_entry_mode(entry) & 067777);
948
+ if ((archive_entry_mode(entry) & AE_IFMT) == 0)
949
+ archive_entry_set_mode(entry, archive_entry_mode(entry) | AE_IFREG);
950
+ }
951
+ archive_entry_set_uid(entry, header[bin_uid_offset] * 256 + header[bin_uid_offset + 1]);
952
+ archive_entry_set_gid(entry, header[bin_gid_offset] * 256 + header[bin_gid_offset + 1]);
953
+ archive_entry_set_nlink(entry, header[bin_nlink_offset] * 256 + header[bin_nlink_offset + 1]);
954
+ archive_entry_set_rdev(entry, header[bin_rdev_offset] * 256 + header[bin_rdev_offset + 1]);
955
+ archive_entry_set_mtime(entry, be4(header + bin_mtime_offset), 0);
956
+ *namelength = header[bin_namesize_offset] * 256 + header[bin_namesize_offset + 1];
957
+ *name_pad = *namelength & 1; /* Pad to even. */
958
+
959
+ cpio->entry_bytes_remaining = be4(header + bin_filesize_offset);
960
+ archive_entry_set_size(entry, cpio->entry_bytes_remaining);
961
+ cpio->entry_padding = cpio->entry_bytes_remaining & 1; /* Pad to even. */
962
+ __archive_read_consume(a, bin_header_size);
963
+ return (ARCHIVE_OK);
964
+ }
965
+
966
+ static int
967
+ archive_read_format_cpio_cleanup(struct archive_read *a)
968
+ {
969
+ struct cpio *cpio;
970
+
971
+ cpio = (struct cpio *)(a->format->data);
972
+ /* Free inode->name map */
973
+ while (cpio->links_head != NULL) {
974
+ struct links_entry *lp = cpio->links_head->next;
975
+
976
+ free(cpio->links_head->name);
977
+ free(cpio->links_head);
978
+ cpio->links_head = lp;
979
+ }
980
+ free(cpio);
981
+ (a->format->data) = NULL;
982
+ return (ARCHIVE_OK);
983
+ }
984
+
985
+ static int64_t
986
+ le4(const unsigned char *p)
987
+ {
988
+ return ((p[0] << 16) + (((int64_t)p[1]) << 24) + (p[2] << 0) + (p[3] << 8));
989
+ }
990
+
991
+
992
+ static int64_t
993
+ be4(const unsigned char *p)
994
+ {
995
+ return ((((int64_t)p[0]) << 24) + (p[1] << 16) + (p[2] << 8) + (p[3]));
996
+ }
997
+
998
+ /*
999
+ * Note that this implementation does not (and should not!) obey
1000
+ * locale settings; you cannot simply substitute strtol here, since
1001
+ * it does obey locale.
1002
+ */
1003
+ static int64_t
1004
+ atol8(const char *p, unsigned char_cnt)
1005
+ {
1006
+ int64_t l;
1007
+ int digit;
1008
+
1009
+ l = 0;
1010
+ while (char_cnt-- > 0) {
1011
+ if (*p >= '0' && *p <= '7')
1012
+ digit = *p - '0';
1013
+ else
1014
+ return (l);
1015
+ p++;
1016
+ l <<= 3;
1017
+ l |= digit;
1018
+ }
1019
+ return (l);
1020
+ }
1021
+
1022
+ static int64_t
1023
+ atol16(const char *p, unsigned char_cnt)
1024
+ {
1025
+ int64_t l;
1026
+ int digit;
1027
+
1028
+ l = 0;
1029
+ while (char_cnt-- > 0) {
1030
+ if (*p >= 'a' && *p <= 'f')
1031
+ digit = *p - 'a' + 10;
1032
+ else if (*p >= 'A' && *p <= 'F')
1033
+ digit = *p - 'A' + 10;
1034
+ else if (*p >= '0' && *p <= '9')
1035
+ digit = *p - '0';
1036
+ else
1037
+ return (l);
1038
+ p++;
1039
+ l <<= 4;
1040
+ l |= digit;
1041
+ }
1042
+ return (l);
1043
+ }
1044
+
1045
+ static int
1046
+ record_hardlink(struct archive_read *a,
1047
+ struct cpio *cpio, struct archive_entry *entry)
1048
+ {
1049
+ struct links_entry *le;
1050
+ dev_t dev;
1051
+ int64_t ino;
1052
+
1053
+ if (archive_entry_nlink(entry) <= 1)
1054
+ return (ARCHIVE_OK);
1055
+
1056
+ dev = archive_entry_dev(entry);
1057
+ ino = archive_entry_ino64(entry);
1058
+
1059
+ /*
1060
+ * First look in the list of multiply-linked files. If we've
1061
+ * already dumped it, convert this entry to a hard link entry.
1062
+ */
1063
+ for (le = cpio->links_head; le; le = le->next) {
1064
+ if (le->dev == dev && le->ino == ino) {
1065
+ archive_entry_copy_hardlink(entry, le->name);
1066
+
1067
+ if (--le->links <= 0) {
1068
+ if (le->previous != NULL)
1069
+ le->previous->next = le->next;
1070
+ if (le->next != NULL)
1071
+ le->next->previous = le->previous;
1072
+ if (cpio->links_head == le)
1073
+ cpio->links_head = le->next;
1074
+ free(le->name);
1075
+ free(le);
1076
+ }
1077
+
1078
+ return (ARCHIVE_OK);
1079
+ }
1080
+ }
1081
+
1082
+ le = (struct links_entry *)malloc(sizeof(struct links_entry));
1083
+ if (le == NULL) {
1084
+ archive_set_error(&a->archive,
1085
+ ENOMEM, "Out of memory adding file to list");
1086
+ return (ARCHIVE_FATAL);
1087
+ }
1088
+ if (cpio->links_head != NULL)
1089
+ cpio->links_head->previous = le;
1090
+ le->next = cpio->links_head;
1091
+ le->previous = NULL;
1092
+ cpio->links_head = le;
1093
+ le->dev = dev;
1094
+ le->ino = ino;
1095
+ le->links = archive_entry_nlink(entry) - 1;
1096
+ le->name = strdup(archive_entry_pathname(entry));
1097
+ if (le->name == NULL) {
1098
+ archive_set_error(&a->archive,
1099
+ ENOMEM, "Out of memory adding file to list");
1100
+ return (ARCHIVE_FATAL);
1101
+ }
1102
+
1103
+ return (ARCHIVE_OK);
1104
+ }