403 Commits
Author SHA1 Message Date
Ilia Alshanetsky 6507d8b33d Merge branch 'PHP-8.6'
* PHP-8.6:
  sapi/cli: Fix built-in server truncating responses after a partial write
2026-09-30 08:06:55 -04:00
Ilia Alshanetsky 31db39c96b Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  sapi/cli: Fix built-in server truncating responses after a partial write
2026-09-30 08:06:54 -04:00
Ilia Alshanetsky 1efdcc6b65 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  sapi/cli: Fix built-in server truncating responses after a partial write
2026-09-30 08:06:37 -04:00
Ilia Alshanetsky 021acbe980 sapi/cli: Fix built-in server truncating responses after a partial write
php_cli_server_content_sender_send() moved on to the next queued chunk
after a short send() of the current one. When that send() succeeded, its
bytes went out ahead of the current chunk's remainder, and the full-send
branch pointed buffer.first past both, unlinking the partially sent chunk.
The client received later chunks spliced into the body, the connection was
closed short of Content-Length, and the unsent remainder leaked. Stop at
the first partial write and resume from that chunk on the next POLLOUT.

Closes GH-23969
2026-09-30 07:38:49 -04:00
Calvin Buckley 20f4c4d605 sapi: Remove sapi_terminate_process (#23524)
This is unused; this is a vestige of 6c158374ba
and 45e327a672, which set up some timeout code
which was removed in 650c1c0a7d. Remove this
useless function from SAPIs.
2026-09-28 15:06:30 -03:00
David Carlier 7e0b2e044c Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  sapi/cli: Fix crash in the CLI server when a client is reset before being accepted
  ext/curl: Preserve callback lifetime without rejecting callback changes (#23863)

# Conflicts:
#	ext/curl/interface.c
2026-09-24 11:02:56 +01:00
David Carlier b0ea8b2537 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  sapi/cli: Fix crash in the CLI server when a client is reset before being accepted
  ext/curl: Preserve callback lifetime without rejecting callback changes (#23863)
2026-09-24 11:02:50 +01:00
David Carlier 83c59b8053 sapi/cli: Fix crash in the CLI server when a client is reset before being accepted
accept() can return a socket without filling in the peer address when the
client has already reset the connection.  The address buffer was left
uninitialized and php_network_populate_name_from_sockaddr() does not set the
output string for an unknown family, so zend_string_dup() was handed a NULL.

Zero the buffer and fall back to "-" when the address is unknown.

Close GH-23840
2026-09-24 10:56:42 +01:00
ndossche 1051af314b Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-23764: Built-in server leaks fd on HEAD request for static file
2026-09-22 17:41:52 +02:00
ndossche e039ee9231 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-23764: Built-in server leaks fd on HEAD request for static file
2026-09-22 17:41:31 +02:00
Jakub Skopal abdcfc38b4 Fix GH-23764: Built-in server leaks fd on HEAD request for static file
php_cli_server_begin_send_static() opens the file, but for HEAD requests
never stores the descriptor in client->file_fd, so nothing closes it.
Close it right away; Content-Length comes from the stat and the body is
never sent, so the descriptor is not needed.

Closes GH-23765.
2026-09-22 17:40:33 +02:00
Daniel Scherzer ed8ff1ec53 CLI server: remove "Host" header reflection from response
The server previously responded with a copy of the requested "Host" header in
the response, without any validation. That header, as defined in RFC 9110, is
intended for use in *requests*; remove it from the responses.
2026-09-20 15:35:15 -07:00
Sjoerd Langkemper b8c43c35d1 sapi/cli: support Expect 100-continue in PHP dev server
When posting large payloads, curl checks whether the server is ready for
the body. It sends an `Expect: 100-continue` header and expects
`HTTP/1.1 100 Continue` as the response before sending the body. The PHP
development server did not support this, causing a timeout in curl. This
made such requests take one second longer.

HTTP/1.0 does not support this, so the response is only sent when the
request is HTTP/1.1.

- https://everything.curl.dev/http/post/expect100.html
- https://github.com/php/php-src/issues/23242

Fix GH-23242
Close GH-23245
2026-08-25 19:51:29 +01:00
David Carlier 74d49165e4 Merge branch 'PHP-8.5'
* PHP-8.5:
  sapi/cli: check php_cli_server_client_send_through() return value
2026-08-24 17:00:00 +01:00
David Carlier 4ddced0e4f Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  sapi/cli: check php_cli_server_client_send_through() return value
2026-08-24 16:57:31 +01:00
Lazizbek Ergashev 6748db3ff5 sapi/cli: check php_cli_server_client_send_through() return value
sapi_cli_server_send_headers() sent the header buffer through
php_cli_server_client_send_through() but dropped the return value, so it
always reported SAPI_HEADER_SENT_SUCCESSFULLY, even when the send failed
and php_handle_aborted_connection() did not bail out (ignore_user_abort=1).
It now compares the send result against the buffer length and returns
SAPI_HEADER_SEND_FAILED when it comes up short.

php_cli_server_client_send_through() itself returned the number of bytes
left on failure, which equals str_len when nothing was sent: the same
value it returns on success. It now returns the number of bytes actually
sent on both paths.

Since sapi_send_headers() resets headers_sent on SAPI_HEADER_SEND_FAILED,
a headers_written flag on the client guards against rebuilding and
resending the whole header block on every subsequent output write.

Close GH-23428
2026-08-24 16:57:24 +01:00
Ilia Alshanetsky 454f1a61b7 sapi/cli: guard Content-Length overflow and enforce post_max_size (#22017)
The dev server's HTTP parser accumulates Content-Length digits into an
ssize_t without an overflow check; a 30-digit value wraps and the
consumer aborts on pemalloc. Guard the decimal and chunked-size
accumulators against SSIZE_MAX, then reject in on_headers_complete when
the parsed length exceeds post_max_size and reply 413 with the
configured limit in the body.

A chunked request carries no Content-Length, so enforce the same limit
as the chunks accumulate in on_body, and honour a non-zero return from
that callback in the parser. The body buffer was reserved from the
declared length and resized down to the bytes in hand on the next line,
so a chunk header of 7FFFFFFFFFFFFF aborted the server for no gain; grow
it from the received length instead. A parse error between a header name
and its value left the copied name owned by nobody; release both header
strings in php_cli_server_client_dtor().

Fixes GH-22003
2026-08-05 12:08:36 -04:00
Gina Peter Banyard 6877f77c62 main: convert last_error_lineno global to type uint32_t
As this is the expected type for lineno everywhere else in the engine
2026-07-30 09:45:57 +01:00
Gina Peter Banyard c30acf5b78 sapi: use bool type for headers_sent global 2026-07-28 08:53:13 +01: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
Ben Ramsey 316629d2ad license-update: sapi/cli source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Tim Düsterhus 04f06e8cf2 zend_portability: Remove EMPTY_SWITCH_DEFAULT_CASE() (#20063)
There are several issues with this macro:

- It is incorrectly named: It's not an empty default case. It's an unreachable
  default case.
- It is hiding control flow in its definition, which can be confusing for
  humans and tools (such as Coccinelle) alike, because it looks like it would
  be a statement that belongs to the "current" case rather than opening a new
  one.

Since this macro is exactly as long as explicitly spelling out its definition
(excluding the useless `break;`), it is not even making the code any more
succinct.
2026-04-06 14:46:15 +02:00
Alexandre Daubois 11a95749b1 Convert more zend_parse_parameters_none() to fast ZPP (#21330) 2026-03-04 14:07:46 +01:00
Khaled Alam d03d69a88a Remove duplicate #include statements (#21085)
* Remove duplicate #include statements across the codebase.

* feat: Restore conditional/unconditional include pairs in lscriu.c
2026-01-30 16:37:13 +01:00
Niels Dossche c27368c939 cli: Use zend_hash_str_find_ptr_lc() in get_mime_type() 2025-12-10 11:13:39 -08:00
David Carlier 5562e5558a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20554: php_cli_server() get http status as string build issue.
2025-11-22 22:26:01 +00:00
David Carlier 30fbcf9d7e Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-20554: php_cli_server() get http status as string build issue.
2025-11-22 22:25:51 +00:00
David Carlier 9149c35514 Fix GH-20554: php_cli_server() get http status as string build issue.
due to the signature of this helper it needs to be const also
bsearch key argument needs to be too.

close GH-20556
2025-11-22 22:25:33 +00:00
Ilija Tovilo 9130ddb42a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Treat accept failing with SOCK_EAGAIN as success in CLI web server
2025-10-06 14:20:40 +02:00
Ilija Tovilo 0099779902 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Treat accept failing with SOCK_EAGAIN as success in CLI web server
2025-10-06 14:20:12 +02:00
Leo Gaskin 7e7d6d6380 Treat accept failing with SOCK_EAGAIN as success in CLI web server
This ensures that no useless "Failed to poll event" error messages are
logged during normal server operation, as the SOCK_EAGAIN error simply
indicates another worker is already serving the request.

Closes GH-19964
2025-10-06 14:19:45 +02:00
Alexandre Daubois bc6117d713 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-19461: Improve error message on listening error with IPv6 (#19462)
2025-09-05 10:50:54 +02:00
Alexandre Daubois d84f463e3c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19461: Improve error message on listening error with IPv6 (#19462)
2025-09-05 10:50:11 +02:00
Alexandre Daubois a41cb62c4c Fix GH-19461: Improve error message on listening error with IPv6 (#19462) 2025-09-05 10:48:33 +02:00
Arnaud Le Blanc c561f7da85 Refresh zend_mm shadow key on fork
The shadow key is refreshed when resetting the memory manager between two
requests. But in forking SAPIs the first request of a child process inherits the
shadow key of the parent. As a result, a leak of the shadow key during the first
request of one process gives away the shadow key used during the first request
of other processes. This makes the key refresh mechanism less useful.

Here I ensure that we refresh the shadow key after a fork. We can not reset the
manager as there may be active allocations. Instead, we have to recompute shadow
pointers with the new key.

Closes GH-16765
2025-07-29 14:00:37 +02:00
Pascal Chevrel ff88701b77 Fix GH-17956 Internal dev server 404 page is not responsive
Add a basic viewport html meta tag with responsive mode parameters
See: https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag

Updated existing tests

close GH-17957
2025-03-03 12:05:00 +00:00
Jakub Zelenka 4b211a7769 Merge branch 'PHP-8.4' 2024-11-20 11:14:32 +01:00
Jakub Zelenka 7c96af42b7 Merge branch 'PHP-8.3' into PHP-8.4 2024-11-20 11:14:04 +01:00
Jakub Zelenka ffff27f734 Merge branch 'PHP-8.2' into PHP-8.3 2024-11-20 11:12:19 +01:00
Niels Dossche f18d429b20 Fix GHSA-4w77-75f9-2c8w 2024-11-20 11:07:28 +01:00
Gina Peter Banyard 6ddab74d55 sapi: Fix some variable shadowing (#16485)
sapi_module, mime_type_map, zend_extensions, php_cgi_globals, and phpdbg_globals are true globals which are being shadowed
2024-10-17 22:46:23 +01:00
Ilija Tovilo 3074cbf5b6 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Skip shebang in cli-server router script
2024-10-14 13:35:41 +02:00
Ilija Tovilo 77f770871b Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Skip shebang in cli-server router script
2024-10-14 13:34:21 +02:00
Ilija Tovilo 06efe44c2e Skip shebang in cli-server router script
Fixes GH-16373
Closes GH-16403
2024-10-14 13:33:16 +02:00
David Carlier 139accecb4 Merge branch 'PHP-8.3' into PHP-8.4 2024-10-03 22:46:02 +01:00
David Carlier 4b7a906d57 Merge branch 'PHP-8.2' into PHP-8.3 2024-10-03 22:45:51 +01:00