Skip to content

Commit cce457c

Browse files
Ville Hukkamäkinikic
Ville Hukkamäki
authored andcommitted
Fix bug #72667
Open data stream after receiving PASV reply, before sending the main request. Included test cases for opendir() with ftp:// and ftps:// wrappers. Test cases re-use ext/ftp/tests/server.inc Conflicts: ext/standard/ftp_fopen_wrapper.c
1 parent 074b86d commit cce457c

File tree

8 files changed

+206
-70
lines changed

8 files changed

+206
-70
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ PHP NEWS
5757
- Streams:
5858
. Fixed bug #41021 (Problems with the ftps wrapper). (vhuk)
5959
. Fixed bug #54431 (opendir() does not work with ftps:// wrapper). (vhuk)
60+
. Fixed bug #72667 (opendir() with ftp:// attempts to open data stream for
61+
non-existent directories). (vhuk)
6062

6163
- SPL:
6264
. Fixed bug #72122 (IteratorIterator breaks '@' error suppression). (kinglozzer)

ext/ftp/tests/cert.pem

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
1-
-----BEGIN CERTIFICATE REQUEST-----
2-
MIIBmzCCAQQCAQAwWzELMAkGA1UEBhMCUFQxCzAJBgNVBAgTAkx4MQswCQYDVQQH
3-
EwJMeDEcMBoGA1UEChMTQSBtaW5oYSBlbXByZXNhLCBTQTEUMBIGA1UECxMLUEhQ
4-
IFFBIFRlYW0wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAM9mfEOSYwXf58ch
5-
4NyO1QOU1XMfquz8OVpvMUITABLAevZpeQn6vZPHNyXHFQC0QC8scydK1rAYd2U+
6-
9K2aPub6ioMjYyjPpAE07l9EAAPUEBlqqsziB/wT8QjWkByyJEkYu+o0Wyjokhfn
7-
BMPvm52wLWUx9nvUeNDCftnKg1wxAgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQDD
8-
s1FeqPxnF2bWj8/dG8MyPaRfOAMVz1UsCZUciXIVG5LSIvR2qnMC3iEYt3s13sEq
9-
z8V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SEWpHSaBs7KduBRXX5+qFxBN6OCPl
16+
7ID0rxAOYfw7ruzbmwgOpBgMIHGn+KqA6CmQI0jh9bZbv5TV2aFpFsUihugPc2lW
17+
5EshCozxlEPmIJNsO8jDqPE4w3m4KiVTscRWjBa5cco+lwLDqboerm2l7vvrtr6B
18+
pgLaZct1c73MouvoJSCGK5EOGW7jsgaxjxJ3UZug+24Ko1wulO2cgBLhda9Ilrnx
19+
CIKI9h8Z2WVWuVQfyCyO1g7XkJgkBec77OhxD+m4onzPY6waqnnhmFOBcS+gKgBV
20+
jHeK9DCvZ9zet3EyEp6fyQOOtsC+gU0piYgfsQL7aCp5oLe+fjTiuUY=
2921
-----END CERTIFICATE-----
30-
-----BEGIN RSA PRIVATE KEY-----
31-
Proc-Type: 4,ENCRYPTED
32-
DEK-Info: DES-EDE3-CBC,928762DB6DE222AD
33-
34-
oOxNUBX0wrqmRqb3IEZMogc1bnVm6JoW6YFjGfHNcIz0jS7UPDhUFDR26y0dYujL
35-
LEgxOcYo8ItvGcXSRbs+3W7lISbosgkB0DOaKx5jVmOGwUVRergUUSY8rbf93FtP
36-
27CEvAfsU6do5HmlJ34mYZW1k+onCznlJXJkupQ5jmiily3GwEdr/5mMIVOmXQ6p
37-
xWkxHySDKyVbR0v4JY3SJLRBuhgofYNG5155PiqZ7KwYY4Aw60eVgINsvJCF9/8b
38-
kEj+lecHbBdAf7N82320Ga+F+VeFnUl0gWFjoIF9UFCO80+7ZvIGdGlyPkr4zMvt
39-
TsC1snJQdHg+IlT3sGayYrQANpTG6GPYhn3KEvK5aqq+bPEe5lija0gw34jbPCo+
40-
TjHR76lToxzubGZODyyF/rjl5KwUbqTCNuv1PX1jTx7n7sCbu+KHpqXMhTHLKtby
41-
+Wh7WAfsVrbIW+P85/mkfhPbPZ2621f9cyStdFGgWU4dHdD00HIGOgAJvUSbC2Au
42-
oVUoKf2818t1s9aA4ptog04sNi+Ixu+z+3yYNLZj51j4ZX3KuXxLIiQvlvFQ8LQi
43-
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+yMUsWEYVSmFAQKBgQDtOvPkhvZsNocUB5nJ
35+
ti3SXyDQ6OZQuKKHPSeDV/EvmZKeNlrQ1ZnwXLP3vkcedDOkt1nEVq/hUewpjt08
36+
2MvmMwJBQEnmbTzMf43DtlXsStdP1lhYaFbU4iMM5zRfyBHDu1GPZEPXvKKpJUk0
37+
M+jYIyTAP3mcZhqDKn0mPVP7VwKBgQDKFy9DtWFKxCvhFQvHx7YeZiVWJbIst/O4
38+
ZyuPVAErni0hzSeCkmm7+F9hgEdPSLRcSaeTWP4L0u1cixECKboIhoNs38aft7o3
39+
MdnI2RDSEKtKX2uVuhvpGDNuGpBAc8Qu8iCiv5INSC36ZhD1h++O/TiiUdgRJ3yX
40+
yeG7ej+CgQKBgCR5F95e0aw5hfMSaBaXJ9xcO9Niu2ZVvMdGI7kR4EcNOXmRqczJ
41+
ym0mE5VXb9/Cxd3hQq/pFAl0avbIvEMKoe62kPYvSC1hRiO6yLT6Z6N4rjncHqEZ
42+
CaCZVAI72dWQEQsi1ZtSMwwMOIYA8YxRHs98N75HBA+DszfPZIZoj2zpAoGBAJHp
43+
B3ElhmeLF/tdTLIj2bQ9H/wBH5H2Bvw/UU4c4vNxMzjSfRJjUAAtpgAptFLkNYTk
44+
kR9sA5DZ7BMDPXaIVg9Nv5peP3SWHNc5IPtI7kIdUu9R0cW7J+e2V3vJphlC/ITA
45+
wRuAoZ0BXmEKTHhae3aMEdXwrcZE8kpNsrO/4hcBAoGBAMISiPJPuxAX1UtqcxTa
46+
mDJfnQ2gxRu6AK9VmXqo0X4IBxDSnTjcL0huUlS849wgsE5oTXgdYb2hn+TXM5JJ
47+
NsEXLhV09X1mrk4M4LV1npd0mYxvFsO4+p+IX5YLiahInmQtq0gx3DWE8wouVFER
48+
4yzfp27z8MZT8Qvr/ZI9lzWd
49+
-----END PRIVATE KEY-----

