Commit Graph

121671 Commits

Author SHA1 Message Date
Christoph M. Becker
83cf4aa13a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #73809: Phar Zip parse crash - mmap fail
2020-12-01 17:00:27 +01:00
Christoph M. Becker
c283f53b24 Fix #73809: Phar Zip parse crash - mmap fail
Phar signatures practically are of limited size; for the MD5 and SHA
hashes the size is fixed (at most 64 bytes for SHA512); for OpenSSL
public keys there is no size limit in theory, but "64 KiB ought to be
good enough for anybody".  So we check for that limit, to avoid fatal
errors due to out of memory conditions.

Since it is neither possible to have the signature compressed in the
ZIP archive, nor is it possible to manually add a signature via Phar,
we use ZipArchive to create a suitable archive for the test on the fly.

Closes GH-6474.
2020-12-01 16:58:19 +01:00
Dmitry Stogov
44475e70e2 Fixed bug #80447 (Strange out of memory error when running with JIT) 2020-12-01 16:46:41 +03:00
Dmitry Stogov
1674c96c0b Bug #80447 (Strange out of memory error when running with JIT) 2020-12-01 16:43:05 +03:00
Dmitry Stogov
8ad2b59e12 Disable stack reuse optimization for x86 PIC code. It may clobber local variable used for Global Offset Table. 2020-12-01 15:20:06 +03:00
Nikita Popov
f06afc434a Don't use scope when validating Attribute
This is not safe to do at this point. Even if we made it safe,
we'd see inconsistencies due to a partially compiled class.

Fixes oss-fuzz #28129.
2020-12-01 11:49:27 +01:00
Nikita Popov
5dfec886d6 Fix use after free with file cache and arena allocated strings 2020-12-01 11:31:23 +01:00
Nikita Popov
648cda6c9f Don't mark cpu_supports functions as always inline
The use of no-sanitize may result in an inlining failure, which
will be promoted into a compile error by always-inline. Use a
normal inlining hint without enforcing it.
2020-12-01 10:22:36 +01:00
Dmitry Stogov
4959c60524 Fixed incorrect "skipif.inc" include 2020-12-01 11:34:09 +03:00
Dmitry Stogov
31eafedf2e Skip test if JIT is not available 2020-12-01 09:58:33 +03:00
Christoph M. Becker
f1d11c118d Fix #62004: SplFileObject: fgets after seek returns wrong line
As it is, `::seek(0)` sets the file pointer to the beginning of the
file, but `::seek($n)` where `$n > 0` sets the file pointer to the
beginning of the following line, having line `$n` already read into the
line buffer.  This is pretty inconsistent; we fix it by always seeking
to the beginning of the line.

We also add a test case for the duplicate bug #46569.

Closes GH-6434.
2020-11-30 16:03:37 +01:00
Dmitry Stogov
841b00f641 Preallocate stack space for JIT in execute_ex() to eliminate JIT prologue/epilogue. 2020-11-30 17:56:08 +03:00
Dmitry Stogov
5f36d0497f Fixed "may be used uninitialized" compilation warnings 2020-11-30 17:46:43 +03:00
Christoph M. Becker
57463cf78b Drop all JIT related XFAILS from phpdbg test suite
phpdbg now disables JIT, so these cause XFAIL warnings.
2020-11-30 15:24:15 +01:00
Nikita Popov
32cd5a1bc8 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Next attempt to fix bug #80368
2020-11-30 15:17:27 +01:00
Nikita Popov
ecee3f1209 Next attempt to fix bug #80368
Apparently treating LibreSSL as OpenSSL 1.1 is not just something
we did in our code, it's something that upstream LibreSSL claims,
despite not actually being compatible. Duh.

