[php-src] PHP-7.4: Fix #80901: Info leak in ftp extension

From: Date: Mon, 26 Apr 2021 13:10:02 +0000
Subject: [php-src] PHP-7.4: Fix #80901: Info leak in ftp extension
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-115834@lists.php.net to get a copy of this message
Author: Christoph M. Becker (cmb69) Date: 2021-04-26T15:07:08+02:00 Commit: https://github.com/php/php-src/commit/c0ae3a7fb7f46158a69a1f42aeb9971e619ac969 Raw diff: https://github.com/php/php-src/commit/c0ae3a7fb7f46158a69a1f42aeb9971e619ac969.diff Fix #80901: Info leak in ftp extension We ensure that inbuf is NUL terminated on ftp_readline() failure. Closes GH-6894. Changed paths: A ext/ftp/tests/bug80901.phpt M NEWS M ext/ftp/ftp.c M ext/ftp/tests/server.inc Diff: diff --git a/NEWS b/NEWS index 6a9ec0e0011e..251980934f5b 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,9 @@ PHP NEWS (cmb) . Fixed bug #80972 (Memory exhaustion on invalid string offset). (girgias) +- FTP: + . Fixed bug #80901 (Info leak in ftp extension). (cmb) + - pgsql: . Fixed php_pgsql_fd_cast() wrt. php_stream_can_cast(). (cmb) diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index f2da6e5153fd...9b04edcd0998 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -1349,10 +1349,12 @@ ftp_readline(ftpbuf_t *ftp) data = eol; if ((rcvd = my_recv(ftp, ftp->fd, data, size)) < 1) { + *data = 0; return 0; } } while (size); + *data = 0; return 0; } /* }}} */ diff --git a/ext/ftp/tests/bug80901.phpt b/ext/ftp/tests/bug80901.phpt new file mode 100644 index 000000000000..6196bdce9630 --- /dev/null +++ b/ext/ftp/tests/bug80901.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #80901 (Info leak in ftp extension) +--SKIPIF-- +<?php +require 'skipif.inc'; +?> +--INI-- +log_errors_max_len=0 +--FILE-- +<?php +$bug80901 = true; +require 'server.inc'; + +$ftp = ftp_connect("127.0.0.1", $port); +if (!$ftp) die("Couldn't connect to the server"); +var_dump(ftp_login($ftp, 'user', 'pass')); +ftp_systype($ftp); +?> +--EXPECTF-- +bool(true) + +Warning: ftp_systype(): **************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** in %s on line %d diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index ed21843f431e..71f0881dea66 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -107,6 +107,7 @@ if ($pid) { fputs($s, "234 auth type accepted\r\n"); } else { fputs($s, "666 dummy\r\n"); + sleep(1); fputs($s, "666 bogus msg\r\n"); exit; } @@ -197,6 +198,8 @@ if ($pid) { } elseif ($buf === "SYST\r\n") { if (isset($bug27809)) { fputs($s, "215 OS/400 is the remote operating system. The TCP/IP version is \"V5R2M0\"\r\n"); + } elseif (isset($bug80901)) { + fputs($s, "\r\n" . str_repeat("*", 4096) . "\r\n"); } else { fputs($s, "215 UNIX Type: L8.\r\n"); }

« previous php.cvs (#115834) next »