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

Commit 2d319cda authored by Narayan Kamath's avatar Narayan Kamath Committed by android-build-merger
Browse files

Fix full-eng build breakage due to dbacd826. am: 6e39c88b am:...

Fix full-eng build breakage due to dbacd826. am: 6e39c88b am: cb3d7938 am: 9fd1c2fe am: 6f5467da am: a76b9888 am: 9c44d486 am: cab99bb0 am: da66154b am: 752ab47b
am: fe9a7192

Change-Id: Ic09929e88fb415a3c1a9279c060bbc1ec2b24380
parents 53f49bc4 fe9a7192
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -652,7 +652,7 @@ TEST(ziparchive, StreamUncompressedBadCrc) {
// Manual changes :
// [2] = 0xff  // Corrupt the LFH signature of entry 0.
// [3] = 0xff  // Corrupt the LFH signature of entry 0.
static const std::vector<uint8_t> kZipFileWithBrokenLfhSignature{
static const uint8_t kZipFileWithBrokenLfhSignature[] = {
    //[lfh-sig-----------], [lfh contents---------------------------------
    0x50, 0x4b, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x80,
    //--------------------------------------------------------------------
@@ -683,12 +683,16 @@ static const std::vector<uint8_t> kZipFileWithBrokenLfhSignature{
    0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00};

TEST(ziparchive, BrokenLfhSignature) {
  TemporaryFile tmp_file;
  ASSERT_NE(-1, tmp_file.fd);
  ASSERT_TRUE(android::base::WriteFully(tmp_file.fd, &kZipFileWithBrokenLfhSignature[0],
                                        kZipFileWithBrokenLfhSignature.size()));
  char kTempFilePattern[] = "zip_archive_input_XXXXXX";
  int fd = make_temporary_file(kTempFilePattern);
  ASSERT_NE(-1, fd);

  ASSERT_EQ(static_cast<int32_t>(sizeof(kZipFileWithBrokenLfhSignature)),
      TEMP_FAILURE_RETRY(write(fd, kZipFileWithBrokenLfhSignature,
                               sizeof(kZipFileWithBrokenLfhSignature))));
  ZipArchiveHandle handle;
  ASSERT_EQ(-1, OpenArchiveFd(tmp_file.fd, "LeadingNonZipBytes", &handle));
  ASSERT_EQ(-1, OpenArchiveFd(fd, "LeadingNonZipBytes", &handle));
  close(fd);
}

int main(int argc, char** argv) {