Skip to content

Commit 930c9dc

Browse files
committed
undo free bsd error handling
1 parent cc52619 commit 930c9dc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lib/zip/zip.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,9 +1286,23 @@ def get_e_o_c_d(io) #:nodoc:
12861286
io.seek(-MAX_END_OF_CENTRAL_DIRECTORY_STRUCTURE_SIZE, IO::SEEK_END)
12871287
rescue Errno::EINVAL
12881288
io.seek(0, IO::SEEK_SET)
1289+
rescue Errno::EFBIG # FreeBSD 4.9 raise Errno::EFBIG instead of Errno::EINVAL
1290+
io.seek(0, IO::SEEK_SET)
1291+
end
1292+
1293+
# 'buf = io.read' substituted with lump of code to work around FreeBSD 4.5 issue
1294+
retried = false
1295+
buf = nil
1296+
begin
1297+
buf = io.read
1298+
rescue Errno::EFBIG # FreeBSD 4.5 may raise Errno::EFBIG
1299+
raise if (retried)
1300+
retried = true
1301+
1302+
io.seek(0, IO::SEEK_SET)
1303+
retry
12891304
end
12901305

1291-
buf = io.read
12921306
sigIndex = buf.rindex([END_OF_CENTRAL_DIRECTORY_SIGNATURE].pack('V'))
12931307
raise ZipError, "Zip end of central directory signature not found" unless sigIndex
12941308
buf=buf.slice!((sigIndex+4)..(buf.size))

0 commit comments

Comments
 (0)