[php-src] master: Merge branch 'PHP-8.6'

From: Date: Fri, 16 Oct 2026 08:36:39 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142344@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-16T10:36:29+02:00 Commit: https://github.com/php/php-src/commit/6a02262806e510b0b975e04d3397457d670d849d Raw diff: https://github.com/php/php-src/commit/6a02262806e510b0b975e04d3397457d670d849d.diff Merge branch 'PHP-8.6' * PHP-8.6: Fix double free in ext/ftp data_accept() on accept failure Changed paths: A ext/ftp/tests/ftp_get_data_accept_timeout.phpt M ext/ftp/ftp.c M ext/ftp/tests/server.inc Diff: diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 943ab41e4c49..c6fd158ddaed 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -1752,7 +1752,7 @@ static databuf_t* data_accept(databuf_t *data, ftpbuf_t *ftp) data->listener = -1; if (data->fd == -1) { - efree(data); + /* data is still owned by ftp->data, the caller's data_close() frees it */ return NULL; } diff --git a/ext/ftp/tests/ftp_get_data_accept_timeout.phpt b/ext/ftp/tests/ftp_get_data_accept_timeout.phpt new file mode 100644 index 000000000000..bf0ece9a3fa2 --- /dev/null +++ b/ext/ftp/tests/ftp_get_data_accept_timeout.phpt @@ -0,0 +1,39 @@ +--TEST-- +ftp_get()/ftp_nb_get() fail cleanly when the active data connection is never opened +--EXTENSIONS-- +ftp +pcntl +--FILE-- +<?php +require 'server.inc'; + +$ftp = ftp_connect('127.0.0.1', $port, 1); +if (!$ftp) die("Couldn't connect to the server"); + +var_dump(ftp_login($ftp, 'anonymous', 'IEUser@')); +var_dump(ftp_pasv($ftp, false)); + +$local_file = __DIR__ . DIRECTORY_SEPARATOR . "ftp_get_data_accept_timeout.txt"; + +var_dump(ftp_get($ftp, $local_file, 'no_data_connection', FTP_BINARY)); +var_dump(ftp_nb_get($ftp, $local_file, 'no_data_connection', FTP_BINARY) === FTP_FAILED); + +ftp_close($ftp); +?> +--CLEAN-- +<?php +@unlink(__DIR__ . DIRECTORY_SEPARATOR . "ftp_get_data_accept_timeout.txt"); +?> +--EXPECTF-- +bool(true) +bool(true) + +Warning: ftp_get(): %s timed out in %s on line %d + +Warning: ftp_get(): File status okay; about to open data connection. in %s on line %d +bool(false) + +Warning: ftp_nb_get(): %s timed out in %s on line %d + +Warning: ftp_nb_get(): File status okay; about to open data connection. in %s on line %d +bool(true) diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index b8ac8893ea0d..3fc167148a0e 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -328,6 +328,11 @@ if ($pid) { break; } }elseif (preg_match('/^RETR ([\/]*[\w\h]+)/', $buf, $matches)) { + if ($matches[1] === "no_data_connection") { + // Never open the active data connection. + fputs($s, "150 File status okay; about to open data connection.\r\n"); + continue; + } if(!empty($pasv)){ $fs = $pasvs; }

« previous php.cvs (#142344) next »