This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push: new c797ca791 Add TarArchiveInputStreamTest.testShouldThrowAnExceptionOnTruncatedStream() c797ca791 is described below commit c797ca79124db6a68bae487954aaffe485556a56 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed Dec 11 12:46:17 2024 -0500 Add TarArchiveInputStreamTest.testShouldThrowAnExceptionOnTruncatedStream() --- .../compress/archivers/tar/TarArchiveInputStreamTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java index e8da935c3..1da2c4010 100644 --- a/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStreamTest.java @@ -48,6 +48,7 @@ import java.util.TimeZone; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.zip.GZIPInputStream; @@ -406,6 +407,15 @@ public class TarArchiveInputStreamTest extends AbstractTest { } } + @Test + public void testShouldThrowAnExceptionOnTruncatedStream() throws Exception { + final Path dir = createTempDirectory("COMPRESS-279"); + try (TarArchiveInputStream is = getTestStream("/COMPRESS-279-fail.tar")) { + final AtomicInteger count = new AtomicInteger(); + assertThrows(IOException.class, () -> is.forEach(entry -> Files.copy(is, dir.resolve(String.valueOf(count.getAndIncrement()))))); + } + } + @Test public void testShouldUseSpecifiedEncodingWhenReadingGNULongNames() throws Exception { final ByteArrayOutputStream bos = new ByteArrayOutputStream();