664 Commits
Author SHA1 Message Date
ndossche 6a02262806 Merge branch 'PHP-8.6'
* PHP-8.6:
  Fix double free in ext/ftp data_accept() on accept failure
2026-10-16 10:36:29 +02:00
ndossche 710a135750 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix double free in ext/ftp data_accept() on accept failure
2026-10-16 10:36:12 +02:00
ndossche da4e0ad0e4 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix double free in ext/ftp data_accept() on accept failure
2026-10-16 10:35:55 +02:00
Alejandro Pacheco 0d780377e5 Fix double free in ext/ftp data_accept() on accept failure
When the server never opens the active-mode data connection, my_accept()
fails and data_accept() frees the databuf_t. ftp_getdata() has already
stored it in ftp->data, so the caller's bail path then runs data_close(),
which frees it a second time. This affects ftp_get(), ftp_put(),
ftp_append(), ftp_nb_get(), ftp_nb_put() and the listing functions.

data_accept() does not own the buffer: leave it in ftp->data and let
data_close() release it, as the SSL failure paths in data_accept()
already do.

Closes GH-24339.
2026-10-16 10:35:27 +02:00
Noah Webber 5a9d50dc61 Fix typos, grammatical errors, and refactor misspelled local identifiers (#23803)
Correct typographical and grammatical mistakes across docs, comments, and build tools. Refactor local identifiers childrens to children in RecursiveFilterIterator and sav to saved_char in sapi_header_add_op.
2026-09-24 15:56:13 +02:00
ndossche 6763c25d1a Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-23619: ext/ftp: cryptic error on servers that don't support TLS session resumption on data connection
2026-09-21 22:29:49 +02:00
ndossche b48597db55 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-23619: ext/ftp: cryptic error on servers that don't support TLS session resumption on data connection
2026-09-21 22:29:43 +02:00
ndossche d841b499b8 Fix GH-23619: ext/ftp: cryptic error on servers that don't support TLS session resumption on data connection
Closes GH-23788.
2026-09-21 22:27:29 +02:00
Georgij TsarinandDenis Sergeev cafbcde162 ftp: use SSL_write_ex() in single_send() to fix signed/unsigned handling (#22967)
* ftp: use SSL_write_ex() in single_send()

Replace SSL_write() with SSL_write_ex() and pass its return value
to SSL_get_error(). This preserves the original API contract and
avoids signed/unsigned conversion issues when handling errors.

Signed-off-by: Denis Sergeev <zeff@altlinux.org>

* ftp: widen single_send() return type to ssize_t

* ftp: initialize sent before SSL_write_ex()

---------

Signed-off-by: Denis Sergeev <zeff@altlinux.org>
Co-authored-by: Denis Sergeev <zeff@altlinux.org>
2026-09-07 15:13:40 +02:00
Louis-Arnaud 9e58a1d982 ext/ftp: throw an Error when ftp_nb_fget()/ftp_nb_fput() hit a busy connection (#23540)
* ext/ftp: throw an Error when the connection is already transferring

ftp_nb_fget() and ftp_nb_fput() answered an already busy connection with a
warning and false, against a declared int return type. Reaching that guard
means a transfer was started from inside another transfer, which is a
programming mistake, so throw an Error instead, as ftp_close() already does
on the same in_use flag. The declarations stay int.

The check stays ahead of the direction and closestream writes, so the
running transfer is left untouched. The test reaches the guard through a
stream wrapper that calls back into the extension mid transfer.

* [skip ci] Note the ftp_nb_fget()/ftp_nb_fput() Error in UPGRADING

* Address review: extend the Error to ftp_nb_get() and ftp_nb_put()

The in_use guard is a programming error in all four non-blocking transfer
functions, so all four now throw the same Error instead of two of them
emitting a warning and returning false. ftp_nb_get() and ftp_nb_put() keep
their int|false declaration, which is still returned when the local file
cannot be opened.

ftp_nb_put() closes the local stream before throwing, and the guards stay
ahead of the direction/closestream writes, so a rejected re-entrant call
leaves the running transfer untouched.

ftp_nb_get_during_transfer.phpt and ftp_nb_get_during_nb_transfer.phpt
asserted the old warning; they now record the Error and still assert that
the outer transfer completes.

* Catch Throwable in the re-entrant transfer test

The test asserts the class it prints, so it must not presume Error in the
catch: a change of thrown class has to fail the test rather than escape it.
2026-09-07 15:07:47 +02:00
Dmytro Kulyk 67135cb97b gen_stub: Conditionally include zend_attributes.h to arginfo based on usage (#21570)
Headers required by the generated code (zend_attributes.h, zend_constants.h, zend_enum.h) are collected during generation and emitted as includes at the top of the arginfo file, with the same preprocessor conditions and PHP version guards as the code that needs them.

Removes the manual zend_attributes.h and zend_enum.h includes from sources that only needed them for the arginfo file they include.
2026-09-06 21:25:20 +02:00
Sjoerd Langkemper c282f04efd ext/curl: add more tests (#23333)
- CURLOPT_WRITEHEADER

- CURLOPT_MAXFILESIZE_LARGE

- CURLOPT_POSTREDIR

- CURLOPT_SSH_HOSTKEYFUNCTION

- CURLOPT_FNMATCH_FUNCTION

- CURLINFO_HEADER_OUT

- read_cb by sending a CURLFile twice

- CURLINFO_CERTINFO

- CURLE_ error constants
2026-08-29 15:34:51 +01:00
Gina Peter Banyard 9675080b10 tests: remove unnecessary ZPP tests (#23020) 2026-08-04 21:03:44 +01:00
NickSdot 1da3a6398b Applied fixers to improve test robustness to extensions with no code owners (#23018)
* ext/bz2: applied fixers to improve test robustness

* ext/calendar: applied fixers to improve test robustness

* ext/exif: applied fixers to improve test robustness

* ext/fileinfo: applied fixers to improve test robustness

* ext/filter: applied fixers to improve test robustness

* ext/ftp: applied fixers to improve test robustness

* ext/hash: applied fixers to improve test robustness

* ext/iconv: applied fixers to improve test robustness

* ext/ldap: applied fixers to improve test robustness

* ext/pcre: applied fixers to improve test robustness

* ext/posix: applied fixers to improve test robustness

* ext/readline: applied fixers to improve test robustness

* ext/shmop: applied fixers to improve test robustness

* ext/snmp: applied fixers to improve test robustness

* ext/sodium: applied fixers to improve test robustness

* ext/sqlite3: applied fixers to improve test robustness

* ext/sysvmsg: applied fixers to improve test robustness

* ext/sysvsem: applied fixers to improve test robustness

* ext/sysvshm: applied fixers to improve test robustness

* ext/tidy: applied fixers to improve test robustness

* ext/tokenizer: applied fixers to improve test robustness

* ext/zend_test: applied fixers to improve test robustness

* ext/zlib: applied fixers to improve test robustness
2026-08-04 13:10:07 +01:00
Calvin Buckley de5a5820ef Use php_pollfd_for_ms more consistently for single fd polling (#22872)
* ftp: For single fd poll calls, use php_pollfd_for_ms

* pgsql: Use php_pollfd_for_ms in compat shim

This is only used on pre-libpq 17.

* fastcgi: Use php_pollfd_for_ms for single fd

This also handles the case where poll isn't available (does that even
matter nowadays?)

* io: Use php_pollfd_for_ms for single fd poll

* cli: Convert to php_pollfd_for from select

This is not a poll call, but it is functionally the same as one; convert
it to the single fd polling function which is clearer to read.
2026-07-24 15:14:46 -03:00
Calvin Buckley cdbc479b3a Merge branch 'PHP-8.5'
* PHP-8.5:
  Regenerate the expired ext/ftp/tests/cert.pem (#22873)
2026-07-23 15:10:09 -03:00
Calvin Buckley 060aee9ae2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Regenerate the expired ext/ftp/tests/cert.pem (#22873)
2026-07-23 15:10:01 -03:00
Calvin Buckley cc92d504a4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Regenerate the expired ext/ftp/tests/cert.pem (#22873)
2026-07-23 15:09:51 -03:00
Calvin Buckley d0f817bfd2 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Regenerate the expired ext/ftp/tests/cert.pem (#22873)
2026-07-23 15:09:40 -03:00
Ilia Alshanetsky 011ad34868 Regenerate the expired ext/ftp/tests/cert.pem (#22873)
The self-signed certificate the FTP test server presents
(ext/ftp/tests/server.inc) was generated in 2016 with a ten-year
validity and expired on 2026-07-23, so ext/ftp/tests and the ftps://
stream tests (ext/standard/tests/streams/opendir-003 and -004) fail the
TLS handshake with "certificate expired" on every branch. Regenerate it
as a self-signed CN=127.0.0.1 certificate that expires 2099-12-31, so
the suite does not silently break again on a ten-year cadence.
2026-07-23 15:08:36 -03:00
Ilia Alshanetsky 46a35fff75 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/ftp: apply the connect timeout ceiling to the remaining entry points
2026-07-17 15:54:01 -04:00
Ilia Alshanetsky e193897226 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/ftp: apply the connect timeout ceiling to the remaining entry points
2026-07-17 15:40:50 -04:00
Ilia Alshanetsky c1773a1da2 ext/ftp: apply the connect timeout ceiling to the remaining entry points
GH-20601 capped the timeout in ftp_connect() so a value that overflows the
timeval conversion cannot reach php_network_set_limit_time(). ftp_ssl_connect()
and ftp_set_option(FTP_TIMEOUT_SEC) kept rejecting only non-positive values, so
PHP_INT_MAX still reached ftp_open() and my_poll() through them.

Apply the same bound to both, factored into a shared PHP_FTP_TIMEOUT_SEC_MAX
macro. ftp_ssl_connect() with PHP_INT_MAX hung before this rather than
reporting the bad argument.

Closes GH-22767
2026-07-17 15:37:39 -04:00
Ilia Alshanetsky 47355da494 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/standard: fix out-of-bounds access in the ftp:// directory stream
2026-07-16 22:14:33 -04:00
Ilia Alshanetsky 1ca5d65428 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/standard: fix out-of-bounds access in the ftp:// directory stream
2026-07-16 22:12:57 -04:00
Ilia Alshanetsky b750803b76 ext/standard: fix out-of-bounds access in the ftp:// directory stream
php_ftp_dirstream_read() sized the basename copy with
MIN(sizeof(ent->d_name), ZSTR_LEN(basename) - 1) and wrote the terminator at
[tmp_len - 1]. An empty listing line leaves a basename of length 1, so
tmp_len is 0 and the NUL lands one byte before d_name; a slash-only line
leaves length 0, so the subtraction underflows to SIZE_MAX and memcpy() reads
4096 bytes past the interned empty string. The same off-by-one truncated
entry names that do not end in CRLF.

Closes GH-22768
2026-07-16 22:10:48 -04:00
Ilia Alshanetsky 95a47246dd Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix use-after-free on re-entrant ftp_close() during a transfer
2026-07-12 21:10:28 -04:00
Ilia Alshanetsky 765fe90b59 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix use-after-free on re-entrant ftp_close() during a transfer
2026-07-12 21:07:01 -04:00
Ilia Alshanetsky 1feb20156b Fix use-after-free on re-entrant ftp_close() during a transfer
A user stream wrapper passed to a blocking or non-blocking FTP transfer can
re-enter the engine from its stream_read/stream_write handler while the
engine still holds the freed ftpbuf_t/databuf_t on the C stack, so the
transfer resumes on freed memory. Guard every operation that opens a data
connection with an in_use flag: ftp_close() throws while it is set, and the
transfer and listing functions refuse to run. The non-blocking checks sit
at the userland entry, before the wrapper mutates ftp->direction/stream, so
a rejected re-entrant call cannot corrupt the outer transfer; the nb cleanup
clears ftp->stream before closing the stream so a stream_close() that calls
ftp_close() cannot double-close it.

Closes GH-22400
2026-07-12 20:55:06 -04:00
Ilia Alshanetsky c340b2cf08 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/ftp: fix off-by-one terminator write in ftp_readline()
2026-06-21 17:21:06 -04:00
Ilia Alshanetsky b5e2653705 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/ftp: fix off-by-one terminator write in ftp_readline()
2026-06-21 17:18:53 -04:00
Ilia Alshanetsky 34a9a43904 ext/ftp: fix off-by-one terminator write in ftp_readline()
The bug80901 fix (09696eee9d) terminates an over-long response with
*data = 0, but when the line fills the whole FTP_BUFSIZE inbuf without a
CR/LF, data points at inbuf[FTP_BUFSIZE] and the terminator is written one
byte past the buffer, into the adjacent ftpbuf_t::extra field. Reserve the
final byte for the terminator so it always lands inside inbuf. A
buffer-filling response loses its last character (bug80901's SYST reply is
now 4095 visible chars, with the terminator taking the 4096th slot).

Closes GH-22377
2026-06-21 17:16:06 -04:00
Ilia Alshanetsky f9b2ecfabb ext/ftp: preserve bare CR bytes in ftp_get() ASCII mode (#22364)
In ASCII mode ftp_get() stripped every '\r' and emitted only a following
'\n', dropping bare CR bytes not part of a CRLF sequence. Fold CRLF to
LF but write a lone '\r' through unchanged, carrying a '\r' on the final
byte of a read into the next read and flushing it at EOF, so the buffer
boundary behaves the same as the in-buffer case. ftp_nb_get() already
does this via the lastch carry in ftp_nb_continue_read().
2026-06-20 07:53:54 -04:00
Ilia Alshanetsky e71b4e5928 Merge branch 'PHP-8.5'
* PHP-8.5:
  ext/ftp: fix out-of-bounds read in ftp_get() ASCII CRLF translation
2026-06-18 18:37:36 -04:00
Ilia Alshanetsky 9820f01cd1 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  ext/ftp: fix out-of-bounds read in ftp_get() ASCII CRLF translation
2026-06-18 18:35:25 -04:00
Ilia Alshanetsky 35fde02e42 ext/ftp: fix out-of-bounds read in ftp_get() ASCII CRLF translation
In ASCII mode ftp_get() peeks at the byte after each '\r' to fold CRLF
into LF. When that '\r' is the last byte of a full FTP_BUFSIZE read, the
lookahead reads one byte past the buffer; a server placing '\r' at
offset 4095 of a 4096-byte read hits it (ASAN: heap-buffer-overflow
read of size 1). Bound the lookahead to the received data, as
ftp_readline() does. ftp_nb_continue_read() carries the trailing '\r'
across reads and isn't affected.

Closes GH-22328
2026-06-18 18:32:27 -04:00
Ilija Tovilo 529b145511 Merge branch 'PHP-8.5'
* PHP-8.5:
  GHSA-m8rr-4c36-8gq4: Consistently pass unsigned char to ctype.h functions
2026-05-06 13:11:01 +02:00
Ilija Tovilo b8dad9314c GHSA-m8rr-4c36-8gq4: Consistently pass unsigned char to ctype.h functions
Fixes GHSA-m8rr-4c36-8gq4
Fixes CVE-2026-7258
2026-05-06 13:10:12 +02:00
Ilija Tovilo dc9e21b81c GHSA-m8rr-4c36-8gq4: Consistently pass unsigned char to ctype.h functions
Fixes GHSA-m8rr-4c36-8gq4
Fixes CVE-2026-7258
2026-05-06 13:09:23 +02:00
Ilija Tovilo 398b7dabfb GHSA-m8rr-4c36-8gq4: Consistently pass unsigned char to ctype.h functions
Fixes GHSA-m8rr-4c36-8gq4
Fixes CVE-2026-7258
2026-05-06 13:08:17 +02:00
Ilija Tovilo a38418777f GHSA-m8rr-4c36-8gq4: Consistently pass unsigned char to ctype.h functions
Fixes GHSA-m8rr-4c36-8gq4
Fixes CVE-2026-7258
2026-05-06 13:07:20 +02:00
Tim Düsterhus 7114314c5a tree-wide: Replace XtOffsetOf by its definition (#21899)
`offsetof()` is in `stddef.h` and thus always available. The extra macro is an
unnecessary layer of indirection.
2026-04-28 22:12:56 +02:00
Ben Ramsey 929e489a8a license-update: ext/ftp source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Arshid c524773a4f ext/ftp: Remove unreachable break (#21481) 2026-03-21 11:24:04 +00:00
Arshid c995a6cb4b ext/ftp: Returning a boolean value using RETURN_BOOL (#21187) 2026-02-10 12:26:18 +00:00
Arshid 9580d47898 ext/ftp: Use STANDARD_MODULE_HEADER instead of STANDARD_MODULE_HEADER_EX (#21088) 2026-01-30 09:05:43 +00:00
Arnaud Le Blanc 65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
David Carlier 50abef95bd Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20603 issue on windows 32 bits.
2025-12-03 20:23:01 +00:00
David Carlier f90d1f7aa6 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20603 issue on windows 32 bits.
2025-12-03 20:22:50 +00:00
David Carlier 51f4450b47 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-20603 issue on windows 32 bits.
2025-12-03 20:22:38 +00:00