mirror of
https://github.com/golang/go
synced 2024-11-24 21:10:04 -07:00
fix read the big zip error
fix read the big zip error
This commit is contained in:
parent
b521ebb55a
commit
eab1f0d436
@ -565,10 +565,10 @@ func readDataDescriptor(r io.Reader, f *File) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readDirectoryEnd(r io.ReaderAt, size int64) (dir *directoryEnd, baseOffset int64, err error) {
|
func readDirectoryEnd(r io.ReaderAt, size int64) (dir *directoryEnd, baseOffset int64, err error) {
|
||||||
// look for directoryEndSignature in the last 1k, then in the last 65k
|
// look for directoryEndSignature in the last 1k, then in the last 65k, then in the last 5M
|
||||||
var buf []byte
|
var buf []byte
|
||||||
var directoryEndOffset int64
|
var directoryEndOffset int64
|
||||||
for i, bLen := range []int64{1024, 65 * 1024} {
|
for i, bLen := range []int64{1024, 65 * 1024,5*1024*1024} {
|
||||||
if bLen > size {
|
if bLen > size {
|
||||||
bLen = size
|
bLen = size
|
||||||
}
|
}
|
||||||
@ -581,7 +581,7 @@ func readDirectoryEnd(r io.ReaderAt, size int64) (dir *directoryEnd, baseOffset
|
|||||||
directoryEndOffset = size - bLen + int64(p)
|
directoryEndOffset = size - bLen + int64(p)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if i == 1 || bLen == size {
|
if i == 2 || bLen == size {
|
||||||
return nil, 0, ErrFormat
|
return nil, 0, ErrFormat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user