1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 19:23:22 +02:00
Commit Graph

125485 Commits

Author SHA1 Message Date
Alex Dowad 51e0d323e4 ISO-2022-JP-MS treats truncated multi-byte chars as error
Sigh. I included tests which were intended to check this case in the
test suite for ISO-2022-JP-MS, but those tests were faulty and didn't
actually test what they were supposed to.

Fixing the tests revealed that there were still bugs in this area.
2021-08-30 16:29:58 +02:00
Alex Dowad 57a81af041 ISO-2022-JP-KDDI text conversion doesn't swallow PUA codepoints
There was a bit of legacy code here which looks like the original author
of mbstring intended to allow conversion of Unicode Private Use Area
codepoints to ISO-2022-JP-KDDI. However, that code never worked.
It set the output variable to values which were not matched by any
of the 'if' clauses below, which meant that nothing was actually
emitted to the output. In other words, if one tried to convert Unicode
to ISO-2022-JP-KDDI, and the Unicode string contained PUA codepoints,
they would be quietly 'swallowed' and disappear.

I don't know what ISO-2022-JP-KDDI byte sequences the author wanted
to map those PUA codepoints to, and anyways, this use case is so obscure
that there is little point in worrying about it. However, it is better
to remove the non-functioning code than to leave it in.

This means that if now one tries to convert PUA codepoints to
ISO-2022-JP-KDDI, those codepoints will be treated as erroneous rather
than silently ignored.
2021-08-30 16:29:58 +02:00
Alex Dowad 51b9d7a5e1 Test behavior of 'long' illegal character markers
After mb_substitute_character("long"), mbstring will respond to
erroneous input by inserting 'long' error markers into the output.
Depending on the situation, these error markers will either look like
BAD+XXXX (for general bad input), U+XXXX (when the input is OK, but it
converts to Unicode codepoints which cannot be represented in the
output encoding), or an encoding-specific marker like JISX+XXXX or
W932+XXXX.

We have almost no tests for this feature. Add a bunch of tests to
ensure that all our legacy encoding handlers work in a reasonable
way when 'long' error markers are enabled.
2021-08-30 16:29:58 +02:00
Alex Dowad f6f0506c84 Correct comment in mbfilter_ucs4.c 2021-08-30 16:29:58 +02:00
Alex Dowad 03392ecd50 Simplify code for converting UHC to Unicode 2021-08-30 16:29:58 +02:00
Alex Dowad 9363b0b5a7 Declare ARMSCII-8 conversion functions as 'static' 2021-08-30 16:29:58 +02:00
Alex Dowad 97b7fc893c Output illegal character marker for 4-byte illegal characters > 0x7FFFFFFF
Some text encodings supported by mbstring (such as UCS-4) accept 4-byte
characters. When mbstring encounters an illegal byte sequence for the
encoding it is using, it should emit an 'illegal character' marker,
which can either be a single character like '?', an HTML hexadecimal
entity, or a marker string like 'BAD+XXXX'.

Because of the use of signed integers to hold 4-byte characters,
illegal 4-byte sequences with a 'negative' value (one with the high
bit set) were not handled correctly when emitting the illegal char
marker. The result is that such illegal sequences were just skipped
over (and the marker was not emitted to the output). Fix that.
2021-08-30 16:29:58 +02:00
Máté Kocsis a57b713d66 Fix typo in gen_stub.php 2021-08-30 16:09:10 +02:00
Dmitry Stogov 7690fa0bd8 JIT: Better code for ADD/SUB/MUL and references in tracing JIT. 2021-08-30 17:02:35 +03:00
Máté Kocsis c19e4b9997 Generate optimizer func info from stubs for ext/standard - part 3 (#7426) 2021-08-30 15:56:47 +02:00
Máté Kocsis 1bf1481a2a Specify a few array func info entries (#7425) 2021-08-30 14:29:18 +02:00
Máté Kocsis d5b583a61c Merge branch 'PHP-8.0'
* PHP-8.0:
  Use camelCase method names in OCICollection and OCILob
2021-08-30 14:09:24 +02:00
Máté Kocsis e94731f164 Use camelCase method names in OCICollection and OCILob (#7405) 2021-08-30 14:01:12 +02:00
Dmitry Stogov 8f601be101 JIT: Allow keeping result of FETCH_CONSTANT in a CPU register 2021-08-30 14:56:51 +03:00
Máté Kocsis 8e6e9838b0 Add support for generating MAY_BE_ARRAY_OF_REF func info flag (#7416) 2021-08-30 13:50:34 +02:00
Dmitry Stogov 96c3465513 JIT: Avoid useless EX(func) load 2021-08-30 13:58:23 +03:00
Dmitry Stogov 608d568686 JIT: Avoid reloading of EX(run_time_cache) 2021-08-30 13:19:04 +03:00
Dmitry Stogov 3565d02c6d JIT: Eliminate load of op_array->run_time_cache__ptr and use immediate value for immutable op_arrays if it's known at compile time 2021-08-30 12:26:37 +03:00
Nikita Popov d16992afe2 Use HAVE_SYS_PARAM_H 2021-08-30 11:21:33 +02:00
David CARLIER 59255bffbb Enable getrandom() api on solaris-ish systems (#7417)
Been available long enough to be trustable source.
2021-08-30 11:17:06 +02:00
Nikita Popov 634f2e21d3 Don't expose wchar encoding to users (#7415)
The "wchar" encoding isn't really an encoding -- it's what we
internally use as the representation of decoded characters.

In practice, it tends to behave a lot like the 8bit encoding when
used from userland, because input code units end up being treated
as code points.

This patch removes the wchar encoding from the public encoding
list and reserves it for internal use only.
2021-08-30 11:11:33 +02:00
Nikita Popov 0f926815ca Fix strict-prototypes warning 2021-08-30 10:43:21 +02:00
Nikita Popov fab1222128 Ensure stub files are processed in predictable order
The zend_func_infos.h file was generated in a different order for
me.
2021-08-30 10:28:22 +02:00
Nikita Popov 0f7e0cf34b str_replace() can return the original string 2021-08-30 10:23:09 +02:00
K f6d30cfba7 microptimization of SQLite3Result::fetchArray
Store the result of sqlite3_data_count() into a variable and check that inside a loop instead calling it directly all the time. GCC is not brave enough to figure out the function produces the same result every time and call it repeatedly. This change produces fairly small but measurable and consistent speedup.
2021-08-30 10:15:44 +02:00
Dmitry Stogov 1347d90a23 JIT: Avoid reloading of EX(run_time_cache) 2021-08-30 11:02:30 +03:00
Dmitry Stogov c51b0d9702 JIT: Avoid redundand checks of number of passed arguments 2021-08-30 10:15:54 +03:00
Dmitry Stogov 66a4437c3b Avoid redundand argument type verification 2021-08-29 19:21:01 +03:00
Dmitry Stogov 67d6c2db9f JIT: Optimize zend_vm_stack_free_args()
Avoid code genearation for destructors of immutable parameters of internal functions that cannot be changed in place.
Keep destructors for immutable array parameters, because few function may modufy them in-pace.
2021-08-29 17:49:54 +03:00
Máté Kocsis b49d340f74 Generate optimizer func info from stubs for ext/standard - part 2 (#7414) 2021-08-27 16:54:04 +02:00
Máté Kocsis 3f0b586338 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix a few func info
2021-08-27 16:48:06 +02:00
Máté Kocsis cdf0550fe5 Fix a few func info entries 2021-08-27 16:45:32 +02:00
dixyes e4c23fa16b Add haiku shared objects support in libtool 2021-08-27 16:44:10 +02:00
Nikita Popov 51a504c8be Avoid string copy in get_cfg_var()
basic_functions.c already has a macro for returning an ini
value to userland, so make use of it for get_cfg_var() as well,
after generalizing it to not write to return_value in particular.
2021-08-27 15:34:46 +02:00
Nikita Popov 43cb2548f7 Flush filter during non-strict encoding detection
If we reach the end of the string without reducing to a single
encoding, then we should flush to check whether the last character
is incomplete.
2021-08-27 14:48:32 +02:00
Máté Kocsis 1ce81b6bcd Generate optimizer func info from stubs for ext/standard - part 1 (#7413) 2021-08-27 13:11:57 +02:00
Máté Kocsis 8712fb5fe8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix func info for str_replace() and str_ireplace()
2021-08-27 12:56:14 +02:00
Máté Kocsis 492821a302 Fix func info for str_replace() and str_ireplace() 2021-08-27 12:53:44 +02:00
Nikita Popov 7157a2a9ee Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove incorrect refcount info for addcslashes()
2021-08-27 12:13:57 +02:00
Nikita Popov 9d70946b16 Remove incorrect refcount info for addcslashes()
This function may return the input string.
2021-08-27 12:13:08 +02:00
Nikita Popov 2cc47a04df Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix Closure::call() on internal method closure
2021-08-27 12:00:07 +02:00
Nikita Popov 2467f759f5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix Closure::call() on internal method closure
2021-08-27 11:59:38 +02:00
Nikita Popov eda9f5f740 Fix Closure::call() on internal method closure
In this case we should use the original internal handler. Otherwise
the trampoline will attempt to free the closure, but the function
being used is not actually part of a closure anymore.
2021-08-27 11:58:13 +02:00
Nikita Popov 4fcf0db649 Fix use after free when rebinding __call closure
We would end up freeing the function name twice here, once for
the original closure, and once for the rebound one.

Rather than further special casing the zend_closure_call_magic
case, always addref the function_name for internal functions,
the same we do for userland functions. To compensate, we need to
release the original function name when creating from callable
or call frame.

Fixes oss-fuzz #37695.
2021-08-27 11:34:22 +02:00
Máté Kocsis fdc6082902 Generate optimizer func info from stubs for various extensions (#7409)
ext/hash, ext/iconv, ext/mbstring, ext/xml, ext/zlib
2021-08-26 19:52:11 +02:00
Christoph M. Becker c95e036813 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #53580: During resize gdImageCopyResampled cause colors change
2021-08-26 18:44:04 +02:00
Christoph M. Becker 35e1f134f5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #53580: During resize gdImageCopyResampled cause colors change
2021-08-26 18:41:08 +02:00
Christoph M. Becker 526407ca35 Fix #53580: During resize gdImageCopyResampled cause colors change
We port the upstream fix[1], and also revert commit a3383ac3d7[2] which
is now obsolete, and also not part of libgd.  Especially the change to
gd.png.c was at best a half-baked optimization.

[1] <https://github.com/libgd/libgd/commit/a24e96f01989bf9ca05a08d33862a08d6f4c4ed6>
[2] <https://github.com/php/php-src/commit/a3383ac3d7e21e54b1d7d89f308088d0692abc9f>

Closes GH-7402.
2021-08-26 18:38:17 +02:00
Máté Kocsis 68946bdd90 Generate optimizer func info from stubs for ext/gd and ext/pgsql (#7408) 2021-08-26 17:38:08 +02:00
Máté Kocsis 7d3cdb3681 Fix mysqli stub alias verification issues
I had to add a few no-verify annotations since the return type of the function and method counterparts cannot be aligned properly (easily)
2021-08-26 17:36:53 +02:00