com php-src: Fix #72764: NEWS ext/ftp/tests/server.inc ext/standard/ftp_fopen_wrapper.c
| From: | Nikita Popov | Date: | Fri, 05 Aug 2016 20:56:54 +0000 |
| Subject: | com php-src: Fix #72764: NEWS ext/ftp/tests/server.inc ext/standard/ftp_fopen_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93633@lists.php.net to get a copy of this message | ||
Commit: 65056e9d6c74adef89332080b5458fd4850fb3b7
Author: Ville Hukkamaki <ville@fihells01.fi.dhl.com> Fri, 5 Aug 2016 16:09:13 +0300
Committer: Nikita Popov <nikic@php.net> Fri, 5 Aug 2016 22:56:54 +0200
Parents: a8515a339d227ace5d5bad40b2a6e6cbe096d894
Branches: PHP-5.6 PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src..git;a=commitdiff;h=65056e9d6c74adef89332080b5458fd4850fb3b7
Log:
Fix #72764
Negotiate data channel encryption after NLST command.
This is to prevent issues with IIS and ProFTPD.
Bugs:
https://bugs.php.net/72764
Changed paths:
M NEWS
M ext/ftp/tests/server.inc
M ext/standard/ftp_fopen_wrapper.c
Diff:
diff --git a/NEWS b/NEWS
index 21427cc..8b95572 100644
--- a/NEWS
+++ b/NEWS
@@ -90,6 +90,8 @@ PHP NEWS
. Fixed bug #54431 (opendir() does not work with ftps:// wrapper). (vhuk)
. Fixed bug #72667 (opendir() with ftp:// attempts to open data stream for
non-existent directories). (vhuk)
+ . Fixed bug #72764 (ftps:// opendir wrapper data channel encryption fails
+ with IIS FTP 7.5, 8.5). (vhuk)
- SPL:
. Fixed bug #72122 (IteratorIterator breaks '@' error suppression). (kinglozzer)
diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc
index e2a7402..5629c2e 100644
--- a/ext/ftp/tests/server.inc
+++ b/ext/ftp/tests/server.inc
@@ -288,6 +288,10 @@ if ($pid) {
}
+ if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true,
STREAM_CRYPTO_METHOD_SSLv23_SERVER))) {
+ die("SSLv23 handshake failed.\n");
+ }
+
if (empty($m[1]) || $m[1] !== 'emptydir') {
fputs($fs, "file1\r\nfile1\r\nfile\nb0rk\r\n");
}
@@ -403,10 +407,6 @@ if ($pid) {
$pasvs = stream_socket_accept($soc,10);
- if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true,
STREAM_CRYPTO_METHOD_SSLv23_SERVER))) {
- die("SSLv23 handshake failed.\n");
- }
-
}elseif (preg_match('/^EPSV/', $buf, $matches)) {
fputs($s, "550 Extended passsive mode not supported.\r\n");
} elseif (preg_match('/^SITE EXEC/', $buf, $matches)) {
diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c
index 0d5384e..bfb1631 100644
--- a/ext/standard/ftp_fopen_wrapper.c
+++ b/ext/standard/ftp_fopen_wrapper.c
@@ -737,17 +737,6 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char
*pat
goto opendir_errexit;
}
- php_stream_context_set(datastream, context);
- if (use_ssl_on_data && (php_stream_xport_crypto_setup(datastream,
- STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 ||
- php_stream_xport_crypto_enable(datastream, 1 TSRMLS_CC) < 0)) {
-
- php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to activate SSL
mode");
- php_stream_close(datastream);
- datastream = NULL;
- goto opendir_errexit;
- }
-
php_stream_printf(stream TSRMLS_CC, "NLST %s\r\n", (resource->path != NULL ?
resource->path : "/"));
@@ -761,6 +750,17 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char
*pat
goto opendir_errexit;
}
+ php_stream_context_set(datastream, context);
+ if (use_ssl_on_data && (php_stream_xport_crypto_setup(datastream,
+ STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 ||
+ php_stream_xport_crypto_enable(datastream, 1 TSRMLS_CC) < 0)) {
+
+ php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to activate SSL
mode");
+ php_stream_close(datastream);
+ datastream = NULL;
+ goto opendir_errexit;
+ }
+
php_url_free(resource);
dirsdata = emalloc(sizeof *dirsdata);