libarchive-static 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1,7 +1,7 @@
1
1
  /*-
2
2
  * Copyright (c) 2003-2007 Tim Kientzle
3
3
  * Copyright (c) 2009 Andreas Henriksson <andreas@fatal.se>
4
- * Copyright (c) 2009 Michihiro NAKAJIMA
4
+ * Copyright (c) 2009-2012 Michihiro NAKAJIMA
5
5
  * All rights reserved.
6
6
  *
7
7
  * Redistribution and use in source and binary forms, with or without
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_iso9660.c 20
47
47
  #include "archive.h"
48
48
  #include "archive_endian.h"
49
49
  #include "archive_entry.h"
50
+ #include "archive_entry_locale.h"
50
51
  #include "archive_private.h"
51
52
  #include "archive_read_private.h"
52
53
  #include "archive_string.h"
@@ -261,13 +262,17 @@ struct file_info {
261
262
  struct file_info *use_next;
262
263
  struct file_info *parent;
263
264
  struct file_info *next;
265
+ struct file_info *re_next;
264
266
  int subdirs;
265
267
  uint64_t key; /* Heap Key. */
266
268
  uint64_t offset; /* Offset on disk. */
267
269
  uint64_t size; /* File size in bytes. */
268
270
  uint32_t ce_offset; /* Offset of CE. */
269
271
  uint32_t ce_size; /* Size of CE. */
272
+ char rr_moved; /* Flag to rr_moved. */
273
+ char rr_moved_has_re_only;
270
274
  char re; /* Having RRIP "RE" extension. */
275
+ char re_descendant;
271
276
  uint64_t cl_offset; /* Having RRIP "CL" extension. */
272
277
  int birthtime_is_set;
273
278
  time_t birthtime; /* File created time. */
@@ -281,6 +286,8 @@ struct file_info {
281
286
  int64_t number;
282
287
  int nlinks;
283
288
  struct archive_string name; /* Pathname */
289
+ unsigned char *utf16be_name;
290
+ size_t utf16be_bytes;
284
291
  char name_continues; /* Non-zero if name continues */
285
292
  struct archive_string symlink;
286
293
  char symlink_continues; /* Non-zero if link continues */
@@ -294,7 +301,10 @@ struct file_info {
294
301
  struct content *first;
295
302
  struct content **last;
296
303
  } contents;
297
- char exposed;
304
+ struct {
305
+ struct file_info *first;
306
+ struct file_info **last;
307
+ } rede_files;
298
308
  };
299
309
 
300
310
  struct heap_queue {
@@ -312,13 +322,11 @@ struct iso9660 {
312
322
 
313
323
  struct archive_string pathname;
314
324
  char seenRockridge; /* Set true if RR extensions are used. */
315
- char seenSUSP; /* Set true if SUSP is beging used. */
325
+ char seenSUSP; /* Set true if SUSP is being used. */
316
326
  char seenJoliet;
317
327
 
318
328
  unsigned char suspOffset;
319
329
  struct file_info *rr_moved;
320
- struct heap_queue re_dirs;
321
- struct heap_queue cl_files;
322
330
  struct read_ce_queue {
323
331
  struct read_ce_req {
324
332
  uint64_t offset;/* Offset of CE on disk. */
@@ -337,6 +345,10 @@ struct iso9660 {
337
345
  struct file_info *first;
338
346
  struct file_info **last;
339
347
  } cache_files;
348
+ struct {
349
+ struct file_info *first;
350
+ struct file_info **last;
351
+ } re_files;
340
352
 
341
353
  uint64_t current_position;
342
354
  ssize_t logical_block_size;
@@ -348,22 +360,36 @@ struct iso9660 {
348
360
  uint32_t size;
349
361
  } primary, joliet;
350
362
 
351
- off_t entry_sparse_offset;
363
+ int64_t entry_sparse_offset;
352
364
  int64_t entry_bytes_remaining;
365
+ size_t entry_bytes_unconsumed;
353
366
  struct zisofs entry_zisofs;
354
367
  struct content *entry_content;
368
+ struct archive_string_conv *sconv_utf16be;
369
+ /*
370
+ * Buffers for a full pathname in UTF-16BE in Joliet extensions.
371
+ */
372
+ #define UTF16_NAME_MAX 1024
373
+ unsigned char *utf16be_path;
374
+ size_t utf16be_path_len;
375
+ unsigned char *utf16be_previous_path;
376
+ size_t utf16be_previous_path_len;
377
+ /* Null buffer used in bidder to improve its performance. */
378
+ unsigned char null[2048];
355
379
  };
356
380
 
357
- static int archive_read_format_iso9660_bid(struct archive_read *);
381
+ static int archive_read_format_iso9660_bid(struct archive_read *, int);
358
382
  static int archive_read_format_iso9660_options(struct archive_read *,
359
383
  const char *, const char *);
360
384
  static int archive_read_format_iso9660_cleanup(struct archive_read *);
361
385
  static int archive_read_format_iso9660_read_data(struct archive_read *,
362
- const void **, size_t *, off_t *);
386
+ const void **, size_t *, int64_t *);
363
387
  static int archive_read_format_iso9660_read_data_skip(struct archive_read *);
364
388
  static int archive_read_format_iso9660_read_header(struct archive_read *,
365
389
  struct archive_entry *);
366
- static const char *build_pathname(struct archive_string *, struct file_info *);
390
+ static const char *build_pathname(struct archive_string *, struct file_info *, int);
391
+ static int build_pathname_utf16be(unsigned char *, size_t, size_t *,
392
+ struct file_info *);
367
393
  #if DEBUG
368
394
  static void dump_isodirrec(FILE *, const unsigned char *isodirrec);
369
395
  #endif
@@ -377,12 +403,14 @@ static int isJolietSVD(struct iso9660 *, const unsigned char *);
377
403
  static int isSVD(struct iso9660 *, const unsigned char *);
378
404
  static int isEVD(struct iso9660 *, const unsigned char *);
379
405
  static int isPVD(struct iso9660 *, const unsigned char *);
380
- static struct file_info *next_cache_entry(struct iso9660 *iso9660);
381
- static int next_entry_seek(struct archive_read *a, struct iso9660 *iso9660,
382
- struct file_info **pfile);
406
+ static int next_cache_entry(struct archive_read *, struct iso9660 *,
407
+ struct file_info **);
408
+ static int next_entry_seek(struct archive_read *, struct iso9660 *,
409
+ struct file_info **);
383
410
  static struct file_info *
384
411
  parse_file_info(struct archive_read *a,
385
- struct file_info *parent, const unsigned char *isodirrec);
412
+ struct file_info *parent, const unsigned char *isodirrec,
413
+ size_t reclen);
386
414
  static int parse_rockridge(struct archive_read *a,
387
415
  struct file_info *file, const unsigned char *start,
388
416
  const unsigned char *end);
@@ -400,17 +428,19 @@ static void parse_rockridge_ZF1(struct file_info *,
400
428
  static void register_file(struct iso9660 *, struct file_info *);
401
429
  static void release_files(struct iso9660 *);
402
430
  static unsigned toi(const void *p, int n);
431
+ static inline void re_add_entry(struct iso9660 *, struct file_info *);
432
+ static inline struct file_info * re_get_entry(struct iso9660 *);
433
+ static inline int rede_add_entry(struct file_info *);
434
+ static inline struct file_info * rede_get_entry(struct file_info *);
403
435
  static inline void cache_add_entry(struct iso9660 *iso9660,
404
436
  struct file_info *file);
405
- static inline void cache_add_to_next_of_parent(struct iso9660 *iso9660,
406
- struct file_info *file);
407
437
  static inline struct file_info *cache_get_entry(struct iso9660 *iso9660);
408
- static void heap_add_entry(struct heap_queue *heap,
438
+ static int heap_add_entry(struct archive_read *a, struct heap_queue *heap,
409
439
  struct file_info *file, uint64_t key);
410
440
  static struct file_info *heap_get_entry(struct heap_queue *heap);
411
441
 
412
- #define add_entry(iso9660, file) \
413
- heap_add_entry(&((iso9660)->pending_files), file, file->offset)
442
+ #define add_entry(arch, iso9660, file) \
443
+ heap_add_entry(arch, &((iso9660)->pending_files), file, file->offset)
414
444
  #define next_entry(iso9660) \
415
445
  heap_get_entry(&((iso9660)->pending_files))
416
446
 
@@ -421,15 +451,20 @@ archive_read_support_format_iso9660(struct archive *_a)
421
451
  struct iso9660 *iso9660;
422
452
  int r;
423
453
 
424
- iso9660 = (struct iso9660 *)malloc(sizeof(*iso9660));
454
+ archive_check_magic(_a, ARCHIVE_READ_MAGIC,
455
+ ARCHIVE_STATE_NEW, "archive_read_support_format_iso9660");
456
+
457
+ iso9660 = (struct iso9660 *)calloc(1, sizeof(*iso9660));
425
458
  if (iso9660 == NULL) {
426
- archive_set_error(&a->archive, ENOMEM, "Can't allocate iso9660 data");
459
+ archive_set_error(&a->archive, ENOMEM,
460
+ "Can't allocate iso9660 data");
427
461
  return (ARCHIVE_FATAL);
428
462
  }
429
- memset(iso9660, 0, sizeof(*iso9660));
430
463
  iso9660->magic = ISO9660_MAGIC;
431
464
  iso9660->cache_files.first = NULL;
432
465
  iso9660->cache_files.last = &(iso9660->cache_files.first);
466
+ iso9660->re_files.first = NULL;
467
+ iso9660->re_files.last = &(iso9660->re_files.first);
433
468
  /* Enable to support Joliet extensions by default. */
434
469
  iso9660->opt_support_joliet = 1;
435
470
  /* Enable to support Rock Ridge extensions by default. */
@@ -443,7 +478,10 @@ archive_read_support_format_iso9660(struct archive *_a)
443
478
  archive_read_format_iso9660_read_header,
444
479
  archive_read_format_iso9660_read_data,
445
480
  archive_read_format_iso9660_read_data_skip,
446
- archive_read_format_iso9660_cleanup);
481
+ NULL,
482
+ archive_read_format_iso9660_cleanup,
483
+ NULL,
484
+ NULL);
447
485
 
448
486
  if (r != ARCHIVE_OK) {
449
487
  free(iso9660);
@@ -454,14 +492,18 @@ archive_read_support_format_iso9660(struct archive *_a)
454
492
 
455
493
 
456
494
  static int
457
- archive_read_format_iso9660_bid(struct archive_read *a)
495
+ archive_read_format_iso9660_bid(struct archive_read *a, int best_bid)
458
496
  {
459
497
  struct iso9660 *iso9660;
460
498
  ssize_t bytes_read;
461
- const void *h;
462
499
  const unsigned char *p;
463
500
  int seenTerminator;
464
501
 
502
+ /* If there's already a better bid than we can ever
503
+ make, don't bother testing. */
504
+ if (best_bid > 48)
505
+ return (-1);
506
+
465
507
  iso9660 = (struct iso9660 *)(a->format->data);
466
508
 
467
509
  /*
@@ -470,12 +512,11 @@ archive_read_format_iso9660_bid(struct archive_read *a)
470
512
  * if the I/O layer gives us more, we'll take it.
471
513
  */
472
514
  #define RESERVED_AREA (SYSTEM_AREA_BLOCK * LOGICAL_BLOCK_SIZE)
473
- h = __archive_read_ahead(a,
515
+ p = __archive_read_ahead(a,
474
516
  RESERVED_AREA + 8 * LOGICAL_BLOCK_SIZE,
475
517
  &bytes_read);
476
- if (h == NULL)
518
+ if (p == NULL)
477
519
  return (-1);
478
- p = (const unsigned char *)h;
479
520
 
480
521
  /* Skip the reserved area. */
481
522
  bytes_read -= RESERVED_AREA;
@@ -491,10 +532,8 @@ archive_read_format_iso9660_bid(struct archive_read *a)
491
532
  /* Standard Identifier must be "CD001" */
492
533
  if (memcmp(p + 1, "CD001", 5) != 0)
493
534
  return (0);
494
- if (!iso9660->primary.location) {
495
- if (isPVD(iso9660, p))
496
- continue;
497
- }
535
+ if (isPVD(iso9660, p))
536
+ continue;
498
537
  if (!iso9660->joliet.location) {
499
538
  if (isJolietSVD(iso9660, p))
500
539
  continue;
@@ -550,10 +589,27 @@ archive_read_format_iso9660_options(struct archive_read *a,
550
589
 
551
590
  /* Note: The "warn" return is just to inform the options
552
591
  * supervisor that we didn't handle it. It will generate
553
- * a suitable error if noone used this option. */
592
+ * a suitable error if no one used this option. */
554
593
  return (ARCHIVE_WARN);
555
594
  }
556
595
 
596
+ static int
597
+ isNull(struct iso9660 *iso9660, const unsigned char *h, unsigned offset,
598
+ unsigned bytes)
599
+ {
600
+
601
+ while (bytes >= sizeof(iso9660->null)) {
602
+ if (!memcmp(iso9660->null, h + offset, sizeof(iso9660->null)))
603
+ return (0);
604
+ offset += sizeof(iso9660->null);
605
+ bytes -= sizeof(iso9660->null);
606
+ }
607
+ if (bytes)
608
+ return memcmp(iso9660->null, h + offset, bytes) == 0;
609
+ else
610
+ return (1);
611
+ }
612
+
557
613
  static int
558
614
  isBootRecord(struct iso9660 *iso9660, const unsigned char *h)
559
615
  {
@@ -599,8 +655,6 @@ isVolumePartition(struct iso9660 *iso9660, const unsigned char *h)
599
655
  static int
600
656
  isVDSetTerminator(struct iso9660 *iso9660, const unsigned char *h)
601
657
  {
602
- int i;
603
-
604
658
  (void)iso9660; /* UNUSED */
605
659
 
606
660
  /* Type of the Volume Descriptor Set Terminator must be 255. */
@@ -612,9 +666,8 @@ isVDSetTerminator(struct iso9660 *iso9660, const unsigned char *h)
612
666
  return (0);
613
667
 
614
668
  /* Reserved field must be 0. */
615
- for (i = 7; i < 2048; ++i)
616
- if (h[i] != 0)
617
- return (0);
669
+ if (!isNull(iso9660, h, 7, 2048-7))
670
+ return (0);
618
671
 
619
672
  return (1);
620
673
  }
@@ -675,7 +728,6 @@ isSVD(struct iso9660 *iso9660, const unsigned char *h)
675
728
  ssize_t logical_block_size;
676
729
  int32_t volume_block;
677
730
  int32_t location;
678
- int i;
679
731
 
680
732
  (void)iso9660; /* UNUSED */
681
733
 
@@ -684,15 +736,12 @@ isSVD(struct iso9660 *iso9660, const unsigned char *h)
684
736
  return (0);
685
737
 
686
738
  /* Reserved field must be 0. */
687
- for (i = 0; i < SVD_reserved1_size; ++i)
688
- if (h[SVD_reserved1_offset + i] != 0)
689
- return (0);
690
- for (i = 0; i < SVD_reserved2_size; ++i)
691
- if (h[SVD_reserved2_offset + i] != 0)
692
- return (0);
693
- for (i = 0; i < SVD_reserved3_size; ++i)
694
- if (h[SVD_reserved3_offset + i] != 0)
695
- return (0);
739
+ if (!isNull(iso9660, h, SVD_reserved1_offset, SVD_reserved1_size))
740
+ return (0);
741
+ if (!isNull(iso9660, h, SVD_reserved2_offset, SVD_reserved2_size))
742
+ return (0);
743
+ if (!isNull(iso9660, h, SVD_reserved3_offset, SVD_reserved3_size))
744
+ return (0);
696
745
 
697
746
  /* File structure version must be 1 for ISO9660/ECMA119. */
698
747
  if (h[SVD_file_structure_version_offset] != 1)
@@ -709,16 +758,18 @@ isSVD(struct iso9660 *iso9660, const unsigned char *h)
709
758
 
710
759
  /* Location of Occurrence of Type L Path Table must be
711
760
  * available location,
712
- * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
761
+ * >= SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
713
762
  location = archive_le32dec(h+SVD_type_L_path_table_offset);
714
- if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
763
+ if (location < SYSTEM_AREA_BLOCK+2 || location >= volume_block)
715
764
  return (0);
716
765
 
717
- /* Location of Occurrence of Type M Path Table must be
718
- * available location,
719
- * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
766
+ /* The Type M Path Table must be at a valid location (WinISO
767
+ * and probably other programs omit this, so we allow zero)
768
+ *
769
+ * >= SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
720
770
  location = archive_be32dec(h+SVD_type_M_path_table_offset);
721
- if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
771
+ if ((location > 0 && location < SYSTEM_AREA_BLOCK+2)
772
+ || location >= volume_block)
722
773
  return (0);
723
774
 
724
775
  /* Read Root Directory Record in Volume Descriptor. */
@@ -736,7 +787,6 @@ isEVD(struct iso9660 *iso9660, const unsigned char *h)
736
787
  ssize_t logical_block_size;
737
788
  int32_t volume_block;
738
789
  int32_t location;
739
- int i;
740
790
 
741
791
  (void)iso9660; /* UNUSED */
742
792
 
@@ -753,14 +803,12 @@ isEVD(struct iso9660 *iso9660, const unsigned char *h)
753
803
  return (0);
754
804
 
755
805
  /* Reserved field must be 0. */
756
- for (i = 0; i < PVD_reserved2_size; ++i)
757
- if (h[PVD_reserved2_offset + i] != 0)
758
- return (0);
806
+ if (!isNull(iso9660, h, PVD_reserved2_offset, PVD_reserved2_size))
807
+ return (0);
759
808
 
760
809
  /* Reserved field must be 0. */
761
- for (i = 0; i < PVD_reserved3_size; ++i)
762
- if (h[PVD_reserved3_offset + i] != 0)
763
- return (0);
810
+ if (!isNull(iso9660, h, PVD_reserved3_offset, PVD_reserved3_size))
811
+ return (0);
764
812
 
765
813
  /* Logical block size must be > 0. */
766
814
  /* I've looked at Ecma 119 and can't find any stronger
@@ -781,27 +829,26 @@ isEVD(struct iso9660 *iso9660, const unsigned char *h)
781
829
 
782
830
  /* Location of Occurrence of Type L Path Table must be
783
831
  * available location,
784
- * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
832
+ * >= SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
785
833
  location = archive_le32dec(h+PVD_type_1_path_table_offset);
786
- if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
834
+ if (location < SYSTEM_AREA_BLOCK+2 || location >= volume_block)
787
835
  return (0);
788
836
 
789
837
  /* Location of Occurrence of Type M Path Table must be
790
838
  * available location,
791
- * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
839
+ * >= SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
792
840
  location = archive_be32dec(h+PVD_type_m_path_table_offset);
793
- if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
841
+ if ((location > 0 && location < SYSTEM_AREA_BLOCK+2)
842
+ || location >= volume_block)
794
843
  return (0);
795
844
 
796
845
  /* Reserved field must be 0. */
797
- for (i = 0; i < PVD_reserved4_size; ++i)
798
- if (h[PVD_reserved4_offset + i] != 0)
799
- return (0);
846
+ if (!isNull(iso9660, h, PVD_reserved4_offset, PVD_reserved4_size))
847
+ return (0);
800
848
 
801
849
  /* Reserved field must be 0. */
802
- for (i = 0; i < PVD_reserved5_size; ++i)
803
- if (h[PVD_reserved5_offset + i] != 0)
804
- return (0);
850
+ if (!isNull(iso9660, h, PVD_reserved5_offset, PVD_reserved5_size))
851
+ return (0);
805
852
 
806
853
  /* Read Root Directory Record in Volume Descriptor. */
807
854
  p = h + PVD_root_directory_record_offset;
@@ -833,14 +880,12 @@ isPVD(struct iso9660 *iso9660, const unsigned char *h)
833
880
  return (0);
834
881
 
835
882
  /* Reserved field must be 0. */
836
- for (i = 0; i < PVD_reserved2_size; ++i)
837
- if (h[PVD_reserved2_offset + i] != 0)
838
- return (0);
883
+ if (!isNull(iso9660, h, PVD_reserved2_offset, PVD_reserved2_size))
884
+ return (0);
839
885
 
840
886
  /* Reserved field must be 0. */
841
- for (i = 0; i < PVD_reserved3_size; ++i)
842
- if (h[PVD_reserved3_offset + i] != 0)
843
- return (0);
887
+ if (!isNull(iso9660, h, PVD_reserved3_offset, PVD_reserved3_size))
888
+ return (0);
844
889
 
845
890
  /* Logical block size must be > 0. */
846
891
  /* I've looked at Ecma 119 and can't find any stronger
@@ -862,25 +907,29 @@ isPVD(struct iso9660 *iso9660, const unsigned char *h)
862
907
  * available location,
863
908
  * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
864
909
  location = archive_le32dec(h+PVD_type_1_path_table_offset);
865
- if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
910
+ if (location < SYSTEM_AREA_BLOCK+2 || location >= volume_block)
866
911
  return (0);
867
912
 
868
- /* Location of Occurrence of Type M Path Table must be
869
- * available location,
870
- * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
913
+ /* The Type M Path Table must also be at a valid location
914
+ * (although ECMA 119 requires a Type M Path Table, WinISO and
915
+ * probably other programs omit it, so we permit a zero here)
916
+ *
917
+ * >= SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */
871
918
  location = archive_be32dec(h+PVD_type_m_path_table_offset);
872
- if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block)
919
+ if ((location > 0 && location < SYSTEM_AREA_BLOCK+2)
920
+ || location >= volume_block)
873
921
  return (0);
874
922
 
875
923
  /* Reserved field must be 0. */
924
+ /* But accept NetBSD/FreeBSD "makefs" images with 0x20 here. */
876
925
  for (i = 0; i < PVD_reserved4_size; ++i)
877
- if (h[PVD_reserved4_offset + i] != 0)
926
+ if (h[PVD_reserved4_offset + i] != 0
927
+ && h[PVD_reserved4_offset + i] != 0x20)
878
928
  return (0);
879
929
 
880
930
  /* Reserved field must be 0. */
881
- for (i = 0; i < PVD_reserved5_size; ++i)
882
- if (h[PVD_reserved5_offset + i] != 0)
883
- return (0);
931
+ if (!isNull(iso9660, h, PVD_reserved5_offset, PVD_reserved5_size))
932
+ return (0);
884
933
 
885
934
  /* XXX TODO: Check other values for sanity; reject more
886
935
  * malformed PVDs. XXX */
@@ -890,11 +939,15 @@ isPVD(struct iso9660 *iso9660, const unsigned char *h)
890
939
  if (p[DR_length_offset] != 34)
891
940
  return (0);
892
941
 
893
- iso9660->logical_block_size = logical_block_size;
894
- iso9660->volume_block = volume_block;
895
- iso9660->volume_size = logical_block_size * (uint64_t)volume_block;
896
- iso9660->primary.location = archive_le32dec(p + DR_extent_offset);
897
- iso9660->primary.size = archive_le32dec(p + DR_size_offset);
942
+ if (!iso9660->primary.location) {
943
+ iso9660->logical_block_size = logical_block_size;
944
+ iso9660->volume_block = volume_block;
945
+ iso9660->volume_size =
946
+ logical_block_size * (uint64_t)volume_block;
947
+ iso9660->primary.location =
948
+ archive_le32dec(p + DR_extent_offset);
949
+ iso9660->primary.size = archive_le32dec(p + DR_size_offset);
950
+ }
898
951
 
899
952
  return (48);
900
953
  }
@@ -905,35 +958,41 @@ read_children(struct archive_read *a, struct file_info *parent)
905
958
  struct iso9660 *iso9660;
906
959
  const unsigned char *b, *p;
907
960
  struct file_info *multi;
908
- size_t step;
961
+ size_t step, skip_size;
909
962
 
910
963
  iso9660 = (struct iso9660 *)(a->format->data);
964
+ /* flush any remaining bytes from the last round to ensure
965
+ * we're positioned */
966
+ if (iso9660->entry_bytes_unconsumed) {
967
+ __archive_read_consume(a, iso9660->entry_bytes_unconsumed);
968
+ iso9660->entry_bytes_unconsumed = 0;
969
+ }
911
970
  if (iso9660->current_position > parent->offset) {
912
971
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
913
972
  "Ignoring out-of-order directory (%s) %jd > %jd",
914
973
  parent->name.s,
915
- iso9660->current_position,
916
- parent->offset);
974
+ (intmax_t)iso9660->current_position,
975
+ (intmax_t)parent->offset);
917
976
  return (ARCHIVE_WARN);
918
977
  }
919
978
  if (parent->offset + parent->size > iso9660->volume_size) {
920
979
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
921
980
  "Directory is beyond end-of-media: %s",
922
- parent->name);
981
+ parent->name.s);
923
982
  return (ARCHIVE_WARN);
924
983
  }
925
984
  if (iso9660->current_position < parent->offset) {
926
985
  int64_t skipsize;
927
986
 
928
987
  skipsize = parent->offset - iso9660->current_position;
929
- skipsize = __archive_read_skip(a, skipsize);
988
+ skipsize = __archive_read_consume(a, skipsize);
930
989
  if (skipsize < 0)
931
990
  return ((int)skipsize);
932
991
  iso9660->current_position = parent->offset;
933
992
  }
934
993
 
935
- step = ((parent->size + iso9660->logical_block_size -1) /
936
- iso9660->logical_block_size) * iso9660->logical_block_size;
994
+ step = (size_t)(((parent->size + iso9660->logical_block_size -1) /
995
+ iso9660->logical_block_size) * iso9660->logical_block_size);
937
996
  b = __archive_read_ahead(a, step, NULL);
938
997
  if (b == NULL) {
939
998
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -941,14 +1000,15 @@ read_children(struct archive_read *a, struct file_info *parent)
941
1000
  "ISO9660 directory list");
942
1001
  return (ARCHIVE_FATAL);
943
1002
  }
944
- __archive_read_consume(a, step);
945
1003
  iso9660->current_position += step;
946
1004
  multi = NULL;
1005
+ skip_size = step;
947
1006
  while (step) {
948
1007
  p = b;
949
1008
  b += iso9660->logical_block_size;
950
1009
  step -= iso9660->logical_block_size;
951
- for (; *p != 0 && p < b && p + *p <= b; p += *p) {
1010
+ for (; *p != 0 && p + DR_name_offset < b && p + *p <= b;
1011
+ p += *p) {
952
1012
  struct file_info *child;
953
1013
 
954
1014
  /* N.B.: these special directory identifiers
@@ -964,48 +1024,51 @@ read_children(struct archive_read *a, struct file_info *parent)
964
1024
  if (*(p + DR_name_len_offset) == 1
965
1025
  && *(p + DR_name_offset) == '\001')
966
1026
  continue;
967
- child = parse_file_info(a, parent, p);
968
- if (child == NULL)
1027
+ child = parse_file_info(a, parent, p, b - p);
1028
+ if (child == NULL) {
1029
+ __archive_read_consume(a, skip_size);
969
1030
  return (ARCHIVE_FATAL);
970
- if (child->cl_offset)
971
- heap_add_entry(&(iso9660->cl_files),
972
- child, child->cl_offset);
973
- else {
974
- if (child->multi_extent || multi != NULL) {
975
- struct content *con;
976
-
977
- if (multi == NULL) {
978
- multi = child;
979
- multi->contents.first = NULL;
980
- multi->contents.last =
981
- &(multi->contents.first);
982
- }
983
- con = malloc(sizeof(struct content));
984
- if (con == NULL) {
985
- archive_set_error(
986
- &a->archive, ENOMEM,
987
- "No memory for "
988
- "multi extent");
989
- return (ARCHIVE_FATAL);
990
- }
991
- con->offset = child->offset;
992
- con->size = child->size;
993
- con->next = NULL;
994
- *multi->contents.last = con;
995
- multi->contents.last = &(con->next);
996
- if (multi == child)
997
- add_entry(iso9660, child);
998
- else {
999
- multi->size += child->size;
1000
- if (!child->multi_extent)
1001
- multi = NULL;
1002
- }
1003
- } else
1004
- add_entry(iso9660, child);
1005
1031
  }
1032
+ if (child->cl_offset == 0 &&
1033
+ (child->multi_extent || multi != NULL)) {
1034
+ struct content *con;
1035
+
1036
+ if (multi == NULL) {
1037
+ multi = child;
1038
+ multi->contents.first = NULL;
1039
+ multi->contents.last =
1040
+ &(multi->contents.first);
1041
+ }
1042
+ con = malloc(sizeof(struct content));
1043
+ if (con == NULL) {
1044
+ archive_set_error(
1045
+ &a->archive, ENOMEM,
1046
+ "No memory for multi extent");
1047
+ __archive_read_consume(a, skip_size);
1048
+ return (ARCHIVE_FATAL);
1049
+ }
1050
+ con->offset = child->offset;
1051
+ con->size = child->size;
1052
+ con->next = NULL;
1053
+ *multi->contents.last = con;
1054
+ multi->contents.last = &(con->next);
1055
+ if (multi == child) {
1056
+ if (add_entry(a, iso9660, child)
1057
+ != ARCHIVE_OK)
1058
+ return (ARCHIVE_FATAL);
1059
+ } else {
1060
+ multi->size += child->size;
1061
+ if (!child->multi_extent)
1062
+ multi = NULL;
1063
+ }
1064
+ } else
1065
+ if (add_entry(a, iso9660, child) != ARCHIVE_OK)
1066
+ return (ARCHIVE_FATAL);
1006
1067
  }
1007
1068
  }
1008
1069
 
1070
+ __archive_read_consume(a, skip_size);
1071
+
1009
1072
  /* Read data which recorded by RRIP "CE" extension. */
1010
1073
  if (read_CE(a, iso9660) != ARCHIVE_OK)
1011
1074
  return (ARCHIVE_FATAL);
@@ -1014,90 +1077,88 @@ read_children(struct archive_read *a, struct file_info *parent)
1014
1077
  }
1015
1078
 
1016
1079
  static int
1017
- relocate_dir(struct iso9660 *iso9660, struct file_info *file)
1080
+ choose_volume(struct archive_read *a, struct iso9660 *iso9660)
1018
1081
  {
1019
- struct file_info *re;
1082
+ struct file_info *file;
1083
+ int64_t skipsize;
1084
+ struct vd *vd;
1085
+ const void *block;
1086
+ char seenJoliet;
1020
1087
 
1021
- re = heap_get_entry(&(iso9660->re_dirs));
1022
- while (re != NULL && re->offset < file->cl_offset) {
1023
- /* This case is wrong pattern.
1024
- * But dont't reject this directory entry to be robust. */
1025
- cache_add_entry(iso9660, re);
1026
- re = heap_get_entry(&(iso9660->re_dirs));
1088
+ vd = &(iso9660->primary);
1089
+ if (!iso9660->opt_support_joliet)
1090
+ iso9660->seenJoliet = 0;
1091
+ if (iso9660->seenJoliet &&
1092
+ vd->location > iso9660->joliet.location)
1093
+ /* This condition is unlikely; by way of caution. */
1094
+ vd = &(iso9660->joliet);
1095
+
1096
+ skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location;
1097
+ skipsize = __archive_read_consume(a, skipsize);
1098
+ if (skipsize < 0)
1099
+ return ((int)skipsize);
1100
+ iso9660->current_position = skipsize;
1101
+
1102
+ block = __archive_read_ahead(a, vd->size, NULL);
1103
+ if (block == NULL) {
1104
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1105
+ "Failed to read full block when scanning "
1106
+ "ISO9660 directory list");
1107
+ return (ARCHIVE_FATAL);
1027
1108
  }
1028
- if (re == NULL)
1029
- /* This case is wrong pattern. */
1030
- return (0);
1031
- if (re->offset == file->cl_offset) {
1032
- re->parent->subdirs--;
1033
- re->parent = file->parent;
1034
- re->parent->subdirs++;
1035
- cache_add_to_next_of_parent(iso9660, re);
1036
- return (1);
1037
- } else
1038
- /* This case is wrong pattern. */
1039
- heap_add_entry(&(iso9660->re_dirs), re, re->offset);
1040
- return (0);
1041
- }
1042
1109
 
1043
- static int
1044
- read_entries(struct archive_read *a)
1045
- {
1046
- struct iso9660 *iso9660;
1047
- struct file_info *file;
1048
- int r;
1110
+ /*
1111
+ * While reading Root Directory, flag seenJoliet must be zero to
1112
+ * avoid converting special name 0x00(Current Directory) and
1113
+ * next byte to UCS2.
1114
+ */
1115
+ seenJoliet = iso9660->seenJoliet;/* Save flag. */
1116
+ iso9660->seenJoliet = 0;
1117
+ file = parse_file_info(a, NULL, block, vd->size);
1118
+ if (file == NULL)
1119
+ return (ARCHIVE_FATAL);
1120
+ iso9660->seenJoliet = seenJoliet;
1049
1121
 
1050
- iso9660 = (struct iso9660 *)(a->format->data);
1122
+ /*
1123
+ * If the iso image has both RockRidge and Joliet, we preferentially
1124
+ * use RockRidge Extensions rather than Joliet ones.
1125
+ */
1126
+ if (vd == &(iso9660->primary) && iso9660->seenRockridge
1127
+ && iso9660->seenJoliet)
1128
+ iso9660->seenJoliet = 0;
1051
1129
 
1052
- while ((file = next_entry(iso9660)) != NULL &&
1053
- (file->mode & AE_IFMT) == AE_IFDIR) {
1054
- r = read_children(a, file);
1055
- if (r != ARCHIVE_OK)
1056
- return (r);
1130
+ if (vd == &(iso9660->primary) && !iso9660->seenRockridge
1131
+ && iso9660->seenJoliet) {
1132
+ /* Switch reading data from primary to joliet. */
1133
+ vd = &(iso9660->joliet);
1134
+ skipsize = LOGICAL_BLOCK_SIZE * (int64_t)vd->location;
1135
+ skipsize -= iso9660->current_position;
1136
+ skipsize = __archive_read_consume(a, skipsize);
1137
+ if (skipsize < 0)
1138
+ return ((int)skipsize);
1139
+ iso9660->current_position += skipsize;
1057
1140
 
1058
- if (iso9660->seenRockridge &&
1059
- file->parent != NULL &&
1060
- file->parent->parent == NULL &&
1061
- iso9660->rr_moved == NULL &&
1062
- (strcmp(file->name.s, "rr_moved") == 0 ||
1063
- strcmp(file->name.s, ".rr_moved") == 0)) {
1064
- iso9660->rr_moved = file;
1065
- } else if (file->re)
1066
- heap_add_entry(&(iso9660->re_dirs), file,
1067
- file->offset);
1068
- else
1069
- cache_add_entry(iso9660, file);
1141
+ block = __archive_read_ahead(a, vd->size, NULL);
1142
+ if (block == NULL) {
1143
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1144
+ "Failed to read full block when scanning "
1145
+ "ISO9660 directory list");
1146
+ return (ARCHIVE_FATAL);
1147
+ }
1148
+ iso9660->seenJoliet = 0;
1149
+ file = parse_file_info(a, NULL, block, vd->size);
1150
+ if (file == NULL)
1151
+ return (ARCHIVE_FATAL);
1152
+ iso9660->seenJoliet = seenJoliet;
1070
1153
  }
1071
- if (file != NULL)
1072
- add_entry(iso9660, file);
1073
1154
 
1074
- if (iso9660->rr_moved != NULL) {
1075
- /*
1076
- * Relocate directory which rr_moved has.
1077
- */
1078
- while ((file = heap_get_entry(&(iso9660->cl_files))) != NULL)
1079
- relocate_dir(iso9660, file);
1080
-
1081
- /* If rr_moved directory still has children,
1082
- * Add rr_moved into pending_files to show
1083
- */
1084
- if (iso9660->rr_moved->subdirs) {
1085
- cache_add_entry(iso9660, iso9660->rr_moved);
1086
- /* If entries which have "RE" extension are still
1087
- * remaining(this case is unlikely except ISO image
1088
- * is broken), the entries won't be exposed. */
1089
- while ((file = heap_get_entry(&(iso9660->re_dirs))) != NULL)
1090
- cache_add_entry(iso9660, file);
1091
- } else
1092
- iso9660->rr_moved->parent->subdirs--;
1093
- } else {
1094
- /*
1095
- * In case ISO image is broken. If the name of rr_moved
1096
- * directory has been changed by damage, subdirectories
1097
- * of rr_moved entry won't be exposed.
1098
- */
1099
- while ((file = heap_get_entry(&(iso9660->re_dirs))) != NULL)
1100
- cache_add_entry(iso9660, file);
1155
+ /* Store the root directory in the pending list. */
1156
+ if (add_entry(a, iso9660, file) != ARCHIVE_OK)
1157
+ return (ARCHIVE_FATAL);
1158
+ if (iso9660->seenRockridge) {
1159
+ a->archive.archive_format = ARCHIVE_FORMAT_ISO9660_ROCKRIDGE;
1160
+ a->archive.archive_format_name =
1161
+ "ISO9660 with Rockridge extensions";
1101
1162
  }
1102
1163
 
1103
1164
  return (ARCHIVE_OK);
@@ -1109,7 +1170,7 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
1109
1170
  {
1110
1171
  struct iso9660 *iso9660;
1111
1172
  struct file_info *file;
1112
- int r, rd_r;
1173
+ int r, rd_r = ARCHIVE_OK;
1113
1174
 
1114
1175
  iso9660 = (struct iso9660 *)(a->format->data);
1115
1176
 
@@ -1119,105 +1180,97 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
1119
1180
  }
1120
1181
 
1121
1182
  if (iso9660->current_position == 0) {
1122
- int64_t skipsize;
1123
- struct vd *vd;
1124
- const void *block;
1125
- char seenJoliet;
1126
-
1127
- vd = &(iso9660->primary);
1128
- if (!iso9660->opt_support_joliet)
1129
- iso9660->seenJoliet = 0;
1130
- if (iso9660->seenJoliet &&
1131
- vd->location > iso9660->joliet.location)
1132
- /* This condition is unlikely; by way of caution. */
1133
- vd = &(iso9660->joliet);
1134
-
1135
- skipsize = LOGICAL_BLOCK_SIZE * vd->location;
1136
- skipsize = __archive_read_skip(a, skipsize);
1137
- if (skipsize < 0)
1138
- return ((int)skipsize);
1139
- iso9660->current_position = skipsize;
1183
+ r = choose_volume(a, iso9660);
1184
+ if (r != ARCHIVE_OK)
1185
+ return (r);
1186
+ }
1140
1187
 
1141
- block = __archive_read_ahead(a, vd->size, NULL);
1142
- if (block == NULL) {
1143
- archive_set_error(&a->archive,
1144
- ARCHIVE_ERRNO_MISC,
1145
- "Failed to read full block when scanning "
1146
- "ISO9660 directory list");
1147
- return (ARCHIVE_FATAL);
1148
- }
1188
+ file = NULL;/* Eliminate a warning. */
1189
+ /* Get the next entry that appears after the current offset. */
1190
+ r = next_entry_seek(a, iso9660, &file);
1191
+ if (r != ARCHIVE_OK)
1192
+ return (r);
1149
1193
 
1194
+ if (iso9660->seenJoliet) {
1150
1195
  /*
1151
- * While reading Root Directory, flag seenJoliet
1152
- * must be zero to avoid converting special name
1153
- * 0x00(Current Directory) and next byte to UCS2.
1196
+ * Convert UTF-16BE of a filename to local locale MBS
1197
+ * and store the result into a filename field.
1154
1198
  */
1155
- seenJoliet = iso9660->seenJoliet;/* Save flag. */
1156
- iso9660->seenJoliet = 0;
1157
- file = parse_file_info(a, NULL, block);
1158
- if (file == NULL)
1159
- return (ARCHIVE_FATAL);
1160
- iso9660->seenJoliet = seenJoliet;
1161
- if (vd == &(iso9660->primary) && iso9660->seenRockridge
1162
- && iso9660->seenJoliet)
1163
- /*
1164
- * If iso image has RockRidge and Joliet,
1165
- * we use RockRidge Extensions.
1166
- */
1167
- iso9660->seenJoliet = 0;
1168
- if (vd == &(iso9660->primary) && !iso9660->seenRockridge
1169
- && iso9660->seenJoliet) {
1170
- /* Switch reading data from primary to joliet. */
1171
- vd = &(iso9660->joliet);
1172
- skipsize = LOGICAL_BLOCK_SIZE * vd->location;
1173
- skipsize -= iso9660->current_position;
1174
- skipsize = __archive_read_skip(a, skipsize);
1175
- if (skipsize < 0)
1176
- return ((int)skipsize);
1177
- iso9660->current_position += skipsize;
1178
-
1179
- block = __archive_read_ahead(a, vd->size, NULL);
1180
- if (block == NULL) {
1181
- archive_set_error(&a->archive,
1182
- ARCHIVE_ERRNO_MISC,
1183
- "Failed to read full block when scanning "
1184
- "ISO9660 directory list");
1199
+ if (iso9660->sconv_utf16be == NULL) {
1200
+ iso9660->sconv_utf16be =
1201
+ archive_string_conversion_from_charset(
1202
+ &(a->archive), "UTF-16BE", 1);
1203
+ if (iso9660->sconv_utf16be == NULL)
1204
+ /* Couldn't allocate memory */
1185
1205
  return (ARCHIVE_FATAL);
1186
- }
1187
- seenJoliet = iso9660->seenJoliet;/* Save flag. */
1188
- iso9660->seenJoliet = 0;
1189
- file = parse_file_info(a, NULL, block);
1190
- if (file == NULL)
1206
+ }
1207
+ if (iso9660->utf16be_path == NULL) {
1208
+ iso9660->utf16be_path = malloc(UTF16_NAME_MAX);
1209
+ if (iso9660->utf16be_path == NULL) {
1210
+ archive_set_error(&a->archive, ENOMEM,
1211
+ "No memory");
1191
1212
  return (ARCHIVE_FATAL);
1192
- iso9660->seenJoliet = seenJoliet;
1213
+ }
1193
1214
  }
1194
- /* Store the root directory in the pending list. */
1195
- add_entry(iso9660, file);
1196
- if (iso9660->seenRockridge) {
1197
- a->archive.archive_format =
1198
- ARCHIVE_FORMAT_ISO9660_ROCKRIDGE;
1199
- a->archive.archive_format_name =
1200
- "ISO9660 with Rockridge extensions";
1215
+ if (iso9660->utf16be_previous_path == NULL) {
1216
+ iso9660->utf16be_previous_path = malloc(UTF16_NAME_MAX);
1217
+ if (iso9660->utf16be_previous_path == NULL) {
1218
+ archive_set_error(&a->archive, ENOMEM,
1219
+ "No memory");
1220
+ return (ARCHIVE_FATAL);
1221
+ }
1201
1222
  }
1202
- rd_r = read_entries(a);
1203
- if (rd_r == ARCHIVE_FATAL)
1223
+
1224
+ iso9660->utf16be_path_len = 0;
1225
+ if (build_pathname_utf16be(iso9660->utf16be_path,
1226
+ UTF16_NAME_MAX, &(iso9660->utf16be_path_len), file) != 0) {
1227
+ archive_set_error(&a->archive,
1228
+ ARCHIVE_ERRNO_FILE_FORMAT,
1229
+ "Pathname is too long");
1204
1230
  return (ARCHIVE_FATAL);
1205
- } else
1206
- rd_r = ARCHIVE_OK;
1231
+ }
1207
1232
 
1208
- /* Get the next entry that appears after the current offset. */
1209
- r = next_entry_seek(a, iso9660, &file);
1210
- if (r != ARCHIVE_OK)
1211
- return (r);
1233
+ r = archive_entry_copy_pathname_l(entry,
1234
+ (const char *)iso9660->utf16be_path,
1235
+ iso9660->utf16be_path_len,
1236
+ iso9660->sconv_utf16be);
1237
+ if (r != 0) {
1238
+ if (errno == ENOMEM) {
1239
+ archive_set_error(&a->archive, ENOMEM,
1240
+ "No memory for Pathname");
1241
+ return (ARCHIVE_FATAL);
1242
+ }
1243
+ archive_set_error(&a->archive,
1244
+ ARCHIVE_ERRNO_FILE_FORMAT,
1245
+ "Pathname cannot be converted "
1246
+ "from %s to current locale.",
1247
+ archive_string_conversion_charset_name(
1248
+ iso9660->sconv_utf16be));
1249
+
1250
+ rd_r = ARCHIVE_WARN;
1251
+ }
1252
+ } else {
1253
+ const char *path = build_pathname(&iso9660->pathname, file, 0);
1254
+ if (path == NULL) {
1255
+ archive_set_error(&a->archive,
1256
+ ARCHIVE_ERRNO_FILE_FORMAT,
1257
+ "Pathname is too long");
1258
+ return (ARCHIVE_FATAL);
1259
+ } else {
1260
+ archive_string_empty(&iso9660->pathname);
1261
+ archive_entry_set_pathname(entry, path);
1262
+ }
1263
+ }
1212
1264
 
1213
1265
  iso9660->entry_bytes_remaining = file->size;
1214
- iso9660->entry_sparse_offset = 0; /* Offset for sparse-file-aware clients. */
1266
+ /* Offset for sparse-file-aware clients. */
1267
+ iso9660->entry_sparse_offset = 0;
1215
1268
 
1216
1269
  if (file->offset + file->size > iso9660->volume_size) {
1217
1270
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1218
- "File is beyond end-of-media: %s", file->name);
1271
+ "File is beyond end-of-media: %s",
1272
+ archive_entry_pathname(entry));
1219
1273
  iso9660->entry_bytes_remaining = 0;
1220
- iso9660->entry_sparse_offset = 0;
1221
1274
  return (ARCHIVE_WARN);
1222
1275
  }
1223
1276
 
@@ -1236,9 +1289,6 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
1236
1289
  /* N.B.: Rock Ridge supports 64-bit device numbers. */
1237
1290
  archive_entry_set_rdev(entry, (dev_t)file->rdev);
1238
1291
  archive_entry_set_size(entry, iso9660->entry_bytes_remaining);
1239
- archive_string_empty(&iso9660->pathname);
1240
- archive_entry_set_pathname(entry,
1241
- build_pathname(&iso9660->pathname, file));
1242
1292
  if (file->symlink.s != NULL)
1243
1293
  archive_entry_copy_symlink(entry, file->symlink.s);
1244
1294
 
@@ -1248,39 +1298,57 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
1248
1298
  * original entry. */
1249
1299
  if (file->number != -1 &&
1250
1300
  file->number == iso9660->previous_number) {
1251
- archive_entry_set_hardlink(entry,
1252
- iso9660->previous_pathname.s);
1301
+ if (iso9660->seenJoliet) {
1302
+ r = archive_entry_copy_hardlink_l(entry,
1303
+ (const char *)iso9660->utf16be_previous_path,
1304
+ iso9660->utf16be_previous_path_len,
1305
+ iso9660->sconv_utf16be);
1306
+ if (r != 0) {
1307
+ if (errno == ENOMEM) {
1308
+ archive_set_error(&a->archive, ENOMEM,
1309
+ "No memory for Linkname");
1310
+ return (ARCHIVE_FATAL);
1311
+ }
1312
+ archive_set_error(&a->archive,
1313
+ ARCHIVE_ERRNO_FILE_FORMAT,
1314
+ "Linkname cannot be converted "
1315
+ "from %s to current locale.",
1316
+ archive_string_conversion_charset_name(
1317
+ iso9660->sconv_utf16be));
1318
+ rd_r = ARCHIVE_WARN;
1319
+ }
1320
+ } else
1321
+ archive_entry_set_hardlink(entry,
1322
+ iso9660->previous_pathname.s);
1253
1323
  archive_entry_unset_size(entry);
1254
1324
  iso9660->entry_bytes_remaining = 0;
1255
- iso9660->entry_sparse_offset = 0;
1256
- return (ARCHIVE_OK);
1325
+ return (rd_r);
1257
1326
  }
1258
1327
 
1259
- /* Except for the hardlink case above, if the offset of the
1260
- * next entry is before our current position, we can't seek
1261
- * backwards to extract it, so issue a warning. Note that
1262
- * this can only happen if this entry was added to the heap
1263
- * after we passed this offset, that is, only if the directory
1264
- * mentioning this entry is later than the body of the entry.
1265
- * Such layouts are very unusual; most ISO9660 writers lay out
1266
- * and record all directory information first, then store
1267
- * all file bodies. */
1268
- /* TODO: Someday, libarchive's I/O core will support optional
1269
- * seeking. When that day comes, this code should attempt to
1270
- * seek and only return the error if the seek fails. That
1271
- * will give us support for whacky ISO images that require
1272
- * seeking while retaining the ability to read almost all ISO
1273
- * images in a streaming fashion. */
1274
1328
  if ((file->mode & AE_IFMT) != AE_IFDIR &&
1275
1329
  file->offset < iso9660->current_position) {
1276
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1277
- "Ignoring out-of-order file @%x (%s) %jd < %jd",
1278
- file,
1279
- iso9660->pathname.s,
1280
- file->offset, iso9660->current_position);
1281
- iso9660->entry_bytes_remaining = 0;
1282
- iso9660->entry_sparse_offset = 0;
1283
- return (ARCHIVE_WARN);
1330
+ int64_t r64;
1331
+
1332
+ r64 = __archive_read_seek(a, file->offset, SEEK_SET);
1333
+ if (r64 != (int64_t)file->offset) {
1334
+ /* We can't seek backwards to extract it, so issue
1335
+ * a warning. Note that this can only happen if
1336
+ * this entry was added to the heap after we passed
1337
+ * this offset, that is, only if the directory
1338
+ * mentioning this entry is later than the body of
1339
+ * the entry. Such layouts are very unusual; most
1340
+ * ISO9660 writers lay out and record all directory
1341
+ * information first, then store all file bodies. */
1342
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1343
+ "Ignoring out-of-order file @%jx (%s) %jd < %jd",
1344
+ (intmax_t)file->number,
1345
+ iso9660->pathname.s,
1346
+ (intmax_t)file->offset,
1347
+ (intmax_t)iso9660->current_position);
1348
+ iso9660->entry_bytes_remaining = 0;
1349
+ return (ARCHIVE_WARN);
1350
+ }
1351
+ iso9660->current_position = (uint64_t)r64;
1284
1352
  }
1285
1353
 
1286
1354
  /* Initialize zisofs variables. */
@@ -1302,7 +1370,13 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
1302
1370
  }
