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 81d8a9635 org.apache.commons.compress.archivers.ar.ArArchiveInputStream.read(byte[], int, int) now throws ArchiveException instead of ArithmeticException 81d8a9635 is described below commit 81d8a96353ce258df73535087c9dc44de78a06ef Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Fri Aug 8 13:55:01 2025 -0400 org.apache.commons.compress.archivers.ar.ArArchiveInputStream.read(byte[], int, int) now throws ArchiveException instead of ArithmeticException --- src/changes/changes.xml | 3 ++- .../org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a304e4bad..599fd6738 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -67,9 +67,10 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Gary Gregory">Classes in org.apache.commons.compress.compressors now throw a subclass of IOException called CompressorException instead of IOException when a formatting problem is found.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">Use non-deprecated ArchiveException constructor.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.archivers.ar.ArArchiveInputStream.readGNUStringTable(byte[], int, int) now provides a better exception message, wrapping the underlying exception.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.archivers.ar.ArArchiveInputStream.read(byte[], int, int) now throws ArchiveException instead of ArithmeticException.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.harmony.unpack200.BandSet now throws ArchiveException instead of Arithmetic exception.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.harmony.pack200.BHSDCodec now throws ArchiveException instead of Arithmetic exception.</action> - <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.archivers.zip.ExplodingInputStream now throws ArchiveException instead of Arithmetic exception.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.archivers.zip.ExplodingInputStream now throws ArchiveException instead of ArithmeticException.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.harmony.pack200.RunCodec now throws ArchiveException instead of Arithmetic exception.</action> <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.commons.compress.harmony.pack200.FileBands now throws ArchiveException instead of Arithmetic exception.</action> <action type="fix" dev="ggregory" due-to="Stan, Gary Gregory">org.apache.commons.compress.archivers.cpio.CpioArchiveEntry now throws ArchiveException instead of Arithmetic exception.</action> diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java index cccd2a387..2ff7f085f 100644 --- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java @@ -374,7 +374,7 @@ public int read(final byte[] b, final int off, final int len) throws IOException if (len < 0 || offset >= entryEnd) { return -1; } - final int toRead = (int) Math.min(len, entryEnd - offset); + final int toRead = ArchiveException.toIntExact(Math.min(len, entryEnd - offset)); final int ret = this.in.read(b, off, toRead); trackReadBytes(ret); return ret;