Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-301

Illegal argument exception when extracting .tgz file

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: 1.8.1, 1.9
    • Fix Version/s: None
    • Component/s: Compressors
    • Labels:
      None
    • Environment:

      Mac OSX 10.10.2

      Description

      When attempting to unpack a .tgz file, I am receiving the illegal argument exception: java.lang.IllegalArgumentException: Invalid byte 0 at offset 5 in '05412

      {NUL}11' len=8. This is causing a java.io.IOException: Error detected parsing the header error.

      This is being thrown when the function TarArchiveInputStream.getNextTarEntry() is called.

      Here is the code I am using.
                  TarArchiveInputStream tarIn = new TarArchiveInputStream(
                          new GZIPInputStream(
                                  new BufferedInputStream(
                                          new FileInputStream(
                                                  tempDirPath + fileName))));
      
                  TarArchiveEntry entry = tarIn.getNextTarEntry();
      
                  while (entry != null) {
                      File path = new File(tempDirPath, entry.getName());
                      if (entry.isDirectory()) {
                          path.mkdirs();
                      } else {          
                          path.createNewFile();
                          byte[] read = new byte[2048];
                          BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(path));
                          int len;
                          while ((len = tarIn.read(read)) != -1) {
                              bout.write(read, 0, len);
                              System.out.print(new String(read, "UTF-8"));
                          }
                          bout.close();
                          read = null;
                      }
                      entry = tarIn.getNextTarEntry();
                  }
                  tarIn.close();
      


      Here is the full stack trace:

      [2015-02-12T23:17:31.944+0000] [glassfish 4.0] [SEVERE] [] [] [tid: _ThreadID=123 _ThreadName=Thread-4] [timeMillis: 1423783051944] [levelValue: 1000] [[
      java.io.IOException: Error detected parsing the header
      at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:257)
      at org.unavco.ws.tilt.ExtractTiltFile.extractFile(ExtractTiltFile.java:125)
      at org.unavco.ws.tilt.ExtractTiltFile.run(ExtractTiltFile.java:59)
      at org.unavco.ws.cache.ProcessDataFile.getFileData(ProcessDataFile.java:100)
      at org.unavco.ws.cache.ProcessDataFile.getResultSet(ProcessDataFile.java:81)
      at org.unavco.ws.tilt.TiltDsClient.write(TiltDsClient.java:47)
      at org.glassfish.jersey.message.internal.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:76)
      at org.glassfish.jersey.message.internal.StreamingOutputProvider.writeTo(StreamingOutputProvider.java:58)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:194)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
      at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:103)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
      at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:88)
      at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
      at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1005)
      at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:471)
      at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:333)
      at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:323)
      at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:227)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
      at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198)
      at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946)
      at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:323)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
      at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
      at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
      at com.thetransactioncompany.cors.CORSFilter.doFilter(Unknown Source)
      at com.thetransactioncompany.cors.CORSFilter.doFilter(Unknown Source)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
      at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
      at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
      at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:745)
      Caused by: java.lang.IllegalArgumentException: Invalid byte 0 at offset 5 in '05412{NUL}

      11' len=8
      at org.apache.commons.compress.archivers.tar.TarUtils.parseOctal(TarUtils.java:138)
      at org.apache.commons.compress.archivers.tar.TarUtils.parseOctalOrBinary(TarUtils.java:169)
      at org.apache.commons.compress.archivers.tar.TarArchiveEntry.parseTarHeader(TarArchiveEntry.java:951)
      at org.apache.commons.compress.archivers.tar.TarArchiveEntry.parseTarHeader(TarArchiveEntry.java:940)
      at org.apache.commons.compress.archivers.tar.TarArchiveEntry.<init>(TarArchiveEntry.java:324)
      at org.apache.commons.compress.archivers.tar.TarArchiveInputStream.getNextTarEntry(TarArchiveInputStream.java:255)
      ... 63 more]]

        Attachments

        1. P693.201212614Tilt.tgz
          91 kB
          Collin Molnar

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              molnar Collin Molnar
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: