]> Cypherpunks repositories - gostls13.git/commitdiff
archive/zip: fix bug reading zip64 files
authorBrad Fitzpatrick <bradfitz@golang.org>
Mon, 6 Jan 2014 18:43:56 +0000 (10:43 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 6 Jan 2014 18:43:56 +0000 (10:43 -0800)
ZIP64 Extra records are variably sized, but we weren't capping
our reading of the extra fields at its previously-declared
size.

No test because I don't know how to easily create such files
and don't feel like manually construction one.  But all
existing tests pass, and this is "obviously correct" (queue
laughter).

Fixes #7069

R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/48150043

src/pkg/archive/zip/reader.go

index 116737337fb36f0b536a1c4b0c9de21e840f1510..80ee03006f09691740f8d8ccd4c6b217ab718120 100644 (file)
@@ -253,7 +253,7 @@ func readDirectoryHeader(f *File, r io.Reader) error {
                        }
                        if tag == zip64ExtraId {
                                // update directory values from the zip64 extra block
-                               eb := readBuf(b)
+                               eb := readBuf(b[:size])
                                if len(eb) >= 8 {
                                        f.UncompressedSize64 = eb.uint64()
                                }