Commit Graph

134452 Commits

Author SHA1 Message Date
Niels Dossche
54be2656f4 Remove always-true condition in process_numeric_entity() 2023-12-12 16:43:43 +00:00
Niels Dossche
ddedd15eae Remove always-true condition in php_conv_open() 2023-12-12 16:43:43 +00:00
Niels Dossche
5e02bca537 Remove always-true condition from php_copy_file_ctx()
srcstream is always checked before.
2023-12-12 16:43:43 +00:00
Dmitry Stogov
a146487739 Update IR
IR commit: 8065a69830820e600e19e6d41fb184541535546d
2023-12-12 02:12:51 +03:00
Niels Dossche
642e11140c
Minor pcre optimizations (#12923)
* Update signature of pcre API

This changes the variables that are bools to actually be bools instead
of ints, which allows some additional optimization by the compiler (e.g.
removing some ternaries and move extensions).

It also gets rid of the use_flags argument because that's just the same
as flags == 0. This reduces the call frame.

* Use zend_string_release_ex where possible

* Remove duplicate symbols from strchr

* Avoid useless value conversions

* Use a raw HashTable* instead of a zval

* Move condition

* Make for loop cheaper by reusing a recently used value as start iteration index

* Remove useless condition

This can't be true if the second condition is true because it would
require the string to occupy the entire address space.

* Upgrading + remark
2023-12-11 19:43:26 +01:00
Ilija Tovilo
185627f0c6
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix zend_jit_undefined_long_key overwriting dim when dim == result
2023-12-11 15:07:52 +01:00
Ilija Tovilo
e83a5683f9
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix zend_jit_undefined_long_key overwriting dim when dim == result
2023-12-11 15:07:44 +01:00
Ilija Tovilo
623da03845
Fix zend_jit_undefined_long_key overwriting dim when dim == result
Fixes oss-fuzz #64727
Closes GH-12900
2023-12-11 15:07:09 +01:00
Dmitry Stogov
a8eecec9b6 Fixed AAech64 build 2023-12-11 15:11:59 +03:00
Dmitry Stogov
9fa7763d32 Update IR
IR commit: eeed93083e73396985d8ade7d90006021b517315
2023-12-11 15:11:34 +03:00
Thomas Hurst
b90c9ca7db Enable ifunc checks on FreeBSD 12+
This was disabled in 2019 due to problems reported in FreeBSD 11. The original
report (PHP bug 77284) includes a comment that FreeBSD 12 worked - which also
happens to be the first version ifunc use appeared in libc.

Close GH-12288
2023-12-11 09:07:28 +00:00
Peter Kokot
07a4f89c49
Sync ODBC version (#12922)
When passing `--without-odbcver` or `--with-odbcver=no` to configure,
the ODBC version has been designed to be highest supported version
(0x0350). This syncs the behavior with the Windows build system.
2023-12-11 09:55:30 +01:00
Peter Kokot
82349769b0
Remove obsolete SVN files excluding when packaging phar (#12920)
This was used in pecl.php.net/phar packaging when using the obsolete SVN
PHP repository.
2023-12-11 09:55:13 +01:00
Dmitry Stogov
7714f1fcf2 Support for IR API changes 2023-12-11 10:29:25 +03:00
Dmitry Stogov
f6376f5b12 Update IR
IR commit: dab739f3d2ea4eb547d0c61629473c10197444d5
2023-12-11 10:28:41 +03:00
Dmitry Stogov
52d53c30b3 Merge branch 'PHP-8.3'
* PHP-8.3:
  JIT: Fix .debug_abbrev section in GDB JIT API.
2023-12-11 10:11:13 +03:00
Dmitry Stogov
1bf55959eb Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  JIT: Fix .debug_abbrev section in GDB JIT API.
2023-12-11 10:09:38 +03:00
Dmitry Stogov
ff22409082 JIT: Fix .debug_abbrev section in GDB JIT API. 2023-12-11 10:08:55 +03:00
Kamil Tekiela
550fd8a25e
Update comment regarding MySQL user max length
The username can be up to 32 chars long as of MySQL 5.7.8
2023-12-10 17:30:08 +01:00
Alex Dowad
fea895bb49 Merge branch 'PHP-8.3'
* PHP-8.3:
  Character indices used by mb_strpos and mb_substr have same meaning, even on invalid strings
2023-12-10 15:04:14 +02:00
Alex Dowad
ec348a12d1 Character indices used by mb_strpos and mb_substr have same meaning, even on invalid strings
Starting many years ago, libmbfl included a 'mblen_table' for selected
text encodings. This table allows looking up the byte length of a
(possibly multi-byte) character from the value of the first byte.
libmbfl uses these tables to optimize certain operations; if a
text-processing operation can be performed using an mblen_table,
it may not be necessary to decode the text to codepoints. Since
libmbfl's decoding filters are generally slow, this improves
performance.

Since mbstring is (or was) based on libmbfl, it has always used
these mblen_tables to implement some functions. This design has a
significant downside. Let me explain:

While some mbstring functions are implemented by converting input text
to codepoints and operating on the codepoints, others operate directly
on the original input bytes (using an mblen_table to identify character
boundaries). Both of these implementation styles, if correctly coded,
yield equivalent results on valid strings. However, on strings which
contain encoding errors, the results are often different.

When decoding byte strings to codepoints using some text encoding,
mbstring uses the non-existent codepoint 0xFFFFFFFF to represent a
byte sequence which cannot be decoded. Then, when mbstring indexes into
the resulting sequence of codepoints, the index of any particular
character depends on the number of such 'error markers' which were
produced during the decoding process. In contrast, when an mblen_table
is used to split a byte sequence into characters, there is no question
of counting encoding errors; rather, table lookups into the mblen_table
are used to repeatedly 'bite off' some number of bytes (which are
treated as one 'character'). In the presence of encoding errors, these
two methods of mapping between byte indices and character indices are
inherently different and will rarely agree.

(For completeness, it must be said that some internal mbstring code
which operates only on UTF-8 text uses a third method for mapping
between byte indices and character indices, that is: counting
non-continuation UTF-8 bytes, which are all bytes whose binary
representation is NOT like 0b10xxxxxx. This method happens to agree with
the method which involves decoding the input text to codepoints and then
counting the codepoints.)

I have been aware of this issue for years, but only recently became
aware that in the case of mb_strstr, mb_strpos, and mb_substr,
this issue can cause seriously unintuitive behavior (and even security
vulnerabilities). This was reported by Stefan Schiller.

Stefan Schiller shared the following example for mb_strstr:

    var_dump(mb_strstr("\xf0start", "start", false, "UTF-8"));
    // string(2) "rt"

Similarly, when mb_strpos and mb_substr are used to identify and
extract a substring from a string with encoding errors, Stefan Schiller
pointed out that the extracted portion may be completely different than
desired. This is because (for UTF-8 strings) mb_strpos works by counting
non-continuation bytes, but mb_substr uses an mblen_table.

Since some mbstring functions *cannot* be implemented using an
mblen_table, as long as mblen_tables are used, similar inconsistencies
cannot be totally avoided. But the mblen_tables are critical to
mbstring's performance. Or are they? Benchmarking mb_substr on various
UTF-8, SJIS, and EUC-JP strings revealed something interesting.
On all SJIS and EUC-JP test cases, mb_substr was slightly faster when
the mblen_table based code was deleted. For some UTF-8 test cases, the
mblen_table-based code was a tiny bit faster, while for others the
fallback code was a touch faster; in no case was the difference
significant.

Therefore, the simple fix is to delete the mblen_table-based
implementation of mb_substr.

Aside from making the function behave consistently with other mbstring
functions on invalid strings, there is ONE case where behavior is now
different on valid strings: that is, on SJIS-Mac (MacJapanese) strings
which contain any of the following code units:

0x85AB-0x85AD, 0x85BF, 0x85C0, 0x85C1, 0x8645, 0x864B, 0x865D, 0x869E,
0x86CE, 0x86D3-0x86D5, 0x86D6, 0x8971, 0x8792, 0x879D, 0x87FB, 0x87FC,
0xEB41, 0xEB42, 0xEB50, 0xEB5B, 0xEB5D, 0xEB60-0xEB6E, and all from
0xEB81 and above.

All of these SJIS-Mac code units share the (very unusual) property that
they do not correspond to any one Unicode codepoint. When converting
from SJIS-Mac to Unicode, these must be converted to 2, 3, 4, or 5
codepoints each.

The previous, mblen_table-based implementation of mb_substr would treat
all of these SJIS-Mac byte sequences as 'one character'. Now, they are
treated as multiple characters (one for each of the Unicode codepoints
which they decode to). The new behavior is more consistent with other
mbstring functions.

I don't know if SJIS-Mac users will like this change or not (probably
most will never notice), but the BC break is justified by the very
real security impact of the previous, inconsistent behavior.

Finally, I should comment on whether similar changes are needed
elsewhere. The remaining functions which use an mblen_table are:
mb_str_split, mb_strcut, and various search functions (such as
mb_strpos). The search functions are only affected now when they
receive a positive 'offset' parameter specifying where to start
searching from.

The search functions should definitely be fixed so they do not use
an mblen_table to implement the 'offset' parameter. I am not convinced
that there is any good reason to change mb_str_split and mb_strcut.
2023-12-10 14:40:30 +02:00
Arnaud Le Blanc
3c3aba11be Merge branch 'PHP-8.3'
* PHP-8.3:
  WS
  Clarify the stack limit exception message
  Fix GH-12643: Stack limit tests failing on ppc64le
2023-12-10 13:27:13 +01:00
Arnaud Le Blanc
6aa70b577d WS 2023-12-10 13:24:49 +01:00
Arnaud Le Blanc
b1516d95e0 Clarify the stack limit exception message
Make it clearer why the size is not exactly zend.max_allowed_stack_size
2023-12-10 13:20:21 +01:00
Arnaud Le Blanc
dad6912b99 Fix GH-12643: Stack limit tests failing on ppc64le
These tests were setting zend.max_allowed_stack_size to a small value. On ppc64le
this value is too small and the limit may be reached too soon.
2023-12-10 13:20:21 +01:00
Marc Bennewitz
b3f259d623
number_format: cast large floats within range of int to int
This prevents loosing precision for numbers above 2^52.

Closes GH-12333
2023-12-09 19:07:37 +00:00
David Carlier
19eb727b6a [ci skip] zend_call_stack NEWS update 2023-12-09 16:12:48 +00:00
David CARLIER
09838f17cb
zend_call_stack support proposal for solaris/illumos. (#12862) 2023-12-09 14:19:07 +00:00
Jakub Zelenka
2ffd040ffd
Merge branch 'PHP-8.3' 2023-12-09 13:26:29 +00:00
Jakub Zelenka
43900bd568
Merge branch 'PHP-8.2' into PHP-8.3 2023-12-09 13:26:09 +00:00
Jakub Zelenka
62682cbd97
Add FPM tester logs printing for all errors
Closes GH-12902
2023-12-09 13:21:41 +00:00
Niels Dossche
a9064816db
Optimizations for HTML 5 loading (#12896)
* Fix inverted NULL and add dictionary

* Avoid useless error processing if no reporting is set

* Avoid double work while processing attributes and use fast text instantiation
2023-12-08 18:45:01 +01:00
Niels Dossche
90eb5679d2
Cleanup libxml_get_external_entity_loader() (#12893)
We can directly put the value into return_value instead of copying
things around.
2023-12-08 18:44:46 +01:00
George Peter Banyard
90d41cccfd ext/mbstring: move another test case that only works on 64 bits 2023-12-08 17:17:28 +00:00
Niels Dossche
b34b4d54c3 Fix #44383: PHP DateTime not converted to xsd:datetime
Closes GH-12437.
Closes GH-11725.
2023-12-08 17:26:52 +01:00
Niels Dossche
2318a81725 Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] NEWS
2023-12-08 17:19:28 +01:00
Niels Dossche
ed40004139 [ci skip] NEWS 2023-12-08 17:19:17 +01:00
Ilija Tovilo
c5c189da34
Merge branch 'PHP-8.3'
* PHP-8.3:
  [skip ci] Skip intermittently failing curl test on macOS
2023-12-08 13:38:54 +01:00
Ilija Tovilo
1c39cdd63e
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [skip ci] Skip intermittently failing curl test on macOS
2023-12-08 13:38:48 +01:00
Ilija Tovilo
1b5a159183
[skip ci] Skip intermittently failing curl test on macOS
The test fails with "CURL ERROR: 56". I will create an issue for it shortly.
2023-12-08 13:36:52 +01:00
Niels Dossche
ec79fc9d9c Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12870: Creating an xmlns attribute results in a DOMException
2023-12-07 22:51:02 +01:00
Niels Dossche
e658f80501 Fix GH-12870: Creating an xmlns attribute results in a DOMException
There were multiple things here since forever, see the GH thread [1]
for discussion.

There were already many fixes to this function previously, and as a
consequence of one of those fixes this started throwing exceptions for a
correct use-case. It turns out that even when reverting to the previous
behaviour there are still bugs. Just fix all of them while we have the
chance.

[1] https://github.com/php/php-src/issues/12870

Closes GH-12888.
2023-12-07 22:42:32 +01:00
Gina Peter Banyard
7684a3d138
ext/mbstring: move unsigned 32 bit integer tests to a new test (#12891)
And only run it on 64 bit architectures as those are floats on 32 bit.
2023-12-07 20:19:11 +00:00
Alex Dowad
b0f7df1a67 Use optimized implementation of mb_strcut for Japanese mobile vendor UTF-8 variants
To facilitate sharing of mb_cut_utf8, I combined mbfilter_utf8.c and
mbfilter_utf8_mobile.c into a single source file.
2023-12-07 20:37:15 +02:00
Saki Takamachi
834cb64403
Feature: ext/pdo_firebird: Add transaction isolation level and mode settings (#12815)
* Added transaction isolation level and access mode

* Raise a ValueError if an invalid value is passed to PDO::FB_TRANSACTION_ISOLATION_LEVEL.
2023-12-07 17:34:55 +00:00
Ilija Tovilo
d6d838a21a
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix asan shadow memory and shared_alloc_mmap clash
2023-12-07 18:29:23 +01:00
Ilija Tovilo
8524da6d30
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix asan shadow memory and shared_alloc_mmap clash
2023-12-07 18:29:14 +01:00
Ilija Tovilo
53909896e0
Fix asan shadow memory and shared_alloc_mmap clash
The memory region found by find_prefered_mmap_base may clash with memory regions
reserved by asan for tracking memory. The symptom of this is that mprotect for
JIT fails adding the PROT_EXEC flag to the shared memory region.

Closes GH-12890
2023-12-07 18:28:21 +01:00
Gina Peter Banyard
88ba9dc61b
ext/mbstring: Always throw ValueErrors for invalid mb_http_input() type 2023-12-07 17:23:01 +00:00
Ilija Tovilo
5f3b4c5d6c
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix max_execution_time with cli-server router script
2023-12-07 16:13:27 +01:00