[php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5

From: Date: Fri, 16 Oct 2026 08:36:37 +0000
Subject: [php-src] PHP-8.5: Merge branch 'PHP-8.4' into PHP-8.5
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142345@lists.php.net to get a copy of this message
Author: ndossche (ndossche) Date: 2026-10-16T10:35:55+02:00 Commit: https://github.com/php/php-src/commit/da4e0ad0e44350baff8c69c195a23048165f5335 Raw diff: https://github.com/php/php-src/commit/da4e0ad0e44350baff8c69c195a23048165f5335.diff Merge branch 'PHP-8.4' into PHP-8.5 * PHP-8.4: Fix double free in ext/ftp data_accept() on accept failure Changed paths: A ext/ftp/tests/ftp_get_data_accept_timeout.phpt M NEWS M ext/ftp/ftp.c M ext/ftp/tests/server.inc Diff: diff --git a/NEWS b/NEWS index 9b8dd7b924ee..71c1239257cf 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,9 @@ PHP NEWS . Fixed bug GH-24229 (fcgi_close() passes shutdown() a literal 1, which is SHUT_RD in WASI). (Ryosuke Ishibashi) +- FTP: + . Fix double free in ext/ftp data_accept() on accept failure. (alepacheco) + - MBString: . Fixed bug GH-23958 (truncated encoding names resolving to full names). (Kamil Tekiela) diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index dd5580c08a53..c8168b8ffca3 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -1746,7 +1746,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 65c1af1b7aab..4ed9d29b1f4a 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)){ ; }

« previous php.cvs (#142345) next »