Commit Graph

121710 Commits

Author SHA1 Message Date
Nikita Popov
2df09b9b64 PDO MySQL: Normalize handling of empty stored procedure result set
MySQL always returns a trailing empty result set for stored
procedure calls, which is used to convey status information.
The PDO MySQL implementation is presently confused about what to
do with it: If mysqlnd is used and native prepared statements are
used, this result set is skipped. In all other cases it is not
skipped. We also have quite a few XFAILed tests relating to this.

This patch normalizes (for PHP-8.0 only) the behavior towards
always retaining the empty result set. This is simply how MySQL
stored procedures work (some expletives omitted here) and we can't
distinguish this "useless" result set from an empty result of a
multi query. Multi queries are not a concern for native prepared
statements, as PDO does not allow them in that case, but they are
a concern for emulated prepared statements.

Closes GH-6497.
2020-12-08 17:01:56 +01:00
Nikita Popov
bfa69d27bc Handle column count change in PDO MySQL
This has been fixed for PDO SQlite by GH-4313, however the same
issue also applied to PDO MySQL.

Move the column count setting function into the main PDO layer
(and export it) and then use it in both PDO SQLite and PDO MySQL.
2020-12-08 16:41:35 +01:00
Nikita Popov
713ef8511b Enable XFAILed test
This one had a rather scary XFAIL message, but seems to work just
fine...
2020-12-08 16:03:50 +01:00
Christoph M. Becker
fb4bc0f9e5 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #48725: Support for flushing in zlib stream
2020-12-08 12:24:49 +01:00
Christoph M. Becker
20e75329f2 Fix #48725: Support for flushing in zlib stream
When `php_zlib_deflate_filter()` is called with `PSFS_FLAG_FLUSH_INC`
but without new buckets being available (e.g. because a user calls
`rewind()` after writing to the stream), we have to make sure that any
pending data are flushed.  This could basically be done like in the
attached patch[1], but that could cause unnessary flushes, which can be
harmful for compression, and adds unnecessary flush markers to the
stream.  Thus, we use the `php_zlib_filter_data.finished` field, which
has not been used for `zlib.deflate` filters, and properly keep track
of the need to flush.

[1] <https://bugs.php.net/patch-display.php?bug_id=48725&patch=zlib-filter-flush-fix.patch&revision=latest>

Closes GH-6019.
2020-12-08 12:23:24 +01:00
Christoph M. Becker
d6ae0f010e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #77069: stream filter loses final block of data
2020-12-08 11:49:28 +01:00
Christoph M. Becker
65f5573bc8 Fix #77069: stream filter loses final block of data
Reading from a stream may return greater than zero, but nonetheless the
stream's EOF flag may have been set.  We have to cater to this
condition by setting the close flag for filters.

We also have to cater to that change in the zlib.inflate filter:

If `inflate()` is called with flush mode `Z_FINISH`, but the output
buffer is not large enough to inflate all available data, it fails with
`Z_BUF_ERROR`.  However, `Z_BUF_ERROR` is not fatal; in fact, the zlib
manual states: "If deflate returns with Z_OK or Z_BUF_ERROR, this
function must be called again with Z_FINISH and more output space
(updated avail_out) but no more input data, until it returns with
Z_STREAM_END or an error."  Hence, we do so.

Closes GH-6001.
2020-12-08 11:47:49 +01:00
Christoph M. Becker
c3734f9ae1 ldap_exop_whoami() does not return TRUE
Closes GH-6496.
2020-12-08 11:44:04 +01:00
Nikita Popov
bd72e4aa44 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #63185
2020-12-08 11:35:57 +01:00
Nikita Popov
bd093ad861 Fixed bug #63185 2020-12-08 11:30:54 +01:00
Dmitry Stogov
db34491a62 Avoid unnecessary checks 2020-12-08 13:10:35 +03:00
Nikita Popov
2d467abc46 Fix another typed resource issue in unserialization
We also need to discard old entries in the ref_props HT when values
are overwritten.

We should really forbid these kinds of overwrites. I believe they
can only occur in manually crafted serialization strings, and
cause so many problems...

Fixes oss-fuzz #28257.
2020-12-07 12:36:09 +01:00
Dmitry Stogov
7971602574 Fixed bug #80480 (Segmentation fault with JIT enabled) 2020-12-07 13:28:37 +03:00
Nikita Popov
9dc42b4114 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80458
2020-12-04 17:00:51 +01:00
Dharman
a83cc03c13 Fixed bug #80458
If there is no result set (e.g. for upsert queries), still allow
fetching to occur without error, i.e. treat it the same way as
an empty result set.

This normalizes behavior between native and emulated prepared
statements and addresses a regression in PHP 7.4.13.
2020-12-04 16:59:47 +01:00
Christoph M. Becker
b52db133df Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #75102: `PharData` says invalid checksum for valid tar
2020-12-04 13:04:33 +01:00
Christoph M. Becker
8588ae7215 Fix #75102: PharData says invalid checksum for valid tar
Apparently, there are broken tarballs out there which are actually in
ustar format, but did not write the `ustar` marker.  Since popular tar
tools like GNU tar and 7zip have no issues dealing with such tarballs,
Phar should also be more resilient.

