You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Jerome Lacoste (Created) (JIRA)" <ji...@apache.org> on 2011/12/20 13:39:30 UTC

[jira] [Created] (COMPRESS-169) RuntimeException on corrupted file

RuntimeException on corrupted file
----------------------------------

                 Key: COMPRESS-169
                 URL: https://issues.apache.org/jira/browse/COMPRESS-169
             Project: Commons Compress
          Issue Type: Bug
    Affects Versions: 1.3
            Reporter: Jerome Lacoste
            Priority: Minor


We wrote a tool to simulate file corruption before parsing them with tika. This caused a few strange problems including:

{code}
java.lang.RuntimeException: failed to skip file name in local file header
	at org.apache.commons.compress.archivers.zip.ZipFile.resolveLocalFileHeaderData(ZipFile.java:817)
	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:207)
	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:181)
	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:142)
	at org.apache.tika.parser.pkg.ZipContainerDetector.detect(ZipContainerDetector.java:69)
	at org.apache.tika.detect.CompositeDetector.detect(CompositeDetector.java:60)
	at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:113)
	at org.apache.tika.Tika.parseToString(Tika.java:380)
	at org.apache.tika.Tika.parseToString(Tika.java:414)
	at no.finntech.tika.harderner.TikaIndexerHardenerTest.parseContent(TikaIndexerHardenerTest.java:106)
	at no.finntech.tika.harderner.TikaIndexerHardenerTest.flipBitAndIndexContent(TikaIndexerHardenerTest.java:89)
	at no.finntech.tika.harderner.TikaIndexerHardenerTest.originalFileIndexesProperly4(TikaIndexerHardenerTest.java:34)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
{code}

This is caused by:
{code}
            while (lenToSkip > 0) {
                int skipped = archive.skipBytes(lenToSkip);
                if (skipped <= 0) {
                    throw new RuntimeException("failed to skip file name in"
                                               + " local file header");
                }
                lenToSkip -= skipped;
            }
{code}


Any reason this is using a RuntimeException instead of a IOException ? Changing it to a IOE would solve our problem.

Finally, our test code is available from https://github.com/lacostej/tika-hardener
You might want to reuse similar technique for your other decompressors. Let us know if you want help.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (COMPRESS-169) RuntimeException on corrupted file

Posted by "Stefan Bodewig (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COMPRESS-169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig resolved COMPRESS-169.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.4

fixed with svn revision 1222360

I've put giving the TIKA hardener a try on my TODO list, but that's not really too short anyway.

Thanks!
                
> RuntimeException on corrupted file
> ----------------------------------
>
>                 Key: COMPRESS-169
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-169
>             Project: Commons Compress
>          Issue Type: Bug
>    Affects Versions: 1.3
>            Reporter: Jerome Lacoste
>            Priority: Minor
>             Fix For: 1.4
>
>
> We wrote a tool to simulate file corruption before parsing them with tika. This caused a few strange problems including:
> {code}
> java.lang.RuntimeException: failed to skip file name in local file header
> 	at org.apache.commons.compress.archivers.zip.ZipFile.resolveLocalFileHeaderData(ZipFile.java:817)
> 	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:207)
> 	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:181)
> 	at org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:142)
> 	at org.apache.tika.parser.pkg.ZipContainerDetector.detect(ZipContainerDetector.java:69)
> 	at org.apache.tika.detect.CompositeDetector.detect(CompositeDetector.java:60)
> 	at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:113)
> 	at org.apache.tika.Tika.parseToString(Tika.java:380)
> 	at org.apache.tika.Tika.parseToString(Tika.java:414)
> 	at no.finntech.tika.harderner.TikaIndexerHardenerTest.parseContent(TikaIndexerHardenerTest.java:106)
> 	at no.finntech.tika.harderner.TikaIndexerHardenerTest.flipBitAndIndexContent(TikaIndexerHardenerTest.java:89)
> 	at no.finntech.tika.harderner.TikaIndexerHardenerTest.originalFileIndexesProperly4(TikaIndexerHardenerTest.java:34)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> 	at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
> {code}
> This is caused by:
> {code}
>             while (lenToSkip > 0) {
>                 int skipped = archive.skipBytes(lenToSkip);
>                 if (skipped <= 0) {
>                     throw new RuntimeException("failed to skip file name in"
>                                                + " local file header");
>                 }
>                 lenToSkip -= skipped;
>             }
> {code}
> Any reason this is using a RuntimeException instead of a IOException ? Changing it to a IOE would solve our problem.
> Finally, our test code is available from https://github.com/lacostej/tika-hardener
> You might want to reuse similar technique for your other decompressors. Let us know if you want help.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira