Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5382a520 authored by Adam Lesinski's avatar Adam Lesinski Committed by android-build-merger
Browse files

Merge "ZipWriter: Keep LFH and CFH in sync" am: a309bc49

am: 80d8a935

Change-Id: Ic6b7335a0af0203368fda3f5fb130716229ec0d8
parents 31e27b7b 80d8a935
Loading
Loading
Loading
Loading
+11 −0
Original line number Original line Diff line number Diff line
@@ -563,6 +563,17 @@ static int32_t FindEntry(const ZipArchive* archive, const int ent,


  // Paranoia: Match the values specified in the local file header
  // Paranoia: Match the values specified in the local file header
  // to those specified in the central directory.
  // to those specified in the central directory.

  // Verify that the central directory and local file header agree on the use of a trailing
  // Data Descriptor.
  if ((lfh->gpb_flags & kGPBDDFlagMask) != (cdr->gpb_flags & kGPBDDFlagMask)) {
    ALOGW("Zip: gpb flag mismatch. expected {%04" PRIx16 "}, was {%04" PRIx16 "}",
          cdr->gpb_flags, lfh->gpb_flags);
    return kInconsistentInformation;
  }

  // If there is no trailing data descriptor, verify that the central directory and local file
  // header agree on the crc, compressed, and uncompressed sizes of the entry.
  if ((lfh->gpb_flags & kGPBDDFlagMask) == 0) {
  if ((lfh->gpb_flags & kGPBDDFlagMask) == 0) {
    data->has_data_descriptor = 0;
    data->has_data_descriptor = 0;
    if (data->compressed_length != lfh->compressed_size
    if (data->compressed_length != lfh->compressed_size
+3 −1
Original line number Original line Diff line number Diff line
@@ -479,7 +479,9 @@ int32_t ZipWriter::Finish() {
  for (FileEntry& file : files_) {
  for (FileEntry& file : files_) {
    CentralDirectoryRecord cdr = {};
    CentralDirectoryRecord cdr = {};
    cdr.record_signature = CentralDirectoryRecord::kSignature;
    cdr.record_signature = CentralDirectoryRecord::kSignature;
    if ((file.compression_method & kCompressDeflated) || !seekable_) {
      cdr.gpb_flags |= kGPBDDFlagMask;
      cdr.gpb_flags |= kGPBDDFlagMask;
    }
    cdr.compression_method = file.compression_method;
    cdr.compression_method = file.compression_method;
    cdr.last_mod_time = file.last_mod_time;
    cdr.last_mod_time = file.last_mod_time;
    cdr.last_mod_date = file.last_mod_date;
    cdr.last_mod_date = file.last_mod_date;