Commit graph

349 commits

Author SHA1 Message Date
Peter Kokot
cf3b9fca8f
Sync #if/ifdef/defined (-Wundef) (#14623)
These are either define (to value 1) or undefined:
- __GNUC__
- DBA_CDB_BUILTIN
- DBA_GDBM
- HAVE_FORK
- HAVE_PUTENV
- HAVE_SETENV
- HAVE_SYS_SELECT_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_WAIT_H
- HAVE_UNSETENV
- RFC3678_API
- ZEND_ENABLE_ZVAL_LONG64
- ZTS

Follow-up of GH-5526
2024-06-24 19:37:07 +02:00
Peter Kokot
5d3fab9334
Sync #if/ifdef/defined (#14520)
These are either undefined or defined (to value 1):
- __DragonFly__
- __FreeBSD__
- HAS_MCAST_EXT
- HAVE_GETCWD
- HAVE_GETWD
- HAVE_GLIBC_ICONV
- HAVE_JIT
- HAVE_LCHOWN
- HAVE_NL_LANGINFO
- HAVE_RL_CALLBACK_READ_CHAR
- HAVE_RL_ON_NEW_LINE
- HAVE_SQL_EXTENDED_FETCH
- HAVE_UTIME

Follow up of GH-5526 (-Wundef)
2024-06-11 22:47:05 +02:00
Peter Kokot
84a0da1574
Sync #if/ifdef/defined (#14508)
This syncs CPP macro conditions:
- _WIN32
- _WIN64
- HAVE_ALLOCA_H
- HAVE_ALPHASORT
- HAVE_ARPA_INET_H
- HAVE_CONFIG_H
- HAVE_DIRENT_H
- HAVE_DLFCN_H
- HAVE_GETTIMEOFDAY
- HAVE_LIBDL
- HAVE_POLL_H
- HAVE_PWD_H
- HAVE_SCANDIR
- HAVE_SYS_FILE_H
- HAVE_SYS_PARAM_H
- HAVE_SYS_SOCKET_H
- HAVE_SYS_TIME_H
- HAVE_SYS_TYPES_H
- HAVE_SYS_WAIT_H
- HAVE_UNISTD_H
- PHP_WIN32
- ZEND_WIN32

These are either undefined or defined to 1 in Autotools and Windows.

Follow up of GH-5526 (-Wundef).
2024-06-09 14:23:41 +02:00
Peter Kokot
2d66562e4b
Sync HAVE_IPV6 and HAVE_GETADDRINFO in #if/ifdef/defined (#14341)
Follow up of GH-5526 (-Wundef)
2024-05-28 11:52:25 +02:00
Cristian Rodríguez
8e62e2b829
Mark multple functions as static (#13864)
* Mark many functions as static

Multiple functions are missing the static qualifier.

* remove unused struct sigactions

struct sigaction act, old_term, old_quit, old_int;
all unused.

* optimizer: minXOR and maxXOR are unused
2024-05-22 13:11:46 +02:00
Ilija Tovilo
cd66fcc68b
Add request_parse_body() function
RFC: https://wiki.php.net/rfc/rfc1867-non-post

This function allows populating the $_POST and $_FILES globals for non-post
requests. This avoids manual parsing of RFC1867 requests.

Fixes #55815
Closes GH-11472
2024-02-08 12:08:07 +01:00
Ilija Tovilo
c149b4f56f
Fix missing syntax error message in cli-server router script
Fixes GH-13113
Closes GH-13275
2024-02-07 16:13:08 +01:00
Ilija Tovilo
d7d0d19d32
Support index.php fallback for files in built-in server
If no router script is used, the built-in webserver will now look for a fallback
index file recursively in all cases, including URLs with a period.

Fixes GH-12604
Closes GH-12992
2024-01-09 16:13:39 +01:00
Ilija Tovilo
8876639d11
Add X-Powered-By header to builtin 404 page (#13092)
As requested by 30929c9a88 (r1434156785).
2024-01-09 16:10:39 +01:00
Ilija Tovilo
a559a5e530
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix max_execution_time with cli-server router script
2023-12-07 16:13:21 +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
7c41509e26 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  php_cli_server: ensure single date header is present
2023-10-06 17:51:38 +02: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
d58e3c05c9 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11716: cli server crashes on SIGINT when compiled with ZEND_RC_DEBUG=1
2023-07-21 15:31:33 +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
George Peter Banyard
d5ad75108e
More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
Cédric Anne
c02348cf9d
Make SERVER_SOFTWARE compliant with RFC3875 (#11093) 2023-05-05 12:43:34 +01:00
George Peter Banyard
382148d7bb
Fix UBSAN warning about applying zero offset to null pointer (#10700)
vpath may be NULL here so check for it before trying to add 0 (the length of the vpath) to it.
2023-02-26 14:06:30 +00:00
Max Kellermann
d46dea169c
Make globals const (part 2) (#10610)
* Zend/zend_enum: make `forbidden_methods` static+const

* main/php_syslog: make `xdigits` static

* sapi/fpm: make several globals `const`

* sapi/phpdbg: make `OPTIONS` static

* sapi/phpdbg/help: make help texts const

* sapi/cli: make `template_map` const

* ext/ffi: make `zend_ffi_types` static

* ext/bcmath: make `ref_str` const

* ext/phar: make several globals static+const
2023-02-18 19:52:53 +00:00
Christoph M. Becker
c8955c078a
Revert GH-10220
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491.
This reverts commit 588a07f737.
This reverts commit f377e15751.
This reverts commit b4ba16fe18.
This reverts commit 694ec1deea.
This reverts commit 6b34de8eba.
This reverts commit aa1cd02a43.
This reverts commit 308fd311ea.
This reverts commit 16203b53e1.
This reverts commit 738fb5ca54.
This reverts commit 9fdbefacd3.
This reverts commit cd4a7c1d90.
This reverts commit 928685eba2.
This reverts commit 01e5ffc85c.
2023-01-16 12:27:33 +01:00
Max Kellermann
6b34de8eba sapi/*: add missing includes 2023-01-10 14:19:03 +00:00
David Carlier
84988d2093 cli server addressing few todos.
Closes GH-10124.
2022-12-22 14:03:35 +00:00
Ilija Tovilo
ec55d341bf
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix cli server blocking on accept when using multiple workers
2022-10-20 13:04:32 +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
George Peter Banyard
f8b53e7028
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix memory-leak in CLI web server
2022-10-06 11:36:50 +01: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
Ilija Tovilo
ecc3fc180f
Use PDEATHSIG to kill cli-server workers if parent exists
Closes GH-9476
2022-09-08 10:48:20 +02: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