Menu

#59 java.lang.ArrayIndexOutOfBoundsException

open
nobody
None
5
2013-04-08
2013-04-08
Anonymous
No

jsch-0.1.49.jar; jdk 1.7.0_17
exception is thrown
2013/04/08 11:56:59 ERROR - jmeter.protocol.ssh.sampler.AbstractSSHSampler: SSH connexion error com.jcraft.jsch.JSchException: java.lang.ArrayIndexOutOfBoundsException
at com.jcraft.jsch.KeyPair.load(KeyPair.java:783)
at com.jcraft.jsch.KeyPair.load(KeyPair.java:467)
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:40)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:359)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:319)
at org.apache.jmeter.protocol.ssh.sampler.AbstractSSHSampler.connect(AbstractSSHSampler.java:67)
at org.apache.jmeter.protocol.ssh.sampler.SSHSFTPSampler.sample(SSHSFTPSampler.java:73)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at com.jcraft.jsch.KeyPair.load(KeyPair.java:653)
... 9 more

this exception is thrown because of this code in com.jcraft.jsch.KeyPair.java:
646 i = 0;
647
648 int _len = _buf.length;
649 while(i<_len){
650 if(_buf[i]==0x0a){
651 boolean xd=(_buf[i-1]==0x0d);
652 // move 0x0a (or 0x0d0x0a) to the end of '_buf'.
653 System.arraycopy(_buf, i+1,
654 _buf,
655 i-(xd ? 1 : 0),
656 _len-i-1-(xd ? 1 : 0)
657 );
658 if(xd)_len--;
659 _len--;
660 continue;
661 }
662 if(_buf[i]=='-'){ break; }
663 i++;
664 }

when i = _len-1 and _buf[i]=0x0a and _buf[i-1] = 0x0d then xd = true, _len - i - 1 - (xd? 1: 0) = -1. and thus the exception is thrown. Maybe there should not be (xd? 1: 0) in expression _len - i - 1 - (xd? 1: 0).

Discussion


Log in to post a comment.