diff options
author | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-09-08 19:06:39 +0200 |
---|---|---|
committer | Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de> | 2017-09-08 19:06:39 +0200 |
commit | 0d3103c84bbe5a5058c9b4abbc9d0892c4d6b38d (patch) | |
tree | 0ec0f8af7d2b8349514fd6a4d4bf2b449f3fdd57 | |
parent | 69bd3aed62890937aadd8ab93ebe14ef230ca47e (diff) | |
parent | 4f84775fef93119cb80be7bd93b6bfaf8c02b192 (diff) | |
download | system_core-0d3103c84bbe5a5058c9b4abbc9d0892c4d6b38d.tar.gz system_core-0d3103c84bbe5a5058c9b4abbc9d0892c4d6b38d.tar.bz2 system_core-0d3103c84bbe5a5058c9b4abbc9d0892c4d6b38d.zip |
Merge remote-tracking branch 'lineageos/cm-13.0' into replicant-6.0replicant-6.0-0002
-rw-r--r-- | libziparchive/zip_archive.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc index a17091f95..8c2c559b1 100644 --- a/libziparchive/zip_archive.cc +++ b/libziparchive/zip_archive.cc @@ -580,6 +580,14 @@ static int32_t ParseZipArchive(ZipArchive* archive) { const uint8_t* const cd_end = cd_ptr + cd_length; const uint8_t* ptr = cd_ptr; for (uint16_t i = 0; i < num_entries; i++) { + if (ptr > cd_end - sizeof(CentralDirectoryRecord)) { + ALOGW("Zip: ran off the end (at %" PRIu16 ")", i); +#if defined(__ANDROID__) + android_errorWriteLog(0x534e4554, "36392138"); +#endif + return -1; + } + const CentralDirectoryRecord* cdr = reinterpret_cast<const CentralDirectoryRecord*>(ptr); if (cdr->record_signature != CentralDirectoryRecord::kSignature) { @@ -587,11 +595,6 @@ static int32_t ParseZipArchive(ZipArchive* archive) { return -1; } - if (ptr + sizeof(CentralDirectoryRecord) > cd_end) { - ALOGW("Zip: ran off the end (at %" PRIu16 ")", i); - return -1; - } - const off64_t local_header_offset = cdr->local_file_header_offset; if (local_header_offset >= archive->directory_offset) { ALOGW("Zip: bad LFH offset %" PRId64 " at entry %" PRIu16, |