ext/ftp/tests/server.inc

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$socket = null;
44
$errno = 0;
5-
$context = stream_context_create(array('ssl' => array('local_cert' => dirname(__FILE__).'/cert.pem', 'passphrase' => 'pass')));
5+
$context = stream_context_create(array('ssl' => array('local_cert' => dirname(__FILE__).'/cert.pem')));
66

77
for ($i=0; $i<10 && !$socket; ++$i) {
88
$port = rand(50000, 65535);
@@ -265,7 +265,7 @@ if ($pid) {
265265

266266
} elseif (preg_match("~^NLST(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) {
267267

268-
if (isset($m[1]) && $m[1] === 'bogusdir') {
268+
if (isset($m[1]) && (($m[1] === 'bogusdir') || ($m[1] === '/bogusdir'))) {
269269
fputs($s, "250 $m[1]: No such file or directory\r\n");
270270
continue;
271271
}
@@ -276,13 +276,18 @@ if ($pid) {
276276
continue;
277277
}
278278

279-
fputs($s, "150 File status okay; about to open data connection\r\n");
280-
281-
if (!$fs = stream_socket_client("tcp://$host:$port")) {
282-
fputs($s, "425 Can't open data connection\r\n");
283-
continue;
279+
if (empty($pasv)) {
280+
fputs($s, "150 File status okay; about to open data connection\r\n");
281+
if (!$fs = stream_socket_client("tcp://$host:$port")) {
282+
fputs($s, "425 Can't open data connection\r\n");
283+
continue;
284+
}
285+
} else {
286+
fputs($s, "125 Data connection already open; transfer starting.\r\n");
287+
$fs=$pasvs;
284288
}
285289

290+
286291
if (empty($m[1]) || $m[1] !== 'emptydir') {
287292
fputs($fs, "file1\r\nfile1\r\nfile\nb0rk\r\n");
288293
}
@@ -368,7 +373,7 @@ if ($pid) {
368373
}
369374
fputs($s, "226 Closing data Connection.\r\n");
370375
break;
371-
case "mediumfile":
376+
case "mediumfile":
372377
fputs($s, "150 File status okay; about to open data connection.\r\n");
373378
for($i = 0; $i < 150; $i++){
374379
fputs($fs, "This is line $i of the test data.\n");
@@ -384,13 +389,26 @@ if ($pid) {
384389

385390

386391
}elseif (preg_match('/^PASV/', $buf, $matches)) {
387-
$port = $pasv_port;
388-
$p2 = $port % ((int) 1 << 8);
389-
$p1 = ($port-$p2)/((int) 1 << 8);
392+
$pasv=true;
393+
$p2 = $pasv_port % ((int) 1 << 8);
394+
$p1 = ($pasv_port-$p2)/((int) 1 << 8);
390395
$host = "127.0.0.1";
396+
if (!empty($ssl)) {
397+
$soc = stream_socket_server("tcp://127.0.0.1:$pasv_port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
398+
} else {
399+
$soc = stream_socket_server("tcp://127.0.0.1:$pasv_port");
400+
}
401+
391402
fputs($s, "227 Entering Passive Mode. (127,0,0,1,{$p1},{$p2})\r\n");
392403

404+
$pasvs = stream_socket_accept($soc,10);
405+
406+
if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) {
407+
die("SSLv23 handshake failed.\n");
408+
}
393409

410+
}elseif (preg_match('/^EPSV/', $buf, $matches)) {
411+
fputs($s, "550 Extended passsive mode not supported.\r\n");
394412
} elseif (preg_match('/^SITE EXEC/', $buf, $matches)) {
395413
fputs($s, "200 OK\r\n");
396414

ext/standard/ftp_fopen_wrapper.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -716,43 +716,47 @@ php_stream * php_stream_ftp_opendir(php_stream_wrapper *wrapper, const char *pat
716716
if (result > 299 || result < 200)
717717
goto opendir_errexit;
718718

719+
// tmp_line isn't relevant after the php_fopen_do_pasv().
720+
tmp_line[0] = '\0';
721+
719722
/* set up the passive connection */
720723
portno = php_fopen_do_pasv(stream, ip, sizeof(ip), &hoststart TSRMLS_CC);
721724

722725
if (!portno) {
723726
goto opendir_errexit;
724727
}
725728

726-
php_stream_printf(stream TSRMLS_CC, "NLST %s\r\n", (resource->path != NULL ? resource->path : "/"));
727-
728729
/* open the data channel */
729730
if (hoststart == NULL) {
730731
hoststart = resource->host;
731732
}
733+
732734
datastream = php_stream_sock_open_host(hoststart, portno, SOCK_STREAM, 0, 0);
733735
if (datastream == NULL) {
734736
goto opendir_errexit;
735737
}
736738

737-
result = GET_FTP_RESULT(stream);
738-
if (result != 150 && result != 125) {
739-
/* Could not retrieve or send the file
740-
* this data will only be sent to us after connection on the data port was initiated.
741-
*/
742-
php_stream_close(datastream);
743-
datastream = NULL;
744-
goto opendir_errexit;
745-
}
746-
747739
php_stream_context_set(datastream, context);
748-
749740
if (use_ssl_on_data && (php_stream_xport_crypto_setup(datastream,
750741
STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 ||
751742
php_stream_xport_crypto_enable(datastream, 1 TSRMLS_CC) < 0)) {
752743

753744
php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Unable to activate SSL mode");
754745
php_stream_close(datastream);
755746
datastream = NULL;
747+
goto opendir_errexit;
748+
}
749+
750+
751+
php_stream_printf(stream TSRMLS_CC, "NLST %s\r\n", (resource->path != NULL ? resource->path : "/"));
752+
753+
result = GET_FTP_RESULT(stream);
754+
if (result != 150 && result != 125) {
755+
/* Could not retrieve or send the file
756+
* this data will only be sent to us after connection on the data port was initiated.
757+
*/
758+
php_stream_close(datastream);
759+
datastream = NULL;
756760
goto opendir_errexit;
757761
}
758762

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
opendir() with 'ftp://' stream.
3+
--SKIPIF--
4+
<?php
5+
if (array_search('ftp',stream_get_wrappers()) === FALSE) die("skip ftp wrapper not available.");
6+
if (!function_exists('pcntl_fork')) die("skip pcntl_fork() not available.");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require __DIR__ . "/../../../ftp/tests/server.inc";
12+
13+
$path="ftp://localhost:" . $port."/bogusdir";
14+
15+
var_dump(opendir($path));
16+
?>
17+
==DONE==
18+
--EXPECTF--
19+
Warning: opendir(ftp://localhost:%d/bogusdir): failed to open dir: FTP server reports 250 /bogusdir: No such file or directory
20+
in %s on line %d
21+
bool(false)
22+
==DONE==
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
opendir() with 'ftp://' stream.
3+
--SKIPIF--
4+
<?php
5+
if (array_search('ftp',stream_get_wrappers()) === FALSE) die("skip ftp wrapper not available.");
6+
if (!function_exists('pcntl_fork')) die("skip pcntl_fork() not available.");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require __DIR__ . "/../../../ftp/tests/server.inc";
12+
13+
$path="ftp://localhost:" . $port."/";
14+
15+
$ds=opendir($path);
16+
var_dump($ds);
17+
18+
while ($fn=readdir($ds)) {
19+
var_dump($fn);
20+
}
21+
22+
closedir($ds);
23+
?>
24+
==DONE==
25+
--EXPECTF--
26+
resource(%d) of type (stream)
27+
string(5) "file1"
28+
string(5) "file1"
29+
string(3) "fil"
30+
string(4) "b0rk"
31+
==DONE==
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
opendir() with 'ftps://' stream.
3+
--SKIPIF--
4+
<?php
5+
if (array_search('ftp',stream_get_wrappers()) === FALSE) die("skip ftp wrapper not available.");
6+
if (!function_exists('pcntl_fork')) die("skip pcntl_fork() not available.");
7+
if (!extension_loaded('openssl')) die ("skip openssl not available.");
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$ssl=true;
13+
require __DIR__ . "/../../../ftp/tests/server.inc";
14+
15+
$path="ftps://127.0.0.1:" . $port."/bogusdir";
16+
17+
$context = stream_context_create(array('ssl' => array('cafile' => __DIR__ . '/../../../ftp/tests/cert.pem')));
18+
19+
var_dump(opendir($path, $context));
20+
?>
21+
==DONE==
22+
--EXPECTF--
23+
Warning: opendir(ftps://127.0.0.1:%d/bogusdir): failed to open dir: FTP server reports 250 /bogusdir: No such file or directory
24+
in %s on line %d
25+
bool(false)
26+
==DONE==
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
opendir() with 'ftps://' stream.
3+
--SKIPIF--
4+
<?php
5+
if (array_search('ftp',stream_get_wrappers()) === FALSE) die("skip ftp wrapper not available.");
6+
if (!function_exists('pcntl_fork')) die("skip pcntl_fork() not available.");
7+
if (!extension_loaded('openssl')) die ("skip openssl not available.");
8+
?>
9+
--FILE--
10+
<?php
11+
12+
$ssl=true;
13+
require __DIR__ . "/../../../ftp/tests/server.inc";
14+
15+
$path="ftps://127.0.0.1:" . $port."/";
16+
17+
$context = stream_context_create(array('ssl' => array('cafile' => __DIR__ . '/../../../ftp/tests/cert.pem')));
18+
19+
$ds=opendir($path, $context);
20+
var_dump($ds);
21+
while ($fn=readdir($ds)) {
22+
var_dump($fn);
23+
}
24+
?>
25+
==DONE==
26+
--EXPECTF--
27+
resource(%d) of type (stream)
28+
string(5) "file1"
29+
string(5) "file1"
30+
string(3) "fil"
31+
string(4) "b0rk"
32+
==DONE==

0 commit comments

Comments
 (0)