Commit graph

328 commits

Author SHA1 Message Date
David Carlier
3d80d98a10
Fix GH-16137: "Deduplicate" http headers values but Set-Cookie.
Those are meant to have 1 or plus values separated by a comma even
 if the client set them separately.

close GH-16154
2024-10-03 22:45:31 +01:00
Ilija Tovilo
299c3ba89e
Fix max_execution_time with cli-server router script
When the cli-server specifies a router script, we run it using
zend_execute_scripts instead of php_execute_script, because the former preserves
the return value of the script. However, php_execute_script also starts resets
the execution timer with the value from max_execution_time. If the timer has
previously been initialized with max_input_time, it will never be reset, and
thus trigger at the incorrect time.

Closes GH-12886
2023-12-07 16:11:48 +01:00
Niels Dossche
a1845944ce Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  php_cli_server: ensure single date header is present
2023-10-06 17:50:13 +02:00
coppolafab
f6ac08c6a3 php_cli_server: ensure single date header is present
Currently the PHP Development Server appends a Date header in the
response, despite already set from user code.

Added a check condition before append the header, and a test file.

Closes GH-12363.
2023-10-06 17:49:30 +02:00
Niels Dossche
272dc9a09c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
2023-07-21 15:31:20 +02:00
Niels Dossche
af77d3b8da Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
Closes GH-11757.
2023-07-21 15:23:56 +02:00
Ilija Tovilo
ce527ed599
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix cli server blocking on accept when using multiple workers
2022-10-20 13:04:25 +02:00
Ilija Tovilo
6be8efdf78
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix cli server blocking on accept when using multiple workers
2022-10-20 13:04:14 +02:00
Ilija Tovilo
d52f0451ad
Fix cli server blocking on accept when using multiple workers
Fixes GH-9400
Closes GH-9693
2022-10-20 13:03:35 +02:00
Benoit Viguier
58fc34ffb7
Fix memory-leak in CLI web server
Closes GH-9680

