[
https://issues.apache.org/jira/browse/COMPRESS-715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory updated COMPRESS-715:
-------------------------------------
Assignee: Gary D. Gregory
> ZipArchiveInputStream fails with "Unexpected record signature: 0x0"
> -------------------------------------------------------------------
>
> Key: COMPRESS-715
> URL: https://issues.apache.org/jira/browse/COMPRESS-715
> Project: Commons Compress
> Issue Type: Bug
> Affects Versions: 1.28.0
> Reporter: Soheila Esmaeili
> Assignee: Gary D. Gregory
> Priority: Major
> Attachments: testFile.zip
>
>
> We are currently facing an issue that ZipArchiveInputStream throws a
> ZipException with the message "Unexpected record signature: 0x0" when
> processing ZIP archives that contain zero padding. The implementation
> currently rejects signature 0x0 even though it should handle archives with
> zero padding to consume them completely.
>
> *Actual Behavior*
> The method throws:
> java.util.zip.ZipException: Unexpected record signature: 0x0
> at
> org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:847)
>
> *Test Case*
> @Test
> void testShouldConsumeArchiveWithZeroPaddingCompletely() throws Exception {
> try (InputStream is =
> ZipArchiveInputStreamTest.class.getResourceAsStream("/testFile.zip");
> ZipArchiveInputStream zip =
> ZipArchiveInputStream.builder().setInputStream(is).get()) {
> while (zip.getNextZipEntry() != null) {
> // noop
> }
> }
> }
>
>
> *Root Cause*
> In ZipArchiveInputStream.getNextZipEntry() at line 847, the code checks for
> specific signatures and throws an exception for unexpected ones, including
> 0x0.
>
>
> *Suggested Fix*
> Add the check for 0x0 signature in the condition that handles end-of-archive
> scenarios (line 841):
>
> if (sig.equals(ZipLong.CFH_SIG) || sig.equals(ZipLong.AED_SIG) ||
> isApkSigningBlock(lfhBuf) || sig.equals(new ZipLong(0X0L))) {
> hitCentralDirectory = true;
> skipRemainderOfArchive();
> return null;
> }
--
This message was sent by Atlassian Jira
(v8.20.10#820010)