Skip to content

Commit af7828a

Browse files
Ville Hukkamäkinikic
Ville Hukkamäki
authored andcommitted
Test case for bug #72771
1 parent 207dab5 commit af7828a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

ext/ftp/tests/server.inc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ if ($pid) {
139139
$buf = fread($s, 2048);
140140
}
141141

142-
if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
142+
if ($buf == "AUTH TLS\r\n") {
143+
fputs($s, "500 not supported.\r\n");
144+
return ;
145+
} else if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
143146
fputs($s, "500 Syntax error, command unrecognized.\r\n");
144147
dump_and_exit($buf);
145148
}
@@ -208,6 +211,10 @@ if ($pid) {
208211
$ascii = true;
209212
fputs($s, "200 OK\r\n");
210213

214+
} elseif ($buf === "AUTH SSL\r\n") {
215+
$ascii = true;
216+
fputs($s, "500 not supported\r\n");
217+
211218
} elseif ($buf === "TYPE I\r\n") {
212219
$ascii = false;
213220
fputs($s, "200 OK\r\n");
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #72771. FTPS to FTP downgrade not allowed when server doesn't support AUTH TLS or AUTH SSL.
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+
require __DIR__ . "/../../../ftp/tests/server.inc";
13+
14+
$path="ftps://127.0.0.1:" . $port."/";
15+
16+
$ds=opendir($path, $context);
17+
var_dump($ds);
18+
?>
19+
==DONE==
20+
--EXPECTF--
21+
Warning: opendir(ftps://127.0.0.1:%d/): failed to open dir: Server doesn't support FTPS. in %s on line %d
22+
bool(false)
23+
==DONE==

0 commit comments

Comments
 (0)