Signed-off-by: George Peter Banyard <girgias@php.net>
2022-10-06 11:36:08 +01:00
Vedran Miletić
7065a222b7 Respond with HTTP status 405 to DELETE/PUT/PATCH request on a static resource
Co-authored-by: Marin Martuslović <marin.martuslovic@student.uniri.hr>
2022-08-28 13:26:30 +01:00
Vedran Miletić
4f509058a9 Respond without body to HEAD request on a static resource
Co-authored-by: Marin Martuslović <marin.martuslovic@student.uniri.hr>
2022-08-28 13:26:30 +01:00
Ilija Tovilo
98bdb7f99b
Make pestr[n]dup infallible (#9295)
Fixes GH-9128
Closes GH-9295
2022-08-12 12:21:14 +02:00
George Peter Banyard
c8f4801382
Convert client->request.request_uri to zend_string (#9086) 2022-07-22 10:39:13 +01:00
David Carlier
37e214bdc2 Merge branch 'PHP-8.1' 2022-07-14 12:20:59 +01:00
David Carlier
b44a17c02a Merge branch 'PHP-8.0' into PHP-8.1 2022-07-14 12:13:21 +01:00
guoyiyuan
789a37f144 Prevent potential buffer overflow for large value of php_cli_server_workers_max
Fixes #8989.
Closes #9000.
2022-07-14 12:12:25 +01:00
George Peter Banyard
1c753a958b Pre-compute remote address length in CLI SAPI 2022-07-01 21:18:26 +01:00
George Peter Banyard
b37245b8da Refactor registration of variables for the CLI SAPI 2022-07-01 21:18:26 +01:00
George Peter Banyard
3bf4098eee
Refactor (again) CLI SAPI server_client struct to use zend_string* (#8605)
This time in a way which works under a RC Debug build.
2022-05-30 13:03:23 +01:00
Nikita Popov
82d407b7e0 Revert "Refactor CLI SAPI php_cli_server_client struct to use zend_string (#8522)"
This reverts commit 9b19d90432.

This has broken the ZEND_RC_DEBUG build.
2022-05-21 16:52:21 +02:00
George Peter Banyard
9b19d90432
Refactor CLI SAPI php_cli_server_client struct to use zend_string (#8522)
This is a stepping stone in converting more pairs of ``char*`` and ``size_t`` to ``zend_string*`` across the CLI SAPI.

Also amend the CLI SAPI test setup to output it's content when it crashes/errors so that one can debug ASAN/UBSAN/MSAN violations.

Drive-by MSAN fix.

Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
2022-05-15 21:11:13 +01:00
George Peter Banyard
d4e24e72af Fix Windows build
sapi\cli\php_cli_server.c(2637): warning C4133: 'function': incompatible types - from 'zend_result (__cdecl *)(void *,php_socket_t,int)' to 'int (__cdecl *)(void *,php_socket_t,int)'

Probably a good idea to make GCC complain about these sort of issues too
2022-05-10 12:26:54 +01:00
George Peter Banyard
0fad4d1d96 Fix ASAN build 2022-05-10 12:04:42 +01:00
George Peter Banyard
9601475ebb
Minimal refactoring of CLI SAPI (#8519)
More specific types, some cleanup and voidifying functions which always return ``SUCCESS``
2022-05-09 22:29:16 +01:00
George Peter Banyard
b5db594fd2
Refacto php_module_startup() (#8303)
It only ever uses at most 1 additional modules
2022-04-27 23:07:11 +01:00
Remi Collet
bc9d604430
Merge branch 'PHP-8.1'
* PHP-8.1:
  fix [-Wstrict-prototypes] buid warnings
2021-11-24 14:55:30 +01:00
Remi Collet
ef2fd0e5b5
fix [-Wstrict-prototypes] buid warnings 2021-11-24 14:55:11 +01:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Joe Watkins
e829284b53
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81496: CLI server logs wrong request method
2021-10-05 08:43:38 +02:00
Joe Watkins
03e9bed5b5
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81496: CLI server logs wrong request method
2021-10-05 08:43:09 +02:00
Lauri Kenttä
cdcdb33080
Fix #81496: CLI server logs wrong request method 2021-10-05 08:42:38 +02:00
Nikita Popov
28e882a162 Fix null pointer ubsan warning
Don't pass null pointer to memmove, even with zero length.
2021-09-17 10:25:52 +02:00
Christoph M. Becker
be2df43b08
Fix #78919: CLI server: insufficient cleanup if request startup fails
We need to run the full `php_cli_server_request_shutdown()` in case of
failing `php_cli_server_request_startup()`.

Patch contributed by @cataphract.

Closes GH-7322.
2021-08-17 12:41:06 +02:00
Nikita Popov
efbb2198d4 Return value from ZEND_ATOL
Instead of assigning it as part of the macro itself, which makes
usage quite awkward.
2021-07-12 16:51:24 +02:00
Christoph M. Becker
0189c8b740
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #73630: Built-in Weberver - overwrite $_SERVER['request_uri']
2021-06-30 16:17:02 +02:00
Christoph M. Becker
70b0330e53
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73630: Built-in Weberver - overwrite $_SERVER['request_uri']
2021-06-30 16:15:50 +02:00
Christoph M. Becker
d7db5701a3
Fix #73630: Built-in Weberver - overwrite $_SERVER['request_uri']
The built-in Webserver's `on_path`, `on_query_string` and `on_url`
callbacks may be called multiple times from the parser; we must not
simply replace the old values, but need to concatenate the new values
instead.

This appears to be tricky for `on_path` due to the path normalization,
so we fail if the function is called again.

The built-in Webserver logs errors during request parsing to stderr,
but this is ignored by the php_cli_server framework, and apparently the
Webserver does not send a resonse at all in such cases (instead of an
4xx).  Thus we can only check that a request with an overly long path
fails.

Closes GH-7207.
2021-06-30 16:13:08 +02:00
George Peter Banyard
c40231afbf
Mark various functions with void arguments.
This fixes a bunch of [-Wstrict-prototypes] warning,
because in C func() and func(void) have different semantics.
2021-05-12 14:55:53 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
b66eb866c9 Convert last_error_file to zend_string 2021-04-23 11:05:14 +02:00
George Peter Banyard
5caaf40b43
Introduce pseudo-keyword ZEND_FALLTHROUGH
And use it instead of comments
2021-04-07 00:46:29 +01:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Nikita Popov
8786625e1e Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix CLI server worker support
2021-02-04 15:24:20 +01:00
Nikita Popov
5cb25a2d32 Fix CLI server worker support
If we create separate listening sockets in each worker using
SO_REUSEADDR, then an incoming connection may be load-balanced
to a process that is already busy, either due to a long-running
request, or because it is a recursive request (in which case we
would deadlock).

Instead, only create one listening socket, and only create worker
forks afterwards. This way the incoming request will be served
by one of the workers that is currently listening for an incoming
connection.
2021-02-04 15:22:34 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
George Peter Banyard
a29b4a7bea Fix [-Wduplicated-branches] in CLI SAPI 2020-10-09 20:54:39 +01:00
Sara Golemon
a61a9fe9a0
Support ephemeral ports in debug server 2020-09-17 14:44:07 +00:00
twosee
bd1d11d352 Simplify error type filter
Closes GH-6049.
2020-09-10 17:36:04 +08:00
Christoph M. Becker
1902f730ee Support cli_server.color on Windows
On Windows, we have to check whether stdout is attached to a console,
and whether that console supports VT100 control codes.

Closes GH-5996
2020-08-28 18:45:09 +02:00