diff options
author | Piotr Jastrzebski <haaawk@google.com> | 2014-08-15 12:53:00 +0100 |
---|---|---|
committer | Piotr Jastrzebski <haaawk@google.com> | 2014-08-19 11:02:58 +0100 |
commit | 78271ba97b5d867e3597b7fc2257dd1bbd513b05 (patch) | |
tree | 2a61b66b34059658444392c8d7ae13eb50631676 | |
parent | 7fb0ee0c4d3ba83ec960493e43cba9cfa7a6130f (diff) | |
download | system_core-78271ba97b5d867e3597b7fc2257dd1bbd513b05.tar.gz system_core-78271ba97b5d867e3597b7fc2257dd1bbd513b05.tar.bz2 system_core-78271ba97b5d867e3597b7fc2257dd1bbd513b05.zip |
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
-rw-r--r-- | libziparchive/zip_archive.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc index 24088bb93..5008bf27a 100644 --- a/libziparchive/zip_archive.cc +++ b/libziparchive/zip_archive.cc @@ -640,9 +640,15 @@ static int32_t ParseZipArchive(ZipArchive* archive) { const uint16_t file_name_length = cdr->file_name_length; const uint16_t extra_length = cdr->extra_field_length; const uint16_t comment_length = cdr->comment_length; + const uint8_t* file_name = ptr + sizeof(CentralDirectoryRecord); + + /* check that file name doesn't contain \0 character */ + if (memchr(file_name, 0, file_name_length) != NULL) { + ALOGW("Zip: entry name can't contain \\0 character"); + goto bail; + } /* add the CDE filename to the hash table */ - const uint8_t* file_name = ptr + sizeof(CentralDirectoryRecord); ZipEntryName entry_name; entry_name.name = file_name; entry_name.name_length = file_name_length; |