rubyzip 3.2.1 → 3.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4f451a3c548c2fb166c19e08e716375d3f27850975e33fad1ef57a09e15fadc0
4
- data.tar.gz: 2578620d86942c589aa4b74178d92fa7690a408be4fc1ecdc3285dfcebc7526b
3
+ metadata.gz: 67852d915e2ec168efb617d7577ac60196bf7433b3c2800981a14c5a43b939c5
4
+ data.tar.gz: '039b39e7e9e7f46e056da4d0070554eba081e26a4dd99e3dd47d76428628d29f'
5
5
  SHA512:
6
- metadata.gz: 93d7eaa1d76b58942f116334e1195a88ed7cae1f7bc77493c087464323fe3a1829c04bcfe56beebffe18bb252bb45b08574b65782fa30b5d0d2f25d80241e0d0
7
- data.tar.gz: 2dbdc409218799a047fc396eae4f7ba3e9087122aa4dbeefc5f0c0b10953c870680820f7ac086207f9f006118fdd2f26211ebea2414f6f0ea16f13a9ec4745f7
6
+ metadata.gz: ba24363c26265acbd295289685d5baa4d351a913d98de67064171c35f0055f04ac34b2e6db384af248e124b12abc505bac558205eadb2975d3d4da59178b9a54
7
+ data.tar.gz: b654167d21076c70ea58b6a185f4be83a6ef172d208bf4f8a8928ac82aa909773b20df462870dc833b1182f669334e18fd7283e23cf4040b770faea1a49d1e6a
data/Changelog.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 3.2.2 (2025-11-02)
2
+
3
+ - Fix reading EOCDs when header signatures are in an Entry payload. [#656](https://github.com/rubyzip/rubyzip/issues/656)
4
+
5
+ Tooling/internal:
6
+
7
+ - Stop using macos-13 runners in GitHub Actions.
8
+ - Update YJIT GitHub Actions runners.
9
+
1
10
  # 3.2.1 (2025-10-24)
2
11
 
3
12
  - Fix `Entry#gather_fileinfo_from_srcpath` error messages. [#654](https://github.com/rubyzip/rubyzip/issues/654)
@@ -143,28 +143,27 @@ module Zip
143
143
  zip64_eocd_offset
144
144
  end
145
145
 
146
- def unpack_e_o_c_d(buffer) # :nodoc:
146
+ # Unpack the EOCD and return a boolean indicating whether this header is
147
+ # complete without needing Zip64 extensions.
148
+ def unpack_e_o_c_d(buffer) # :nodoc: # rubocop:disable Naming/PredicateMethod
147
149
  _, # END_OF_CD_SIG. We know we have this at this point.
148
- num_disk,
149
- num_disk_cdir,
150
- num_cdir_disk,
151
- num_entries,
152
- size_in_bytes,
153
- cdir_offset,
150
+ @number_of_this_disk,
151
+ @number_of_disk_with_start_of_cdir,
152
+ @total_number_of_entries_in_cdir_on_this_disk,
153
+ @size,
154
+ @size_in_bytes,
155
+ @cdir_offset,
154
156
  comment_length = buffer.unpack('VvvvvVVv')
155
157
 
156
- @number_of_this_disk = num_disk unless num_disk == 0xFFFF
157
- @number_of_disk_with_start_of_cdir = num_disk_cdir unless num_disk_cdir == 0xFFFF
158
- @total_number_of_entries_in_cdir_on_this_disk = num_cdir_disk unless num_cdir_disk == 0xFFFF
159
- @size = num_entries unless num_entries == 0xFFFF
160
- @size_in_bytes = size_in_bytes unless size_in_bytes == 0xFFFFFFFF
161
- @cdir_offset = cdir_offset unless cdir_offset == 0xFFFFFFFF
162
-
163
158
  @comment = if comment_length.positive?
164
159
  buffer.slice(STATIC_EOCD_SIZE, comment_length)
165
160
  else
166
161
  ''
167
162
  end
163
+
164
+ !([@number_of_this_disk, @number_of_disk_with_start_of_cdir,
165
+ @total_number_of_entries_in_cdir_on_this_disk, @size].any?(0xFFFF) ||
166
+ @size_in_bytes == 0xFFFFFFFF || @cdir_offset == 0xFFFFFFFF)
168
167
  end
169
168
 
170
169
  def read_central_directory_entries(io) # :nodoc:
@@ -217,30 +216,37 @@ module Zip
217
216
  eocd_location = data.rindex([END_OF_CD_SIG].pack('V'))
218
217
  raise Error, 'Zip end of central directory signature not found' unless eocd_location
219
218
 
220
- zip64_eocd_locator = data.rindex([ZIP64_EOCD_LOCATOR_SIG].pack('V'))
221
-
222
- if zip64_eocd_locator
223
- zip64_eocd_location = data.rindex([ZIP64_END_OF_CD_SIG].pack('V'))
219
+ # Parse the EOCD and return if it is complete without Zip64 extensions.
220
+ return if unpack_e_o_c_d(data.slice(eocd_location..-1))
224
221
 
225
- zip64_eocd_data =
226
- if zip64_eocd_location
227
- data.slice(zip64_eocd_location..zip64_eocd_locator)
228
- else
229
- zip64_eocd_location = unpack_64_eocd_locator(
230
- data.slice(zip64_eocd_locator..eocd_location)
231
- )
232
- unless zip64_eocd_location
233
- raise Error, 'Zip64 end of central directory signature not found'
234
- end
222
+ # Need to read in the Zip64 EOCD locator and then the Zip64 EOCD.
223
+ zip64_eocd_locator = data.rindex([ZIP64_EOCD_LOCATOR_SIG].pack('V'), eocd_location)
224
+ unless zip64_eocd_locator
225
+ raise Error, 'Zip64 end of central directory locator signature expected but not found'
226
+ end
235
227
 
236
- io.seek(zip64_eocd_location, IO::SEEK_SET)
237
- io.read(base_location + zip64_eocd_locator - zip64_eocd_location)
228
+ # Do we already have the Zip64 EOCD in the data we've read?
229
+ zip64_eocd_location = data.rindex([ZIP64_END_OF_CD_SIG].pack('V'), zip64_eocd_locator)
230
+
231
+ zip64_eocd_data =
232
+ if zip64_eocd_location
233
+ # Yes.
234
+ data.slice(zip64_eocd_location..zip64_eocd_locator)
235
+ else
236
+ # No. Read its location from the locator and then read it in.
237
+ zip64_eocd_location = unpack_64_eocd_locator(
238
+ data.slice(zip64_eocd_locator..eocd_location)
239
+ )
240
+ unless zip64_eocd_location
241
+ raise Error, 'Zip64 end of central directory signature not found'
238
242
  end
239
243
 
240
- unpack_64_e_o_c_d(zip64_eocd_data)
241
- end
244
+ io.seek(zip64_eocd_location, IO::SEEK_SET)
245
+ io.read(base_location + zip64_eocd_locator - zip64_eocd_location)
246
+ end
242
247
 
243
- unpack_e_o_c_d(data.slice(eocd_location..-1))
248
+ # Finally, unpack the Zip64 EOCD.
249
+ unpack_64_e_o_c_d(zip64_eocd_data)
244
250
  end
245
251
 
246
252
  def eocd_data(io)
data/lib/zip/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Zip
4
4
  # The version of the Rubyzip library.
5
- VERSION = '3.2.1'
5
+ VERSION = '3.2.2'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyzip
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Haines
@@ -195,9 +195,9 @@ licenses:
195
195
  - BSD-2-Clause
196
196
  metadata:
197
197
  bug_tracker_uri: https://github.com/rubyzip/rubyzip/issues
198
- changelog_uri: https://github.com/rubyzip/rubyzip/blob/v3.2.1/Changelog.md
199
- documentation_uri: https://www.rubydoc.info/gems/rubyzip/3.2.1
200
- source_code_uri: https://github.com/rubyzip/rubyzip/tree/v3.2.1
198
+ changelog_uri: https://github.com/rubyzip/rubyzip/blob/v3.2.2/Changelog.md
199
+ documentation_uri: https://www.rubydoc.info/gems/rubyzip/3.2.2
200
+ source_code_uri: https://github.com/rubyzip/rubyzip/tree/v3.2.2
201
201
  wiki_uri: https://github.com/rubyzip/rubyzip/wiki
202
202
  rubygems_mfa_required: 'true'
203
203
  rdoc_options: []