Skip to content

Commit 5d7219d

Browse files
committed
Merge branch 'PHP-8.0'
* PHP-8.0: Fix #80901: Info leak in ftp extension
2 parents 7372a3e + 33d4955 commit 5d7219d

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

ext/ftp/ftp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,10 +1313,12 @@ ftp_readline(ftpbuf_t *ftp)
13131313

13141314
data = eol;
13151315
if ((rcvd = my_recv(ftp, ftp->fd, data, size)) < 1) {
1316+
*data = 0;
13161317
return 0;
13171318
}
13181319
} while (size);
13191320

1321+
*data = 0;
13201322
return 0;
13211323
}
13221324
/* }}} */

ext/ftp/tests/bug80901.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #80901 (Info leak in ftp extension)
3+
--SKIPIF--
4+
<?php
5+
require 'skipif.inc';
6+
?>
7+
--INI--
8+
log_errors_max_len=0
9+
--FILE--
10+
<?php
11+
$bug80901 = true;
12+
require 'server.inc';
13+
14+
$ftp = ftp_connect("127.0.0.1", $port);
15+
if (!$ftp) die("Couldn't connect to the server");
16+
var_dump(ftp_login($ftp, 'user', 'pass'));
17+
ftp_systype($ftp);
18+
?>
19+
--EXPECTF--
20+
bool(true)
21+
22+
Warning: ftp_systype(): **************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** in %s on line %d

ext/ftp/tests/server.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ if ($pid) {
7373
fputs($s, "234 auth type accepted\r\n");
7474
} else {
7575
fputs($s, "666 dummy\r\n");
76+
sleep(1);
7677
fputs($s, "666 bogus msg\r\n");
7778
exit;
7879
}
@@ -161,6 +162,8 @@ if ($pid) {
161162
} elseif ($buf === "SYST\r\n") {
162163
if (isset($bug27809)) {
163164
fputs($s, "215 OS/400 is the remote operating system. The TCP/IP version is \"V5R2M0\"\r\n");
165+
} elseif (isset($bug80901)) {
166+
fputs($s, "\r\n" . str_repeat("*", 4096) . "\r\n");
164167
} else {
165168
fputs($s, "215 UNIX Type: L8.\r\n");
166169
}

0 commit comments

Comments
 (0)