Commit graph

35 commits

Author SHA1 Message Date
Piotr Jastrzebski
8fd1f27ed8 Merge "Reject zip archives with entry names containing \0." 2014-08-16 05:59:09 +00:00
Piotr Jastrzebski
78271ba97b Reject zip archives with entry names containing \0.
There should never be a need of an entry name with \0 character.

Bug: 16162465
Change-Id: Ia2ec57959280c1bb972c4d59d890c8540c5b9081
2014-08-19 11:02:58 +01:00
Piotr Jastrzebski
10aa9a0e24 Cleanup ziparchive
Addressed review comments from 8e08536108

Change-Id: If576e2d6cc5ad330a7dee66b09663e0c04ea3801
2014-08-19 10:58:03 +01:00
Piotr Jastrzebski
8e08536108 Fix win_sdk build by not using vector
Change-Id: I4e9ee4286ea29e1f5f2ee477525e79bfa16ad9a0
2014-08-18 14:04:56 +01:00
Piotr Jastrzebski
ecccc5ad93 Replace char* with ZipEntryName in ziparchive API.
It's important because entry names can be encoded in UTF-8 and can have \0
character in the middle.
Use vector instead of char* for prefix in IterationHandle.

Bug: 16162465
Change-Id: Ie34c8d7c6231cc258530c22bdde5542895213649
2014-08-15 12:39:45 +01:00
Piotr Jastrzebski
bd0a74854e Revert "Make sure that names of all entries have the same encoding."
This reverts commit 6a7f4bb79d.

Change-Id: Id4f5b601ff0b9d82ce2c9beeb9162eba9594b3a7
2014-08-13 09:49:25 +00:00
Piotr Jastrzebski
6a7f4bb79d Make sure that names of all entries have the same encoding.
Add new public method to allow checkisc if an archive has entry names encoded in
UTF-8. If not then they will be encoded in IBM PC character encoding.

Bug: 16162465
Change-Id: I4468d76accca8a9b0b31cae8d43399ffc22cad42
2014-08-13 09:58:16 +01:00
Piotr Jastrzebski
34e03bdfdf Make a copy of a prefix param in StartIteration
and delete it in EndIteration.

Change-Id: I4de4167700a9dba3119fde22fcd45725742f3731
2014-08-11 14:20:24 +01:00
Piotr Jastrzebski
79c8b34f36 Add EndIteration method to free memory allocated
in StartIteration. This method should always be called when the
iteration is over to make sure that we don't leak memory.

Change-Id: I5205c754dfafbab9bb5f06003c3663d2ec4e8a35
2014-08-11 07:58:00 +01:00
Neil Fuller
e91d9d80d1 Merge "Prevent the accidental closure of fd[0] for missing zip files." 2014-07-23 19:33:25 +00:00
Neil Fuller
b1a113f618 Prevent the accidental closure of fd[0] for missing zip files.
Bug: 16530747
Change-Id: I3593f2bc4d56a2f91252ea795c90ce3c78e1ec06
2014-07-25 16:06:20 +01:00
Tim Murray
06fce9db05 Update makefiles for host clang.
bug 16172793

Change-Id: If7484c5dbcccce7d925bec97bff0a3e4c30e9434
2014-07-24 12:18:22 -07:00
Ian Rogers
5af80aa119 Enable host multilib for ART testing.
Change-Id: Ic3ae5122eba13565fb5a4cb1bd0e7e465fb2140c
2014-06-17 01:50:25 -07:00
Narayan Kamath
926973ec14 Replace hand written offsets with structures.
Given that all current & future android ABIs are
little endian, we can get rid of the explicit conversions
from memory regions to little endian data members.

Also cleans up a few C style casts that snuck in during
several -Werror efforts and fixes temporary file generation
on target.

bug: 15448202

Change-Id: I4fcbb3c1124cb82c82139d328344e54fc7895353
2014-06-10 10:36:34 +01:00
Narayan Kamath
c00de56063 Fix build.
Uncommitted changes from a rename.

Change-Id: If1cac7104c436970f905eede683040ae79529292
2014-06-06 10:20:37 +00:00
Narayan Kamath
4f6b499ead Reject zip files that have trailing bytes after their CD.
bug: 15287086
Change-Id: I03219c4c2ca6afc9d417a35bd98ae682f478fc25
2014-06-05 18:37:08 +01:00
Ying Wang
cf86e2f85d Fix host 64-bit build.
Bug: 13751317
Change-Id: Ib42d24408d053bacc24142ed18fc5f3181d2345b
2014-05-16 09:36:17 -07:00
Mark Salyzyn
96c5c99bda libziparchive: off64_t is not int64_t (part deux)
Change-Id: I38e78bdba338a0c40aec43d6c86f26f388cee6ab
2014-05-08 19:16:40 -07:00
Mark Salyzyn
56a90a08db libziparchive: off64_t is not int64_t
- ToDo: investigate why our system headers let us down.