1303
1371
 
1304
1372
  iso9660->previous_number = file->number;
1305
- archive_strcpy(&iso9660->previous_pathname, iso9660->pathname.s);
1373
+ if (iso9660->seenJoliet) {
1374
+ memcpy(iso9660->utf16be_previous_path, iso9660->utf16be_path,
1375
+ iso9660->utf16be_path_len);
1376
+ iso9660->utf16be_previous_path_len = iso9660->utf16be_path_len;
1377
+ } else
1378
+ archive_strcpy(
1379
+ &iso9660->previous_pathname, iso9660->pathname.s);
1306
1380
 
1307
1381
  /* Reset entry_bytes_remaining if the file is multi extent. */
1308
1382
  iso9660->entry_content = file->contents.first;
@@ -1315,8 +1389,6 @@ archive_read_format_iso9660_read_header(struct archive_read *a,
1315
1389
  archive_entry_set_nlink(entry, 2 + file->subdirs);
1316
1390
  /* Directory data has been read completely. */
1317
1391
  iso9660->entry_bytes_remaining = 0;
1318
- iso9660->entry_sparse_offset = 0;
1319
- file->exposed = 1;
1320
1392
  }
1321
1393
 
1322
1394
  if (rd_r != ARCHIVE_OK)
@@ -1337,7 +1409,7 @@ archive_read_format_iso9660_read_data_skip(struct archive_read *a)
1337
1409
 
