"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/archive/zip/reader.go" between
go1.16.4.src.tar.gz and go1.16.5.src.tar.gz

About: Google’s Go is a compiled, garbage-collected, concurrent programming language. Latest stable release (1.16).

reader.go  (go1.16.4.src):reader.go  (go1.16.5.src)
skipping to change at line 102 skipping to change at line 102
} }
return zr, nil return zr, nil
} }
func (z *Reader) init(r io.ReaderAt, size int64) error { func (z *Reader) init(r io.ReaderAt, size int64) error {
end, err := readDirectoryEnd(r, size) end, err := readDirectoryEnd(r, size)
if err != nil { if err != nil {
return err return err
} }
z.r = r z.r = r
z.File = make([]*File, 0, end.directoryRecords) // Since the number of directory records is not validated, it is not
// safe to preallocate z.File without first checking that the specified
// number of files is reasonable, since a malformed archive may
// indicate it contains up to 1 << 128 - 1 files. Since each file has a
// header which will be _at least_ 30 bytes we can safely preallocate
// if (data size / 30) >= end.directoryRecords.
if (uint64(size)-end.directorySize)/30 >= end.directoryRecords {
z.File = make([]*File, 0, end.directoryRecords)
}
z.Comment = end.comment z.Comment = end.comment
rs := io.NewSectionReader(r, 0, size) rs := io.NewSectionReader(r, 0, size)
if _, err = rs.Seek(int64(end.directoryOffset), io.SeekStart); err != nil { if _, err = rs.Seek(int64(end.directoryOffset), io.SeekStart); err != nil {
return err return err
} }
buf := bufio.NewReader(rs) buf := bufio.NewReader(rs)
// The count of files inside a zip is truncated to fit in a uint16. // The count of files inside a zip is truncated to fit in a uint16.
// Gloss over this by reading headers until we encounter // Gloss over this by reading headers until we encounter
// a bad one, and then only report an ErrFormat or UnexpectedEOF if // a bad one, and then only report an ErrFormat or UnexpectedEOF if
 End of changes. 1 change blocks. 
1 lines changed or deleted 9 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)