Change-Id: Iada422adbbbd4fbd0fc09b51b97b3cd06ccc6374
2014-05-08 17:20:55 -07:00
Mark Salyzyn
088bf90e5d libziparchive: 64 bit issues
Change-Id: I1b53aff5b1527a3623d17deed306624707d345ef
2014-05-08 16:06:54 -07:00
Mark Salyzyn
51d562d399 libziparchive: Turn on -Werror
Change-Id: I98a93273b9e1bac0324dd210f6a8493ba780e878
2014-05-07 16:56:21 -07:00
Mark Salyzyn
99ef9914be libziparchive: 64 bit compile issues
- All within LOG messages.

Change-Id: I52e81b49e8127276359c62febd4cc1d8d69102d9
2014-03-14 14:47:15 -07:00
Mathieu Chartier
5f98b12640 Add free to CloseArchive.
Currently CloseArchive doesn't call free and call sites don't appear
to either. I could not find any call sites which manually freed the
archive by deleting the handle. This fixes several memory leaks.

Change-Id: I21f187dde60fd87e6e54bde06de9e76fd0791104
2014-03-04 17:44:58 -08:00
Colin Cross
f4b0b7971c Fix logging errors inside ALOGV
Fix errors exposed by adding checking to disabled ALOGVs.

Change-Id: I36b77bb0ad8dc7661b0f834f20d1179b86134d57
2014-02-07 13:26:04 -08:00
Narayan Kamath
48953a1b8f Fix entry handling for 0 length entries.
Two minor issues were fixed:
- The offset to entry data can be the same as the
  central directory offset when the last entry in the
  file has length 0 and is stored (not deflated). Fix
  a check that disallowed this. We already have a strict
  check that entry data must end before the central directory,
  so we're covered.
- We would attempt to map a segment of length 0 when writing
  an entry whose length is 0. We should just return early in
  this case.

bug: 12623277
Change-Id: I2a4ca0c4d170cc3cbf326e5ca13894acd9c434c9
2014-01-24 13:41:55 +00:00
Elliott Hughes
f5447b0eb9 Merge "Fix a sporadic build breakage." 2014-01-03 21:08:01 +00:00
Narayan Kamath
95986aae91 Fix a sporadic build breakage.
The issue here is that the makefile sets LOCAL_LDFLAGS
and asks for -llog without declaring a dependency on it.
This will cause build breakages if liblog hasn't already
been built yet.

Change-Id: Ia38761cda44a38b6c2a88902d6108cbe64a328ce
2014-01-03 15:40:37 +00:00
Narayan Kamath
a1ff801e5f Change a debug log to a verbose log.
Unlike ALOGV, messages from ALOGD are logged on
all configurations. Not finding an entry in a zip
file is a "normal" occurrence so using an ALOGD
message for it amounts to spam.

Change-Id: I2c60d11e8a750be5106afd65c3c5e335f53f01b6
2014-01-02 19:41:00 +00:00
Narayan Kamath
00a258cec7 Fix ExtractEntryToFile.
We would always write uncompressed data at offset 0 instead
of the current filedescriptor offset.

Also adds a unit-test & a clarifying comment on the API.

Change-Id: If44757e96dde504ce63d81b4dec7115fc6f6d5fb
2013-12-13 17:56:57 +00:00
Narayan Kamath
7d92b7cc65 Merge "Get rid of some log spam." 2013-12-12 17:19:40 +00:00
Narayan Kamath
f6a196522a Get rid of some log spam.
We don't need a warning if an entry isn't found in a zip
file. It can happen as part of normal operation.

Change-Id: I86c132a040371f36f0dd981b49c02b3173821439
2013-12-12 10:29:31 +00:00
Narayan Kamath
eaf988532b Use FileMap from libcutil instead of rolling our own.
Adds windows support as a side effect.

Change-Id: I912c1f980f284d01d4f3936291999646ddf6250a
2013-12-11 15:17:06 +00:00
Narayan Kamath
58aaf46e4d Add unit tests for libziparchive.
- Add a build rule for host tests
- Add basic tests for Find / Iterate and Extract
  for both deflated & stored entries.
- Fix an off by one error that the test uncovered.

Change-Id: If72009b1ea9791d5a265829f05c32ffe1c2752c4
2013-12-10 16:48:50 +00:00
Narayan Kamath
eb41ad212e Fix return code for ended iteration.
The API promises a return code of -1 for an
ended iteration and lower negative values for
errors.

Change-Id: I688a1ee2efad1bdfc6959cf27e49c0426ebf27f8
2013-12-09 16:26:36 +00:00
Narayan Kamath
7462f02f82 Unify zipfile implementations : Step 1.
Extract zip file processing logic from libdvm into a
standalone library.

This library is a stricter than the libdvm library in
several ways:
- Duplicate zip entry names are now disallowed. Files with
  such entries will fail to parse.
- We now verify CD file size information with the individual
  file header information. (This was pointed out as a deficiency
  of this implementation in past discussions.)
- We also add support for crc checking, which means we might
  need to parse the optional data descriptor footer (if one
  exists).

We also provide an API for iterating over the entries of
a zip file. This library is optimized for two use cases :

- Lookup for a single entry in the file, with the intention
  of processing or extracting the data associated with that
  entry
- Iterating over all entries in a file *and* processing
  / extracting their data.

Change-Id: Ia87de6184ef753cc470b0af755c47a4f92ac8198
2013-12-04 13:28:40 +00:00