From 94cc0985ea07a2d69ef07ac9d3a9943e094794f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?X=C3=B9d=C5=8Dng=20Y=C3=A1ng?= Date: Fri, 8 Apr 2022 17:02:22 +0200 Subject: [PATCH] Support ZIP files with total number of disks = 0 (#15200) We came across [a problem](https://buildkite.com/bazel/intellij-plugin/builds/15968#0863eaa6-499b-46a2-a146-79d4c2b830c0) adding a jar provided by IntelliJ in its 2022.1 (lib/app.jar) to a `java_import` target because the jar in this version has a total number of disks = 0. This value is supported by other tools: https://github.com/python/cpython/blob/main/Lib/zipfile.py#L258 PiperOrigin-RevId: 440322029 Co-authored-by: messa --- third_party/ijar/zip.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/third_party/ijar/zip.cc b/third_party/ijar/zip.cc index ef8479ee2d6371..45b7fc7598eac5 100644 --- a/third_party/ijar/zip.cc +++ b/third_party/ijar/zip.cc @@ -707,7 +707,8 @@ bool FindZip64CentralDirectory(const u1 *bytes, size_t in_length, if (MaybeReadZip64CentralDirectory(bytes, in_length, bytes + zip64_end_of_central_dir_offset, end_of_central_dir, cd)) { - if (disk_with_zip64_central_directory != 0 || zip64_total_disks != 1) { + // TODO(b/228519294) Add a test for a valid zip64 file with total disks = 0 + if (disk_with_zip64_central_directory != 0 || zip64_total_disks > 1) { fprintf(stderr, "multi-disk JAR files are not supported\n"); return false; }