Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-681

SevenZFile can't open 7z files containing ArchiveProperties

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.26.2
    • 1.27.0
    • Archivers
    • None

    Description

      I added archive properies based on the example provided in the official 7zip code and was able to decompress it properly using the 7zip tool, but when I decompress it using commons-compress I get the following error(The COMMPRESS-681.7z is in attachment):

      code:
          SevenZFile.builder().setPath(Paths.get(("COMPRESS-681.7z"))).get();
      
      Below is the output I receive:
      
      java.io.IOException: invalid property size
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.sanityCheckArchiveProperties(SevenZFile.java:1746)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.sanityCheckAndCollectStatistics(SevenZFile.java:1715)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.readHeader(SevenZFile.java:1437)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.initializeArchive(SevenZFile.java:1081)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.readHeaders(SevenZFile.java:1499)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.<init>(SevenZFile.java:619)
          at org.apache.commons.compress.archivers.sevenz.SevenZFile.<init>(SevenZFile.java:83) 

      Example of writing to an archive file from the official 7zip source code, 7zOut.cpp:

       /*
        {
          // It's example for per archive properies writing
       
          WriteByte(NID::kArchiveProperties);
          // you must use random 40-bit number that will identify you
          // then you can use same kDeveloperID for any properties and methods
          const UInt64 kDeveloperID = 0x123456789A; // change that value to real random 40-bit number
          #define GENERATE_7Z_ID(developerID, subID) (((UInt64)0x3F << 56) | ((UInt64)developerID << 16) | subID)
         
      {       const UInt64 kSubID = 0x1; // you can use small number for subID       const UInt64 kID = GENERATE_7Z_ID(kDeveloperID, kSubID);       WriteNumber(kID);       const unsigned kPropsSize = 3; // it's example size       WriteNumber(kPropsSize);       for (unsigned i = 0; i < kPropsSize; i++)         WriteByte((Byte)(i & 0xFF));     }
         
      {       const UInt64 kSubID = 0x2; // you can use small number for subID       const UInt64 kID = GENERATE_7Z_ID(kDeveloperID, kSubID);       WriteNumber(kID);       const unsigned kPropsSize = 5; // it's example size       WriteNumber(kPropsSize);       for (unsigned i = 0; i < kPropsSize; i++)         WriteByte((Byte)(i + 16));     }
          WriteByte(NID::kEnd);
        }
        */ 

      Attachments

        1. COMPRESS-681.7z
          0.2 kB
          johnikezheng

        Activity

          People

            Unassigned Unassigned
            jokerni53 johnikezheng
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: