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

Commit b054582b authored by Narayan Kamath's avatar Narayan Kamath Committed by Gerrit Code Review
Browse files

Merge "libziparchive: fix issue with a directory with one file"

parents ee2e362f 50afc159
Loading
Loading
Loading
Loading
+886 B

File added.

No diff preview for this file type.

+1 −1
Original line number Diff line number Diff line
@@ -824,7 +824,7 @@ static int32_t FindEntry(const ZipArchive* archive, const int ent,
  // name in the central directory.
  if (lfh->file_name_length == nameLen) {
    const off64_t name_offset = local_header_offset + sizeof(LocalFileHeader);
    if (name_offset + lfh->file_name_length >= cd_offset) {
    if (name_offset + lfh->file_name_length > cd_offset) {
      ALOGW("Zip: Invalid declared length");
      return kInvalidOffset;
    }
+16 −0
Original line number Diff line number Diff line
@@ -171,6 +171,22 @@ TEST(ziparchive, FindEntry) {
  CloseArchive(handle);
}

TEST(ziparchive, TestInvalidDeclaredLength) {
  ZipArchiveHandle handle;
  ASSERT_EQ(0, OpenArchiveWrapper("declaredlength.zip", &handle));

  void* iteration_cookie;
  ASSERT_EQ(0, StartIteration(handle, &iteration_cookie, NULL));

  ZipEntryName name;
  ZipEntry data;

  ASSERT_EQ(Next(iteration_cookie, &data, &name), 0);
  ASSERT_EQ(Next(iteration_cookie, &data, &name), 0);

  CloseArchive(handle);
}

TEST(ziparchive, ExtractToMemory) {
  ZipArchiveHandle handle;
  ASSERT_EQ(0, OpenArchiveWrapper(kValidZip, &handle));