1338
1410
  static int
1339
1411
  zisofs_read_data(struct archive_read *a,
1340
- const void **buff, size_t *size, off_t *offset)
1412
+ const void **buff, size_t *size, int64_t *offset)
1341
1413
  {
1342
1414
  struct iso9660 *iso9660;
1343
1415
  struct zisofs *zisofs;
@@ -1357,7 +1429,7 @@ zisofs_read_data(struct archive_read *a,
1357
1429
  return (ARCHIVE_FATAL);
1358
1430
  }
1359
1431
  if (bytes_read > iso9660->entry_bytes_remaining)
1360
- bytes_read = iso9660->entry_bytes_remaining;
1432
+ bytes_read = (ssize_t)iso9660->entry_bytes_remaining;
1361
1433
  avail = bytes_read;
1362
1434
  uncompressed_size = 0;
1363
1435
 
@@ -1365,9 +1437,9 @@ zisofs_read_data(struct archive_read *a,
1365
1437
  size_t ceil, xsize;
1366
1438
 
1367
1439
  /* Allocate block pointers buffer. */
1368
- ceil = (zisofs->pz_uncompressed_size +
1369
- (1LL << zisofs->pz_log2_bs) - 1)
1370
- >> zisofs->pz_log2_bs;
1440
+ ceil = (size_t)((zisofs->pz_uncompressed_size +
1441
+ (((int64_t)1) << zisofs->pz_log2_bs) - 1)
1442
+ >> zisofs->pz_log2_bs);
1371
1443
  xsize = (ceil + 1) * 4;
1372
1444
  if (zisofs->block_pointers_alloc < xsize) {
1373
1445
  size_t alloc;
@@ -1386,7 +1458,7 @@ zisofs_read_data(struct archive_read *a,
1386
1458
  zisofs->block_pointers_size = xsize;
1387
1459
 
1388
1460
  /* Allocate uncompressed data buffer. */
1389
- xsize = 1UL << zisofs->pz_log2_bs;
1461
+ xsize = (size_t)1UL << zisofs->pz_log2_bs;
1390
1462
  if (zisofs->uncompressed_buffer_size < xsize) {
1391
1463
  if (zisofs->uncompressed_buffer != NULL)
1392
1464
  free(zisofs->uncompressed_buffer);
@@ -1459,7 +1531,7 @@ zisofs_read_data(struct archive_read *a,
1459
1531
  }
1460
1532
 
1461
1533
  if (!zisofs->initialized)
1462
- goto next_data; /* We need more datas. */
1534
+ goto next_data; /* We need more data. */
1463
1535
  }
1464
1536
 
1465
1537
  /*
@@ -1470,21 +1542,26 @@ zisofs_read_data(struct archive_read *a,
1470
1542
 
1471
1543
  if (zisofs->block_off + 4 >= zisofs->block_pointers_size) {
1472
1544
  /* There isn't a pair of offsets. */
1473
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
1545
+ archive_set_error(&a->archive,
1546
+ ARCHIVE_ERRNO_FILE_FORMAT,
1474
1547
  "Illegal zisofs block pointers");
1475
1548
  return (ARCHIVE_FATAL);
1476
1549
  }
1477
- bst = archive_le32dec(zisofs->block_pointers + zisofs->block_off);
1550
+ bst = archive_le32dec(
1551
+ zisofs->block_pointers + zisofs->block_off);
1478
1552
  if (bst != zisofs->pz_offset + (bytes_read - avail)) {
1479
- /* TODO: Should we seek offset of current file by bst ? */
1480
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
1553
+ /* TODO: Should we seek offset of current file
1554
+ * by bst ? */
1555
+ archive_set_error(&a->archive,
1556
+ ARCHIVE_ERRNO_FILE_FORMAT,
1481
1557
  "Illegal zisofs block pointers(cannot seek)");
1482
1558
  return (ARCHIVE_FATAL);
1483
1559
  }
1484
1560
  bed = archive_le32dec(
1485
1561
  zisofs->block_pointers + zisofs->block_off + 4);
1486
1562
  if (bed < bst) {
1487
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
1563
+ archive_set_error(&a->archive,
1564
+ ARCHIVE_ERRNO_FILE_FORMAT,
1488
1565
  "Illegal zisofs block pointers");
1489
1566
  return (ARCHIVE_FATAL);
1490
1567
  }
@@ -1507,7 +1584,7 @@ zisofs_read_data(struct archive_read *a,
1507
1584
  }
1508
1585
 
1509
1586
  /*
1510
- * Make uncompressed datas.
1587
+ * Make uncompressed data.
1511
1588
  */
1512
1589
  if (zisofs->block_avail == 0) {
1513
1590
  memset(zisofs->uncompressed_buffer, 0,
@@ -1518,9 +1595,10 @@ zisofs_read_data(struct archive_read *a,
1518
1595
  if (avail > zisofs->block_avail)
1519
1596
  zisofs->stream.avail_in = zisofs->block_avail;
1520
1597
  else
1521
- zisofs->stream.avail_in = avail;
1598
+ zisofs->stream.avail_in = (uInt)avail;
1522
1599
  zisofs->stream.next_out = zisofs->uncompressed_buffer;
1523
- zisofs->stream.avail_out = zisofs->uncompressed_buffer_size;
1600
+ zisofs->stream.avail_out =
1601
+ (uInt)zisofs->uncompressed_buffer_size;
1524
1602
 
1525
1603
  r = inflate(&zisofs->stream, 0);
1526
1604
  switch (r) {
@@ -1535,7 +1613,7 @@ zisofs_read_data(struct archive_read *a,
1535
1613
  uncompressed_size =
1536
1614
  zisofs->uncompressed_buffer_size - zisofs->stream.avail_out;
1537
1615
  avail -= zisofs->stream.next_in - p;
1538
- zisofs->block_avail -= zisofs->stream.next_in - p;
1616
+ zisofs->block_avail -= (uint32_t)(zisofs->stream.next_in - p);
1539
1617
  }
1540
1618
  next_data:
1541
1619
  bytes_read -= avail;
@@ -1545,8 +1623,8 @@ next_data:
1545
1623
  iso9660->entry_sparse_offset += uncompressed_size;
1546
1624
  iso9660->entry_bytes_remaining -= bytes_read;
1547
1625
  iso9660->current_position += bytes_read;
1548
- zisofs->pz_offset += bytes_read;
1549
- __archive_read_consume(a, bytes_read);
1626
+ zisofs->pz_offset += (uint32_t)bytes_read;
1627
+ iso9660->entry_bytes_unconsumed += bytes_read;
1550
1628
 
1551
1629
  return (ARCHIVE_OK);
1552
1630
  }
@@ -1555,7 +1633,7 @@ next_data:
1555
1633
 
1556
1634
  static int
1557
1635
  zisofs_read_data(struct archive_read *a,
1558
- const void **buff, size_t *size, off_t *offset)
1636
+ const void **buff, size_t *size, int64_t *offset)
1559
1637
  {
1560
1638
 
1561
1639
  (void)buff;/* UNUSED */
@@ -1570,12 +1648,18 @@ zisofs_read_data(struct archive_read *a,
1570
1648
 
1571
1649
  static int
1572
1650
  archive_read_format_iso9660_read_data(struct archive_read *a,
1573
- const void **buff, size_t *size, off_t *offset)
1651
+ const void **buff, size_t *size, int64_t *offset)
1574
1652
  {
1575
1653
  ssize_t bytes_read;
1576
1654
  struct iso9660 *iso9660;
1577
1655
 
1578
1656
  iso9660 = (struct iso9660 *)(a->format->data);
1657
+
1658
+ if (iso9660->entry_bytes_unconsumed) {
1659
+ __archive_read_consume(a, iso9660->entry_bytes_unconsumed);
1660
+ iso9660->entry_bytes_unconsumed = 0;
1661
+ }
1662
+
1579
1663
  if (iso9660->entry_bytes_remaining <= 0) {
1580
1664
  if (iso9660->entry_content != NULL)
1581
1665
  iso9660->entry_content = iso9660->entry_content->next;
@@ -1591,7 +1675,7 @@ archive_read_format_iso9660_read_data(struct archive_read *a,
1591
1675
 
1592
1676
  step = iso9660->entry_content->offset -
1593
1677
  iso9660->current_position;
1594
- step = __archive_read_skip(a, step);
1678
+ step = __archive_read_consume(a, step);
1595
1679
  if (step < 0)
1596
1680
  return ((int)step);
1597
1681
  iso9660->current_position =
@@ -1601,8 +1685,8 @@ archive_read_format_iso9660_read_data(struct archive_read *a,
1601
1685
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1602
1686
  "Ignoring out-of-order file (%s) %jd < %jd",
1603
1687
  iso9660->pathname.s,
1604
- iso9660->entry_content->offset,
1605
- iso9660->current_position);
1688
+ (intmax_t)iso9660->entry_content->offset,
1689
+ (intmax_t)iso9660->current_position);
1606
1690
  *buff = NULL;
1607
1691
  *size = 0;
1608
1692
  *offset = iso9660->entry_sparse_offset;
@@ -1620,13 +1704,13 @@ archive_read_format_iso9660_read_data(struct archive_read *a,
1620
1704
  if (*buff == NULL)
1621
1705
  return (ARCHIVE_FATAL);
1622
1706
  if (bytes_read > iso9660->entry_bytes_remaining)
1623
- bytes_read = iso9660->entry_bytes_remaining;
1707
+ bytes_read = (ssize_t)iso9660->entry_bytes_remaining;
1624
1708
  *size = bytes_read;
1625
1709
  *offset = iso9660->entry_sparse_offset;
1626
1710
  iso9660->entry_sparse_offset += bytes_read;
1627
1711
  iso9660->entry_bytes_remaining -= bytes_read;
1712
+ iso9660->entry_bytes_unconsumed = bytes_read;
1628
1713
  iso9660->current_position += bytes_read;
1629
- __archive_read_consume(a, bytes_read);
1630
1714
  return (ARCHIVE_OK);
1631
1715
  }
1632
1716
 
@@ -1641,12 +1725,7 @@ archive_read_format_iso9660_cleanup(struct archive_read *a)
1641
1725
  free(iso9660->read_ce_req.reqs);
1642
1726
  archive_string_free(&iso9660->pathname);
1643
1727
  archive_string_free(&iso9660->previous_pathname);
1644
- if (iso9660->pending_files.files)
1645
- free(iso9660->pending_files.files);
1646
- if (iso9660->re_dirs.files)
1647
- free(iso9660->re_dirs.files);
1648
- if (iso9660->cl_files.files)
1649
- free(iso9660->cl_files.files);
1728
+ free(iso9660->pending_files.files);
1650
1729
  #ifdef HAVE_ZLIB_H
1651
1730
  free(iso9660->entry_zisofs.uncompressed_buffer);
1652
1731
  free(iso9660->entry_zisofs.block_pointers);
@@ -1658,6 +1737,8 @@ archive_read_format_iso9660_cleanup(struct archive_read *a)
1658
1737
  }
1659
1738
  }
1660
1739
  #endif
1740
+ free(iso9660->utf16be_path);
1741
+ free(iso9660->utf16be_previous_path);
1661
1742
  free(iso9660);
1662
1743
  (a->format->data) = NULL;
1663
1744
  return (r);
@@ -1669,28 +1750,34 @@ archive_read_format_iso9660_cleanup(struct archive_read *a)
1669
1750
  */
1670
1751
  static struct file_info *
1671
1752
  parse_file_info(struct archive_read *a, struct file_info *parent,
1672
- const unsigned char *isodirrec)
1753
+ const unsigned char *isodirrec, size_t reclen)
1673
1754
  {
1674
1755
  struct iso9660 *iso9660;
1675
- struct file_info *file;
1756
+ struct file_info *file, *filep;
1676
1757
  size_t name_len;
1677
1758
  const unsigned char *rr_start, *rr_end;
1678
1759
  const unsigned char *p;
1679
- size_t dr_len;
1760
+ size_t dr_len = 0;
1761
+ uint64_t fsize, offset;
1680
1762
  int32_t location;
1681
1763
  int flags;
1682
1764
 
1683
1765
  iso9660 = (struct iso9660 *)(a->format->data);
1684
1766
 
1685
- dr_len = (size_t)isodirrec[DR_length_offset];
1686
- name_len = (size_t)isodirrec[DR_name_len_offset];
1687
- location = archive_le32dec(isodirrec + DR_extent_offset);
1688
- /* Sanity check that dr_len needs at least 34. */
1689
- if (dr_len < 34) {
1767
+ if (reclen != 0)
1768
+ dr_len = (size_t)isodirrec[DR_length_offset];
1769
+ /*
1770
+ * Sanity check that reclen is not zero and dr_len is greater than
1771
+ * reclen but at least 34
1772
+ */
1773
+ if (reclen == 0 || reclen < dr_len || dr_len < 34) {
1690
1774
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1691
- "Invalid length of directory record");
1775
+ "Invalid length of directory record");
1692
1776
  return (NULL);
1693
1777
  }
1778
+ name_len = (size_t)isodirrec[DR_name_len_offset];
1779
+ location = archive_le32dec(isodirrec + DR_extent_offset);
1780
+ fsize = toi(isodirrec + DR_size_offset, DR_size_size);
1694
1781
  /* Sanity check that name_len doesn't exceed dr_len. */
1695
1782
  if (dr_len - 33 < name_len || name_len == 0) {
1696
1783
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -1703,25 +1790,46 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
1703
1790
  * link or file size is zero. As far as I know latest mkisofs
1704
1791
  * do that.
1705
1792
  */
1706
- if (location >= iso9660->volume_block) {
1793
+ if (location > 0 &&
1794
+ (location + ((fsize + iso9660->logical_block_size -1)
1795
+ / iso9660->logical_block_size))
1796
+ > (uint32_t)iso9660->volume_block) {
1797
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1798
+ "Invalid location of extent of file");
1799
+ return (NULL);
1800
+ }
1801
+ /* Sanity check that location doesn't have a negative value
1802
+ * when the file is not empty. it's too large. */
1803
+ if (fsize != 0 && location < 0) {
1707
1804
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
1708
1805
  "Invalid location of extent of file");
1709
1806
  return (NULL);
1710
1807
  }
1711
1808
 
1809
+ /* Sanity check that this entry does not create a cycle. */
1810
+ offset = iso9660->logical_block_size * (uint64_t)location;
1811
+ for (filep = parent; filep != NULL; filep = filep->parent) {
1812
+ if (filep->offset == offset) {
1813
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
1814
+ "Directory structure contains loop");
1815
+ return (NULL);
1816
+ }
1817
+ }
1818
+
1712
1819
  /* Create a new file entry and copy data from the ISO dir record. */
1713
- file = (struct file_info *)malloc(sizeof(*file));
1820
+ file = (struct file_info *)calloc(1, sizeof(*file));
1714
1821
  if (file == NULL) {
1715
1822
  archive_set_error(&a->archive, ENOMEM,
1716
1823
  "No memory for file entry");
1717
1824
  return (NULL);
1718
1825
  }
1719
- memset(file, 0, sizeof(*file));
1720
1826
  file->parent = parent;
1721
- file->offset = iso9660->logical_block_size * (uint64_t)location;
1722
- file->size = toi(isodirrec + DR_size_offset, DR_size_size);
1827
+ file->offset = offset;
1828
+ file->size = fsize;
1723
1829
  file->mtime = isodate7(isodirrec + DR_date_offset);
1724
1830
  file->ctime = file->atime = file->mtime;
1831
+ file->rede_files.first = NULL;
1832
+ file->rede_files.last = &(file->rede_files.first);
1725
1833
 
1726
1834
  p = isodirrec + DR_name_offset;
1727
1835
  /* Rockridge extensions (if any) follow name. Compute this
@@ -1735,24 +1843,13 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
1735
1843
  * names which are 103 UCS2 characters(206 bytes) by their
1736
1844
  * option '-joliet-long'.
1737
1845
  */
1738
- wchar_t wbuff[103+1], *wp;
1739
- const unsigned char *c;
1740
-
1741
1846
  if (name_len > 206)
1742
1847
  name_len = 206;
1743
- /* convert BE UTF-16 to wchar_t */
1744
- for (c = p, wp = wbuff;
1745
- c < (p + name_len) &&
1746
- wp < (wbuff + sizeof(wbuff)/sizeof(*wbuff) - 1);
1747
- c += 2) {
1748
- *wp++ = (((255 & (int)c[0]) << 8) | (255 & (int)c[1]));
1749
- }
1750
- *wp = L'\0';
1848
+ name_len &= ~1;
1751
1849
 
1752
- #if 0 /* untested code, is it at all useful on Joliet? */
1753
1850
  /* trim trailing first version and dot from filename.
1754
1851
  *
1755
- * Remember we where in UTF-16BE land!
1852
+ * Remember we were in UTF-16BE land!
1756
1853
  * SEPARATOR 1 (.) and SEPARATOR 2 (;) are both
1757
1854
  * 16 bits big endian characters on Joliet.
1758
1855
  *
@@ -1761,18 +1858,21 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
1761
1858
  * *, /, :, ;, ? and \.
1762
1859
  */
1763
1860
  /* Chop off trailing ';1' from files. */
1764
- if (*(wp-2) == ';' && *(wp-1) == '1') {
1765
- wp-=2;
1766
- *wp = L'\0';
1767
- }
1768
-
1861
+ if (name_len > 4 && p[name_len-4] == 0 && p[name_len-3] == ';'
1862
+ && p[name_len-2] == 0 && p[name_len-1] == '1')
1863
+ name_len -= 4;
1864
+ #if 0 /* XXX: this somehow manages to strip of single-character file extensions, like '.c'. */
1769
1865
  /* Chop off trailing '.' from filenames. */
1770
- if (*(wp-1) == '.')
1771
- *(--wp) = L'\0';
1866
+ if (name_len > 2 && p[name_len-2] == 0 && p[name_len-1] == '.')
1867
+ name_len -= 2;
1772
1868
  #endif
1773
-
1774
- /* store the result in the file name field. */
1775
- archive_strappend_w_utf8(&file->name, wbuff);
1869
+ if ((file->utf16be_name = malloc(name_len)) == NULL) {
1870
+ archive_set_error(&a->archive, ENOMEM,
1871
+ "No memory for file name");
1872
+ goto fail;
1873
+ }
1874
+ memcpy(file->utf16be_name, p, name_len);
1875
+ file->utf16be_bytes = name_len;
1776
1876
  } else {
1777
1877
  /* Chop off trailing ';1' from files. */
1778
1878
  if (name_len > 2 && p[name_len - 2] == ';' &&
@@ -1795,31 +1895,31 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
1795
1895
  else
1796
1896
  file->multi_extent = 0;
1797
1897
  /*
1798
- * Use location for file number.
1799
- * File number is treated as inode number to find out harlink
1800
- * target. If Rockridge extensions is being used, file number
1801
- * will be overwritten by FILE SERIAL NUMBER of RRIP "PX"
1802
- * extension.
1803
- * NOTE: Old mkisofs did not record that FILE SERIAL NUMBER
1898
+ * Use a location for the file number, which is treated as an inode
1899
+ * number to find out hardlink target. If Rockridge extensions is
1900
+ * being used, the file number will be overwritten by FILE SERIAL
1901
+ * NUMBER of RRIP "PX" extension.
1902
+ * Note: Old mkisofs did not record that FILE SERIAL NUMBER
1804
1903
  * in ISO images.
1904
+ * Note2: xorriso set 0 to the location of a symlink file.
1805
1905
  */
1806
- if (file->size == 0 && location >= 0)
1807
- /* If file->size is zero, its location points wrong place.
1808
- * Dot not use it for file number.
1809
- * When location has negative value, it can be used
1810
- * for file number.
1906
+ if (file->size == 0 && location >= 0) {
1907
+ /* If file->size is zero, its location points wrong place,
1908
+ * and so we should not use it for the file number.
1909
+ * When the location has negative value, it can be used
1910
+ * for the file number.
1811
1911
  */
1812
1912
  file->number = -1;
1813
- else
1913
+ /* Do not appear before any directory entries. */
1914
+ file->offset = -1;
1915
+ } else
1814
1916
  file->number = (int64_t)(uint32_t)location;
1815
1917
 
1816
1918
  /* Rockridge extensions overwrite information from above. */
1817
1919
  if (iso9660->opt_support_rockridge) {
1818
1920
  if (parent == NULL && rr_end - rr_start >= 7) {
1819
1921
  p = rr_start;
1820
- if (p[0] == 'S' && p[1] == 'P'
1821
- && p[2] == 7 && p[3] == 1
1822
- && p[4] == 0xBE && p[5] == 0xEF) {
1922
+ if (memcmp(p, "SP\x07\x01\xbe\xef", 6) == 0) {
1823
1923
  /*
1824
1924
  * SP extension stores the suspOffset
1825
1925
  * (Number of bytes to skip between
@@ -1848,9 +1948,20 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
1848
1948
  file->symlink_continues = 0;
1849
1949
  rr_start += iso9660->suspOffset;
1850
1950
  r = parse_rockridge(a, file, rr_start, rr_end);
1851
- if (r != ARCHIVE_OK) {
1852
- free(file);
1853
- return (NULL);
1951
+ if (r != ARCHIVE_OK)
1952
+ goto fail;
1953
+ /*
1954
+ * A file size of symbolic link files in ISO images
1955
+ * made by makefs is not zero and its location is
1956
+ * the same as those of next regular file. That is
1957
+ * the same as hard like file and it causes unexpected
1958
+ * error.
1959
+ */
1960
+ if (file->size > 0 &&
1961
+ (file->mode & AE_IFMT) == AE_IFLNK) {
1962
+ file->size = 0;
1963
+ file->number = -1;
1964
+ file->offset = -1;
1854
1965
  }
1855
1966
  } else
1856
1967
  /* If there isn't SUSP, disable parsing
@@ -1860,9 +1971,100 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
1860
1971
 
1861
1972
  file->nlinks = 1;/* Reset nlink. we'll calculate it later. */
1862
1973
  /* Tell file's parent how many children that parent has. */
1863
- if (parent != NULL && (flags & 0x02) && file->cl_offset == 0)
1974
+ if (parent != NULL && (flags & 0x02))
1864
1975
  parent->subdirs++;
1865
1976
 
1977
+ if (iso9660->seenRockridge) {
1978
+ if (parent != NULL && parent->parent == NULL &&
1979
+ (flags & 0x02) && iso9660->rr_moved == NULL &&
1980
+ file->name.s &&
1981
+ (strcmp(file->name.s, "rr_moved") == 0 ||
1982
+ strcmp(file->name.s, ".rr_moved") == 0)) {
1983
+ iso9660->rr_moved = file;
1984
+ file->rr_moved = 1;
1985
+ file->rr_moved_has_re_only = 1;
1986
+ file->re = 0;
1987
+ parent->subdirs--;
1988
+ } else if (file->re) {
1989
+ /*
1990
+ * Sanity check: file's parent is rr_moved.
1991
+ */
1992
+ if (parent == NULL || parent->rr_moved == 0) {
1993
+ archive_set_error(&a->archive,
1994
+ ARCHIVE_ERRNO_MISC,
1995
+ "Invalid Rockridge RE");
1996
+ goto fail;
1997
+ }
1998
+ /*
1999
+ * Sanity check: file does not have "CL" extension.
2000
+ */
2001
+ if (file->cl_offset) {
2002
+ archive_set_error(&a->archive,
2003
+ ARCHIVE_ERRNO_MISC,
2004
+ "Invalid Rockridge RE and CL");
2005
+ goto fail;
2006
+ }
2007
+ /*
2008
+ * Sanity check: The file type must be a directory.
2009
+ */
2010
+ if ((flags & 0x02) == 0) {
2011
+ archive_set_error(&a->archive,
2012
+ ARCHIVE_ERRNO_MISC,
2013
+ "Invalid Rockridge RE");
2014
+ goto fail;
2015
+ }
2016
+ } else if (parent != NULL && parent->rr_moved)
2017
+ file->rr_moved_has_re_only = 0;
2018
+ else if (parent != NULL && (flags & 0x02) &&
2019
+ (parent->re || parent->re_descendant))
2020
+ file->re_descendant = 1;
2021
+ if (file->cl_offset) {
2022
+ struct file_info *r;
2023
+
2024
+ if (parent == NULL || parent->parent == NULL) {
2025
+ archive_set_error(&a->archive,
2026
+ ARCHIVE_ERRNO_MISC,
2027
+ "Invalid Rockridge CL");
2028
+ goto fail;
2029
+ }
2030
+ /*
2031
+ * Sanity check: The file type must be a regular file.
2032
+ */
2033
+ if ((flags & 0x02) != 0) {
2034
+ archive_set_error(&a->archive,
2035
+ ARCHIVE_ERRNO_MISC,
2036
+ "Invalid Rockridge CL");
2037
+ goto fail;
2038
+ }
2039
+ parent->subdirs++;
2040
+ /* Overwrite an offset and a number of this "CL" entry
2041
+ * to appear before other dirs. "+1" to those is to
2042
+ * make sure to appear after "RE" entry which this
2043
+ * "CL" entry should be connected with. */
2044
+ file->offset = file->number = file->cl_offset + 1;
2045
+
2046
+ /*
2047
+ * Sanity check: cl_offset does not point at its
2048
+ * the parents or itself.
2049
+ */
2050
+ for (r = parent; r; r = r->parent) {
2051
+ if (r->offset == file->cl_offset) {
2052
+ archive_set_error(&a->archive,
2053
+ ARCHIVE_ERRNO_MISC,
2054
+ "Invalid Rockridge CL");
2055
+ goto fail;
2056
+ }
2057
+ }
2058
+ if (file->cl_offset == file->offset ||
2059
+ parent->rr_moved) {
2060
+ archive_set_error(&a->archive,
2061
+ ARCHIVE_ERRNO_MISC,
2062
+ "Invalid Rockridge CL");
2063
+ goto fail;
2064
+ }
2065
+ }
2066
+ }
2067
+
1866
2068
  #if DEBUG
1867
2069
  /* DEBUGGING: Warn about attributes I don't yet fully support. */
1868
2070
  if ((flags & ~0x02) != 0) {
@@ -1889,6 +2091,10 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
1889
2091
  #endif
1890
2092
  register_file(iso9660, file);
1891
2093
  return (file);
2094
+ fail:
2095
+ archive_string_free(&file->name);
2096
+ free(file);
2097
+ return (NULL);
1892
2098
  }
1893
2099
 
1894
2100
  static int
@@ -1896,6 +2102,7 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
1896
2102
  const unsigned char *p, const unsigned char *end)
1897
2103
  {
1898
2104
  struct iso9660 *iso9660;
2105
+ int entry_seen = 0;
1899
2106
 
1900
2107
  iso9660 = (struct iso9660 *)(a->format->data);
1901
2108
 
@@ -1908,14 +2115,9 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
1908
2115
  int data_length = p[2] - 4;
1909
2116
  int version = p[3];
1910
2117
 
1911
- /*
1912
- * Yes, each 'if' here does test p[0] again.
1913
- * Otherwise, the fall-through handling to catch
1914
- * unsupported extensions doesn't work.
1915
- */
1916
2118
  switch(p[0]) {
1917
2119
  case 'C':
1918
- if (p[0] == 'C' && p[1] == 'E') {
2120
+ if (p[1] == 'E') {
1919
2121
  if (version == 1 && data_length == 24) {
1920
2122
  /*
1921
2123
  * CE extension comprises:
@@ -1933,46 +2135,42 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
1933
2135
  != ARCHIVE_OK)
1934
2136
  return (ARCHIVE_FATAL);
1935
2137
  }
1936
- break;
1937
2138
  }
1938
- if (p[0] == 'C' && p[1] == 'L') {
2139
+ else if (p[1] == 'L') {
1939
2140
  if (version == 1 && data_length == 8) {
1940
2141
  file->cl_offset = (uint64_t)
1941
2142
  iso9660->logical_block_size *
1942
2143
  (uint64_t)archive_le32dec(data);
1943
2144
  iso9660->seenRockridge = 1;
1944
2145
  }
1945
- break;
1946
2146
  }
1947
- /* FALLTHROUGH */
2147
+ break;
1948
2148
  case 'N':
1949
- if (p[0] == 'N' && p[1] == 'M') {
2149
+ if (p[1] == 'M') {
1950
2150
  if (version == 1) {
1951
2151
  parse_rockridge_NM1(file,
1952
2152
  data, data_length);
1953
2153
  iso9660->seenRockridge = 1;
1954
2154
  }
1955
- break;
1956
2155
  }
1957
- /* FALLTHROUGH */
2156
+ break;
1958
2157
  case 'P':
1959
- if (p[0] == 'P' && p[1] == 'D') {
1960
- /*
1961
- * PD extension is padding;
1962
- * contents are always ignored.
1963
- */
1964
- break;
1965
- }
1966
- if (p[0] == 'P' && p[1] == 'N') {
2158
+ /*
2159
+ * PD extension is padding;
2160
+ * contents are always ignored.
2161
+ *
2162
+ * PL extension won't appear;
2163
+ * contents are always ignored.
2164
+ */
2165
+ if (p[1] == 'N') {
1967
2166
  if (version == 1 && data_length == 16) {
1968
2167
  file->rdev = toi(data,4);
1969
2168
  file->rdev <<= 32;
1970
2169
  file->rdev |= toi(data + 8, 4);
1971
2170
  iso9660->seenRockridge = 1;
1972
2171
  }
1973
- break;
1974
2172
  }
1975
- if (p[0] == 'P' && p[1] == 'X') {
2173
+ else if (p[1] == 'X') {
1976
2174
  /*
1977
2175
  * PX extension comprises:
1978
2176
  * 8 bytes for mode,
@@ -1999,35 +2197,31 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
1999
2197
  = toi(data + 32, 4);
2000
2198
  iso9660->seenRockridge = 1;
2001
2199
  }
2002
- break;
2003
2200
  }
2004
- /* FALLTHROUGH */
2201
+ break;
2005
2202
  case 'R':
2006
- if (p[0] == 'R' && p[1] == 'E' && version == 1) {
2203
+ if (p[1] == 'E' && version == 1) {
2007
2204
  file->re = 1;
2008
2205
  iso9660->seenRockridge = 1;
2009
- break;
2010
2206
  }
2011
- if (p[0] == 'R' && p[1] == 'R' && version == 1) {
2207
+ else if (p[1] == 'R' && version == 1) {
2012
2208
  /*
2013
2209
  * RR extension comprises:
2014
2210
  * one byte flag value
2015
2211
  * This extension is obsolete,
2016
2212
  * so contents are always ignored.
2017
2213
  */
2018
- break;
2019
2214
  }
2020
- /* FALLTHROUGH */
2215
+ break;
2021
2216
  case 'S':
2022
- if (p[0] == 'S' && p[1] == 'L') {
2217
+ if (p[1] == 'L') {
2023
2218
  if (version == 1) {
2024
2219
  parse_rockridge_SL1(file,
2025
2220
  data, data_length);
2026
2221
  iso9660->seenRockridge = 1;
2027
2222
  }
2028
- break;
2029
2223
  }
2030
- if (p[0] == 'S' && p[1] == 'T'
2224
+ else if (p[1] == 'T'
2031
2225
  && data_length == 0 && version == 1) {
2032
2226
  /*
2033
2227
  * ST extension marks end of this
@@ -2042,35 +2236,38 @@ parse_rockridge(struct archive_read *a, struct file_info *file,
2042
2236
  iso9660->seenRockridge = 0;
2043
2237
  return (ARCHIVE_OK);
2044
2238
  }
2239
+ break;
2045
2240
  case 'T':
2046
- if (p[0] == 'T' && p[1] == 'F') {
2241
+ if (p[1] == 'F') {
2047
2242
  if (version == 1) {
2048
2243
  parse_rockridge_TF1(file,
2049
2244
  data, data_length);
2050
2245
  iso9660->seenRockridge = 1;
2051
2246
  }
2052
- break;
2053
2247
  }
2054
- /* FALLTHROUGH */
2248
+ break;
2055
2249
  case 'Z':
2056
- if (p[0] == 'Z' && p[1] == 'F') {
2250
+ if (p[1] == 'F') {
2057
2251
  if (version == 1)
2058
2252
  parse_rockridge_ZF1(file,
2059
2253
  data, data_length);
2060
- break;
2061
2254
  }
2062
- /* FALLTHROUGH */
2255
+ break;
2063
2256
  default:
2064
- /* The FALLTHROUGHs above leave us here for
2065
- * any unsupported extension. */
2066
2257
  break;
2067
2258
  }
2068
2259
 
2069
-
2070
-
2071
2260
  p += p[2];
2261
+ entry_seen = 1;
2262
+ }
2263
+
2264
+ if (entry_seen)
2265
+ return (ARCHIVE_OK);
2266
+ else {
2267
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
2268
+ "Tried to parse Rockridge extensions, but none found");
2269
+ return (ARCHIVE_WARN);
2072
2270
  }
2073
- return (ARCHIVE_OK);
2074
2271
  }
2075
2272
 
2076
2273
  static int
@@ -2087,9 +2284,13 @@ register_CE(struct archive_read *a, int32_t location,
2087
2284
  offset = ((uint64_t)location) * (uint64_t)iso9660->logical_block_size;
2088
2285
  if (((file->mode & AE_IFMT) == AE_IFREG &&
2089
2286
  offset >= file->offset) ||
2090
- offset < iso9660->current_position) {
2287
+ offset < iso9660->current_position ||
2288
+ (((uint64_t)file->ce_offset) + file->ce_size)
2289
+ > (uint64_t)iso9660->logical_block_size ||
2290
+ offset + file->ce_offset + file->ce_size
2291
+ > iso9660->volume_size) {
2091
2292
  archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
2092
- "Invalid location in SUSP \"CE\" extension");
2293
+ "Invalid parameter in SUSP \"CE\" extension");
2093
2294
  return (ARCHIVE_FATAL);
2094
2295
  }
2095
2296
 
@@ -2103,11 +2304,15 @@ register_CE(struct archive_read *a, int32_t location,
2103
2304
  else
2104
2305
  new_size = heap->allocated * 2;
2105
2306
  /* Overflow might keep us from growing the list. */
2106
- if (new_size <= heap->allocated)
2107
- __archive_errx(1, "Out of memory");
2108
- p = malloc(new_size * sizeof(p[0]));
2109
- if (p == NULL)
2110
- __archive_errx(1, "Out of memory");
2307
+ if (new_size <= heap->allocated) {
2308
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
2309
+ return (ARCHIVE_FATAL);
2310
+ }
2311
+ p = calloc(new_size, sizeof(p[0]));
2312
+ if (p == NULL) {
2313
+ archive_set_error(&a->archive, ENOMEM, "Out of memory");
2314
+ return (ARCHIVE_FATAL);
2315
+ }
2111
2316
  if (heap->reqs != NULL) {
2112
2317
  memcpy(p, heap->reqs, heap->cnt * sizeof(*p));
2113
2318
  free(heap->reqs);
@@ -2128,7 +2333,7 @@ register_CE(struct archive_read *a, int32_t location,
2128
2333
  heap->reqs[hole].file = file;
2129
2334
  return (ARCHIVE_OK);
2130
2335
  }
2131
- // Move parent into hole <==> move hole up tree.
2336
+ /* Move parent into hole <==> move hole up tree. */
2132
2337
  heap->reqs[hole] = heap->reqs[parent];
2133
2338
  hole = parent;
2134
2339
  }
@@ -2155,14 +2360,14 @@ next_CE(struct read_ce_queue *heap)
2155
2360
  /*
2156
2361
  * Rebalance the heap.
2157
2362
  */
2158
- a = 0; // Starting element and its offset
2363
+ a = 0; /* Starting element and its offset */
2159
2364
  a_offset = heap->reqs[a].offset;
2160
2365
  for (;;) {
2161
- b = a + a + 1; // First child
2366
+ b = a + a + 1; /* First child */
2162
2367
  if (b >= heap->cnt)
2163
2368
  return;
2164
2369
  b_offset = heap->reqs[b].offset;
2165
- c = b + 1; // Use second child if it is smaller.
2370
+ c = b + 1; /* Use second child if it is smaller. */
2166
2371
  if (c < heap->cnt) {
2167
2372
  c_offset = heap->reqs[c].offset;
2168
2373
  if (c_offset < b_offset) {
@@ -2204,6 +2409,12 @@ read_CE(struct archive_read *a, struct iso9660 *iso9660)
2204
2409
  }
2205
2410
  do {
2206
2411
  file = heap->reqs[0].file;
2412
+ if (file->ce_offset + file->ce_size > step) {
2413
+ archive_set_error(&a->archive,
2414
+ ARCHIVE_ERRNO_FILE_FORMAT,
2415
+ "Malformed CE information");
2416
+ return (ARCHIVE_FATAL);
2417
+ }
2207
2418
  p = b + file->ce_offset;
2208
2419
  end = p + file->ce_size;
2209
2420
  next_CE(heap);
@@ -2212,7 +2423,7 @@ read_CE(struct archive_read *a, struct iso9660 *iso9660)
2212
2423
  return (ARCHIVE_FATAL);
2213
2424
  } while (heap->cnt &&
2214
2425
  heap->reqs[0].offset == iso9660->current_position);
2215
- /* NOTE: Do not move this consume's code to fron of
2426
+ /* NOTE: Do not move this consume's code to front of
2216
2427
  * do-while loop. Registration of nested CE extension
2217
2428
  * might cause error because of current position. */
2218
2429
  __archive_read_consume(a, step);
@@ -2244,12 +2455,14 @@ parse_rockridge_NM1(struct file_info *file,
2244
2455
  case 0:
2245
2456
  if (data_length < 2)
2246
2457
  return;
2247
- archive_strncat(&file->name, (const char *)data + 1, data_length - 1);
2458
+ archive_strncat(&file->name,
2459
+ (const char *)data + 1, data_length - 1);
2248
2460
  break;
2249
2461
  case 1:
2250
2462
  if (data_length < 2)
2251
2463
  return;
2252
- archive_strncat(&file->name, (const char *)data + 1, data_length - 1);
2464
+ archive_strncat(&file->name,
2465
+ (const char *)data + 1, data_length - 1);
2253
2466
  file->name_continues = 1;
2254
2467
  break;
2255
2468
  case 2:
@@ -2345,9 +2558,6 @@ parse_rockridge_SL1(struct file_info *file, const unsigned char *data,
2345
2558
 
2346
2559
  if (!file->symlink_continues || file->symlink.length < 1)
2347
2560
  archive_string_empty(&file->symlink);
2348
- else if (!file->symlink_continues &&
2349
- file->symlink.s[file->symlink.length - 1] != '/')
2350
- separator = "/";
2351
2561
  file->symlink_continues = 0;
2352
2562
 
2353
2563
  /*
@@ -2460,6 +2670,7 @@ release_files(struct iso9660 *iso9660)
2460
2670
 
2461
2671
  archive_string_free(&file->name);
2462
2672
  archive_string_free(&file->symlink);
2673
+ free(file->utf16be_name);
2463
2674
  con = file->contents.first;
2464
2675
  while (con != NULL) {
2465
2676
  connext = con->next;
@@ -2476,21 +2687,30 @@ next_entry_seek(struct archive_read *a, struct iso9660 *iso9660,
2476
2687
  struct file_info **pfile)
2477
2688
  {
2478
2689
  struct file_info *file;
2690
+ int r;
2479
2691
 
2480
- *pfile = file = next_cache_entry(iso9660);
2481
- if (file == NULL)
2482
- return (ARCHIVE_EOF);
2692
+ r = next_cache_entry(a, iso9660, pfile);
2693
+ if (r != ARCHIVE_OK)
2694
+ return (r);
2695
+ file = *pfile;
2483
2696
 
2484
2697
  /* Don't waste time seeking for zero-length bodies. */
2485
2698
  if (file->size == 0)
2486
2699
  file->offset = iso9660->current_position;
2487
2700
 
2701
+ /* flush any remaining bytes from the last round to ensure
2702
+ * we're positioned */
2703
+ if (iso9660->entry_bytes_unconsumed) {
2704
+ __archive_read_consume(a, iso9660->entry_bytes_unconsumed);
2705
+ iso9660->entry_bytes_unconsumed = 0;
2706
+ }
2707
+
2488
2708
  /* Seek forward to the start of the entry. */
2489
2709
  if (iso9660->current_position < file->offset) {
2490
2710
  int64_t step;
2491
2711
 
2492
2712
  step = file->offset - iso9660->current_position;
2493
- step = __archive_read_skip(a, step);
2713
+ step = __archive_read_consume(a, step);
2494
2714
  if (step < 0)
2495
2715
  return ((int)step);
2496
2716
  iso9660->current_position = file->offset;
@@ -2500,8 +2720,9 @@ next_entry_seek(struct archive_read *a, struct iso9660 *iso9660,
2500
2720
  return (ARCHIVE_OK);
2501
2721
  }
2502
2722
 
2503
- static struct file_info *
2504
- next_cache_entry(struct iso9660 *iso9660)
2723
+ static int
2724
+ next_cache_entry(struct archive_read *a, struct iso9660 *iso9660,
2725
+ struct file_info **pfile)
2505
2726
  {
2506
2727
  struct file_info *file;
2507
2728
  struct {
@@ -2513,21 +2734,131 @@ next_cache_entry(struct iso9660 *iso9660)
2513
2734
 
2514
2735
  file = cache_get_entry(iso9660);
2515
2736
  if (file != NULL) {
2516
- while (file->parent != NULL && !file->parent->exposed) {
2517
- /* If file's parent is not exposed, it's moved
2518
- * to next entry of its parent. */
2519
- cache_add_to_next_of_parent(iso9660, file);
2520
- file = cache_get_entry(iso9660);
2521
- }
2522
- return (file);
2737
+ *pfile = file;
2738
+ return (ARCHIVE_OK);
2523
2739
  }
2524
2740
 
2525
- file = next_entry(iso9660);
2526
- if (file == NULL)
2527
- return (NULL);
2741
+ for (;;) {
2742
+ struct file_info *re, *d;
2743
+
2744
+ *pfile = file = next_entry(iso9660);
2745
+ if (file == NULL) {
2746
+ /*
2747
+ * If directory entries all which are descendant of
2748
+ * rr_moved are still remaining, expose their.
2749
+ */
2750
+ if (iso9660->re_files.first != NULL &&
2751
+ iso9660->rr_moved != NULL &&
2752
+ iso9660->rr_moved->rr_moved_has_re_only)
2753
+ /* Expose "rr_moved" entry. */
2754
+ cache_add_entry(iso9660, iso9660->rr_moved);
2755
+ while ((re = re_get_entry(iso9660)) != NULL) {
2756
+ /* Expose its descendant dirs. */
2757
+ while ((d = rede_get_entry(re)) != NULL)
2758
+ cache_add_entry(iso9660, d);
2759
+ }
2760
+ if (iso9660->cache_files.first != NULL)
2761
+ return (next_cache_entry(a, iso9660, pfile));
2762
+ return (ARCHIVE_EOF);
2763
+ }
2764
+
2765
+ if (file->cl_offset) {
2766
+ struct file_info *first_re = NULL;
2767
+ int nexted_re = 0;
2768
+
2769
+ /*
2770
+ * Find "RE" dir for the current file, which
2771
+ * has "CL" flag.
2772
+ */
2773
+ while ((re = re_get_entry(iso9660))
2774
+ != first_re) {
2775
+ if (first_re == NULL)
2776
+ first_re = re;
2777
+ if (re->offset == file->cl_offset) {
2778
+ re->parent->subdirs--;
2779
+ re->parent = file->parent;
2780
+ re->re = 0;
2781
+ if (re->parent->re_descendant) {
2782
+ nexted_re = 1;
2783
+ re->re_descendant = 1;
2784
+ if (rede_add_entry(re) < 0)
2785
+ goto fatal_rr;
2786
+ /* Move a list of descendants
2787
+ * to a new ancestor. */
2788
+ while ((d = rede_get_entry(
2789
+ re)) != NULL)
2790
+ if (rede_add_entry(d)
2791
+ < 0)
2792
+ goto fatal_rr;
2793
+ break;
2794
+ }
2795
+ /* Replace the current file
2796
+ * with "RE" dir */
2797
+ *pfile = file = re;
2798
+ /* Expose its descendant */
2799
+ while ((d = rede_get_entry(
2800
+ file)) != NULL)
2801
+ cache_add_entry(
2802
+ iso9660, d);
2803
+ break;
2804
+ } else
2805
+ re_add_entry(iso9660, re);
2806
+ }
2807
+ if (nexted_re) {
2808
+ /*
2809
+ * Do not expose this at this time
2810
+ * because we have not gotten its full-path
2811
+ * name yet.
2812
+ */
2813
+ continue;
2814
+ }
2815
+ } else if ((file->mode & AE_IFMT) == AE_IFDIR) {
2816
+ int r;
2817
+
2818
+ /* Read file entries in this dir. */
2819
+ r = read_children(a, file);
2820
+ if (r != ARCHIVE_OK)
2821
+ return (r);
2822
+
2823
+ /*
2824
+ * Handle a special dir of Rockridge extensions,
2825
+ * "rr_moved".
2826
+ */
2827
+ if (file->rr_moved) {
2828
+ /*
2829
+ * If this has only the subdirectories which
2830
+ * have "RE" flags, do not expose at this time.
2831
+ */
2832
+ if (file->rr_moved_has_re_only)
2833
+ continue;
2834
+ /* Otherwise expose "rr_moved" entry. */
2835
+ } else if (file->re) {
2836
+ /*
2837
+ * Do not expose this at this time
2838
+ * because we have not gotten its full-path
2839
+ * name yet.
2840
+ */
2841
+ re_add_entry(iso9660, file);
2842
+ continue;
2843
+ } else if (file->re_descendant) {
2844
+ /*
2845
+ * If the top level "RE" entry of this entry
2846
+ * is not exposed, we, accordingly, should not
2847
+ * expose this entry at this time because
2848
+ * we cannot make its proper full-path name.
2849
+ */
2850
+ if (rede_add_entry(file) == 0)
2851
+ continue;
2852
+ /* Otherwise we can expose this entry because
2853
+ * it seems its top level "RE" has already been
2854
+ * exposed. */
2855
+ }
2856
+ }
2857
+ break;
2858
+ }
2528
2859
 
2529
2860
  if ((file->mode & AE_IFMT) != AE_IFREG || file->number == -1)
2530
- return (file);
2861
+ return (ARCHIVE_OK);
2531
2862
 
2532
2863
  count = 0;
2533
2864
  number = file->number;
@@ -2537,7 +2868,7 @@ next_cache_entry(struct iso9660 *iso9660)
2537
2868
  empty_files.last = &empty_files.first;
2538
2869
  /* Collect files which has the same file serial number.
2539
2870
  * Peek pending_files so that file which number is different
2540
- * is not put bak. */
2871
+ * is not put back. */
2541
2872
  while (iso9660->pending_files.used > 0 &&
2542
2873
  (iso9660->pending_files.files[0]->number == -1 ||
2543
2874
  iso9660->pending_files.files[0]->number == number)) {
@@ -2545,7 +2876,7 @@ next_cache_entry(struct iso9660 *iso9660)
2545
2876
  /* This file has the same offset
2546
2877
  * but it's wrong offset which empty files
2547
2878
  * and symlink files have.
2548
- * NOTE: This wrong offse was recorded by
2879
+ * NOTE: This wrong offset was recorded by
2549
2880
  * old mkisofs utility. If ISO images is
2550
2881
  * created by latest mkisofs, this does not
2551
2882
  * happen.
@@ -2560,8 +2891,10 @@ next_cache_entry(struct iso9660 *iso9660)
2560
2891
  file = next_entry(iso9660);
2561
2892
  }
2562
2893
 
2563
- if (count == 0)
2564
- return (file);
2894
+ if (count == 0) {
2895
+ *pfile = file;
2896
+ return ((file == NULL)?ARCHIVE_EOF:ARCHIVE_OK);
2897
+ }
2565
2898
  if (file->number == -1) {
2566
2899
  file->next = NULL;
2567
2900
  *empty_files.last = file;
@@ -2586,24 +2919,79 @@ next_cache_entry(struct iso9660 *iso9660)
2586
2919
  *iso9660->cache_files.last = empty_files.first;
2587
2920
  iso9660->cache_files.last = empty_files.last;
2588
2921
  }
2589
- return (cache_get_entry(iso9660));
2922
+ *pfile = cache_get_entry(iso9660);
2923
+ return ((*pfile == NULL)?ARCHIVE_EOF:ARCHIVE_OK);
2924
+
2925
+ fatal_rr:
2926
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
2927
+ "Failed to connect 'CL' pointer to 'RE' rr_moved pointer of "
2928
+ "Rockridge extensions: current position = %jd, CL offset = %jd",
2929
+ (intmax_t)iso9660->current_position, (intmax_t)file->cl_offset);
2930
+ return (ARCHIVE_FATAL);
2590
2931
  }
2591
2932
 
2592
2933
  static inline void
2593
- cache_add_entry(struct iso9660 *iso9660, struct file_info *file)
2934
+ re_add_entry(struct iso9660 *iso9660, struct file_info *file)
2594
2935
  {
2595
- file->next = NULL;
2596
- *iso9660->cache_files.last = file;
2597
- iso9660->cache_files.last = &(file->next);
2936
+ file->re_next = NULL;
2937
+ *iso9660->re_files.last = file;
2938
+ iso9660->re_files.last = &(file->re_next);
2939
+ }
2940
+
2941
+ static inline struct file_info *
2942
+ re_get_entry(struct iso9660 *iso9660)
2943
+ {
2944
+ struct file_info *file;
2945
+
2946
+ if ((file = iso9660->re_files.first) != NULL) {
2947
+ iso9660->re_files.first = file->re_next;
2948
+ if (iso9660->re_files.first == NULL)
2949
+ iso9660->re_files.last =
2950
+ &(iso9660->re_files.first);
2951
+ }
2952
+ return (file);
2953
+ }
2954
+
2955
+ static inline int
2956
+ rede_add_entry(struct file_info *file)
2957
+ {
2958
+ struct file_info *re;
2959
+
2960
+ /*
2961
+ * Find "RE" entry.
2962
+ */
2963
+ re = file->parent;
2964
+ while (re != NULL && !re->re)
2965
+ re = re->parent;
2966
+ if (re == NULL)
2967
+ return (-1);
2968
+
2969
+ file->re_next = NULL;
2970
+ *re->rede_files.last = file;
2971
+ re->rede_files.last = &(file->re_next);
2972
+ return (0);
2973
+ }
2974
+
2975
+ static inline struct file_info *
2976
+ rede_get_entry(struct file_info *re)
2977
+ {
2978
+ struct file_info *file;
2979
+
2980
+ if ((file = re->rede_files.first) != NULL) {
2981
+ re->rede_files.first = file->re_next;
2982
+ if (re->rede_files.first == NULL)
2983
+ re->rede_files.last =
2984
+ &(re->rede_files.first);
2985
+ }
2986
+ return (file);
2598
2987
  }
2599
2988
 
2600
2989
  static inline void
2601
- cache_add_to_next_of_parent(struct iso9660 *iso9660, struct file_info *file)
2990
+ cache_add_entry(struct iso9660 *iso9660, struct file_info *file)
2602
2991
  {
2603
- file->next = file->parent->next;
2604
- file->parent->next = file;
2605
- if (iso9660->cache_files.last == &(file->parent->next))
2606
- iso9660->cache_files.last = &(file->next);
2992
+ file->next = NULL;
2993
+ *iso9660->cache_files.last = file;
2994
+ iso9660->cache_files.last = &(file->next);
2607
2995
  }
2608
2996
 
2609
2997
  static inline struct file_info *
@@ -2614,13 +3002,15 @@ cache_get_entry(struct iso9660 *iso9660)
2614
3002
  if ((file = iso9660->cache_files.first) != NULL) {
2615
3003
  iso9660->cache_files.first = file->next;
2616
3004
  if (iso9660->cache_files.first == NULL)
2617
- iso9660->cache_files.last = &(iso9660->cache_files.first);
3005
+ iso9660->cache_files.last =
3006
+ &(iso9660->cache_files.first);
2618
3007
  }
2619
3008
  return (file);
2620
3009
  }
2621
3010
 
2622
- static void
2623
- heap_add_entry(struct heap_queue *heap, struct file_info *file, uint64_t key)
3011
+ static int
3012
+ heap_add_entry(struct archive_read *a, struct heap_queue *heap,
3013
+ struct file_info *file, uint64_t key)
2624
3014
  {
2625
3015
  uint64_t file_key, parent_key;
2626
3016
  int hole, parent;
@@ -2633,16 +3023,22 @@ heap_add_entry(struct heap_queue *heap, struct file_info *file, uint64_t key)
2633
3023
  if (heap->allocated < 1024)
2634
3024
  new_size = 1024;
2635
3025
  /* Overflow might keep us from growing the list. */
2636
- if (new_size <= heap->allocated)
2637
- __archive_errx(1, "Out of memory");
3026
+ if (new_size <= heap->allocated) {
3027
+ archive_set_error(&a->archive,
3028
+ ENOMEM, "Out of memory");
3029
+ return (ARCHIVE_FATAL);
3030
+ }
2638
3031
  new_pending_files = (struct file_info **)
2639
3032
  malloc(new_size * sizeof(new_pending_files[0]));
2640
- if (new_pending_files == NULL)
2641
- __archive_errx(1, "Out of memory");
2642
- memcpy(new_pending_files, heap->files,
2643
- heap->allocated * sizeof(new_pending_files[0]));
2644
- if (heap->files != NULL)
2645
- free(heap->files);
3033
+ if (new_pending_files == NULL) {
3034
+ archive_set_error(&a->archive,
3035
+ ENOMEM, "Out of memory");
3036
+ return (ARCHIVE_FATAL);
3037
+ }
3038
+ if (heap->allocated)
3039
+ memcpy(new_pending_files, heap->files,
3040
+ heap->allocated * sizeof(new_pending_files[0]));
3041
+ free(heap->files);
2646
3042
  heap->files = new_pending_files;
2647
3043
  heap->allocated = new_size;
2648
3044
  }
@@ -2658,13 +3054,15 @@ heap_add_entry(struct heap_queue *heap, struct file_info *file, uint64_t key)
2658
3054
  parent_key = heap->files[parent]->key;
2659
3055
  if (file_key >= parent_key) {
2660
3056
  heap->files[hole] = file;
2661
- return;
3057
+ return (ARCHIVE_OK);
2662
3058
  }
2663
- // Move parent into hole <==> move hole up tree.
3059
+ /* Move parent into hole <==> move hole up tree. */
2664
3060
  heap->files[hole] = heap->files[parent];
2665
3061
  hole = parent;
2666
3062
  }
2667
3063
  heap->files[0] = file;
3064
+
3065
+ return (ARCHIVE_OK);
2668
3066
  }
2669
3067
 
2670
3068
  static struct file_info *
@@ -2690,14 +3088,14 @@ heap_get_entry(struct heap_queue *heap)
2690
3088
  /*
2691
3089
  * Rebalance the heap.
2692
3090
  */
2693
- a = 0; // Starting element and its heap key
3091
+ a = 0; /* Starting element and its heap key */
2694
3092
  a_key = heap->files[a]->key;
2695
3093
  for (;;) {
2696
- b = a + a + 1; // First child
3094
+ b = a + a + 1; /* First child */
2697
3095
  if (b >= heap->used)
2698
3096
  return (r);
2699
3097
  b_key = heap->files[b]->key;
2700
- c = b + 1; // Use second child if it is smaller.
3098
+ c = b + 1; /* Use second child if it is smaller. */
2701
3099
  if (c < heap->used) {
2702
3100
  c_key = heap->files[c]->key;
2703
3101
  if (c_key < b_key) {
@@ -2730,6 +3128,8 @@ isodate7(const unsigned char *v)
2730
3128
  {
2731
3129
  struct tm tm;
2732
3130
  int offset;
3131
+ time_t t;
3132
+
2733
3133
  memset(&tm, 0, sizeof(tm));
2734
3134
  tm.tm_year = v[0];
2735
3135
  tm.tm_mon = v[1] - 1;
@@ -2743,7 +3143,10 @@ isodate7(const unsigned char *v)
2743
3143
  tm.tm_hour -= offset / 4;
2744
3144
  tm.tm_min -= (offset % 4) * 15;
2745
3145
  }
2746
- return (time_from_tm(&tm));
3146
+ t = time_from_tm(&tm);
3147
+ if (t == (time_t)-1)
3148
+ return ((time_t)0);
3149
+ return (t);
2747
3150
  }
2748
3151
 
2749
3152
  static time_t
@@ -2751,6 +3154,8 @@ isodate17(const unsigned char *v)
2751
3154
  {
2752
3155
  struct tm tm;
2753
3156
  int offset;
3157
+ time_t t;
3158
+
2754
3159
  memset(&tm, 0, sizeof(tm));
2755
3160
  tm.tm_year = (v[0] - '0') * 1000 + (v[1] - '0') * 100
2756
3161
  + (v[2] - '0') * 10 + (v[3] - '0')
@@ -2766,33 +3171,49 @@ isodate17(const unsigned char *v)
2766
3171
  tm.tm_hour -= offset / 4;
2767
3172
  tm.tm_min -= (offset % 4) * 15;
2768
3173
  }
2769
- return (time_from_tm(&tm));
3174
+ t = time_from_tm(&tm);
3175
+ if (t == (time_t)-1)
3176
+ return ((time_t)0);
3177
+ return (t);
2770
3178
  }
2771
3179
 
2772
3180
  static time_t
2773
3181
  time_from_tm(struct tm *t)
2774
3182
  {
2775
3183
  #if HAVE_TIMEGM
2776
- /* Use platform timegm() if available. */
2777
- return (timegm(t));
3184
+ /* Use platform timegm() if available. */
3185
+ return (timegm(t));
3186
+ #elif HAVE__MKGMTIME64
3187
+ return (_mkgmtime64(t));
2778
3188
  #else
2779
- /* Else use direct calculation using POSIX assumptions. */
2780
- /* First, fix up tm_yday based on the year/month/day. */
2781
- mktime(t);
2782
- /* Then we can compute timegm() from first principles. */
2783
- return (t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600
2784
- + t->tm_yday * 86400 + (t->tm_year - 70) * 31536000
2785
- + ((t->tm_year - 69) / 4) * 86400 -
2786
- ((t->tm_year - 1) / 100) * 86400
2787
- + ((t->tm_year + 299) / 400) * 86400);
3189
+ /* Else use direct calculation using POSIX assumptions. */
3190
+ /* First, fix up tm_yday based on the year/month/day. */
3191
+ if (mktime(t) == (time_t)-1)
3192
+ return ((time_t)-1);
3193
+ /* Then we can compute timegm() from first principles. */
3194
+ return (t->tm_sec
3195
+ + t->tm_min * 60
3196
+ + t->tm_hour * 3600
3197
+ + t->tm_yday * 86400
3198
+ + (t->tm_year - 70) * 31536000
3199
+ + ((t->tm_year - 69) / 4) * 86400
3200
+ - ((t->tm_year - 1) / 100) * 86400
3201
+ + ((t->tm_year + 299) / 400) * 86400);
2788
3202
  #endif
2789
3203
  }
2790
3204
 
2791
3205
  static const char *
2792
- build_pathname(struct archive_string *as, struct file_info *file)
3206
+ build_pathname(struct archive_string *as, struct file_info *file, int depth)
2793
3207
  {
3208
+ // Plain ISO9660 only allows 8 dir levels; if we get
3209
+ // to 1000, then something is very, very wrong.
3210
+ if (depth > 1000) {
3211
+ return NULL;
3212
+ }
2794
3213
  if (file->parent != NULL && archive_strlen(&file->parent->name) > 0) {
2795
- build_pathname(as, file->parent);
3214
+ if (build_pathname(as, file->parent, depth + 1) == NULL) {
3215
+ return NULL;
3216
+ }
2796
3217
  archive_strcat(as, "/");
2797
3218
  }
2798
3219
  if (archive_strlen(&file->name) == 0)
@@ -2802,6 +3223,32 @@ build_pathname(struct archive_string *as, struct file_info *file)
2802
3223
  return (as->s);
2803
3224
  }
2804
3225
 
3226
+ static int
3227
+ build_pathname_utf16be(unsigned char *p, size_t max, size_t *len,
3228
+ struct file_info *file)
3229
+ {
3230
+ if (file->parent != NULL && file->parent->utf16be_bytes > 0) {
3231
+ if (build_pathname_utf16be(p, max, len, file->parent) != 0)
3232
+ return (-1);
3233
+ p[*len] = 0;
3234
+ p[*len + 1] = '/';
3235
+ *len += 2;
3236
+ }
3237
+ if (file->utf16be_bytes == 0) {
3238
+ if (*len + 2 > max)
3239
+ return (-1);/* Path is too long! */
3240
+ p[*len] = 0;
3241
+ p[*len + 1] = '.';
3242
+ *len += 2;
3243
+ } else {
3244
+ if (*len + file->utf16be_bytes > max)
3245
+ return (-1);/* Path is too long! */
3246
+ memcpy(p + *len, file->utf16be_name, file->utf16be_bytes);
3247
+ *len += file->utf16be_bytes;
3248
+ }
3249
+ return (0);
3250
+ }
3251
+
2805
3252
  #if DEBUG
2806
3253
  static void
2807
3254
  dump_isodirrec(FILE *out, const unsigned char *isodirrec)
@@ -2814,17 +3261,19 @@ dump_isodirrec(FILE *out, const unsigned char *isodirrec)
2814
3261
  toi(isodirrec + DR_extent_offset, DR_extent_size));
2815
3262
  fprintf(out, " s %d,",
2816
3263
  toi(isodirrec + DR_size_offset, DR_extent_size));
2817
- fprintf(out, " f 0x%02x,",
3264
+ fprintf(out, " f 0x%x,",
2818
3265
  toi(isodirrec + DR_flags_offset, DR_flags_size));
2819
3266
  fprintf(out, " u %d,",
2820
3267
  toi(isodirrec + DR_file_unit_size_offset, DR_file_unit_size_size));
2821
3268
  fprintf(out, " ilv %d,",
2822
3269
  toi(isodirrec + DR_interleave_offset, DR_interleave_size));
2823
3270
  fprintf(out, " seq %d,",
2824
- toi(isodirrec + DR_volume_sequence_number_offset, DR_volume_sequence_number_size));
3271
+ toi(isodirrec + DR_volume_sequence_number_offset,
3272
+ DR_volume_sequence_number_size));
2825
3273
  fprintf(out, " nl %d:",
2826
3274
  toi(isodirrec + DR_name_len_offset, DR_name_len_size));
2827
3275
  fprintf(out, " `%.*s'",
2828
- toi(isodirrec + DR_name_len_offset, DR_name_len_size), isodirrec + DR_name_offset);
3276
+ toi(isodirrec + DR_name_len_offset, DR_name_len_size),
3277
+ isodirrec + DR_name_offset);
2829
3278
  }
2830
3279
  #endif