Commit Graph

6170 Commits

Author SHA1 Message Date
Ilija Tovilo
a5833577d7
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix in-place modification of filename in php_message_handler_for_zend
2023-11-20 14:13:12 +01:00
Ilija Tovilo
05a815399e
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix in-place modification of filename in php_message_handler_for_zend
2023-11-20 14:13:06 +01:00
Ilija Tovilo
d8e866da04
Fix in-place modification of filename in php_message_handler_for_zend
php_strip_url_passwd modifies url in-place. We cannot assume from
php_message_handler_for_zend that data is a temporary, modifiable string.

Fixes oss-fuzz #64209
Closes GH-12733
2023-11-20 14:12:25 +01:00
David CARLIER
931a8b0739
inet_ntop requirement check at configure time instead (#12700) 2023-11-17 16:01:46 +00:00
Jakub Zelenka
62b2ad4b8a
Merge branch 'PHP-8.3' 2023-11-17 13:42:59 +00:00
Jakub Zelenka
7abe3fe4c6
Merge branch 'PHP-8.2' into PHP-8.3 2023-11-17 13:41:50 +00:00
Jakub Zelenka
4da89d86ec
Fix stream fclose_stdiocast_flush_in_progress type 2023-11-17 13:33:55 +00:00
Jakub Zelenka
6734880ef5
Fix bug #79945: Stream wrappers in imagecreatefrompng causes segfault
Closes GH-12696
2023-11-17 13:26:42 +00:00
Ben Ramsey
55dfc29539
PHP-8.1 is now for PHP 8.1.27-dev 2023-11-07 14:28:31 -06:00
Sergey Panteleev
239a26fa90
PHP-8.2 is now for PHP 8.2.14-dev 2023-11-07 17:12:19 +03:00
David Carlier
44f9c226aa following-up on GH-12551: removing inet_ntoa usage
Close GH-12554
2023-11-06 12:05:56 +00:00
Jakub Zelenka
a66c926b68
Merge branch 'PHP-8.3' 2023-11-03 14:08:39 +00:00
Jakub Zelenka
e43438544e
Merge branch 'PHP-8.2' into PHP-8.3 2023-11-03 14:07:36 +00:00
Jakub Zelenka
e3d1beb0f1
Fix bug #76922: FastCGI terminates conn after FCGI_GET_VALUES
Closes GH-12387
2023-11-03 14:06:36 +00:00
Patrick Allaert
be64db5939
PHP-8.1 is now for PHP 8.1.26-dev 2023-10-10 22:54:03 +02:00
Pierrick Charron
2642a08697
PHP-8.2 is now for PHP 8.2.13-dev 2023-10-10 11:45:26 -04:00
Jakub Zelenka
96a30882ca
Merge branch 'PHP-8.3' 2023-09-24 16:51:35 +01:00
Jakub Zelenka
5e8c992c78
Reduce impact of stream file path check in filestat
Fix for #76857 introduced slight perf regression so this is an attempt
to fix it. The idea is to re-use stream path check from ZendAccelerator
that should be quicker than strstr.

Signed-off-by: Jakub Zelenka <bukka@php.net>
2023-09-24 16:50:01 +01:00
David Carlier
4834e7ede5 Merge branch 'PHP-8.3' 2023-09-24 15:21:10 +01:00
David Carlier
4400eb270f Merge branch 'PHP-8.2' into PHP-8.3 2023-09-24 15:20:24 +01:00
David Carlier
4bfd3459fe Merge branch 'PHP-8.1' into PHP-8.2 2023-09-24 15:19:02 +01:00
David Carlier
d65c80031a Fix GH-12190: stream_context_create with address and port at 0.
Prior to the 8.1 rewrite, inet_aton was used for ipv4 addresses
therefore addresses like `0` passed.
For the bindto's case where both ip and port are set as such, we discard
the address binding.

Close GH-12195
2023-09-24 15:17:53 +01:00
Peter Kokot
abed8b8e41 Remove _IO_cookie_io_functions_t in favor of cookie_io_functions_t
As noted in glibc, the cookie_io_functions_t should be used instead of
internal _IO_cookie_io_functions_t.

The _IO_cookie_io_functions_t was once used as a convenience for not
having the cookie_io_functions_t available (glibc <=2.1.1) as noted in
67bb9d1ae2.

Check in the build system was also always setting the
COOKIE_IO_FUNCTIONS_T to cookie_io_functions_t due to a typo. There is
unused variable have_IO_cookie_io_functions_t vs.
have_cookie_io_functions_t.

- COOKIE_IO_FUNCTIONS_T removed

Closes GH-12236
2023-09-22 22:31:19 +02:00
Christian Clauss
886bf820c9
[skip ci] Fix typos discovered by codespell (#12228) 2023-09-18 11:07:17 +01:00
Ilija Tovilo
692cea5cbc
Use zend_error_noreturn for E_ERROR consistently
To be clear, these already don't return. zend_error_noreturn just hints at this
fact through the ZEND_NORETURN attribute.

Closes GH-12204
2023-09-14 11:44:55 +02:00
Ben Ramsey
c1cf0026e5
PHP-8.1 is now for PHP 8.1.25-dev 2023-09-12 16:21:51 -05:00
Sergey Panteleev
5c1f746716
PHP-8.2 is now for PHP 8.2.12-dev 2023-09-12 14:53:56 +03:00
Máté Kocsis
58657ff26a
Fix type of the PHP_FLOAT_DIG constant
It used to be an int (https://github.com/php/php-src/pull/9616/files#diff-2978fe1c2c45b4eca89dc476376ddc7193bc4e5e7fff0c7d1c465f057b35a5e6L2155) before constant registration was refactored.
2023-09-10 22:31:19 +02:00
George Peter Banyard
8f8f31a16a
Merge branch 'PHP-8.3'
* PHP-8.3:
  streams: Checking if a stream is castable should not emit warnings for user defined streams
2023-09-08 13:23:20 +01:00
George Peter Banyard
d68073c23b
streams: Checking if a stream is castable should not emit warnings for user defined streams
Closes GH-10435
2023-09-08 13:22:43 +01:00
Máté Kocsis
2fad7cdd60
Fix type of the PHP_FLOAT_DIG constant
It used to be an int (https://github.com/php/php-src/pull/9616/files#diff-2978fe1c2c45b4eca89dc476376ddc7193bc4e5e7fff0c7d1c465f057b35a5e6L2155) before constant registration was refactored.
2023-09-07 10:01:02 +02:00
Pierrick Charron
ad2ac6f05f
Prepare for PHP 8.4 2023-08-29 15:25:46 -04:00
Jakub Zelenka
7deb84b7a6
Start PHP 8.4 development cycle 2023-08-29 17:19:01 +01:00
Jakub Zelenka
2eb21b0b1e
Update API versions and numbers 2023-08-29 17:04:24 +01:00
Jakub Zelenka
ba9650d697
Fix bug #52335 (fseek() on memory stream behavior different then file)
This changes memory stream to allow seeking past end which makes it the
same as seeking on files. It means the position is allowed to be higher
than the string length. The size only increases if data is appended to
the past position. The space between the previous string and position
is filled with zero bytes.

Fixes GH-9441
Closes GH-12058
2023-08-28 13:32:34 +01:00
Niels Dossche
26d6bb3627
Remove useless duplicated call to php_stream_parse_fopen_modes (#12059) 2023-08-27 17:22:23 +02:00
Mikhail Galanin
418cdc0bea
Set CLOEXEC on listened/accepted sockets in the FPM children
Closes GH-11708

Co-authored-by: Jakub Zelenka <bukka@php.net>
2023-08-26 15:19:03 +01:00
Cristian Rodríguez
782ffd761b
Use a single version of strnlen (#12015)
* Zend: Make zend_strnlen available for use outside zend_compile

* exif: remove local php_strnlen, use zend_strnlen instead

* main: remove local strnlen, use zend_strnlen instead

* phar: remove local strnlen, use zend_strnlen
2023-08-22 17:40:24 +02:00
Pierrick Charron
4467f33e89
PHP-8.2 is now for PHP 8.2.11-dev 2023-08-15 16:08:52 -04:00
Patrick Allaert
6e3f93f2f8
PHP-8.1 is now for PHP 8.1.24-dev 2023-08-15 21:09:58 +02:00
Levi Morrison
0311e60eb4
Add php_version and php_version_id PHPAPI funcs (#11875)
Mostly, extensions will use `PHP_VERSION` and `PHP_VERSION_ID`
respectfully but sometimes they want to grab the version at run-time
rather than at compile-time. For example, extensions which distribute
pre-built binaries may want this.
2023-08-04 15:39:50 -06:00
Ilija Tovilo
127ad70782
Fix open_basedir leak
Fixes oss-fuzz #60741
Closes GH-11780
2023-07-25 17:54:14 +02:00
Ilija Tovilo
b0037eda26
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix use-after-free when unregistering user stream wrapper from itself
2023-07-19 11:20:18 +02:00
Ilija Tovilo
c3ccc363c6
Fix use-after-free when unregistering user stream wrapper from itself
Fixes GH-11735
Closes GH-11737
2023-07-19 11:17:57 +02:00
Ben Ramsey
6e3c520f51
PHP-8.1 is now for PHP-8.1.23-dev 2023-07-18 16:30:49 -05:00
Ilija Tovilo
9bcdf219ec
Resolve open_basedir paths on ini update
Closes GH-10987
2023-07-18 14:43:40 +02:00
Sergey Panteleev
796a75f967
PHP-8.2 is now for PHP 8.2.10-dev 2023-07-18 14:02:43 +03:00
Jakub Zelenka
4a5d13e205
Fix GH-11242: Use dynamic buffer for large length in stream mem copy 2023-07-08 11:43:05 +01:00
Niels Dossche
0b2e6bc2b0 Cache d_type in directory entry 2023-07-07 18:02:32 +02:00
Niels Dossche
00c1e7bf0f Reserve less file space if possible in a directory entry
On POSIX systems, we can use the maximum file length instead of maximum
path length. This saves space and time for clearing the memory.
2023-07-07 18:02:17 +02:00
Alexander M. Turek
5d5664f72f
[skip ci] Fix typo (#11558) 2023-06-30 12:59:33 +02:00
Sergey Panteleev
884a53f39a
PHP-8.2 is now for PHP 8.2.9-dev 2023-06-20 17:25:30 +03:00
Patrick Allaert
6c4b1e0417
PHP-8.1 is now for PHP 8.1.22-dev 2023-06-20 16:07:05 +02:00
Jakub Zelenka
49fbbea2ea
Fix GH-10406: fgets on a redis socket connection fails on PHP 8.3
This is an alternative implementation for GH-10406 that resets the
has_buffered_data flag after finishing stream read so it does not impact
other ops->read use like for example php_stream_get_line.

Closes GH-11421
2023-06-11 13:27:00 +01:00
Niels Dossche
d22d0e26dc Implement GH-8641: STREAM_NOTIFY_COMPLETED over HTTP never emitted
This adds support for the completed event. Since the read handler could
be entered twice towards the end of the stream we remember what the eof
flag was before reading so we can emit the completed event when the flag
changes to true.

Closes GH-10505.
2023-06-10 19:47:36 +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
George Peter Banyard
13ad8ef40b memory stream: fix [-Wanalyzer-deref-before-check]
|  732 |                 ts->mode = mode && mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0;
    |      |                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~

Although mode is already dereference on line 723 in the call to strlen()
2023-06-02 20:33:20 +01:00
Ben Ramsey
2f2fd06be0
PHP-8.1 is now for PHP 8.1.21-dev 2023-05-23 16:19:16 -05:00
Pierrick Charron
d5f68b50fc
PHP-8.2 is now for PHP 8.2.8-dev 2023-05-23 16:56:58 -04:00
iamluc
730f32bad9
Keep the orig_path for xport stream
Closes GH-11113
2023-05-12 15:33:55 +01:00
Niels Dossche
acc940645e
Remove unnecessary NULL assignments after ecalloc in streams (#11209)
ecalloc already zeroes the structure, so writing NULL is not necessary.
2023-05-09 19:46:45 +02:00
Niels Dossche
ac5920f92b Fix GH-11141: Could not open input file: should be sent to stderr
I grepped for php_printf cases in main/ and sapi/ and converted the
cases which clearly indicate errors to fprintf(stderr, ...), like
suggested in the linked issue.

Closes GH-11163.
2023-05-05 19:31:23 +02:00
Javier Eguiluz
732d92c0e5
[skip ci] Fix various typos and grammar issues (#11143) 2023-04-28 11:05:32 +02:00
Sergey Panteleev
8318f4a6b1
PHP-8.2 is now for PHP 8.2.7-dev 2023-04-25 18:33:13 +03:00
Patrick Allaert
725f136f9a
PHP-8.1 is now for PHP 8.1.20-dev 2023-04-25 16:18:30 +02:00
Ilija Tovilo
6f63d4b274
Fix -Wenum-int-mismatch warnings on gcc 13
Closes GH-11103
2023-04-20 16:04:59 +02:00
Niels Dossche
115afeedac Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10737: PHP 8.1.16 segfaults on line 597 of sapi/apache2handler/sapi_apache2.c
2023-04-08 16:47:05 +02:00
Niels Dossche
9261ff7ba9 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10737: PHP 8.1.16 segfaults on line 597 of sapi/apache2handler/sapi_apache2.c
2023-04-08 16:42:52 +02:00
Niels Dossche
51faf04dbd Fix GH-10737: PHP 8.1.16 segfaults on line 597 of sapi/apache2handler/sapi_apache2.c
The TSRM keeps a hashtable mapping the thread IDs to the thread resource pointers.
It's possible that the thread disappears without us knowing, and then another thread
gets spawned some time later with the same ID as the disappeared thread.
Note that since it's a new thread the TSRM key pointer and cached pointer will be NULL.

The Apache request handler `php_handler()` will try to fetch some fields from the SAPI globals.
It uses a lazy thread resource allocation by calling `ts_resource(0);`.
This allocates a thread resource and sets up the TSRM pointers if they haven't been set up yet.

At least, that's what's supposed to happen. But since we are in a situation where the thread ID
still has the resources of the *old* thread associated in the hashtable,
the loop in `ts_resource_ex` will find that thread resource and assume the thread has been setup
already. But this is not the case since this thread is actually a new thread, just reusing the ID
of the old one, without any relation whatsoever to the old thread.
Because of this assumption, the TSRM pointers will not be setup, leading to a
NULL pointer dereference when trying to access the SAPI globals.

We can easily detect this scenario: if we're in the fallback path, and the pointer is NULL,
and we're looking for our own thread resource, we know we're actually reusing a thread ID.
In that case, we'll free up the old thread resources gracefully (gracefully because
there might still be resources open like database connection which need to be
shut down cleanly). After freeing the resources, we'll create the new resources for
this thread as if the stale resources never existed in the first place.
From that point forward, it is as if that situation never occurred.
The fact that this situation happens isn't that bad because a child process containing
threads will eventually be respawned anyway by the SAPI, so the stale thread resources
won't remain forever.

Note that we can't simply assign our own TSRM pointers to the existing
thread resource for our ID, since it was actually from a different thread
(just with the same ID!). Furthermore, the dynamically loaded extensions
have their own pointer, which is only set when their constructor is
called, so we'd have to call their constructor anyway...
I also tried to call the dtor and then the ctor again for those resources
on the pre-existing thread resource to reuse storage, but that didn't work properly
because other code doesn't expect something like that to happen, which breaks assumptions,
and this in turn caused Valgrind to (rightfully) complain about memory bugs.

Note 2: I also had to fix a bug in the core globals destruction because it
always assumed that the thread destroying them was the owning thread,
which on TSRM shutdown isn't always the case. A similar bug was fixed
recently with the JIT globals.

Closes GH-10863.
2023-04-08 16:34:07 +02:00
Dmitry Stogov
c9d728cbd6 Revert "Zend/zend_types.h: move zend_rc_debug to zend_rc_debug.h"
This reverts commit d6e95041e2.
2023-04-04 22:48:26 +03:00
Jakub Zelenka
c0b89e064c
Merge branch 'PHP-8.2' 2023-03-30 13:36:14 +01:00
Jakub Zelenka
e80073d3d2
Fix GH-10406: feof() behavior change for UNIX based socket resources
This change restores the old behaviour for the server socket streams
that don't support IO. This is now stored in the stream flags so it can
be later used to do some other decisions and possibly introduce some
better error reporting.

Closes GH-10877
2023-03-30 13:31:46 +01:00
Ben Ramsey
d9df750b22
PHP-8.1 is now for PHP 8.1.19-dev 2023-03-29 19:51:20 -05:00
Pierrick Charron
f7c692a940
PHP-8.2 is now for PHP 8.2.6-dev 2023-03-28 17:27:17 -04:00
Ilija Tovilo
a7f91e37de
Fix buffer-overflow in open_basedir() 2023-03-26 10:28:27 +02:00
Ilija Tovilo
61e98bf35e
Disallow parent dir components (..) in open_basedir() at runtime
Fix GH-10469
Closes GH-10913
2023-03-25 18:02:20 +01:00
Niels Dossche
6a6e91f3c7
Shrink some commonly used structs by reordering members (#10880)
Struct members require some alignment based on their type. This means
that if a struct member is not aligned, there will be a hole created by
the compiler in the struct, which is wasted space. This patch reorders
some of the most commonly used structs, but in such a way that the
fields which were in the same cache line still belong together.
The only exception to this is exception_ignore_args, which was
temporally not close to nearby members, and as such I placed
it further up to close a hole.

On 64-bit Linux this gives us the following shrinks:
* zend_op_array: 248 -> 240
* zend_ssa_var: 56 -> 48
* zend_ssa_var_info: 48 -> 40
* php_core_globals: 672 -> 608
* zend_executor_globals: 1824 -> 1792

On 32-bit, the sizes will either remain the same or will result in
smaller shrinks.
2023-03-22 19:26:42 +01:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Niels Dossche
4da0da7f2d
Implement GH-10854: TSRM should set a smarter value for expected_threads (#10867)
The tsrm_startup() function is currently always called with expected_threads = 1.
This means that the hashtable used in the TSRM will only contain a single bucket,
and all thread resources will therefore be in the same linked list.
So it's not really a hashtable right now, even though it's supposed to be.

This patch adds a function tsrm_startup_ex() which takes the expected
thread count as an argument. It also keeps the tsrm_startup() function
so there are no BC breaks.

In the Apache SAPI we query how many threads we have, and pass that to
the tsrm_startup_ex() function.
2023-03-17 17:08:47 +01:00
Patrick Allaert
729f006de8
PHP-8.1 is now for PHP 8.1.18-dev 2023-02-28 21:37:52 +01:00
Sergey Panteleev
23ce3423c1
PHP-8.2 is now for PHP 8.2.5-dev 2023-02-28 18:15:20 +03:00
Max Kellermann
d6e95041e2 Zend/zend_types.h: move zend_rc_debug to zend_rc_debug.h
`zend_rc_debug` is not a type and does not really belong in
`zend_types.h`; this allows using `ZEND_RC_MOD_CHECK()` without
including the huge `zend_types.h` header and allows decoupling
circular header dependencies.
2023-02-26 14:16:53 +00:00
David Carlier
a890b0ba73 Merge branch 'PHP-8.2' 2023-02-25 14:33:59 +00:00
David Carlier
bf68d10bb4 Merge branch 'PHP-8.1' into PHP-8.2 2023-02-25 14:33:11 +00:00
Niels Dossche
df579adac7 Fix GH-10692: PHP crashes on Windows when an inexistent filename is executed
Fixes GH-10692

php_fopen_primary_script() does not initialize all fields of
zend_file_handle. So when it fails and when fastcgi is true, the
zend_destroy_file_handle() function will try to free uninitialized
pointers, causing a segmentation fault. Fix it by zero-initializing file
handles just like the zend_stream_init_fp() counterpart does.

Closes GH-10697.
2023-02-25 14:32:55 +00:00
Max Kellermann
d5c649b36b
zend_compiler, ...: use uint8_t instead of zend_uchar (#10621)
`zend_uchar` suggests that the value is an ASCII character, but here,
it's about very small integers.  This is misleading, so let's use a
C99 integer instead.

On all architectures currently supported by PHP, `zend_uchar` and
`uint8_t` are identical.  This change is only about code readability.
2023-02-23 14:56:54 +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
Max Kellermann
413844d626
Zend/zend_types.h: deprecate zend_bool, zend_intptr_t, zend_uintptr_t (#10597)
These types are standard C99.

For compatibility with out-of-tree extensions, keep the typedefs
in main/php.h.
2023-02-18 19:31:28 +00:00
Pierrick Charron
dc054488da
PHP-8.2 is now for PHP 8.2.4-dev 2023-02-14 10:02:46 -05:00
Jakub Zelenka
c81b7ce1a3
Merge branch 'PHP-8.2' 2023-02-14 11:07:59 +00:00
Jakub Zelenka
cbf089018b
Merge branch 'PHP-8.1' into PHP-8.2 2023-02-14 11:00:20 +00:00
Jakub Zelenka
4058d20608
Merge branch 'PHP-8.0' into PHP-8.1 2023-02-14 10:52:17 +00:00
Jakub Zelenka
716de0cff5
Introduce max_multipart_body_parts INI
This fixes GHSA-54hq-v5wp-fqgv DOS vulnerabality by limitting number of
parsed multipart body parts as currently all parts were always parsed.
2023-02-14 10:21:23 +00:00
Jakub Zelenka
e45850c195
Fix repeated warning for file uploads limit exceeding 2023-02-14 10:21:07 +00:00
Ben Ramsey
28d68f5013
PHP-8.1 is now for PHP 8.1.17-dev 2023-02-13 13:16:07 -06:00
Stanislav Malyshev
0ebef331ac Merge branch 'PHP-8.2' 2023-02-12 21:34:14 -07:00
Stanislav Malyshev
e8c64b62da Merge branch 'PHP-8.1' into PHP-8.2 2023-02-12 21:34:10 -07:00
Stanislav Malyshev
85d9278db2 Merge branch 'PHP-8.0' into PHP-8.1 2023-02-12 21:33:39 -07:00
Niels Dossche
ec10b28d64 Fix array overrun when appending slash to paths
Fix it by extending the array sizes by one character. As the input is
limited to the maximum path length, there will always be place to append
the slash. As the php_check_specific_open_basedir() simply uses the
strings to compare against each other, no new failures related to too
long paths are introduced.
We'll let the DOM and XML case handle a potentially too long path in the
library code.
2023-02-12 20:56:19 -07:00
Arnaud Le Blanc
4ec366429e Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  Fix GH-10548: copy() fails on cifs mounts because of incorrect length (cfr_max) specified in streams.c:1584 copy_file_range() (#10551)
2023-02-11 16:30:11 +01:00
Niels Dossche
e787d6c9e6
Fix GH-10548: copy() fails on cifs mounts because of incorrect length (cfr_max) specified in streams.c:1584 copy_file_range() (#10551)
On some filesystems, the copy operation fails if we specify a size
larger than the file size in certain circumstances and configurations.
In those cases EIO will be returned as errno and we will therefore fall
back to other methods.
2023-02-11 16:25:14 +01:00
Derick Rethans
a92ecdb140 Merge branch 'PHP-8.2' 2023-02-10 14:45:41 +00:00
Derick Rethans
b463bc4349 Merge remote-tracking branch 'derickr/precision-equivalence' into PHP-8.2 2023-02-10 14:45:26 +00:00
Arnaud Le Blanc
d49e41925b Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix concurrent testing
  [ci skip] NEWS
  Fix GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range (#10440)
2023-02-10 13:32:42 +01:00
Niels Dossche
b4db690cb3
Fix GH-10370: File corruption in _php_stream_copy_to_stream_ex when using copy_file_range (#10440)
copy_file_range can return early without copying all the data. This is
legal behaviour and worked properly, unless the mmap fallback was used.
The mmap fallback would read too much data into the destination,
corrupting the destination file. Furthermore, if the mmap fallback would
fail and have to fallback to the regular file copying mechanism, a
similar issue would occur because both maxlen and haveread are modified.
Furthermore, there was a mmap-resource in one of the failure paths of
the mmap fallback code.
This patch fixes these issues. This also adds regression tests using the
new copy_file_range early-return simulation added in the previous
commit.
2023-02-10 13:08:44 +01:00
Derick Rethans
93fb2c12b9 Bring minimum precision inline with spprintf
The precision "minimum" for spprintf was changed in
3f23e6bca9 with the cryptic comment "Enable 0
mode for echo/print". Since then the behaviour of spprintf and snprintf has not
been the same. This results in some APIs handling precision differently than
others, which then resulted in the following Xdebug issue:
https://bugs.xdebug.org/view.php?id=2151

The "manpage" for snprinf says about precision:

       An optional precision, in the form of a period ('.')   followed  by  an
       optional  decimal  digit string.  Instead of a decimal digit string one
       may write "*" or "*m$" (for some decimal integer m) to specify that the
       precision  is  given in the next argument, or in the m-th argument, re‐
       spectively, which must be of type int.  If the precision  is  given  as
       just  '.',  the precision is taken to be zero.  A negative precision is
       taken as if the precision were omitted.

However, the snprintf implementation never supported this "negative precision",
which is what PHP's default setting is in PG(precision). However, in
3f23e6bca9 spprintf was made to support this.

Although this techinically can break BC, there is clearly a bug here, and I
could not see any failing tests locally.
2023-01-30 19:00:42 +00:00
Jakub Zelenka
443eb50a4c
Merge branch 'PHP-8.2' 2023-01-19 19:06:38 +00:00
Jakub Zelenka
cc931af35d
Fix GH-8086: Introduce mail.mixed_lf_and_crlf INI
When this INI option is enabled, it reverts the line separator for
headers and message to LF which was a non conformant behavior in PHP 7.
It is done because some non conformant MTAs fail to parse CRLF line
separator for headers and body.

This is used for mail and mb_send_mail functions.
2023-01-19 19:05:39 +00:00
Sergey Panteleev
eee988e86d
PHP-8.2 is now for PHP 8.2.3-dev 2023-01-17 20:55:22 +03:00
Patrick Allaert
c47a1a260d
PHP-8.1 is now for PHP 8.1.16-dev 2023-01-17 17:24:25 +01: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
Christoph M. Becker
2f4973fd88
Revert GH-10279
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit 45a128c9de.
This reverts commit 1eb71c3f15.
This reverts commit 492523a779.
This reverts commit c7a4633891.
This reverts commit 308adb915c.
This reverts commit cd27d5e07f.
This reverts commit c5933409b4.
This reverts commit 46371f4eb3.
This reverts commit 623e2e9fc6.
This reverts commit e7434c1247.
This reverts commit d28d323ca2.
This reverts commit 1a067b84ee.
This reverts commit a55c0c5fc3.
This reverts commit b5aeb3a4d4.
This reverts commit f061a035e4.
This reverts commit b088575119.
This reverts commit b1d48774a7.
This reverts commit 94f9a20ce6.
This reverts commit 4831e48708.
This reverts commit cd985de190.
This reverts commit 9521d21681.
This reverts commit d6136151e9.
2023-01-16 12:25:59 +01:00
Christoph M. Becker
bf1cfc0753
Revert GH-10300
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit 68ada76f9a.
his reverts commit 45384c6e20.
This reverts commit ef7fbfd710.
This reverts commit 9b9ea0d7c6.
This reverts commit f15747c26b.
This reverts commit e883ba93c4.
This reverts commit 7e87551c37.
This reverts commit 921274d2b8.
This reverts commit fc1f528e5e.
This reverts commit 0961715cda.
This reverts commit a93f264526.
This reverts commit 72dd94e1c6.
This reverts commit 29b2dc8964.
This reverts commit 05c7653bba.
This reverts commit 5190e5c260.
This reverts commit 6b55bf228c.
This reverts commit 184b4a12d3.
This reverts commit 4c31b7888a.
This reverts commit d44e9680f0.
This reverts commit 4069a5c43f.
2023-01-16 12:22:54 +01:00
Max Kellermann
184b4a12d3 main/php.h: add missing includes 2023-01-15 15:07:58 +00:00
Tim Düsterhus
4c9ae81c28
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix comment for php_safe_bcmp (#10306)
2023-01-12 23:31:08 +01:00
Tim Düsterhus
fd7214436a
Fix comment for php_safe_bcmp (#10306)
* main: Fix comment for php_safe_bcmp

* main: Include note about php_safe_bcmp being security sensitive

This is taken from the implementation of `hash_equals()`.
2023-01-12 23:30:36 +01:00
Max Kellermann
9521d21681 main/php_globals.h: add missing include for PHPAPI 2023-01-12 15:12:45 +00:00
Max Kellermann
16203b53e1 main: add missing includes 2023-01-10 14:19:03 +00:00
Max Kellermann
9fdbefacd3 main/s[np]printf: include cleanup 2023-01-10 14:19:03 +00:00
Max Kellermann
d53ad4b566 main/SAPI: make "ini_entries" a const string 2023-01-04 12:49:48 +00:00
Pierrick Charron
002d54db9f
PHP-8.2 is now for PHP 8.2.2-dev 2022-12-13 19:29:29 -05:00
Elan Ruusamäe
e114f32596
Avoid code duplication in php_ini.c (#4512) 2022-12-10 12:51:13 +01:00
Ben Ramsey
696bb385df
PHP-8.1 is now for PHP 8.1.15-dev 2022-12-07 11:29:37 -06:00
Jorg Adam Sowa
77ee92a50c
Remove unnecessary usage of CONST_CS
Closes GH-9685.
2022-11-28 17:12:07 +01:00
Sara Golemon
ac508301c9
Bump for 8.0.27 2022-11-08 22:10:29 +00:00
Pierrick Charron
44d652c00a
PHP-8.2 is now for PHP 8.2.1-dev and prepare NEWS for 8.2.0 2022-11-08 13:26:35 -05:00
Patrick Allaert
540488c74e
PHP-8.1 is now for PHP 8.1.14-dev 2022-11-08 17:57:34 +01:00
Ilija Tovilo
51a99456e2
Merge branch 'PHP-8.2'
* PHP-8.2:
  Remove unnecessary ast eval bailout
2022-10-27 10:56:04 +02:00
Ilija Tovilo
1d6b32f65c
Remove unnecessary ast eval bailout
We can just reset the filename_override to NULL in php_request_shutdown.

Closes GH-9805
2022-10-27 10:54:59 +02:00
Jakub Zelenka
b8d013a48d
Merge branch 'PHP-8.2' 2022-10-23 12:41:51 +01:00
Jakub Zelenka
b732d80329
Fix bug GH-9779: stream_copy_to_stream fail when dest in append mode 2022-10-23 12:40:22 +01:00
Arnaud Le Blanc
77eadc5c9f Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  [ci skip] NEWS
  [ci skip] NEWS
  Fix compilation warning
  Fix crash when memory limit is exceeded during generator initialization
2022-10-22 10:45:21 +02:00
Arnaud Le Blanc
cfd5fb98e4 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  [ci skip] NEWS
  Fix compilation warning
  Fix crash when memory limit is exceeded during generator initialization
2022-10-22 10:44:55 +02:00
Arnaud Le Blanc
ebe58459aa Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Fix compilation warning
  Fix crash when memory limit is exceeded during generator initialization
2022-10-22 10:44:06 +02:00
Benoit
994097093c Fix compilation warning 2022-10-22 10:41:02 +02:00
George Peter Banyard
a1953d5b29
Drop usage of confusing zend_fcall_info_call() API
The last parameter which is named zval *args, does NOT set the FCI params field. It is expected to be a PHP array which gets looped over to set the arguments which is also a zval pointer...

Since PHP 8.0, the named_params field is a more appropriate way of doing this.
2022-10-21 18:31:40 +01:00
Jakub Zelenka
18fe337bae
Fix bug #51056: fread() on blocking stream will block even if data is available
This is applied only on socket connection which already returns
immediately if there is no data in the buffer.
2022-10-16 12:17:47 +01:00
Máté Kocsis
66f3b5ffb2
Declare main constants in stubs - part 3 (#9731) 2022-10-12 14:42:22 +02:00
Ben Ramsey
865161af33
PHP-8.1 is now for PHP 8.1.13-dev 2022-10-11 19:47:00 -04:00
Máté Kocsis
d90ecb9582
Declare main constants in stubs - part 2 (#9714) 2022-10-11 13:48:52 +02:00
Arnaud Le Blanc
5b6f9df51a Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  [ci skip] NEWS
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:26:17 +02:00
Arnaud Le Blanc
246d13cd99 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:24:23 +02:00
Arnaud Le Blanc
d4b99542d5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:23:34 +02:00
Arnaud Le Blanc
80232de0e4
Return immediately when FD_SETSIZE is exceeded (#9602) 2022-10-01 11:20:43 +02:00
Máté Kocsis
93982b144d
Declare main constants in stubs - part 1 (#9616) 2022-09-30 13:49:59 +02:00
Jakub Zelenka
d2288ec5ed
Clarify memory usage and slightly improve sapi_read_post_data
This is a result of checking GH-8800 which assumed potential
memory leaks here. Even though it was not the case in reality,
the function deserves a bit of clarification to prevent similar
attempts in the future.
2022-09-30 11:54:41 +01:00
Ilija Tovilo
138fd5b3c8
Replace reallocarray with safe_perealloc
Fixes GH-9581
2022-09-29 15:15:40 +02:00
Derick Rethans
01677cafae Merge branch 'PHP-8.2' 2022-09-27 14:11:47 +01:00
Derick Rethans
25290cd25c Merge branch 'PHP-8.1' into PHP-8.2 2022-09-27 14:11:40 +01:00
Derick Rethans
cfee252a95 Merge branch 'PHP-8.0' into PHP-8.1 2022-09-27 14:11:31 +01:00
Derick Rethans
def8c8d174 Merge branch 'PHP-7.4' into PHP-8.0 2022-09-27 14:11:14 +01:00
Ilija Tovilo
b61c81c949
Replace reallocarray with safe_perealloc (#9593) 2022-09-22 14:55:41 +02:00
Sara Golemon
559da529a0
Bump for 8.0.25 2022-09-13 23:46:26 +00:00
Patrick Allaert
0f575aa698
PHP-8.1 is now for PHP 8.1.12-dev 2022-09-13 23:09:47 +02:00
Dmitry Stogov
72fec0bbf3 Merge branch 'PHP-8.2'
* PHP-8.2:
  Reset FG(user_stream_current_filename) at the end of request
2022-09-12 11:39:36 +03:00
Dmitry Stogov
d64aa6f646 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Reset FG(user_stream_current_filename) at the end of request
2022-09-12 11:39:27 +03:00
Dmitry Stogov
f4afa9adc6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Reset FG(user_stream_current_filename) at the end of request
2022-09-12 11:39:18 +03:00
Dmitry Stogov
d0b3096ff0 Reset FG(user_stream_current_filename) at the end of request
Attempt to fix oss-fuzz #51047
2022-09-12 11:38:31 +03:00
Derick Rethans
0611be4e82 Fix #81727: Don't mangle HTTP variable names that clash with ones that have a specific semantic meaning. 2022-09-09 17:10:04 +01:00
Pierrick Charron
58a92772ab
Prepare PHP 8.2.0 RC1 2022-08-30 11:57:05 -04:00
Pierrick Charron
327c95237c
Prepare for PHP 8.3 2022-08-30 11:17:15 -04:00
Sara Golemon
3d6ed8c852
Catch up dev version numbers 2022-08-30 12:15:27 +00:00
Jakub Zelenka
f3c357c446
Merge branch 'PHP-8.1' 2022-08-29 22:34:48 +01:00
Jakub Zelenka
bf97b3649d
Merge branch 'PHP-8.0' into PHP-8.1 2022-08-29 22:33:02 +01:00
Jakub Zelenka
3503b1daa2
Fix bug #77780: "Headers already sent" when previous connection was aborted
This change primarily splits SAPI deactivation to module and destroy
parts. The reason is that currently some SAPIs might bail out
on deactivation. One of those SAPI is PHP-FPM that can bail out on
request end if for example the connection is closed by the client
(web sever). The problem is that in such case the resources are not
freed and some values reset. The most visible impact can have not
resetting the PG(headers_sent) which can cause erorrs in the next
request. One such issue is described in #77780 bug which this fixes
and is also cover by a test in this commit. It seems reasonable
to separate deactivation and destroying of the resource which means
that the bail out will not impact it.
2022-08-29 22:25:53 +01:00
Ben Ramsey
7f26661993
PHP-8.1 is now for PHP 8.1.11-dev 2022-08-16 10:45:29 -05:00
twosee
ef39adb638
Merge branch 'PHP-8.1'
* PHP-8.1:
  Re-fix GH-8409: SSL handshake timeout persistent connections hanging
  Revert "Fix GH-8409: SSL handshake timeout persistent connections hanging"
2022-08-14 20:15:35 +08:00
twosee
14d71957ca
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Re-fix GH-8409: SSL handshake timeout persistent connections hanging
2022-08-14 20:14:57 +08:00
twosee
b8d07451d4
Re-fix GH-8409: SSL handshake timeout persistent connections hanging
This fix is another solution to replace d0527427be, use zend_try and zend_catch to make sure persistent stream will be released when error occurred.

Closes GH-9332.
2022-08-14 20:13:36 +08:00
Jakub Zelenka
897ca85d33
Revert "Fix GH-8409: SSL handshake timeout persistent connections hanging"
This reverts commit d0527427be.

This patch makes Swoole/Swow can not work anymore, because Coroutine will yield to another one during socket operation, EG(record_errors) assertion will always fail, and zend_begin_record_errors() was only used during compile time before.
Note: zend_emit_recorded_errors() and the typo fix are reserved.
2022-08-14 19:41:06 +08:00
Jakub Zelenka
438f692e92
Merge branch 'PHP-8.1' 2022-08-12 17:12:28 +01:00
Jakub Zelenka
d0527427be
Fix GH-8409: SSL handshake timeout persistent connections hanging
This is not actually related to SSL handshake but stream socket creation
which does not clean errors if the error handler is set. This fix
prevents emitting errors until the stream is freed.
2022-08-12 17:09:24 +01:00
David CARLIER
393577ced9
reallocarray using proper inline facility to check overflow on windows. (#9300) 2022-08-12 12:08:03 +01:00
Jakub Zelenka
80197c59ec
Merge branch 'PHP-8.1' 2022-08-07 14:22:33 +01:00
Jakub Zelenka
c9fa98a174
Merge branch 'PHP-8.0' into PHP-8.1 2022-08-07 14:21:39 +01:00
Jakub Zelenka
d9ff5e079f
Fix GH-8472: stream_socket_accept result may have incorrect metadata 2022-08-07 14:17:38 +01:00
Jakub Zelenka
1a9e6895f1
Fix #65069: GlobIterator incorrect handling of open_basedir check
This PR changes the glob stream wrapper so it impacts "glob://"
streamsas well. The idea is to do a check for each found path instead
of the pattern which was not working correctly.
2022-07-28 11:42:42 +01:00
Patrick Allaert
9af3327176
PHP-8.1 is now for PHP 8.1.10-dev 2022-07-20 06:48:52 +02:00
Javier Eguiluz
37cf7f6d3c
[ci skip] Fix minor typos
Closes GH-9047.
2022-07-19 16:43:44 +02:00
Go Kudo
4d8dd8d258
Implement Random Extension
https://wiki.php.net/rfc/rng_extension
https://wiki.php.net/rfc/random_extension_improvement
2022-07-19 10:27:38 +01:00
Eric Norris
09237f6126
Update request startup error messages 2022-07-18 23:19:59 +01:00
Jakub Zelenka
922371f3b1
Do not send X-Powered-By if headers sent (#9039)
Co-authored-by: Eric Norris <erictnorris@gmail.com>
2022-07-18 18:01:05 +01:00
Mikhail Galanin
ffdf25a270
Add "error_log_mode" setting 2022-07-18 15:41:28 +01:00
Jakub Zelenka
0a4a55fd44
Allow to not close stream on rscr dtor in php cli sapi 2022-07-18 10:58:50 +01:00
Rowan Tommins
af15923bc3
Extend deprecation notices to is_callable($foo) and callable $foo
Implements https://wiki.php.net/rfc/partially-supported-callables-expand-deprecation-notices
so that uses of "self" and "parent" in is_callable() and callable
type constraints now raise a deprecation notice, independent of the
one raised when and if the callable is actually invoked.

A new flag is added to the existing check_flags parameter of
zend_is_callable / zend_is_callable_ex, for use in internal calls
that would otherwise repeat the notice multiple times. In particular,
arguments to internal function calls are checked first based on
arginfo, and then again during ZPP, so the former suppresses the
deprecation notice.

Some existing tests which raised this deprecation have been updated
to avoid the syntax, but the existing version retained for maximum
regression coverage until it is made an error.

With thanks to Juliette Reinders Folmer for the RFC and initial
investigation.

Closes GH-8823.
2022-07-14 17:07:42 +02:00
Christoph M. Becker
31b02a13ab
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-8923: error_log on Windows can hold the file write lock
2022-07-12 13:39:55 +02:00
Christoph M. Becker
5a459f6783
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-8923: error_log on Windows can hold the file write lock
2022-07-12 13:38:35 +02:00
Christoph M. Becker
77e954afaa
Fix GH-8923: error_log on Windows can hold the file write lock
On Windows, closing a file which is locked may not immediately remove
the lock.  The `LockFileEx()` documentation states:

| Therefore, it is recommended that your process explicitly unlock all
| files it has locked when it terminates.

We comply, and also use the macro `LOCK_EX` instead of the magic number
`2`.

Closes GH-8925.
2022-07-12 13:36:20 +02:00
George Peter Banyard
55908db007 Add php_register_known_variable() for know var names 2022-07-01 21:18:26 +01:00
David Carlier
7ceae66182 streams/xp_socket: fix clang build error with enum usage on bool condition.
Fix targeted for oses defining those flags as enums (like Linux/glibc).

`error: converting the enum constant to a boolean [-Werror,-Wint-in-bool-context]
                                } else if ((!sslsock->ssl_active && value == 0 && (MSG_DONTWAIT || !sslsock->s.is_blocked)) ||`

Closes #8895.
2022-06-30 05:45:33 +01:00
Max Kellermann
e2bd3b1e99 main/streams/plain_wrapper: skip lseek(SEEK_CUR) for newly opened files
A file that has just been opened is known to be at offset zero, and
the lseek(SEEK_CUR) system call to determine the current offset can be
skipped.

Closes #8540.
2022-06-29 18:11:01 +01:00
David CARLIER
bf29ee6917 Add reallocarray implementation.
In a similar model as _safe_*alloc api but for the `userland` it guards
against overflow before (re)allocation, usage concealed in fpm for now.
Modern Linux and most of BSD already have it.
Closes #8871.
2022-06-26 13:10:13 +01:00
Ben Ramsey
f3b45e74f5
PHP-8.1 is now for PHP 8.1.9-dev 2022-06-21 11:03:50 -05:00
Heiko Weber
84e4d2a0e8
Refactor sapi_getenv() (#8786) 2022-06-20 17:32:13 +01:00
David Carlier
bfe6f9e66a Introduction of timing attack safe bcmp implementation.
Nothing new but to refactor usage b/w hash and password
extensions but using volatile pointers to be a bit safer,
allowing to expand its usage eventually.
2022-06-20 16:30:30 +01:00
Christoph M. Becker
640c1c3a09
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix potential use after free in php_binary_init()
2022-06-20 12:03:47 +02:00
Christoph M. Becker
5f24b85fd2
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix potential use after free in php_binary_init()
2022-06-20 12:02:31 +02:00
Heiko Weber
93a44f8c50
Fix potential use after free in php_binary_init()
Closes GH-8791.
2022-06-20 12:00:50 +02:00
Jakub Zelenka
3f836641d5
Merge branch 'PHP-8.1' 2022-06-19 22:57:26 +01:00
Jakub Zelenka
d9cca443ad Fix strict prototype for php_closelog 2022-06-19 22:56:44 +01:00