Check for EVP_CIPH_OCB_MODE instead, which should reliably
determine support...
2020-11-30 15:15:59 +01:00
George Peter Banyard
0076b47326 Fix Bug #80438: imap_msgno() incorrectly warns and return false on valid UIDs in PHP 8.0.0
Checking for a valid Unique ID (UID) cannot use the convenience macro as they might
be larger than the message number which has for maximum value the total number of
current messages available in the mailbox.
2020-11-30 14:08:31 +00:00
George Peter Banyard
a55402d07c Rename XmlParser to XMLParser for consistency with XMLWriter/XMLReader 2020-11-30 14:08:31 +00:00
Nikita Popov
24a19cc232 Suppress stream errors in mysqlnd
mysqlnd currently sets error_reporting=0 to suppress errors while
writing to streams. Unfortunately these errors are still visible
to userland error handlers, which is a source of confusion.
See for example https://bugs.php.net/bug.php?id=80412.

Instead add a stream flag that suppresses the emission of
read/write errors in the first place, and set it in mysqlnd.

I think it might be useful to have this option for userland as
well in the future, but for now this is just an internal
mechanism.

Closes GH-6458.
2020-11-30 15:06:28 +01:00
Dmitry Stogov
a0baa09b99 Hide phpdbg/JIT incompatibility macro (JIT is disabled for phpdbg) 2020-11-30 16:42:17 +03:00
Nikita Popov
4643c0aac5 Add additional entries to unserialize corpus
These are useful to seed typed property fuzzing.
2020-11-30 14:32:07 +01:00
Nikita Popov
ed9532cff0 Fix another ref source management bug in unserialize
When we overwrite an existing property during unserialization,
we also have to drop the ref source from it.
2020-11-30 14:23:54 +01:00
Christoph M. Becker
666833b238 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #76813: Access violation near NULL on source operand
2020-11-30 12:33:13 +01:00
Christoph M. Becker
5e15c9c41f Fix #76813: Access violation near NULL on source operand
We avoid `YYCURSOR` becoming `NULL` by initializing `YYMARKER`, and add
a default rule for `<NORMAL>` where we catch unexpected input.

We also fix the only superficially related issue regarding empty input
followed by `T_SEPARATOR` and command, which caused another segfault.

Closes GH-6464.
2020-11-30 12:29:24 +01:00
Dmitry Stogov
d5a82e2c4e Disable JIT with incompatible third-party extensions 2020-11-30 13:58:34 +03:00
Nikita Popov
15073d8e1d Fixed bug #80437
Only chmod if the file has been created.
2020-11-30 11:40:46 +01:00
Nikita Popov
fdb05b92bf Only replace IN_ARRAY result type for JMPZ/JMPNZ
Replacing the result type in the general case is dangerous,
because not all opcodes support both VAR and TMP. One common case
is the in_array() result being passed to SEND_VAR, which would
have to be changed to SEND_VAL.

Rather than complicating this logic, reduce the scope to only
doing the type replacement for JMPZ and JMPNZ. The only reason
we're doing this in the first place is to enable the smart branch
optimization, so we can limit it to the relevant opcodes. Replacing
the result type may be marginally useful in other cases as well
(as it may avoid reference checks), but not worth the bother.
2020-11-30 11:18:21 +01:00
Nikita Popov
e77ac88a44 Use ephemeral ports in mcast_ipv*_recv.phpt 2020-11-30 09:49:39 +01:00
Christoph M. Becker
44ccccdfb8 tidy::repairFile() and ::repairString() return string|false 2020-11-30 00:29:10 +01:00
Nikita Popov
5b3809e942 Respect strict_types during sccp function call evaluation
Similar to what we do with attributes, add a dummy call frame
on which we can set the strict_types flag.
2020-11-27 20:24:00 +01:00
Nikita Popov
0ce9b5f755 Don't check for throwing calls in sccp function evaluation
We only need to reject functions that could warn (or have runtime
dependent behavior). If a function can throw in some cases, just
let it and discard the result.
2020-11-27 17:49:51 +01:00
Nikita Popov
a505fc627e Fix handling of sccp exceptions
We should clear the exception *before* we destroy the execute_data.
Add a variation of the test that indirects through another file,
and would crash otherwise.
2020-11-27 17:44:30 +01:00
Jakub Zelenka
a87d620543 Merge branch 'PHP-7.4' into PHP-8.0 2020-11-27 16:35:16 +00:00
Jakub Zelenka
b855907f54 Merge branch 'PHP-7.3' into PHP-7.4 2020-11-27 16:33:47 +00:00
Jakub Zelenka
685708160e Fix test for bug62890 to not depend on system cert store 2020-11-27 16:32:43 +00:00
Nikita Popov
08919578ca Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix build for non-x86
2020-11-27 17:04:50 +01:00
Nikita Popov
3430d856ac Fix build for non-x86 2020-11-27 17:04:17 +01:00
Nikita Popov
e5aae35855 Handle exceptions during SCCP function evaluation
Easier to handle them than to ensure they can't happen in the
first place.
2020-11-27 17:00:12 +01:00
Nikita Popov
4f3cf983dc Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix AVX detection
2020-11-27 14:49:45 +01:00
Nikita Popov
4e30ab33d8 Fix AVX detection
Our CPU detection code currently only checks whether hardware
support for AVX exists. However, we also need to check for operating
system support for XSAVE, as well as whether XCR0 has the SSE and
AVX bits set.

If this is not the case, unset the AVX and AVX2 bits in the cpuinfo
structure.

Hopefully this resolves our issues with CPU support detection.

Closes GH-6460.
2020-11-27 14:49:31 +01:00
Nikita Popov
8b281e5b6b Only use travis for cron jobs
Our primary CI has been Azure Pipelines for a while now already.
Travis was primarily retained as a) a fast feedback builder and
b) to test architectures not available elsewhere.

Due to Travis CI open source policy changes, Travis is no longer
useful as a fast feedback builder. As such, only use it for cron
job builds.
2020-11-27 14:15:34 +01:00
Nikita Popov
8e25cf26af Make sure zend_cpu_supports_pclmul() is always defined
If __builtin_cpu_supports() is available, but doesn't have support
for pclmul, the function would end up not being defined at all.
2020-11-27 12:22:03 +01:00
Christoph M. Becker
bcefbf8602 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix mysqli_get_client_stats test
2020-11-27 11:51:30 +01:00
Christoph M. Becker
07c5efbd76 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix mysqli_get_client_stats test
2020-11-27 11:50:59 +01:00
Daniel Black
4a10037cb4 Fix mysqli_get_client_stats test
MySQL removed RENAME DATABASE in 18300001c1dbbfddf9a0adcbaeea68956102bdd0
(Sept 2007, 5.1.23). As this briefest existance is very insignificant lets remove it.

It also breaks when testing against MariaDB.

As the alternate path in this test covers all supported MySQL and MariaDB
versions and a signifant portion of unsupported versions lets keep it simple.

Closes GH-6459.
2020-11-27 11:43:34 +01:00
Nikita Popov
2772f7c3ad Avoid direct calls to zend_cpu_supports()
While the use of zend_cpu_supports_*() is only strictly necessary
inside ifunc resolvers, where the cpu state has not been initialized
yet, we should prefer the compiler builtins in all cases.
2020-11-27 11:18:10 +01:00
Nikita Popov
f35b194029 Assert that cpuinfo is initialized before use
And fix some incorrect indentation.
2020-11-27 11:14:07 +01:00
Nikita Popov
4a7ebb6d83 Move avx check into a macro 2020-11-27 11:06:05 +01:00
Nikita Popov
f4e1768e21 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80368
2020-11-27 10:58:34 +01:00
Nikita Popov
0f579fd7c8 Fixed bug #80368
We assume that usually LibreSSL supports everything OpenSSL 1.1 does.
In this instance, this is not the case.
2020-11-27 10:57:19 +01:00