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

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit c8ac75d120e43eea669fbf90f2bd963773f55e96
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Aug 10 18:10:31 2026 -0400

    DumpArchiveInputStream now throws ArchiveException instead of
    IllegalArgumentException.
---
 src/changes/changes.xml                                  |  1 +
 .../compress/archivers/dump/DumpArchiveInputStream.java  | 16 +---------------
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 207d0be51..a94e2bca8 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -73,6 +73,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="pkarwasz" due-to="Piotr P. Karwasz">Fix 
DumpArchiveInputStream to correctly handle file names up to 255 bytes 
#711.</action>
       <action type="fix" dev="ggregory" due-to="Philip Betzler-Braun, Gary 
Gregory, Piotr P. Karwasz" issue="COMPRESS-712">Unsanitized read causes 
IndexOutOfBoundsException in #749.</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory, KALI 
834X">DumpArchiveEntry rejects out-of-range directory header count 
(#781).</action>
+      <action type="fix" dev="ggregory" due-to="Gary 
Gregory">DumpArchiveInputStream now throws ArchiveException instead of 
IllegalArgumentException.</action>
       <!-- FIX zip -->
       <action type="fix" dev="ggregory" due-to="Dominik Stadler, Gary Gregory" 
issue="COMPRESS-598">ZipArchiveInputStream.read(byte[], int, int) now throws an 
IOException instead of a NullPointerException.</action>
       <action type="fix" dev="ggregory" due-to="Tyler Nighswander, Gary 
Gregory">ZipFile.createBoundedInputStream(long, long) now throws an 
ArchiveException instead of IllegalArgumentException.</action>
diff --git 
a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
 
b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
index 6e30bc076..903384edd 100644
--- 
a/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
+++ 
b/src/main/java/org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java
@@ -407,22 +407,15 @@ public int read(final byte[] buf, int off, int len) 
throws IOException {
             return 0;
         }
         int totalRead = 0;
-
         if (eof || isClosed || entryOffset >= entrySize) {
             return -1;
         }
-
-        if (active == null) {
-            throw new IllegalStateException("No current dump entry");
-        }
-
+        ArchiveException.requireNonNull(active, "No current dump entry");
         if (len + entryOffset > entrySize) {
             len = (int) (entrySize - entryOffset);
         }
-
         while (len > 0) {
             final int sz = Math.min(len, readBuf.length - recordOffset);
-
             // copy any data we have
             if (recordOffset + sz <= readBuf.length) {
                 System.arraycopy(readBuf, recordOffset, buf, off, sz);
@@ -431,20 +424,16 @@ public int read(final byte[] buf, int off, int len) 
throws IOException {
                 len -= sz;
                 off += sz;
             }
-
             // load next block if necessary.
             if (len > 0) {
                 if (readIdx >= 512) {
                     final byte[] headerBytes = raw.readRecord();
-
                     if (!DumpArchiveUtil.verify(headerBytes)) {
                         throw new InvalidFormatException();
                     }
-
                     active = DumpArchiveEntry.parse(headerBytes);
                     readIdx = 0;
                 }
-
                 if (!active.isSparseRecord(readIdx++)) {
                     final int r = raw.read(readBuf, 0, readBuf.length);
                     if (r != readBuf.length) {
@@ -453,13 +442,10 @@ public int read(final byte[] buf, int off, int len) 
throws IOException {
                 } else {
                     Arrays.fill(readBuf, (byte) 0);
                 }
-
                 recordOffset = 0;
             }
         }
-
         entryOffset += totalRead;
-
         return totalRead;
     }
 

Reply via email to