Warn when an entry size is invalid
This commit is contained in:
parent
7849f7362a
commit
97cb6aefe6
|
@ -604,14 +604,19 @@ module Zip
|
|||
set_extra_attributes_on_path(dest_path)
|
||||
|
||||
bytes_written = 0
|
||||
warned = false
|
||||
buf = ''.dup
|
||||
while (buf = is.sysread(::Zip::Decompressor::CHUNK_SIZE, buf))
|
||||
os << buf
|
||||
|
||||
next unless ::Zip.validate_entry_sizes
|
||||
bytes_written += buf.bytesize
|
||||
if bytes_written > size
|
||||
raise ::Zip::EntrySizeError, "Entry #{name} should be #{size}B but is larger when inflated"
|
||||
if bytes_written > size && !warned
|
||||
message = "Entry #{name} should be #{size}B but is larger when inflated"
|
||||
if ::Zip.validate_entry_sizes
|
||||
raise ::Zip::EntrySizeError, message
|
||||
else
|
||||
puts "WARNING: #{message}"
|
||||
warned = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue