Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
38e51282
Commit
38e51282
authored
Jul 22, 2011
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
archive/zip: handle zip files with more than 65535 files
R=r CC=golang-dev
https://golang.org/cl/4812048
parent
226fb099
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
src/pkg/archive/zip/reader.go
src/pkg/archive/zip/reader.go
+18
-4
No files found.
src/pkg/archive/zip/reader.go
View file @
38e51282
...
...
@@ -80,19 +80,33 @@ func (z *Reader) init(r io.ReaderAt, size int64) os.Error {
return
err
}
z
.
r
=
r
z
.
File
=
make
([]
*
File
,
end
.
directoryRecords
)
z
.
File
=
make
([]
*
File
,
0
,
end
.
directoryRecords
)
z
.
Comment
=
end
.
comment
rs
:=
io
.
NewSectionReader
(
r
,
0
,
size
)
if
_
,
err
=
rs
.
Seek
(
int64
(
end
.
directoryOffset
),
os
.
SEEK_SET
);
err
!=
nil
{
return
err
}
buf
:=
bufio
.
NewReader
(
rs
)
for
i
:=
range
z
.
File
{
z
.
File
[
i
]
=
&
File
{
zipr
:
r
,
zipsize
:
size
}
if
err
:=
readDirectoryHeader
(
z
.
File
[
i
],
buf
);
err
!=
nil
{
// The count of files inside a zip is truncated to fit in a uint16.
// Gloss over this by reading headers until we encounter
// a bad one, and then only report a FormatError if
// the file count modulo 65536 is incorrect.
for
{
f
:=
&
File
{
zipr
:
r
,
zipsize
:
size
}
err
:=
readDirectoryHeader
(
f
,
buf
)
if
err
==
FormatError
{
break
}
if
err
!=
nil
{
return
err
}
z
.
File
=
append
(
z
.
File
,
f
)
}
if
uint16
(
len
(
z
.
File
))
!=
end
.
directoryRecords
{
return
FormatError
}
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment