TAR展開でエラー(bad header)
"#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)
パッチ完了。
TARファイルを展開しようとすると、以下のエラーになる。
最初のエントリだけ展開されるが、このファイルが元のデータよりも異常に大きい。