Fix out of bound read in libziparchive am: d9fd1863f4 am: 6908996434
am: 25c0d68d29
Change-Id: I81cde93d4a07077ef54a46d589db868019ac1520
This commit is contained in:
commit
ed33065bfc
1 changed files with 8 additions and 5 deletions
|
|
@ -580,6 +580,14 @@ static int32_t ParseZipArchive(ZipArchive* archive) {
|
||||||
const uint8_t* const cd_end = cd_ptr + cd_length;
|
const uint8_t* const cd_end = cd_ptr + cd_length;
|
||||||
const uint8_t* ptr = cd_ptr;
|
const uint8_t* ptr = cd_ptr;
|
||||||
for (uint16_t i = 0; i < num_entries; i++) {
|
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 =
|
const CentralDirectoryRecord* cdr =
|
||||||
reinterpret_cast<const CentralDirectoryRecord*>(ptr);
|
reinterpret_cast<const CentralDirectoryRecord*>(ptr);
|
||||||
if (cdr->record_signature != CentralDirectoryRecord::kSignature) {
|
if (cdr->record_signature != CentralDirectoryRecord::kSignature) {
|
||||||
|
|
@ -587,11 +595,6 @@ static int32_t ParseZipArchive(ZipArchive* archive) {
|
||||||
return -1;
|
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;
|
const off64_t local_header_offset = cdr->local_file_header_offset;
|
||||||
if (local_header_offset >= archive->directory_offset) {
|
if (local_header_offset >= archive->directory_offset) {
|
||||||
ALOGW("Zip: bad LFH offset %" PRId64 " at entry %" PRIu16,
|
ALOGW("Zip: bad LFH offset %" PRId64 " at entry %" PRIu16,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue