Search code examples
phpsftpreaddir

php sftp seg fault


What i need to do if next code gives me seg fault ?

    $handle = opendir("ssh2.sftp://$sftp".'/usr/bin/');
    $file = readdir($handle);
    closedir($handle);

where $sftp is

    $this->_connection = ssh2_connect($this->_server, 22);
    if($this->_authType==ExportInterface::CONN_AUTH_KEY) {
        ssh2_auth_pubkey_file($this->_connection,$this->_user,$this->_key,$this->_privateKey);
    } else {
        ssh2_auth_password($this->_connection,$this->_user,$this->_password);
    }
    $sftp = ssh2_sftp($this->_connection);

Connect work well. and segfault is when only i use readdir function.


Solution

  • A seg(mentation) fault is an internal error in php or the SSH/SFTP extension. You should file a bug against the extension in question.

    Don't forget to include a short, reproducible example. Since this may be only reproducible with your specific combination of ssh client and server, you should reproduce the bug first in a brand-new VM and record every step you make, like this:

    1. Install Ubuntu 11.04 amd64 in the VM
    2. Install ssh with $ sudo apt-get install ssh
    3. Configure ssh with ...
    4. Install php with $ sudo apt-get install php5-cli
    5. Copy the script [link to http://pastebin.com/ here] to the VM
    6. Type php ssh-segfault.php and receive a segfault.