Repository: commons-compress Updated Branches: refs/heads/master 03239b0ea -> a428e428d
Refactor magic number. Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/a428e428 Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/a428e428 Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/a428e428 Branch: refs/heads/master Commit: a428e428df2766f1d1b2b793b3f812344fa61fdc Parents: 03239b0 Author: Gary Gregory <ggreg...@apache.org> Authored: Thu Dec 8 23:45:42 2016 -0800 Committer: Gary Gregory <ggreg...@apache.org> Committed: Thu Dec 8 23:45:42 2016 -0800 ---------------------------------------------------------------------- .../commons/compress/archivers/ArchiveStreamFactory.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-compress/blob/a428e428/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java index ba786a4..dc59405 100644 --- a/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java +++ b/src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java @@ -88,6 +88,8 @@ import org.apache.commons.compress.utils.Sets; */ public class ArchiveStreamFactory implements ArchiveStreamProvider { + private static final int TAR_HEADER_SIZE = 512; + private static final int DUMP_SIGNATURE_SIZE = 32; private static final int SIGNATURE_SIZE = 12; @@ -508,7 +510,7 @@ public class ArchiveStreamFactory implements ArchiveStreamProvider { } // Tar needs an even bigger buffer to check the signature; read the first block - final byte[] tarheader = new byte[512]; + final byte[] tarheader = new byte[TAR_HEADER_SIZE]; in.mark(tarheader.length); signatureLength = IOUtils.readFully(in, tarheader); in.reset(); @@ -516,7 +518,7 @@ public class ArchiveStreamFactory implements ArchiveStreamProvider { return createArchiveInputStream(TAR, in); } // COMPRESS-117 - improve auto-recognition - if (signatureLength >= 512) { + if (signatureLength >= TAR_HEADER_SIZE) { TarArchiveInputStream tais = null; try { tais = new TarArchiveInputStream(new ByteArrayInputStream(tarheader));