[
https://issues.apache.org/jira/browse/COMPRESS-591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17416947#comment-17416947
]
Lasse Collin commented on COMPRESS-591:
---------------------------------------
I'm aware of only two downsides. Weaker error detection doesn't matter because
in .7z there is CRC32 anyway. The patch only affects handling of the 7z format
so it won't make error detection worse in other LZMA uses.
Another downside is that less input might be read than the actual compressed
size. Does this matter in the 7z code inside Commons Compress?
It is true that the code in 7-Zip is more sophisticated. It tries to sniff if
the end marker is possibly present and (compared to my patch) it's more strict
about what inputs are accepted. That is, with enableRelaxedEndCondition(),
Commons Compress might accept files that 7-Zip would reject. Such files would
need to be intentionally created as accidental corruption would likely get
caught by CRC32. While this might be a problem in some situations, I think
overall the patch is still an improvement as currently Commons Compress can
reject valid 7z files.
Whatever the eventual fix will be, I think it shouldn't be an option. 7-Zip
handles both LZMA stream types silently inside 7z files and so should other 7z
implementations.
> Fix decoding of 7z files containing LZMA streams with end marker
> ----------------------------------------------------------------
>
> Key: COMPRESS-591
> URL: https://issues.apache.org/jira/browse/COMPRESS-591
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Affects Versions: 1.21
> Reporter: Lasse Collin
> Priority: Major
> Attachments: lzma-with-eos.7z
>
>
> Some uncommon but valid .7z files contain LZMA streams that use the end of
> stream marker. Currently Commons Compress together with XZ for Java considers
> such files to be corrupt.
> XZ for Java 1.9 added a new methodÂ
> [LZMAInputStream.enableRelaxedEndCondition()|https://tukaani.org/xz/xz-javadoc/org/tukaani/xz/LZMAInputStream.html#enableRelaxedEndCondition()]
> specifically for this issue. To use this feature in Commons Compress, a
> change is needed to the "decode" function in
> src/main/java/org/apache/commons/compress/archivers/sevenz/LZMADecoder.java:
> {{- return new LZMAInputStream(in, uncompressedLength, propsByte, dictSize);}}
> {{+ final LZMAInputStream lzmaIn = new LZMAInputStream(in,
> uncompressedLength, propsByte, dictSize);}}
> {{+ lzmaIn.enableRelaxedEndCondition();}}
> {{+ return lzmaIn;}}
> A tiny test file is attached (thanks to Simon for providing it). Another test
> file "sheet.7z" can be found from
> <[https://sourceforge.net/p/lzmautils/discussion/708858/thread/822d80d5ea/]>.
> XZ for Java 1.9 is already a few months old, so I apologize for not reporting
> this earlier.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)