commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [1/2] commons-compress git commit: COMPRESS-450 throw specialized exception in case of a bad tar header
Date Tue, 01 May 2018 10:53:35 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/COMPRESS-450 [created] 3a0ac2ca8


COMPRESS-450 throw specialized exception in case of a bad tar header


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/27ff5993
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/27ff5993
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/27ff5993

Branch: refs/heads/COMPRESS-450
Commit: 27ff59931984fed98c4cc3971819ad63f81d35de
Parents: ffb618d
Author: Stefan Bodewig <bodewig@apache.org>
Authored: Tue May 1 12:51:36 2018 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Tue May 1 12:51:36 2018 +0200

----------------------------------------------------------------------
 .../tar/InvalidTarHeaderException.java          | 34 ++++++++++++++++++++
 .../archivers/tar/TarArchiveInputStream.java    |  2 +-
 2 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/27ff5993/src/main/java/org/apache/commons/compress/archivers/tar/InvalidTarHeaderException.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/InvalidTarHeaderException.java
b/src/main/java/org/apache/commons/compress/archivers/tar/InvalidTarHeaderException.java
new file mode 100644
index 0000000..0edd80d
--- /dev/null
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/InvalidTarHeaderException.java
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.commons.compress.archivers.tar;
+
+import java.io.IOException;
+
+/**
+ * Specialized {@link IOException} thrown by {@link
+ * TarArchiveInputStream#getNextTarEntry} if the block read where a
+ * tar header was expected couldn't be parsed.
+ *
+ * @since 1.17
+ */
+public class InvalidTarHeaderException extends IOException {
+    private static final long serialVersionUID = 20180501L;
+    public InvalidTarHeaderException(Exception cause) {
+        super("Error detected parsing the header", cause);
+    }
+}

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/27ff5993/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
index daaf729..a5ade6e 100644
--- a/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
+++ b/src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveInputStream.java
@@ -282,7 +282,7 @@ public class TarArchiveInputStream extends ArchiveInputStream {
         try {
             currEntry = new TarArchiveEntry(headerBuf, zipEncoding);
         } catch (final IllegalArgumentException e) {
-            throw new IOException("Error detected parsing the header", e);
+            throw new InvalidTarHeaderException(e);
         }
 
         entryOffset = 0;


Mime
View raw message