You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Justin Bertram (Jira)" <ji...@apache.org> on 2025/10/03 14:40:00 UTC

[jira] [Commented] (ARTEMIS-5690) ArrayIndexOutOfBoundsException in SimpleString - getChars() method

    [ 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: issues-unsubscribe@activemq.apache.org
For additional commands, e-mail: issues-help@activemq.apache.org
For further information, visit: https://activemq.apache.org/contact