[ 
https://issues.apache.org/jira/browse/ARTEMIS-5690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18024509#comment-18024509
 ] 

Justin Bertram commented on ARTEMIS-5690:
-----------------------------------------

As far as I can tell this is behaving exactly like I would expect since you're 
passing {{getChars}} a {{new char[0]}}. The {{getChars}} method could 
theoretically be changed to perform validation to ensure the destination array 
can hold the requested number of chars, but that would still result in an 
exception (e.g. {{IllegalArgumentException}}).

If you pass {{new char[1]}} it works.

> ArrayIndexOutOfBoundsException in SimpleString - getChars() method
> ------------------------------------------------------------------
>
>                 Key: ARTEMIS-5690
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5690
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.31.2, 2.43.0
>         Environment: openjdk version "21.0.8" 2025-07-15
>            Reporter: Mikhail Titov
>            Priority: Major
>
> I have found an ArrayIndexOutOfBoundsException bug as a result of 
> fuzz-testing SimpleString - getChars() method. 
> Run the following code to reproduce:
> {code:java}
> import org.apache.activemq.artemis.api.core.SimpleString;
>  
> import java.util.Base64;
>  
> public class ArrayIndexOutOfBoundsBug {
>  
>     public static void main(String[] args) {
>  
>         String Base64String = "AA==";
>         Base64.Decoder decoder = Base64.getDecoder();
>  
>         String str = new String(decoder.decode(Base64String));
>         SimpleString simpleStr = SimpleString.of(str);
>  
>         simpleStr.getChars(0, 1, new char[0], 0);
>     }
> }{code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to