php / pecl-networking-ssh2

Bindings for the libssh2 library
http://pecl.php.net/package/ssh2
Other
51 stars 58 forks source link

Fix #79631: SSH disconnect segfault with SFTP (assertion failed) #46

Closed cmb69 closed 3 years ago

cmb69 commented 3 years ago

If the SSH2 Session resource has already been closed, the libssh2 session has been as well, and the LIBSSH2_SESSION* has been set NULL. If that is the case, we must not call libssh2_sftp_shutdown().


Note that this patch only resolves the particular shutdown issue, but does not generally address using the SSH2 SFTP resource after the SSH2 Session resource has been closed (i.e. calling any of the ssh2_sftp_*() functions after ssh2_disconnect($ssh) still segfaults). This would have to be handled for every ssh2_sftp_*() function individually. If you like, I can amend this PR respectively, or submit another PR. But maybe there is a more elegant solution I'm missing?