Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
Zip
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
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
YongYue
Zip
Commits
63cf4227
Commit
63cf4227
authored
Sep 20, 2017
by
Roy Marmelstein
Committed by
GitHub
Sep 20, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #94 from bricklife/feature/uncompressed_size_validation
Add fwrite() and uncompressed_size validation
parents
37433c91
1ea5e961
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
Zip/Zip.swift
Zip/Zip.swift
+9
-1
No files found.
Zip/Zip.swift
View file @
63cf4227
...
...
@@ -187,12 +187,17 @@ public class Zip {
unzCloseCurrentFile
(
zip
)
ret
=
unzGoToNextFile
(
zip
)
}
var
writeBytes
:
UInt64
=
0
var
filePointer
:
UnsafeMutablePointer
<
FILE
>
?
filePointer
=
fopen
(
fullPath
,
"wb"
)
while
filePointer
!=
nil
{
let
readBytes
=
unzReadCurrentFile
(
zip
,
&
buffer
,
bufferSize
)
if
readBytes
>
0
{
fwrite
(
buffer
,
Int
(
readBytes
),
1
,
filePointer
)
guard
fwrite
(
buffer
,
Int
(
readBytes
),
1
,
filePointer
)
==
1
else
{
throw
ZipError
.
unzipFail
}
writeBytes
+=
UInt64
(
readBytes
)
}
else
{
break
...
...
@@ -204,6 +209,9 @@ public class Zip {
if
crc_ret
==
UNZ_CRCERROR
{
throw
ZipError
.
unzipFail
}
guard
writeBytes
==
fileInfo
.
uncompressed_size
else
{
throw
ZipError
.
unzipFail
}
//Set file permissions from current fileInfo
if
fileInfo
.
external_fa
!=
0
{
...
...
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