Skip to content

Commit

Permalink
archive/zip: lazy load file data descriptor
Browse files Browse the repository at this point in the history
Fixes #48374

Signed-off-by: Vinicius Tinti <[email protected]>
  • Loading branch information
tinti committed Oct 3, 2021
1 parent 3bbc823 commit 3fbc23a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/archive/zip/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
if err != nil {
return err
}
f.readDataDescriptor()
z.File = append(z.File, f)
}
if uint16(len(z.File)) != uint16(end.directoryRecords) { // only compare 16 bits here
Expand Down Expand Up @@ -789,6 +788,8 @@ func (r *Reader) Open(name string) (fs.File, error) {
if e.isDir {
return &openDir{e, r.openReadDir(name), 0}, nil
}

e.file.readDataDescriptor()
rc, err := e.file.Open()
if err != nil {
return nil, err
Expand Down

0 comments on commit 3fbc23a

Please sign in to comment.