diff options
author | Steven Laver <lavers@google.com> | 2020-04-14 08:17:16 -0700 |
---|---|---|
committer | Steven Laver <lavers@google.com> | 2020-04-14 08:17:16 -0700 |
commit | 6377bb8fa531e15ee5fa10ffbcd1882fda46a1cc (patch) | |
tree | 5e1c70a0dc02885ec5c47ecc270f4a7b65eb0513 /libziparchive/zip_archive.cc | |
parent | d9f287a3f37aae38c47f76e18b6f9d0d300c9247 (diff) | |
parent | 9403fa4ac16cece623145b139c523fe684cad6ee (diff) |
Merge RP1A.200414.001
Change-Id: I5c1d78b2229f3cd244dc4cb29c8f21ae0d1b2fe8
Diffstat (limited to 'libziparchive/zip_archive.cc')
-rw-r--r-- | libziparchive/zip_archive.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc index 958c34b61d..fb2a1d2204 100644 --- a/libziparchive/zip_archive.cc +++ b/libziparchive/zip_archive.cc @@ -60,7 +60,7 @@ using android::base::get_unaligned; // Used to turn on crc checks - verify that the content CRC matches the values // specified in the local file header and the central directory. -static const bool kCrcChecksEnabled = false; +static constexpr bool kCrcChecksEnabled = false; // The maximum number of bytes to scan backwards for the EOCD start. static const uint32_t kMaxEOCDSearch = kMaxCommentLen + sizeof(EocdRecord); @@ -1076,11 +1076,15 @@ static int32_t CopyEntryToWriter(MappedZipFile& mapped_zip, const ZipEntry* entr if (!writer->Append(&buf[0], block_size)) { return kIoError; } - crc = crc32(crc, &buf[0], block_size); + if (crc_out) { + crc = crc32(crc, &buf[0], block_size); + } count += block_size; } - *crc_out = crc; + if (crc_out) { + *crc_out = crc; + } return 0; } @@ -1092,9 +1096,11 @@ int32_t ExtractToWriter(ZipArchiveHandle archive, ZipEntry* entry, zip_archive:: int32_t return_value = -1; uint64_t crc = 0; if (method == kCompressStored) { - return_value = CopyEntryToWriter(archive->mapped_zip, entry, writer, &crc); + return_value = + CopyEntryToWriter(archive->mapped_zip, entry, writer, kCrcChecksEnabled ? &crc : nullptr); } else if (method == kCompressDeflated) { - return_value = InflateEntryToWriter(archive->mapped_zip, entry, writer, &crc); + return_value = InflateEntryToWriter(archive->mapped_zip, entry, writer, + kCrcChecksEnabled ? &crc : nullptr); } if (!return_value && entry->has_data_descriptor) { |