Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AndroidSystemCore
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Werner Sembach
AndroidSystemCore
Commits
af43cd03
Commit
af43cd03
authored
8 years ago
by
Narayan Kamath
Committed by
android-build-merger
8 years ago
Browse files
Options
Downloads
Plain Diff
resolve merge conflicts of
a47780b9
to lmp-dev am:
61f27551
am:
b5f75c45
Change-Id: Iacea86ad3c142d6f14b5fbdfb5b615f4705b1bd1
parents
0f6c4a0e
b5f75c45
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
libzipfile/centraldir.c
+54
-1
54 additions, 1 deletion
libzipfile/centraldir.c
libzipfile/test_zipfile.c
+0
-1
0 additions, 1 deletion
libzipfile/test_zipfile.c
with
54 additions
and
2 deletions
libzipfile/centraldir.c
+
54
−
1
View file @
af43cd03
...
...
@@ -62,11 +62,16 @@ read_central_dir_values(Zipfile* file, const unsigned char* buf, int len)
return
0
;
}
static
const
int
kCompressionStored
=
0x0
;
static
const
int
kCompressionDeflate
=
0x8
;
static
int
read_central_directory_entry
(
Zipfile
*
file
,
Zipentry
*
entry
,
const
unsigned
char
**
buf
,
ssize_t
*
len
)
{
const
unsigned
char
*
p
;
size_t
remaining
;
const
unsigned
char
*
bufLimit
;
unsigned
short
extraFieldLength
;
unsigned
short
fileCommentLength
;
...
...
@@ -74,6 +79,8 @@ read_central_directory_entry(Zipfile* file, Zipentry* entry,
unsigned
int
dataOffset
;
p
=
*
buf
;
remaining
=
*
len
;
bufLimit
=
file
->
buf
+
file
->
bufsize
;
if
(
*
len
<
ENTRY_LEN
)
{
fprintf
(
stderr
,
"cde entry not large enough
\n
"
);
...
...
@@ -94,31 +101,77 @@ read_central_directory_entry(Zipfile* file, Zipentry* entry,
localHeaderRelOffset
=
read_le_int
(
&
p
[
0x2a
]);
p
+=
ENTRY_LEN
;
remaining
-=
ENTRY_LEN
;
// filename
if
(
entry
->
fileNameLength
!=
0
)
{
if
(
entry
->
fileNameLength
>
remaining
)
{
fprintf
(
stderr
,
"cde entry not large enough for file name.
\n
"
);
return
1
;
}
entry
->
fileName
=
p
;
}
else
{
entry
->
fileName
=
NULL
;
fprintf
(
stderr
,
"cde entry does not contain a file name.
\n
"
);
return
1
;
}
p
+=
entry
->
fileNameLength
;
remaining
-=
entry
->
fileNameLength
;
// extra field
if
(
extraFieldLength
>
remaining
)
{
fprintf
(
stderr
,
"cde entry not large enough for extra field.
\n
"
);
return
1
;
}
p
+=
extraFieldLength
;
remaining
-=
extraFieldLength
;
// comment, if any
if
(
fileCommentLength
>
remaining
)
{
fprintf
(
stderr
,
"cde entry not large enough for file comment.
\n
"
);
return
1
;
}
p
+=
fileCommentLength
;
remaining
-=
fileCommentLength
;
*
buf
=
p
;
*
len
=
remaining
;
// the size of the extraField in the central dir is how much data there is,
// but the one in the local file header also contains some padding.
p
=
file
->
buf
+
localHeaderRelOffset
;
if
(
p
>=
bufLimit
)
{
fprintf
(
stderr
,
"Invalid local header offset for entry.
\n
"
);
return
1
;
}
extraFieldLength
=
read_le_short
(
&
p
[
0x1c
]);
dataOffset
=
localHeaderRelOffset
+
LFH_SIZE
+
entry
->
fileNameLength
+
extraFieldLength
;
entry
->
data
=
file
->
buf
+
dataOffset
;
// Sanity check: make sure that the start of the entry data is within
// our allocated buffer.
if
((
entry
->
data
<
file
->
buf
)
||
(
entry
->
data
>=
bufLimit
))
{
fprintf
(
stderr
,
"Invalid data offset for entry.
\n
"
);
return
1
;
}
// Sanity check: make sure that the end of the entry data is within
// our allocated buffer. We need to look at the uncompressedSize for
// stored entries and the compressed size for deflated entries.
if
((
entry
->
compressionMethod
==
kCompressionStored
)
&&
(
entry
->
uncompressedSize
>
(
unsigned
int
)
(
bufLimit
-
entry
->
data
)))
{
fprintf
(
stderr
,
"Invalid uncompressed size for stored entry.
\n
"
);
return
1
;
}
if
((
entry
->
compressionMethod
==
kCompressionDeflate
)
&&
(
entry
->
compressedSize
>
(
unsigned
int
)
(
bufLimit
-
entry
->
data
)))
{
fprintf
(
stderr
,
"Invalid uncompressed size for deflated entry.
\n
"
);
return
1
;
}
#if 0
printf("file->buf=%p entry->data=%p dataOffset=%x localHeaderRelOffset=%d "
"entry->fileNameLength=%d extraFieldLength=%d\n",
...
...
This diff is collapsed.
Click to expand it.
libzipfile/test_zipfile.c
+
0
−
1
View file @
af43cd03
...
...
@@ -75,7 +75,6 @@ main(int argc, char** argv)
unsize
=
get_zipentry_size
(
entry
);
size
=
unsize
*
1
.
001
;
scratch
=
malloc
(
size
);
printf
(
"scratch=%p
\n
"
,
scratch
);
err
=
decompress_zipentry
(
entry
,
scratch
,
size
);
if
(
err
!=
0
)
{
fprintf
(
stderr
,
"error decompressing file
\n
"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment