Skip to content

Commit 33d4955

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix #80901: Info leak in ftp extension
2 parents 418fcd2 + 09696ee commit 33d4955

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ PHP NEWS
99
(cmb)
1010
. Fixed bug Bug #80972 (Memory exhaustion on invalid string offset). (girgias)
1111

12+
- FTP:
13+
. Fixed bug #80901 (Info leak in ftp extension). (cmb)
14+
1215
- pgsql:
1316
. Fixed php_pgsql_fd_cast() wrt. php_stream_can_cast(). (cmb)
1417

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
@@ -107,6 +107,7 @@ if ($pid) {
107107
fputs($s, "234 auth type accepted\r\n");
108108
} else {
109109
fputs($s, "666 dummy\r\n");
110+
sleep(1);
110111
fputs($s, "666 bogus msg\r\n");
111112
exit;
112113
}
@@ -197,6 +198,8 @@ if ($pid) {
197198
} elseif ($buf === "SYST\r\n") {
198199
if (isset($bug27809)) {
199200
fputs($s, "215 OS/400 is the remote operating system. The TCP/IP version is \"V5R2M0\"\r\n");
201+
} elseif (isset($bug80901)) {
202+
fputs($s, "\r\n" . str_repeat("*", 4096) . "\r\n");
200203
} else {
201204
fputs($s, "215 UNIX Type: L8.\r\n");
202205
}

0 commit comments

Comments
 (0)