Merge pull request #47: Fix #63480: Warning on using the SSH2 Session resource in the uri

This commit is contained in:
Casper Langemeijer
2021-02-24 22:03:19 +01:00
2 changed files with 26 additions and 1 deletions

View File

@@ -310,7 +310,8 @@ php_url *php_ssh2_fopen_wraper_parse_path(const char *path, char *type, php_stre
}
if (psftp) {
sftp_data = (php_ssh2_sftp_data *)zend_fetch_resource(Z_RES_P(zresource), PHP_SSH2_SFTP_RES_NAME, le_ssh2_sftp);
/* suppress potential warning by passing NULL as resource_type_name */
sftp_data = (php_ssh2_sftp_data *)zend_fetch_resource(Z_RES_P(zresource), NULL, le_ssh2_sftp);
if (sftp_data) {
/* Want the sftp layer */
Z_ADDREF_P(zresource);

24
tests/bug63480.phpt Normal file
View File

@@ -0,0 +1,24 @@
--TEST--
Bug #63480 (Warning on using the SSH2 Session resource in the uri)
--SKIPIF--
<?php
require('ssh2_skip.inc');
ssh2t_needs_auth();
ssh2t_writes_remote();
?>
--FILE--
<?php
require('ssh2_test.inc');
$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
ssh2t_auth($ssh);
$filename = ssh2t_tempnam();
file_put_contents("ssh2.sftp://$ssh/$filename", "yada yada");
readfile("ssh2.sftp://$ssh/$filename");
unlink("ssh2.sftp://$ssh/$filename");
?>
--EXPECT--
yada yada