Skip to content

Commit d2b3d00

Browse files
adgt4n6a1ka
authored andcommitted
archive/zip: remove unused special case
This removes a special case that was added to fix issue golang#10956, but that was never actually effective. The code in the test case still fails to read, so perhaps the zip64 support added in CL 6463050 inadvertently caught this particular case. It's possible that the original theorized bug still exists, but I'm not convinced it was ever fixed. Update golang#28700 Change-Id: I4854de616364510f64a6def30b308686563f8dbb Reviewed-on: https://go-review.googlesource.com/c/go/+/179757 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 42eb3ea commit d2b3d00

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/archive/zip/reader.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"bufio"
99
"encoding/binary"
1010
"errors"
11-
"fmt"
1211
"hash"
1312
"hash/crc32"
1413
"io"
@@ -84,9 +83,6 @@ func (z *Reader) init(r io.ReaderAt, size int64) error {
8483
if err != nil {
8584
return err
8685
}
87-
if end.directoryRecords > uint64(size)/fileHeaderLen {
88-
return fmt.Errorf("archive/zip: TOC declares impossible %d files in %d byte zip", end.directoryRecords, size)
89-
}
9086
z.r = r
9187
z.File = make([]*File, 0, end.directoryRecords)
9288
z.Comment = end.comment

src/archive/zip/reader_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -981,15 +981,17 @@ func TestIssue10957(t *testing.T) {
981981
}
982982
}
983983

984-
// Verify the number of files is sane.
984+
// Verify that this particular malformed zip file is rejected.
985985
func TestIssue10956(t *testing.T) {
986986
data := []byte("PK\x06\x06PK\x06\a0000\x00\x00\x00\x00\x00\x00\x00\x00" +
987987
"0000PK\x05\x06000000000000" +
988988
"0000\v\x00000\x00\x00\x00\x00\x00\x00\x000")
989-
_, err := NewReader(bytes.NewReader(data), int64(len(data)))
990-
const want = "TOC declares impossible 3472328296227680304 files in 57 byte"
991-
if err == nil && !strings.Contains(err.Error(), want) {
992-
t.Errorf("error = %v; want %q", err, want)
989+
r, err := NewReader(bytes.NewReader(data), int64(len(data)))
990+
if err == nil {
991+
t.Errorf("got nil error, want ErrFormat")
992+
}
993+
if r != nil {
994+
t.Errorf("got non-nil Reader, want nil")
993995
}
994996
}
995997

0 commit comments

Comments
 (0)