Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ext/ftp/tests/server.inc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ if ($pid) {
$buf = fread($s, 2048);
}

if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
if ($buf == "AUTH TLS\r\n") {
fputs($s, "500 not supported.\r\n");
return ;
} else if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
fputs($s, "500 Syntax error, command unrecognized.\r\n");
dump_and_exit($buf);
}
Expand Down Expand Up @@ -208,6 +211,10 @@ if ($pid) {
$ascii = true;
fputs($s, "200 OK\r\n");

} elseif ($buf === "AUTH SSL\r\n") {
$ascii = true;
fputs($s, "500 not supported\r\n");

} elseif ($buf === "TYPE I\r\n") {
$ascii = false;
fputs($s, "200 OK\r\n");
Expand Down
23 changes: 23 additions & 0 deletions ext/standard/tests/streams/bug72771.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Bug #72771. FTPS to FTP downgrade not allowed when server doesn't support AUTH TLS or AUTH SSL.
--SKIPIF--
<?php
if (array_search('ftp',stream_get_wrappers()) === FALSE) die("skip ftp wrapper not available.");
if (!function_exists('pcntl_fork')) die("skip pcntl_fork() not available.");
if (!extension_loaded('openssl')) die ("skip openssl not available.");
?>
--FILE--
<?php

require __DIR__ . "/../../../ftp/tests/server.inc";

$path="ftps://127.0.0.1:" . $port."/";

$ds=opendir($path, $context);
var_dump($ds);
?>
==DONE==
--EXPECTF--
Warning: opendir(ftps://127.0.0.1:%d/): failed to open dir: Server doesn't support FTPS. in %s on line %d
bool(false)
==DONE==