Skip to content

Commit 928624e

Browse files
jcmcmb69
authored andcommitted
QA - ftp_rawlist - check list return value
Co-authored-by: Christoph M. Becker <[email protected]> Closes phpGH-9012.
1 parent dbdef4a commit 928624e

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

ext/ftp/tests/ftp_rawlist_basic1.phpt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ $ftp = ftp_connect('127.0.0.1', $port);
1313
ftp_login($ftp, 'user', 'pass');
1414
$ftp or die("Couldn't connect to the server");
1515

16-
var_dump(is_array(ftp_rawlist($ftp, 'www/')));
16+
$result = ftp_rawlist($ftp, 'www/');
17+
var_dump(is_array($result));
18+
var_dump($result);
19+
ftp_close($ftp);
1720
?>
1821
--EXPECT--
1922
bool(true)
23+
array(3) {
24+
[0]=>
25+
string(5) "file1"
26+
[1]=>
27+
string(5) "file1"
28+
[2]=>
29+
string(9) "file
30+
b0rk"
31+
}

ext/ftp/tests/server.inc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,27 @@ if ($pid) {
446446
fputs($s, "200 " . $matches[1] . " bytes allocated\r\n");
447447

448448
}elseif (preg_match('/^LIST www\//', $buf, $matches)) {
449-
fputs($s, "226 Transfer complete\r\n");
449+
if (empty($pasv)) {
450+
fputs($s, "150 File status okay; about to open data connection\r\n");
451+
if (!$fs = stream_socket_client("tcp://$host:$port")) {
452+
fputs($s, "425 Can't open data connection\r\n");
453+
continue;
454+
}
455+
} else {
456+
fputs($s, "125 Data connection already open; transfer starting.\r\n");
457+
$fs = $pasvs;
458+
}
459+
450460

461+
if ((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) {
462+
die("SSLv23 handshake failed.\n");
463+
}
464+
465+
fputs($fs, "file1\r\nfile1\r\nfile\nb0rk\r\n");
466+
fputs($s, "226 Closing data Connection.\r\n");
467+
fclose($fs);
468+
469+
fputs($s, "226 Transfer complete\r\n");
451470
}elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) {
452471
fputs($s, "425 Error establishing connection\r\n");
453472

0 commit comments

Comments
 (0)