[
https://issues.apache.org/jira/browse/COMPRESS-712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18038970#comment-18038970
]
Gary D. Gregory commented on COMPRESS-712:
------------------------------------------
Hello [~pbebr]
CC: [~pkarwasz]
Thank you for your update.
Keeping the new test here is fine.
I added {{Compress712Test.testPart2()}} to show the current behavior throwing
{{IndexOutOfBoundsException}}.
We need to decide:
- Is IndexOutOfBoundsException OK and if so, should we document it?
- Do we want to map IndexOutOfBoundsException to DumpArchiveException? It'll be
a huge change if we want to be consistent across Compress.
> 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)