Thus, when the first checksum check of a tarball in (presumed) in old-
style format fails, we check whether the checksum would be suitable for
ustar format; if so, we treat the tarball as being in ustar format.

Closes GH-6479.
2020-12-04 13:02:29 +01:00
Nikita Popov
77325c4448 Fix removal of type source during unserialization
Missed a check for info in this code. Add it, and add an assertion
in type source removal to make it easier to catch this issue.

Fixes oss-fuzz #28208 and #28257.
2020-12-04 12:56:05 +01:00
George Peter Banyard
426fe2f20c Standardize behaviour for int message number between functions 2020-12-03 17:43:08 +00:00
George Peter Banyard
e45cc31c41 Add tests for passing a UID instead of a message number 2020-12-03 16:38:22 +00:00
Nikita Popov
724ee93ce6 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Upload coverage data to codecov.io
2020-12-03 12:05:14 +01:00
Paul Crovella
8f8e6f95af Upload coverage data to codecov.io
Closes GH-6486.
2020-12-03 12:04:50 +01:00
Nikita Popov
1a1eeee716 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix mysqli_expire_password test for mariadb
2020-12-03 11:02:11 +01:00
Nikita Popov
0f6c41c6f8 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix mysqli_expire_password test for mariadb
2020-12-03 11:01:57 +01:00
Daniel Black
0697a64f7e Fix mysqli_expire_password test for mariadb
In MariaDB-10.4.3 EXPIRE passwords where supported for
MariaDB. This only behaves like MySQL when the system
variable disconnect_on_expired_passwords=1.

MariaDB if there was no password it could not be considered
expired. So the test is adjusted to use actual passwords.
(MariaDB commit a94b20a8e0d9e64eeaabdaaa7a3e03fcdb8a686e)

The error codes produced my MariaDB are different
however still conforming to the SQL specification.

Closes GH-6480.
2020-12-03 10:56:00 +01:00
Nikita Popov
98cccd304a Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  fix mysqli_stmt_get_result_metadata_fetch_field test for mariadb
2020-12-03 10:45:27 +01:00
Daniel Black
5d5c1cea5f fix mysqli_stmt_get_result_metadata_fetch_field test for mariadb
MariaDB extended the default decimal field to 39 characters
instead of MySQL's 31 characters.

This small change allows the test to pass on MySQL and MariaDB.

Closes GH-6484.
2020-12-03 10:45:11 +01:00
Dharman
261faa62da Remove PHP 5 mysqli tests
These tests all require functions that no longer exist.
2020-12-03 10:42:46 +01:00
Dharman
53f7bddbeb Fix typos in mysql tests
%d because of line endings on Windows
2020-12-03 10:42:39 +01:00
Nikita Popov
8d2a1c8966 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Backport fix for bug #78750
2020-12-03 10:22:21 +01:00
Peter Kokot
d386ed1e6b Backport fix for bug #78750
Cherry-picks
fe2afef36f
and
86e2b7bb70.
2020-12-03 10:07:09 +01:00
Christian Schneider
7bc7a80445 Make is_file() and friends return false when path contains 0-byte
These functions now return false silently:
is_writable, is_readable, is_executable, is_file, is_dir, is_link,
file_exists

These functions now throw a warning an return false (rather than
throwing a ValueError):
fileperms, fileinode, filesize, fileowner, filegroup, filetype,
fileatime, filemtime, filectime, lstat, stat

See also https://externals.io/message/112333.

Closes GH-6478.
2020-12-03 09:43:15 +01:00
Christoph M. Becker
72cd5793be Fix failing VirtualProtect() calls
Whenever JIT is disabled due to incompatibilities, we also need to set
`JIT_G(on)` to zero.

Closes GH-6470.
2020-12-02 16:51:50 +01:00
Nikita Popov
9dda22bd1e Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80457
2020-12-02 11:29:41 +01:00
Nikita Popov
f2833ca1be Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #80457
2020-12-02 11:29:06 +01:00
Nikita Popov
d6fcaf5da4 Fixed bug #80457
On x32 sizeof(size_t) != sizeof(zend_long), so we need to be
careful with sign extension here.

Patch by bruno dot premont at restena dot lu.
2020-12-02 11:26:10 +01:00
Nikita Popov
a89aaf6c38 Don't throw from imagecreatefromstring() with too short string
If the string is too short, we should treat this the same way as
an unrecognized image type. This function should be usable to
determine whether something is a valid image without doing any
checks beforehand.
2020-12-02 10:51:55 +01:00
Nikita Popov
7a61984a2b Fixed bug #80462 2020-12-02 10:19:32 +01:00
George Peter Banyard
5aaffc8095 Backport IMAP test modernization to PHP-8.0 branch
Closes GH-6476
2020-12-01 16:38:08 +00:00
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