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)
|
set_extra_attributes_on_path(dest_path)
|
||||||
|
|
||||||
bytes_written = 0
|
bytes_written = 0
|
||||||
|
warned = false
|
||||||
buf = ''.dup
|
buf = ''.dup
|
||||||
while (buf = is.sysread(::Zip::Decompressor::CHUNK_SIZE, buf))
|
while (buf = is.sysread(::Zip::Decompressor::CHUNK_SIZE, buf))
|
||||||
os << buf
|
os << buf
|
||||||
|
|
||||||
next unless ::Zip.validate_entry_sizes
|
|
||||||
bytes_written += buf.bytesize
|
bytes_written += buf.bytesize
|
||||||
if bytes_written > size
|
if bytes_written > size && !warned
|
||||||
raise ::Zip::EntrySizeError, "Entry #{name} should be #{size}B but is larger when inflated"
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue