[ 
https://issues.apache.org/jira/browse/COMPRESS-681?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

johnikezheng updated COMPRESS-681:
----------------------------------
    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:
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);
  }
  */

> SevenZFile can't open 7z files containing ArchiveProperties
> -----------------------------------------------------------
>
>                 Key: COMPRESS-681
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-681
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Archivers
>    Affects Versions: 1.26.2
>            Reporter: johnikezheng
>            Priority: Major
>
> 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:
> 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);
>   }
>   */



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to