Commit Graph

57210 Commits

Author SHA1 Message Date
Nikita Popov
706241f82d Fix usage of casted string in ReflectionParameter ctor
Fixes oss-fuzz #27755.
2020-11-24 16:42:16 +01:00
Nikita Popov
fc26ad9b12 Fixed bug #80377
Use $PHP_THREAD_SAFETY instead of $enable_zts to check for ZTS.
This variable is also available for phpize builds, while enable_zts
is only present for in-tree builds.
2020-11-24 15:52:41 +01:00
Christoph M. Becker
bf244757ee Allow PHP_CURL_APIs to be imported by DLLs
Closes GH-6438.
2020-11-24 14:12:39 +01:00
Christoph M. Becker
e589609b4c Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #77961: finfo_open crafted magic parsing SIGABRT
2020-11-24 14:06:53 +01:00
Christoph M. Becker
39f95f5614 Fix #77961: finfo_open crafted magic parsing SIGABRT
libmagic may abort the running process, which is not desirable for PHP;
we raise a fatal error instead.

Closes GH-6437.
2020-11-24 14:01:15 +01:00
Christoph M. Becker
337031abbd [ci skip] Update generate_patch.sh
This has apparently been forgotten when updating to libmagic 5.39.
2020-11-24 13:38:31 +01:00
Christoph M. Becker
deb8b8190e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80366: Return Value of zend_fstat() not Checked
2020-11-24 13:10:35 +01:00
Christoph M. Becker
5f9c82d514 Fix #80366: Return Value of zend_fstat() not Checked
In the somewhat unlikely case that `zend_fstat()` fails, we must not
proceed executing the function, but return `false` instead.

Patch based on the patch contributed by sagpant at microsoft dot com.

Closes GH-6432.
2020-11-24 13:09:16 +01:00
Nikita Popov
03f8bccaf5 Fixed bug #80404
For a division like [1..1]/[2..2] produce [0..1] as a result, which
would be the integer envelope of the floating-point result.

The implementation is pretty ugly (we're now taking min/max across
eight values...) but I couldn't come up with a more elegant way
to handle this that doesn't make things a lot more complex (the
division sign handling is the annoying issue here).
2020-11-24 11:35:44 +01:00
Benjamin Morel
4bbb98c24f Fix PDOStatement::fetchObject() stub
Closes GH-6449.
2020-11-24 09:49:30 +01:00
Christopher Jones
68d5878097 Sync README with package.xml 2020-11-24 10:45:48 +11:00
Christoph M. Becker
807775b641 Fix COMPersistHelper::__construct() stub
`$variant` is optional.
2020-11-24 00:23:29 +01:00
Remi Collet
ce18899b44 zip extension is 1.19.2 2020-11-23 15:59:15 +01:00
Dmitry Stogov
337d2af6ca zend_jit_trace_stack_frame.stack can't be NULL 2020-11-23 16:19:22 +03:00
Dmitry Stogov
586ccfdfd5 Fixed use-after-free in PHPUnit tests 2020-11-23 14:42:38 +03:00
Dmitry Stogov
4cf3da7383 Keep value of register before possible side exit 2020-11-23 12:07:05 +03:00
Christoph M. Becker
9b1c02c2df Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #77594: ob_tidyhandler is never reset
2020-11-22 14:04:59 +01:00
Christoph M. Becker
221345a013 Fix #77594: ob_tidyhandler is never reset
We reset to original INI value on request shutdown.

Closes GH-6425.
2020-11-22 14:02:29 +01:00
Nikita Popov
fa67864c13 Use MIN/MAX when dumping RANGE[]
It's very common that one of the bounds is LONG_MIN or LONG_MAX.
Dump them as MIN/MAX instead of the int representation in that
case, as it makes the dump less noisy.
2020-11-20 16:47:46 +01:00
Dmitry Stogov
c0d1dbcb43 Fixed incorrect TRACE_FRAME_MASK_NESTED flag setting 2020-11-20 18:22:21 +03:00
Dmitry Stogov
c8df28d276 Fixed 32-bit JIT 2020-11-20 15:12:30 +03:00
Christoph M. Becker
c7343510e4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #72964: White space not unfolded for CC/Bcc headers
2020-11-19 19:26:56 +01:00
Christoph M. Becker
881e43a03c Fix #72964: White space not unfolded for CC/Bcc headers
`\r\n` does only terminate a header, if not followed by `\t` or ` `.
We have to cater to that when determining the end position of the
respective headers.

Closes GH-6420.
2020-11-19 19:25:03 +01:00
Dmitry Stogov
069f9cbaa5 Added missing deoptimization code for trampoline handling 2020-11-19 12:32:36 +03:00
Nikita Popov
06c4a501fd Fix curl_multi_getcontent() parameter name
While the function name starts with curl_multi_*, the function
actually accepts a CurlHandle. As such, it should also use just
$handle as the parameter name.

Closes GH-6435.
2020-11-19 10:17:17 +01:00
Dmitry Stogov
feed041fc8 Fixed register clobbering 2020-11-18 10:22:25 +03:00
Dmitry Stogov
9841e8e411 Fixed trampoline handling 2020-11-17 23:56:05 +03:00
Dmitry Stogov
e364af91b5 Fixed allocated register clobbering 2020-11-17 18:31:14 +03:00
Dmitry Stogov
1523733bc4 Fixed false pasitive ASAN NULL pointer dereference warning 2020-11-17 16:23:30 +03:00
Nikita Popov
f4a600be04 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80312: change default engine from MyISAM to InnoDB in tests
2020-11-17 13:16:17 +01:00
Darek Slusarczyk
79a606bd95 Fix #80312: change default engine from MyISAM to InnoDB in tests
Change mysqli and pdo_mysql tests configuration to use by default
InnoDB instead of MyISAM.

Closes GH-6405.
2020-11-17 13:15:15 +01:00
Benjamin Eberlei
1727d96d0e Fixed bug #80370: Segmentation fault reflecting attributes of dynamic property
Closes GH-6428.
2020-11-17 10:54:27 +01:00
Sammy Kaye Powers
58d41b8c4f Provide unused retvals to observers
Make sure that the return value is available to observers, even if
it is not used by the caller.

Closes GH-6422.
2020-11-17 10:28:47 +01:00
Nikita Popov
9cfb5261e4 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix incorrectly optimized out live range
2020-11-17 10:20:23 +01:00
Nikita Popov
df7417d127 Fix incorrectly optimized out live range
For x ? y : z style structures, the live range starts at z, but
may also hold the value of y. Make sure that the refcounting check
takes this into account, by checking the type of a potential phi
user.
2020-11-17 10:19:57 +01:00
Sammy Kaye Powers
0425a6697a
Fire open observer end handlers after a zend_bailout
Closes GH-6377
2020-11-16 15:12:57 -08:00
Dmitry Stogov
3fb1b0862c Fixed MAY_BE_INDIRECT inference 2020-11-16 18:17:05 +03:00
Dmitry Stogov
e3c63de05b Fixed alias handling 2020-11-16 16:11:25 +03:00
Dmitry Stogov
eb6d496a93 Fixed reference-counting 2020-11-16 14:51:55 +03:00
Dmitry Stogov
edf5c1901f Fixed incorrect FETCH_THIS optimization 2020-11-16 14:51:39 +03:00
Dmitry Stogov
bd321df479 Fixed inconsistent VM stack state 2020-11-16 13:19:44 +03:00
Dmitry Stogov
64dc79f906 Trampoline cleanup 2020-11-16 12:05:45 +03:00
Nikita Popov
f5be0e5110 Inline pair production in json parser
Having this as a separate production has a noticeable performance
impact, and doesn't really make things clearer either.
2020-11-13 14:56:29 +01:00
Christoph M. Becker
a08a2b48b4 Strip trailing line breaks and periods from Windows error messages
PHP error messages should not contain line breaks, so we remove these
from the Windows specific error messages.  We also remove trailing
periods for the same reason.

Closes GH-6423.
2020-11-12 16:42:28 +01:00
Nikita Popov
34dd032e4e Don't assume libmysqlclient library name
By simply dropping the additional checks, in line with the general
guideline of trusting the output of config scripts (this should
be migrated to pkg-config though).

Also drop the code for manually adding -z if mysql_config does not
-- that's not our problem.
2020-11-12 15:11:56 +01:00
Nikita Popov
2875d0f920 Fix memory leak when user filter onCreate returns false 2020-11-12 12:18:33 +01:00
Nikita Popov
3d2819e491 Fix memory leak with bcsqrt on number 0<X<1 2020-11-12 11:37:54 +01:00
Nikita Popov
d033d5c07a Fix reflection getDefaultValue() with user arg info
The default value is part of the op_array in that case, but we have
no way to access it. Fail gracefully.
2020-11-12 11:02:04 +01:00
Dmitry Stogov
9acebe14df Fixed incorrectly eliminated type store 2020-11-11 20:13:58 +03:00
Dmitry Stogov
03e7854381 Remove assertion 2020-11-11 18:34:16 +03:00
Nikita Popov
d776c31a34 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Handle errors during next_result()
2020-11-11 16:03:10 +01:00
Nikita Popov
eda7492604 Handle errors during next_result() 2020-11-11 16:02:52 +01:00
Dmitry Stogov
2d2d42b268 Fixed incorrect invariant guard motion 2020-11-11 17:34:46 +03:00
Dmitry Stogov
de359c00b4 Stop on fake frame 2020-11-11 14:54:54 +03:00
Dmitry Stogov
a0de82ad75 Fixed reference-counting propagation 2020-11-11 14:54:00 +03:00
Nikita Popov
800cf5a20f Fix double free when socket_accept fails 2020-11-11 12:48:25 +01:00
Nikita Popov
b4a2a9662b Retain reference to share handle from curl handle
Not keeping a reference will not result in use after free, because
curl protects against it, but it will result in a memory leak,
because curl_share_cleanup() will fail. We should make sure that
the share handle object stays alive as long as the curl handles
use it.
2020-11-11 11:56:03 +01:00
Dmitry Stogov
11c4821ba9 [Observer+JIT] Save opline before calling begin/end handlers 2020-11-11 13:50:53 +03:00
Dmitry Stogov
855d8fa68f [Observer] Save opline before calling begin/end handlers 2020-11-11 13:06:55 +03:00
Nikita Popov
523dd9a2d9 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix phi use chain management when renaming variable
2020-11-09 17:08:38 +01:00
Nikita Popov
d971b67027 Fix phi use chain management when renaming variable
If there is a previous use of the new variable in the phi, we need
to NULL out the use chain of the new source we're adding.

Test case is reduced from an assertion failure in the Symfony Demo.
2020-11-09 17:08:16 +01:00
Nikita Popov
975735c027 Use true/false instead of TRUE/FALSE in intl
And drop the U_DEFINE_TRUE_AND_FALSE flag.
2020-11-09 14:44:11 +01:00
Dharman
114613dc5f Remove embedded property from mysqli_driver
All other leftovers of this feature have been dropped in PHP 8,
so we should remove the property as well.

Closes GH-6407.
2020-11-09 11:00:16 +01:00
Dmitry Stogov
4bbe55b250 Fixed missaligned access 2020-11-09 11:50:26 +03:00
Nikita Popov
5df461bc91 Skip preload test under asan
Just like the other preload tests with startup failures, this may
cause leaks.
2020-11-09 09:46:48 +01:00
Nikita Popov
b1019f46ed Rename PhpToken::getAll() to PhpToken::tokenize()
See https://externals.io/message/112189.
Fixes bug #80328.
2020-11-09 09:40:31 +01:00
Christoph M. Becker
49ca191667 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Split tests for compatibility with ICU 68.1
2020-11-06 17:44:51 +01:00
Christoph M. Becker
77b6e95d92 Split tests for compatibility with ICU 68.1 2020-11-06 17:42:39 +01:00
Christoph M. Becker
d65a520b1d Raise E_WARNING on PHP related errors
If Zip operations fails due to PHP error conditions before libzip even
has been called, there is no meaningful indication what failed; the
functions just return false, and the Zip status indicated that no error
did occur.  Therefore we raise `E_WARNING` in these cases.

Closes GH-6356.
2020-11-06 11:00:43 +01:00
Dmitry Stogov
98e4f9466d Move stack overflow checks out of the loops 2020-11-06 12:09:56 +03:00
Remi Collet
e2509cf98a report about ZSTD compression availability 2020-11-06 09:58:08 +01:00
Remi Collet
8d7ca472e5 only display libzip both headers/library versions if they differ 2020-11-06 09:58:05 +01:00
Nikita Popov
6808968c89 Backport preloading trait fixup fixes
This cherry-picks 33969c2252 and
2effbfd871 from PHP-8.0.

The issues these commits fix could also manifest in PHP 7.4, and
a commenter on bug #80307 reports this this might indeed be
happening.
2020-11-05 16:35:08 +01:00
Dmitry Stogov
ff91800602 Fixed incorrect invariant guard motion 2020-11-05 18:32:00 +03:00
Nikita Popov
2effbfd871 Fixup trait methods even if no traits are used
Trait methods might be non-trivially inherited, in which case we
may have to perform fixup in classes that do not directly use any
traits.
2020-11-05 13:15:32 +01:00
Nikita Popov
33969c2252 Fix multiple trait fixup
If a trait method is inherited, preloading trait fixup might be
performed on it multiple times. Usually this is fine, because
the opcodes pointer will have already been updated, and will thus
not be found in the xlat table.

However, it can happen that the new opcodes pointer is the same
as one of the old opcodes pointers, if the pointer has been reused
by the allocator. In this case we will look up the wrong op array
and overwrite the trait method with an unrelated trait method.

We fix this by indexing the xlat table not by the opcodes pointer,
but by the refcount pointer. The refcount pointer is not changed
during optimization, and accurately represents which op arrays
should use the same opcodes.

Fixes bug #80307. The test case does not reproduce the bug, because
this depends on a lot of "luck" with the allocator. The test case
merely illustrates a case where orig_op_array would have been NULL
in the original code.
2020-11-05 12:04:39 +01:00
Nikita Popov
7c7c6b0d73 End output handlers in preload shutdown
Same as in php_request_shutdown(), we need to end any active
output handlers, as these may no longer be safe to execute
lateron.
2020-11-04 16:05:24 +01:00
Nikita Popov
73321bc300 getlastmod() can return false
At least this can happen during preloading.
2020-11-04 15:53:08 +01:00
Nikita Popov
670fe594b9 Fix static variable in methods inheritance during preloading
This is now "bug compatible" with the normal behavior, and more
imporantly, does not crash :)
2020-11-04 15:42:52 +01:00
Christoph M. Becker
b8f2531ff0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80266: parse_url silently drops port number 0
2020-11-04 14:57:17 +01:00
Christoph M. Becker
00e41a10b8 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #80266: parse_url silently drops port number 0
2020-11-04 14:54:32 +01:00
Christoph M. Becker
2cab085bb3 Fix #80266: parse_url silently drops port number 0
As of commit 81b2f3e[1], `parse_url()` accepts URLs with a zero port,
but does not report that port, what is wrong in hindsight.

Since the port number is stored as `unsigned short` there is no way to
distinguish between port zero and no port.  For BC reasons, we thus
introduce `parse_url_ex2()` which accepts an output parameter that
allows that distinction, and use the new function to fix the behavior.

The introduction of `parse_url_ex2()` has been suggested by Nikita.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=81b2f3e5d9fcdffd87a4fcd12bd8c708a97091e1>

Closes GH-6399.
2020-11-04 14:53:19 +01:00
Nikita Popov
7794925ba4 Assert that references are not persisted
There should not be any need to persist references, and it's unlikely
that persisting a reference will behave correctly at runtime, because
we don't have a concept of an immutable reference.
2020-11-04 14:51:44 +01:00
Nikita Popov
c6563dddac Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix dynamic function definition in preload script
2020-11-04 10:55:59 +01:00
Nikita Popov
e0d6c3f7ba Fix dynamic function definition in preload script
We should use normal function renaming if the function is declared
during preloading itself, rather than afterwards.

This fixes a regression introduced by
68f80be9d1.
2020-11-04 10:54:08 +01:00
Nikita Popov
54668a449e Don't disable early binding during preloading script
We should only disable early binding during the opcache_compile_file()
calls, not inside the preloading script or anything it includes.
The right condition to check for is whether we compile the file
without execution, as declaring classes is "execution".
2020-11-03 16:45:13 +01:00
Nikita Popov
b009573f4e Report parse errors during preloading 2020-11-03 16:24:54 +01:00
Nikita Popov
9fd8e00f1a Fix use of type copy ctor when importing trait properties
We shouldn't call the copy constructor inside the original type,
duh.
2020-11-03 15:29:18 +01:00
Nikita Popov
7e55317558 Allow unlinked classes when performing in_compilation variance check
As preloading runs in in_compilation mode, we also need to allow
use of unlinked classes in lookup_class().
2020-11-03 14:49:10 +01:00
Nikita Popov
ee934f8245 Fix variance checks on resolved union types
This is a bit annoying: When preloading is used, types might be
resolved during inheritance checks, so we need to deal with CE
types rather than just NAME types everywhere.
2020-11-03 14:19:15 +01:00
Nikita Popov
51b5f7d67d Don't ignore internal classes during preloading
When preloading, it's fine to make use of internal class information,
as we do not support Windows. It is also necessary to allow proper
variance checks against internal classes.
2020-11-03 11:50:14 +01:00
Nikita Popov
14c42c6961 Fix persisting property info table with internal parent
If the property info comes from an internal parent, we won't have
an xlat entry for it. Leave it alone in that case.
2020-11-03 11:30:44 +01:00
Nikita Popov
6f2431860b Preserve trait method alias name during preloading 2020-11-03 10:55:59 +01:00
Nikita Popov
0571f09424 Rename opcache.jit_max_loops_unroll to opcache.jit_max_loop_unrolls 2020-11-02 12:25:21 +01:00
Christoph M. Becker
6fc2cab254 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #70461: disable md5 code when it is not supported in net-snmp
2020-11-02 11:41:37 +01:00
Christoph M. Becker
0123f75b5d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #70461: disable md5 code when it is not supported in net-snmp
2020-11-02 11:39:42 +01:00
Christoph M. Becker
9690ded288 Fix #70461: disable md5 code when it is not supported in net-snmp
Patch contributed by Alexander Bergmann.

Closes GH-6389.
2020-11-02 11:36:26 +01:00
Dharman
cf38a6f51f Fix tests for MariaDB
Closes GH-6390.
2020-11-02 09:58:46 +01:00
Alex Dowad
d44235acae Convert numeric string array keys to integers correctly in JITted code
While fixing bugs in mbstring, one of my new test cases failed with a strange
error message stating: 'Warning: Undefined array key 1...', when clearly the
array key had been set properly.

GDB'd that sucker and found that JIT'd PHP code was calling directly into
`zend_hash_add_new` (which was not converting the numeric string key to an
integer properly). But where was that code coming from? I examined the disasm,
looked up symbols to figure out where call instructions were going, then grepped
the codebase for those function names. It soon became clear that the disasm I
was looking at was compiled from `zend_jit_fetch_dim_w_helper`.
2020-10-30 22:07:08 +02:00
Nikita Popov
904c1b6589 FIxed bug #80299
The must_wrap was leaking across iterations.
2020-10-30 17:23:18 +01:00