This is an automated email from the ASF dual-hosted git repository.

bodewig 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 004e873  COMPRESS-567 parsing tar headers actually throws 
IllegalArgumentException
004e873 is described below

commit 004e87375572d459ff51c19fe35aa83685cc0cd0
Author: Stefan Bodewig <bode...@apache.org>
AuthorDate: Sun May 2 13:23:11 2021 +0200

    COMPRESS-567 parsing tar headers actually throws IllegalArgumentException
---
 .../apache/commons/compress/archivers/tar/TarArchiveEntry.java | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git 
a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java 
b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
index 0bd8344..f2205c1 100644
--- 
a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
+++ 
b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
@@ -1568,6 +1568,16 @@ public class TarArchiveEntry implements ArchiveEntry, 
TarConstants, EntryStreamO
     private void parseTarHeader(final byte[] header, final ZipEncoding 
encoding,
                                 final boolean oldStyle, final boolean lenient)
         throws IOException {
+        try {
+            parseTarHeaderUnwrapped(header, encoding, oldStyle, lenient);
+        } catch (IllegalArgumentException ex) {
+            throw new IOException("Corrupted TAR archive.", ex);
+        }
+    }
+
+    private void parseTarHeaderUnwrapped(final byte[] header, final 
ZipEncoding encoding,
+                                         final boolean oldStyle, final boolean 
lenient)
+        throws IOException {
         int offset = 0;
 
         name = oldStyle ? TarUtils.parseName(header, offset, NAMELEN)

Reply via email to