You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/06/28 14:02:00 UTC
[jira] [Resolved] (COMPRESS-681) SevenZFile can't open 7z files containing ArchiveProperties
[ https://issues.apache.org/jira/browse/COMPRESS-681?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gary D. Gregory resolved COMPRESS-681.
--------------------------------------
Fix Version/s: 1.27.0
Resolution: Fixed
> 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
> Fix For: 1.27.0
>
> Attachments: COMPRESS-681.7z
>
>
> 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:java}
> 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) {code}
> Example of writing to an archive file from the official 7zip source code, 7zOut.cpp:
> {code:java}
> /*
> {
> // 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);
> }
> */ {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)