that looks like a bug yes
I fixed it by making a array that is one bigger.

On 10/21/05, Francis Amanfo <[EMAIL PROTECTED]> wrote:
Hi,

There seems to be a bug in src/java/wicket/protocol/http/WebRequestWithCryptedUrl.java thats throwing an ArrayIndexOutOfBoundsException. The culprit is likely in the following snippet cut from the class.

if (pos < 0)
                        {
                                String[] prevValue = (String[])params.get(pair);
                                if(prevValue != null)
                                {
                                        String[] newValue = new String[prevValue.length];
                                        System.arraycopy(prevValue, 0, newValue, 0, prevValue.length);
                                        newValue[prevValue.length] = "";
                                        params.put(pair,newValue);
                                }
                                else
                                {
                                    // Parameter without value
                                        params.put(pair, new String[] {""});
                                }
                        }
                        else
                        {
                            final String key = pair.substring(0, pos);
                            final String value = pair.substring(pos + 1);
                                String[] prevValue = (String[])params.get(key);
                                if(prevValue != null)
                                {
                                        String[] newValue = new String[prevValue.length];
                                        System.arraycopy(prevValue, 0, newValue, 0, prevValue.length);
                                        newValue[prevValue.length] = value;
                                        params.put(key,newValue);
                                }
                                else
                                {
                                    // Parameter without value
                                        params.put(key, new String[] {value});
                                }
                        }
                }

Check especially the code:

String[] newValue = new String[prevValue.length];
                                        System.arraycopy(prevValue, 0, newValue, 0, prevValue.length);
                                        newValue[prevValue.length] = "";
                                        params.put(pair,newValue);

Array length+1 is being set which is out of the bounds of the length of the array defined.

Francis




Reply via email to