"Segmentation fault" when using phpseclib
Asked Answered
A

1

6

I downloaded phpseclib-0.3.10 from http://phpseclib.sourceforge.net/

My php Version : PHP 5.2.4

OS : CentOS release 6.6

When I run following I am getting "Segmentation fault" at this line $ssh->login('username', 'password')

<?php
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SSH2.php');
$ssh=new Net_SSH2('servername');
if (!$ssh->login('username', 'password')) {
     exit('Login Failed');
}
echo $ssh->exec('pwd');
?>

I am unable find the reason for this issue. Could you please help me to find the reason for this.

Airwaves answered 13/5, 2015 at 4:34 Comment(1)
You might not want to hear this, but PHP 5.2 is outdated and not supported anymore. Many, many fixes have been done since then; one might have fixed the segmentation fault.Tintoretto
G
0

My guess: either the fsockopen() call or the stream_select() call. You can figure it out by putting die()'s in your code at successive points within login() and the functions called therein.

Looking it up... login() calls _login():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1801

_login() calls _connect():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1817

eg. before line 964 in Net/SSH2.php add die('this far'). If it says "this far" then try adding it after. If you get a seg fault when it's after but not before that probably means it's the fsockopen that's to blame.

And just keep on doing that until you get the seg fault. Do a die('this far'); before and after the stream_select and just where-ever. And then post the line you're getting it on.

Gant answered 16/5, 2015 at 3:57 Comment(2)
Thanks neubert for the reply. I did stack trace and I see that following lines throwing Segmentation fault Math_BigInteger->modPow() SSH2.php:1405 openssl_public_encrypt() BigInteger.php:1697Airwaves
Can you post a link to your phpinfo()? Maybe put it on a pastebin and post the link. Thanks!Gant

© 2022 - 2024 — McMap. All rights reserved.