You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Matthew Bellew (JIRA)" <ji...@apache.org> on 2010/02/11 04:00:28 UTC
[jira] Updated: (COMPRESS-96) Corrupt zip files can cause infinite
loop
[ https://issues.apache.org/jira/browse/COMPRESS-96?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Matthew Bellew updated COMPRESS-96:
-----------------------------------
Description:
I have a corrupt .zip file (in my Download directory) that causes ZipArchiveInputStream to enter an infinite loop on the second call to getEntry(). This was discovered while testing a Tika/Lucene based search application. Obviously, it would be preferable to detect and throw an exception. The short explanation is that closeEntry() calls skip(Long.MAX_VALUE). skip() calls read() which returns 0 and inf.finished() remains false, so no progress is made and skip() spins.
If it helps, entry.getSize() returns -1 for the first entry. I can provide the file to repro (775800 bytes).
UPDATE: I just hit he same error scanning commons-compress-1.0-bin.zip with this code (and the code work fine for many other zip files)
package main;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class Main
{
public static void main(String[] args) throws IOException
{
File f = new File(args[0]);
FileInputStream fis = new FileInputStream(f);
ZipArchiveInputStream zip = new ZipArchiveInputStream(fis);
ArchiveEntry entry;
entry = zip.getNextEntry();
while (null != entry)
{
if (entry.isDirectory())
System.out.printf("%s/\n", entry.getName());
else
System.out.printf("%s %d\n", entry.getName(), entry.getSize());
entry = zip.getNextEntry();
}
System.out.print("DONE\n");
}
}
was:
I have a corrupt .zip file (in my Download directory) that causes ZipArchiveInputStream to enter an infinite loop on the second call to getEntry(). This was discovered while testing a Tika/Lucene based search application. Obviously, it would be preferable to detect and throw an exception. The short explanation is that closeEntry() calls skip(Long.MAX_VALUE). skip() calls read() which returns 0 and inf.finished() remains false, so no progress is made and skip() spins.
If it helps, entry.getSize() returns -1 for the first entry. I can provide the file to repro (775800 bytes).
> Corrupt zip files can cause infinite loop
> -----------------------------------------
>
> Key: COMPRESS-96
> URL: https://issues.apache.org/jira/browse/COMPRESS-96
> Project: Commons Compress
> Issue Type: Bug
> Affects Versions: 1.0
> Environment: OS/X java 1.6
> Reporter: Matthew Bellew
> Priority: Critical
>
> I have a corrupt .zip file (in my Download directory) that causes ZipArchiveInputStream to enter an infinite loop on the second call to getEntry(). This was discovered while testing a Tika/Lucene based search application. Obviously, it would be preferable to detect and throw an exception. The short explanation is that closeEntry() calls skip(Long.MAX_VALUE). skip() calls read() which returns 0 and inf.finished() remains false, so no progress is made and skip() spins.
> If it helps, entry.getSize() returns -1 for the first entry. I can provide the file to repro (775800 bytes).
> UPDATE: I just hit he same error scanning commons-compress-1.0-bin.zip with this code (and the code work fine for many other zip files)
> package main;
> import org.apache.commons.compress.archivers.ArchiveEntry;
> import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
> import java.io.File;
> import java.io.FileInputStream;
> import java.io.IOException;
> public class Main
> {
> public static void main(String[] args) throws IOException
> {
> File f = new File(args[0]);
> FileInputStream fis = new FileInputStream(f);
> ZipArchiveInputStream zip = new ZipArchiveInputStream(fis);
> ArchiveEntry entry;
> entry = zip.getNextEntry();
> while (null != entry)
> {
> if (entry.isDirectory())
> System.out.printf("%s/\n", entry.getName());
> else
> System.out.printf("%s %d\n", entry.getName(), entry.getSize());
> entry = zip.getNextEntry();
> }
> System.out.print("DONE\n");
> }
> }
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.