You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Soheila Esmaeili (Jira)" <ji...@apache.org> on 2026/01/12 13:35:00 UTC

[jira] [Commented] (COMPRESS-715) ZipArchiveInputStream fails with "Unexpected record signature: 0x0"

    [ https://issues.apache.org/jira/browse/COMPRESS-715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18051241#comment-18051241 ] 

Soheila Esmaeili commented on COMPRESS-715:
-------------------------------------------

kindly reminder - is there any progress or update on this issue?

> 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)