garydgregory commented on code in PR #386: URL: https://github.com/apache/commons-compress/pull/386#discussion_r1511235353
########## src/main/java/org/apache/commons/compress/archivers/ArchiveStreamFactory.java: ########## @@ -268,7 +278,15 @@ public static String detect(final InputStream in) throws ArchiveException { try { tais = new TarArchiveInputStream(new ByteArrayInputStream(tarHeader)); // COMPRESS-191 - verify the header checksum - if (tais.getNextTarEntry().isCheckSumOK()) { + // COMPRESS-644 - do not allow zero byte file entries + TarArchiveEntry tae = tais.getNextTarEntry(); + //try to find the first non-directory entry within the first 10 entries. + int count = 0; + while (tae != null && tae.isDirectory() && count++ < MAX_TAR_RECORDS) { Review Comment: This causes detection to fail for `src/test/resources/COMPRESS-612/test-times-star-folder.tar` (once you rebase on git master which tests more files). ########## src/test/java/org/apache/commons/compress/DetectArchiverTestCase.java: ########## @@ -141,4 +145,14 @@ public void testEmptyJarArchive() throws Exception { public void testEmptyZipArchive() throws Exception { checkEmptyArchive("zip"); } + + @Test + public void ignoreZeroByteEntryInTarDetect_COMPRESS644() throws IOException { Review Comment: IOException is not thrown here, so it shouldn't be in the method signature. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org