Ticket #15596

TAR展開でエラー(bad header)

Date d'ouverture: 2009-03-18 09:58 Dernière mise à jour: 2009-03-18 21:51

Rapporteur:
(Anonyme)
Propriétaire:
Type:
État:
Atteints
Composant:
(Aucun)
Priorité:
5 - moyen
Sévérité:
7
Résolution:
Fixed
Fichier:
Aucun

Détails

TARファイルを展開しようとすると、以下のエラーになる。

$ arm xvf test.tar
(中略)
armadillo: I/O error - bad header: size=-1            

最初のエントリだけ展開されるが、このファイルが元のデータよりも異常に大きい。

Ticket History (3/3 Histories)

2009-03-18 09:58 Updated by: None
  • New Ticket "TAR展開でエラー(bad header)" created
2009-03-18 10:05 Updated by: argius
  • Résolution Update from Aucun to Later
Commentaire

"#15565 ZipInputStreamでエントリのダンプが上手くいかない"によるデグレード。

但し、元の構造が不適当だったのも問題。

以下は修正パッチ。

Index: src/jp/sourceforge/armadillo/tar/TarInputStream.java
===================================================================
--- src/jp/sourceforge/armadillo/tar/TarInputStream.java	(revision 17)
+++ src/jp/sourceforge/armadillo/tar/TarInputStream.java	(working copy)
@@ -31,6 +31,7 @@
         super(is);
         this.header = new TarHeader(charsetName);
         this.skipSize = 0;
+        frontStream = is;
     }
 
     /**
Index: src/jp/sourceforge/armadillo/io/ArchiveInputStream.java
===================================================================
--- src/jp/sourceforge/armadillo/io/ArchiveInputStream.java	(revision 17)
+++ src/jp/sourceforge/armadillo/io/ArchiveInputStream.java	(working copy)
@@ -37,17 +37,19 @@
      */
     public int read() throws IOException {
         ensureOpen();
-        if (frontStream != null && remaining <= 0) {
+        if (frontStream == null) {
+            return super.read();
+        } else if (remaining <= 0) {
             assert remaining == 0;
             return -1;
-        }
-        InputStream is = (frontStream == null) ? in : frontStream;
-        int read = is.read();
-        if (read == -1) {
-            return -1;
+        } else {
+            int read = frontStream.read();
+            if (read == -1) {
+                return -1;
+            }
+            --remaining;
+            return read;
         }
-        --remaining;
-        return read;
     }
 
     /* (overridden)
@@ -55,16 +57,19 @@
      */
     public int read(byte[] b, int off, int len) throws IOException {
         ensureOpen();
-        if (frontStream != null && remaining <= 0) {
+        if (frontStream == null) {
+            return super.read(b, off, len);
+        } else if (remaining <= 0) {
             assert remaining == 0;
             return -1;
-        }
-        InputStream is = (frontStream == null) ? in : frontStream;
-        int readLength = is.read(b, off, (int)Math.min(len, remaining));
-        if (readLength >= 0) {
-            remaining -= readLength;
+        } else {
+            int readLength = frontStream.read(b, off, (int)Math.min(len, remaining));
+            if (readLength >= 0) {
+                remaining -= readLength;
+            }
+            assert readLength != 0;
+            return readLength;
         }
-        return readLength;
     }
 
     /* (overridden)
@@ -72,17 +77,18 @@
      */
     public long skip(long n) throws IOException {
         ensureOpen();
-        if (frontStream != null && remaining <= 0) {
+        if (frontStream == null) {
+            return super.skip(n);
+        } else if (remaining <= 0) {
             assert remaining == 0;
             return -1;
+        } else {
+            long skipped = frontStream.skip(n);
+            if (skipped > 0) {
+                remaining -= skipped;
+            }
+            return skipped;
         }
-        long skipped;
-        InputStream is = (frontStream == null) ? in : frontStream;
-        skipped = is.skip(n);
-        if (skipped > 0) {
-            remaining -= skipped;
-        }
-        return skipped;
     }
 
     /* (overridden)
2009-03-18 21:51 Updated by: argius
  • Résolution Update from Later to Fixed
  • État Update from Ouvert to Atteints
  • Ticket Close date is changed to 2009-03-18 21:51
Commentaire

パッチ完了。

Attachment File List

No attachments

Modifier

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Connexion