Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286174

ZipInputStream and GZIPInputStream do not work correctly anymore on Alpine Linux

    XMLWordPrintable

Details

    • generic
    • generic
    • Verified

    Description

      A DESCRIPTION OF THE PROBLEM :
      The classes ZipInputStream and GZIPInputStream stopped working correctly on Alpine Linux. For well-formed zip respectively gzip files they throw:
      ```
      Exception java.util.zip.ZipException: invalid entry CRC (expected 0x31c74d2a but got 0xeb5ae575)
          at ZipInputStream.readEnd (ZipInputStream.java:410)
          at ZipInputStream.read (ZipInputStream.java:199)
          at ZipInputStream.skip (ZipInputStream.java:252)
      ```
      ```
      Exception java.util.zip.ZipException: Corrupt GZIP trailer
          at GZIPInputStream.readTrailer (GZIPInputStream.java:226)
          at GZIPInputStream.read (GZIPInputStream.java:120)
          at InflaterInputStream.skip (InflaterInputStream.java:213)
      ```

      I don't know when they first stopped working correctly. For Eclipse Temurin it seems to have happened between 11.0.13_8 (Docker image `eclipse-temurin:11.0.13_8-jdk-alpine`; works correctly) and 11.0.15_10 (Docker image ` eclipse-temurin:11.0.15_10-jdk-alpine`; does not work correctly). Not sure if they backported any commits (such as JDK-8281962).

      For the OpenJDK I used the Docker image `openjdk:19-jdk-alpine` to reproduce this.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Start a Docker container
          ```
          docker run -it --rm openjdk:19-jdk-alpine sh
          ```
      2. Download the sample zip file
          ```
          wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_x64_windows_hotspot_17.0.2_8.zip -O test.zip
          ```
          Note: This sample zip file happens to be a Temurin binary because this is where I first noticed the issue; other zip files are likely affected as well.
      3. Verify that the zip file is complete
          ```
          echo "d083479ca927dce2f586f779373d895e8bf668c632505740279390384edf03fa test.zip" | sha256sum -c -
          ```
      4. Download the sample gzip file
          ```
          wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.2%2B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.2_8.tar.gz -O test.tar.gz
          ```
          Note: This sample gzip file happens to be a Temurin binary because this is where I first noticed the issue; other gzip files are likely affected as well.
      5. Verify that the gzip file is complete
          ```
          echo "288f34e3ba8a4838605636485d0365ce23e57d5f2f68997ac4c2e4c01967cd48 test.tar.gz" | sha256sum -c -
          ```
      6. Start `jshell`
      7. Within `jshell` run the following code
          ```java
          var in = new java.util.zip.ZipInputStream(Files.newInputStream(Path.of("test.zip")));
          while (in.getNextEntry() != null) {
              while (in.read() != -1) {
                  in.skip(10000);
              }
          }
          ```
          Bug: It fails with "ZipException: invalid entry CRC"
      8. Within `jshell` run the following code
          ```java
          var in = new java.util.zip.GZIPInputStream(Files.newInputStream(Path.of("test.tar.gz")));
          while (in.read() != -1) {
              in.skip(10000);
          }
          ```
          Bug: It fails with "ZipException: Corrupt GZIP trailer"


      Repeat the same steps for a non-Alpine OS to verify that the zip and gzip files are valid, and that no exceptions are thrown there.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      ZipInputStream and GZIPInputStream should read the files without any issues.
      ACTUAL -
      ZipInputStream and GZIPInputStream throw exceptions while reading the files.

      FREQUENCY : always


      Attachments

        Activity

          People

            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: