Reputation: 160
My application used to run fine on PHP 5.4.34 on Amazon Linux server. We upgraded to PHP 5.5.18 in order to use some of the newer libraries. Now the phpseclib generates an error: Undefined offset: 5827 in /var/www/lib/ShellClient/phpseclib/Math/BigInteger.php on line 1073
In this app I login via Net_SSH2 and execute command another Amazon Linux server.
I start with Crypt_RSA and Net_SSH2 The following code gives notice in infinite loop:
$key = new \Crypt_RSA();
$key->loadKey(file_get_contents([PUBLIC_KEY]));
$ssh = new \Net_SSH2([IP_ADDRESS]], 22);
if(!$ssh->login([USERNAME]], $key)){
return false;
}
$ssh->exec([COMMAND]]);
return true;
The error is in the BigInteger.php in function _subtract, which is used by Net_SSH2).
PHP Notice: Undefined offset: 5827 in /var/www/lib/ShellClient/phpseclib/Math/BigInteger.php on line 1073
if ($carry) {
for (; !$x_value[$i]; ++$i) { //1073
$x_value[$i] = MATH_BIGINTEGER_MAX_DIGIT;
}
--$x_value[$i];
}
Before my app ran on PHP 5.4.34 and login via NetSSH2 worked properly without any warnings.
Upvotes: 0
Views: 1086
Reputation: 16782
My guess: you're not running the latest version of phpseclib. The latest version is 0.3.8. The issue you're describing sounds like https://github.com/phpseclib/phpseclib/pull/331 which has been fixed since 0.3.7.
Upvotes: 1