This is an automated email from the ASF dual-hosted git repository. peterlee pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-compress.git
commit 6270ff564f88804757d859cd4fb1b989df1021d9 Author: theobisproject <theobisproj...@gmail.com> AuthorDate: Sat Oct 10 17:21:36 2020 +0200 COMPRESS-540: Include fix for COMPRESS-553 --- .../java/org/apache/commons/compress/archivers/tar/TarUtils.java | 2 +- .../java/org/apache/commons/compress/archivers/tar/TarFileTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java index e1b87b2..c62b2a6 100644 --- a/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java +++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarUtils.java @@ -682,7 +682,7 @@ public class TarUtils { final String keyword = coll.toString(CharsetNames.UTF_8); // Get rest of entry final int restLen = len - read; - if (restLen == 1) { // only NL + if (restLen <= 1) { // only NL headers.remove(keyword); } else { final byte[] rest = new byte[restLen]; diff --git a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java index feccaf1..d953417 100644 --- a/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/tar/TarFileTest.java @@ -102,4 +102,9 @@ public class TarFileTest extends AbstractTestCase { } } + @Test(expected = IOException.class) + public void testThrowException() throws IOException { + try (TarFile tarFile = new TarFile(getPath("COMPRESS-553.tar"))) { + } + } }