[
https://issues.apache.org/jira/browse/COMPRESS-712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18039580#comment-18039580
]
Philip Betzler-Braun commented on COMPRESS-712:
-----------------------------------------------
Hi [~ggregory] ,
please excuse my late reply, I'm quit overloaded with tasks atm.
My general perception is that a Exception subclass is cleaner then a
RuntimeException subclass, if we are crossing the boundery out of a library. I
do see though that it would require a way bigger time investment then just
documenting a IndexOutOfBoundsException as expected. Ultimativly I cannot even
estimate what the time difference would be in this case and therefore would
refrain from having a priority.
> Unsanitized read causes IndexOutOfBoundsException in
> DumpArchiveInputStream.java:359
> ------------------------------------------------------------------------------------
>
> Key: COMPRESS-712
> URL: https://issues.apache.org/jira/browse/COMPRESS-712
> Project: Commons Compress
> Issue Type: Bug
> Components: Archivers
> Environment: Ubuntu 24.04
> $ java --version
> openjdk 21.0.8 2025-07-15
> OpenJDK Runtime Environment (build 21.0.8+9-Ubuntu-0ubuntu124.04.1)
> OpenJDK 64-Bit Server VM (build 21.0.8+9-Ubuntu-0ubuntu124.04.1, mixed mode,
> sharing)
> Reporter: Philip Betzler-Braun
> Assignee: Gary D. Gregory
> Priority: Major
> Fix For: 1.29.0
>
> Attachments:
> IndexOutOfBoundsReproducerInDumpArchiveInputStream-1.java,
> IndexOutOfBoundsReproducerInDumpArchiveInputStream.java
>
>
> *Issue:*
> When reading in unsanitized data in the readDirectoryEntry(DumpArchiveEntry
> entry)
> (org/apache/commons/compress/archivers/dump/DumpArchiveInputStream.java:514)
> the call to DumpArchiveUtil.convert32(blockBuffer, i)
> (DumpArchiveInputStream.java:542) can return negative numbers that are stored
> down the line as int inos in the "name" HashMap.
> When trying to get the path of the DumpArchiveEntry
> (DumpArchiveInputStream.getPath(DumpArchiveInputStream.java:359)) the "names"
> Hashmap is used as filter befor querrying the visited inos. The visited inos
> are stored in a BitSet. If the DumpArchiveEntry or a parent directory
> contains a negative number that was also saved earlier in the "name" Hashmap,
> the get (java.base/java.util.BitSet.get(BitSet.java:626)) function is
> throwing an java.lang.IndexOutOfBoundsException.
>
> *Suggestion:*
> # Catch negative ino numbers in a wrapper function around
> DumpArchiveUtil.convert32 and throw an expected error.
> # Catch all internal (runtime) exceptions and throw a general expected
> exception.
>
> {*}Reproducer:{*}{*}{{*}}
> (attached as file -> expected position:
> src/test/java/org/apache/commons/compress/archivers/IndexOutOfBoundsReproducerInDumpArchiveInputStream.java)
> *[^IndexOutOfBoundsReproducerInDumpArchiveInputStream.java]*
--
This message was sent by Atlassian Jira
(v8.20.10#820010)