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

CRC check fails for files over 2 GB

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 5.0
    • 1.4.0, 1.4.1
    • core-libs
    • tiger
    • x86, sparc
    • solaris_7, windows_2000



      Name: nt126004 Date: 12/17/2002


      FULL PRODUCT VERSION :
      java version "1.4.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
      Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

      FULL OPERATING SYSTEM VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]


      A DESCRIPTION OF THE PROBLEM :
      CRC check in always failed when the file is bigger than 2GB.
      The code and error show below.




      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.create a file bigger than 2GB
      2.change the code read file by your created file
      3.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      it can pass the CRC check and no error throw

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      entry:TEST_UF024.RAW/_extern.inf
      Before while:801
      Finish while loop.
      entry:TEST_UF024.RAW/_FUNC001.DAT
      Before while:688
      IOError:invalid entry size (expected 2147491650 but got -2147475646 bytes)
      java.util.zip.ZipException: invalid entry size (expected 2147491650 but got -2147475646 bytes)
              at java.util.zip.ZipInputStream.readEnd(Unknown Source)
              at java.util.zip.ZipInputStream.read(Unknown Source)
              at java.io.FilterInputStream.read(Unknown Source)
              at CRCTest.checkCRCFile(CRCTest.java:31)
              at CRCTest.main(CRCTest.java:56)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.zip.*;
      import java.io.*;

      public class CRCTest{

      public CRCTest(){}


      public void checkCRCFile(String inStrFileAbsolutePath) throws IOException, DataFormatException
      {

          final int BUFFER = 1024*1024;
          byte[] buffData = new byte[BUFFER];
          FileInputStream fis = new FileInputStream(inStrFileAbsolutePath);
          BufferedInputStream bis = new BufferedInputStream(fis,BUFFER);
          ZipInputStream zis = new ZipInputStream(bis);


          for(ZipEntry nextZipEntry = zis.getNextEntry(); nextZipEntry != null; nextZipEntry =
      zis.getNextEntry())
          {
                System.out.println("entry:"+nextZipEntry);
            if (!nextZipEntry.isDirectory())
            {
              CRC32 crcGenerated = new CRC32();

              int count = zis.read(buffData);

              System.out.println("Before while:"+count);
              while (count != -1) {
                  crcGenerated.update(buffData, 0, count);
                  count = zis.read(buffData);
              }

              System.out.println("Finish while loop.");

              long lCRC32FromZip = nextZipEntry.getCrc();

              if (lCRC32FromZip == -1)
                throw new DataFormatException("CRC Not present in File " + nextZipEntry.getName());

              if (lCRC32FromZip != crcGenerated.getValue())
                throw new DataFormatException("CRC Error " + nextZipEntry.getName() + " ZipCRC=" +
      lCRC32FromZip + " CalculatedCRC=" + crcGenerated.getValue());
            }
          }

          zis.close();
          bis.close();
          fis.close();

        }

         public static void main(String args[]) {
              CRCTest crc = new CRCTest();

              try {
                      crc.checkCRCFile("c:\\temp\\TEST_UF024.RAW.ZIP");
                      System.out.println("CRC Check success.");
              }catch(IOException ioe){
                      System.out.println("IOError:");
      ioe.printStackTrace();
              }catch(DataFormatException fe){
                      System.out.println("DataFormatError:");
      fe.printStackTrace();
              }catch(Exception e){
                      System.out.println("OtherError:");
      e.printStackTrace();
              }

        }
      }
      ---------- END SOURCE ----------
      (Review ID: 178849)
      ======================================================================

            martin Martin Buchholz
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: