1
0
mirror of https://github.com/php/php-src.git synced 2026-04-27 10:16:41 +02:00
Commit Graph

63552 Commits

Author SHA1 Message Date
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
Tim Düsterhus a92acbad87 crypt: Fix possible buffer overread in php_crypt() 2023-02-12 20:46:51 -07:00
Tim Düsterhus c840f71524 crypt: Fix validation of malformed BCrypt hashes
PHP’s implementation of crypt_blowfish differs from the upstream Openwall
version by adding a “PHP Hack”, which allows one to cut short the BCrypt salt
by including a `$` character within the characters that represent the salt.

Hashes that are affected by the “PHP Hack” may erroneously validate any
password as valid when used with `password_verify` and when comparing the
return value of `crypt()` against the input.

The PHP Hack exists since the first version of PHP’s own crypt_blowfish
implementation that was added in 1e820eca02.

No clear reason is given for the PHP Hack’s existence. This commit removes it,
because BCrypt hashes containing a `$` character in their salt are not valid
BCrypt hashes.
2023-02-12 20:46:44 -07:00
Frank Du a9437ceb6f base64: add avx512 and vbmi version. (#6361)
1. Implementation based on https://github.com/WojciechMula/base64simd
2. Only runtime path is added to reduce the complexity of SIMD variants.
3. Expand test case to cover SIMD implementation.

Signed-off-by: Frank Du <frank.du@intel.com>
2023-02-13 03:30:47 +00:00
David Carlier 19a7281efa sockets add SO_RERROR/SO_ZEROIZE/SO_SPLICE net/openbsd's constants.
Closes GH-10563.
2023-02-12 21:55:55 +00:00
Michael Voříšek a11e9c9d02 Simplify php_reflection.c, class name cannot start with backslash (#10536)
* fix comment typo

* (normalized) class name never start with backslash
2023-02-11 14:50:25 +01:00
Derick Rethans a92ecdb140 Merge branch 'PHP-8.2' 2023-02-10 14:45:41 +00:00
Derick Rethans ada261557b Merge remote-tracking branch 'derickr/ossfuzz-unserialise-fixes' into PHP-8.2 2023-02-10 14:45:07 +00:00
George Peter Banyard 984484ab02 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix memory leaks in ext-tidy
2023-02-10 14:16:55 +00:00
George Peter Banyard d8cec14c11 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix memory leaks in ext-tidy
2023-02-10 14:16:38 +00:00
George Peter Banyard 704aadd098 Fix memory leaks in ext-tidy
We must not instantiate the object prior checking error conditions
Moreover, we need to release the HUGE amount of memory for files which are over 4GB when throwing a ValueError

Closes GH-10545
2023-02-10 14:12:23 +00:00
Derick Rethans 5d9ee8f920 Fixed OSS fuzz issues #55589, #55599, and #55727 2023-02-10 13:03:47 +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
Arnaud Le Blanc 10f2378584 Fix concurrent testing 2023-02-10 13:31:57 +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
David Carlier 8a267b06ca Merge branch 'PHP-8.2' 2023-02-09 19:58:00 +00:00
David Carlier 81aedad452 opcache/pcntl/cli: Fixes few functions signatures. 2023-02-09 19:57:48 +00:00
David Carlier 00ae200143 Merge branch 'PHP-8.2' 2023-02-08 18:33:51 +00:00
David Carlier 06120df71e Merge branch 'PHP-8.1' into PHP-8.2 2023-02-08 18:32:33 +00:00
Max Kellermann 8c8a38a75c ext/curl: suppress -Wdeprecated-declarations
Closes GH-10531.
2023-02-08 18:32:13 +00:00
Marcos Marcolin 641fe23e3a Improve illegal offset error messages (#10504)
Co-authored-by: Marcos Marcolin <marcos@ixcsoft.com.br>
2023-02-08 12:11:41 +00:00
Derick Rethans b7860cd564 Implement More Appropriate Date/Time Exceptions RFC 2023-02-08 10:27:33 +00:00
Tim Düsterhus 0cfc45b667 random: Use branchless implementation for mask generation in Randomizer::getBytesFromString() (#10522)
* random: Add `max_offset` local to Randomizer::getBytesFromString()

* random: Use branchless implementation for mask generation in Randomizer::getBytesFromString()

This was benchmarked against clzl with a standalone script with random inputs
and is slightly faster. clzl requires an additional branch to handle the
source_length = 1 / max_offset = 0 case.

* Improve comment for masking in Randomizer::getBytesFromString()
2023-02-08 09:36:12 +01:00
Niels Dossche 3ff8333473 Cleanup dead code in array_slice (#10539)
We can only get to this if condition if at least preserve_keys is true.
Therefore, the else branch of this check can never execute.
2023-02-08 00:54:42 +01:00
Max Kellermann 0752baa583 Zend/zend_cpuinfo, ext/standard/crc32_x86: fix -Wstrict-prototypes
In plain C, a function without arguments must be explicitly declared
(void).

Close GH-10528
2023-02-07 22:47:43 +00:00
Ben Ramsey 995ac3180e Merge branch 'PHP-8.2' 2023-02-07 09:32:45 -06:00
Ben Ramsey 26e10258ce Merge branch 'PHP-8.1' into PHP-8.2 2023-02-07 09:29:39 -06:00
Michael Voříšek 4df4264ac9 Fix PDO OCI Bug #60994 (Reading a multibyte CLOB caps at 8192 chars) 2023-02-07 09:25:34 -06:00
Dmitry Stogov 1521cafee2 Merge branch 'PHP-8.2'
* PHP-8.2:
  ext/opcache/zend_jit: call TSRM dtor before unloading opcache.so (#10533)
2023-02-07 16:09:58 +03:00
Dmitry Stogov d948b858de Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  ext/opcache/zend_jit: call TSRM dtor before unloading opcache.so (#10533)
2023-02-07 16:09:46 +03:00
Max Kellermann 131b862ac0 ext/opcache/zend_jit: call TSRM dtor before unloading opcache.so (#10533)
Commit a21195650e added a TSRM destructor, but that destructor
will get called by tsrm_shutdown(), which is after opcache.so has
already been unloaded, resulting in a shutdown crash, e.g.:

  #0  0x00007fad01737500 in ?? ()
  #1  0x000055ac54e723c4 in tsrm_shutdown () at TSRM/TSRM.c:194
  #2  0x000055ac54c42180 in main (argc=80, argv=0x55ac57bc14d0) at sapi/cli/php_cli.c:1388

By calling ts_free_id() before opcache.so gets unloaded, we can easily
fix this crash bug.
2023-02-07 16:09:17 +03:00
Dmitry Stogov bf809a918e Merge branch 'PHP-8.2'
* PHP-8.2:
  ext/opcache/zend_jit: cast function to fix -Wincompatible-pointer-types (#10527)
2023-02-07 13:38:52 +03:00
Dmitry Stogov 8ad81c0e8c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  ext/opcache/zend_jit: cast function to fix -Wincompatible-pointer-types (#10527)
2023-02-07 13:38:39 +03:00
Max Kellermann afbb28dfb7 ext/opcache/zend_jit: cast function to fix -Wincompatible-pointer-types (#10527)
* ext/opcache/zend_jit: cast function to fix -Wincompatible-pointer-types

Regression by commit a21195650e

* TSRM/win32: fix ts_allocate_dtor cast

The dtor was casted to ts_allocate_ctor; luckily, ts_allocate_dtor and
ts_allocate_ctor just happen to be the same type.
2023-02-07 13:38:17 +03:00
Dmitry Stogov b33d472431 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix possible exit_counters memory leak in ZTS build
2023-02-06 18:37:37 +03:00
Dmitry Stogov 29efbe593d Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix possible exit_counters memory leak in ZTS build
2023-02-06 18:37:24 +03:00
Dmitry Stogov a21195650e Fix possible exit_counters memory leak in ZTS build 2023-02-06 18:35:06 +03:00
Alex Dowad c8ec2ed730 Add AVX2-accelerated UTF-16 decoding/encoding routines
As with other SIMD-accelerated functions in php-src, the new UTF-16
encoding and decoding routines can be compiled either with AVX2
acceleration "always on", "always off", or else with runtime detection
of AVX2 support.

With the new UTF-16 decoder/encoder, conversion of extremely short
strings (as in several bytes) has the same performance as before,
and conversion of medium-length (~100 character) strings is about 65%
faster, but conversion of long (~10,000 character) strings is around
6 times faster.

Many other mbstring functions will also be faster now when handling
UTF-16; for example, mb_strlen is almost 3 times faster on medium
strings, and almost 9 times faster on long strings. (Why does mb_strlen
benefit more from AVX2 acceleration than mb_convert_encoding? It's
because mb_strlen only needs to decode, but not re-encode, the input
string, and the UTF-16 decoder benefits much more from SIMD
acceleration than the UTF-16 encoder.)
2023-02-05 20:06:42 +02:00
George Peter Banyard 50a2de78a8 Do not build unnecessary FCI in Reflection 2023-02-05 17:11:49 +00:00
Niels Dossche c9cbe525e1 Metaphone performance improvement (#10501)
* Don't do toupper() redundantly in encoding the data for metaphone

All inputs for ENCODE() are already uppercase, so there's no need to
spend time uppercasing them again.

* Don't compute uppercase letter redundantly in checks

If it's a zero-terminator check, or an isalpha() check, there's no need
to convert it to uppercase first.

* Clean-up LookAhead helper

* Add some letter caching to metaphone to increase performance

We don't have to re-read letters, and re-uppercase them if we already
did it once. By caching these results, we gain performance.
Furthermore, we can avoid fetching and uppercasing in some conditions by
first checking what we already had: e.g. if a condition depends on both
Prev_Letter and After_Next_Letter, but we already have Prev_Letter
cached, we can place that first to avoid a fetch+toupper of the
"after next letter".
2023-02-05 17:02:24 +00:00
Niels Dossche 722fbd01a3 Implement an SSE2 accelerated version of zend_adler32 (#10507)
When benchmarking the file cache of opcache on index.php from a dummy
WordPress install, I noticed that 36.42% of the time was spent in
zend_adler32 to verify the checksums of the files. Callgrind reported
that 332,731,216 instructions were executed during that run and average
time to execute the index file was around 91ms.

This patch implements an SSE2 accelerated version of zend_adler32, which
reduces the number of instructions executed on that bench to
248,600,983, which is a reduction of ~25%. There is also a decrease in
wallclock time measurable: around 10ms. Now only 16.05% of the time is
spent computing checksums.

The benchmark tests were performed using Callgrind, and time for the
wallclock time. These tests were executed multiple times and their
results were averaged. The WordPress install only contains two
almost-blank posts.
2023-02-05 15:58:39 +00:00
Max Kellermann d3abcae4a2 ext/snmp: use memcpy() instead of memmove() (#10498)
memcpy() may be faster because it does not have to consider
overlapping buffers.
2023-02-05 15:10:01 +00:00
Niels Dossche c2d4bafc4f Copy UTF-8 flag for str_repeat 2023-02-05 14:32:50 +00:00
Niels Dossche 99b86141ae Introduce convenience macros for copying flags that hold when concatenating two strings
This abstracts away, and cleans up, the flag handling for properties of
strings that hold when concatenating two strings if they both hold that
property. (These macros also work with simply copies of strings because
a copy of a string can be considered a concatenation with the empty
string.) This gets rid of some branches and some repetitive code, and
leaves room for adding more flags like these in the future.
2023-02-05 14:32:50 +00:00
rj1 d2cdfdbe44 fixed some misspellings (#10503) 2023-02-04 07:03:10 +00:00
Alex Dowad c02af98ae5 Use AVX2 to accelerate strto{upper,lower} (only on 'AVX2-native' builds for now)
On short strings, there is no difference in performance. However, for
strings around 10,000 bytes long, the AVX2-accelerated function is
about 55% faster than the SSE2-accelerated one.
2023-02-03 16:29:27 +02:00
Tyson Andre ab87283118 Merge branch 'PHP-8.2' 2023-02-03 09:23:48 -05:00