Commit Graph

1488 Commits

Author SHA1 Message Date
Christoph M. Becker
8ea190ba95 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79084: mysqlnd may fetch wrong column indexes with MYSQLI_BOTH
2020-01-13 13:24:12 +01:00
Christoph M. Becker
b0cdd8cc53 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79084: mysqlnd may fetch wrong column indexes with MYSQLI_BOTH
2020-01-13 13:23:12 +01:00
Christoph M. Becker
1752393bb4 Fix #79084: mysqlnd may fetch wrong column indexes with MYSQLI_BOTH
Column names can be numeric strings, so we have to make sure to insert
the column values with the appropriate numeric keys, instead of adding
them.
2020-01-13 13:21:45 +01:00
Nikita Popov
184f118d3f Merge branch 'PHP-7.4'
* PHP-7.4:
  Handle empty password fast path in caching_sha2_password
  Handle error response during caching_sha2_password auth
  Add support for caching_sha2_password in change user authentication
  Fix unix socket check during caching_sha2_password
  Support auth switch request during caching sha2 auth
2019-12-27 17:31:27 +01:00
Nikita Popov
32cd373dfd Handle empty password fast path in caching_sha2_password
If an empty password is used, no additional packets are exchanged
during caching_sha2_password auth. We're only looking for an
OK/ERR response.
2019-12-27 17:27:45 +01:00
Nikita Popov
813d4a00b4 Handle error response during caching_sha2_password auth
In particular, this fixes handling of expired passwords.
2019-12-27 17:27:45 +01:00
Nikita Popov
e7e1254f3e Add support for caching_sha2_password in change user authentication
Same as for connection handshakes.
2019-12-27 17:27:45 +01:00
Nikita Popov
03ee36d1c5 Fix unix socket check during caching_sha2_password
The fact that conn->unix_socket is set does not mean that a Unix
socket is actually in use -- this member is set in a default
configuration.

Instead check whether a unix_socket stream ops is used.
2019-12-27 17:27:41 +01:00
Nikita Popov
6225137b4a Support auth switch request during caching sha2 auth 2019-12-27 17:27:04 +01:00
Nikita Popov
e2a1dbd502 Merge branch 'PHP-7.4'
* PHP-7.4:
  Free RSA public key in mysqlnd sha256 auth
2019-12-11 10:32:06 +01:00
Nikita Popov
b6a59cee47 Free RSA public key in mysqlnd sha256 auth
Not sure why this only started showing up as a leak now.
2019-12-11 10:31:56 +01:00
Nikita Popov
af301be4ef Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #78823: add zlib library to mysqlnd
2019-12-05 07:25:26 +01:00
Arjen de Korte
ee4295b4ce Fix bug #78823: add zlib library to mysqlnd
The problem is newer binutils will no longer default to --copy-dt-needed-entries but use --no-copy-dt-needed-entries instead. So all libraries needed *must* be provided.

Workarounds (either one works)
1) Add "-Wl,--copy-dt-needed-entries" to LDFLAGS to bring back the old behavior of the linker
2) Add "-lz" to list of libraries to be added

In "ext/mysqlnd/mysqlnd_protocol_frame_codec.c" when the "zlib.h" header is included should also trigger adding '-lz' to the list of libraries.
2019-12-05 07:24:52 +01:00
Nikita Popov
56cee36374 Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove dead code `ext/mysqlnd/mysqlnd_net.c`.
2019-11-04 21:36:36 +01:00
Adam Saponara
6c9821a531 Remove dead code ext/mysqlnd/mysqlnd_net.c.
I believe this code has been dead since 05c5e05 (2015) now replaced
by `ext/mysqlnd/mysqlnd_vio.c`.

Closes GH-4888.
2019-11-04 21:36:13 +01:00
Gabriel Caruso
5d6e923d46
Remove mention of PHP major version in Copyright headers
Closes GH-4732.
2019-09-25 14:51:43 +02:00
Nikita Popov
c25104bb5b Merge branch 'PHP-7.3' into PHP-7.4 2019-09-13 14:37:15 +02:00
Nikita Popov
df982da587 Fix bug #78525
When calling free_result_buffers(), also free field metadata and
restore the mempool state to what it was before any allocations
have been made. Remove the mempool save/restore logic for the
inner result set as this is now handled on a higher level.
2019-09-13 14:37:03 +02:00
Nikita Popov
a2c21e10b2 Remove --with-zlib-dir option from mysqlnd config
mysqlnd doesn't actually use this. PDO MySQL uses it, but also
declares it separately.
2019-09-05 10:39:04 +02:00
Christoph M. Becker
a18f53ec2c Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  fix the problem for connect_attr, set db condition, and add a new attribute _server_host
2019-08-20 13:35:17 +02:00
Christoph M. Becker
3771d66142 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  fix the problem for connect_attr, set db condition, and add a new attribute _server_host
2019-08-20 13:33:45 +02:00
Qianqian Bu
cdf16c010a fix the problem for connect_attr, set db condition, and add a new attribute _server_host 2019-08-20 13:31:58 +02:00
Christoph M. Becker
e60c507362 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #78179: MariaDB server version incorrectly detected
2019-08-02 16:45:29 +02:00
Christoph M. Becker
81efd489db Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #78179: MariaDB server version incorrectly detected
2019-08-02 16:44:15 +02:00
Christoph M. Becker
f9f4a68368 Fix #78179: MariaDB server version incorrectly detected
As of MariaDB 10.0.2, the server reports a fake version number as work-
around for replication issues[1].  We apply the same "fix" as in the
MariaDB client to cater to this.

[1] <c50ee6c23d (diff-5b45fa673c88c06a9651c7906364f592)>
2019-08-02 16:42:49 +02:00
Christoph M. Becker
1f9a77baef Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix 78213: Empty row pocket
2019-07-31 18:08:05 +02:00
Christoph M. Becker
8af14024c2 Fix 78213: Empty row pocket
We have to ensure that we don't create an arena which is smaller than
its header, regardless of the configured alignment.
2019-07-31 18:05:40 +02:00
Nikita Popov
d59aac58b3 Report errors from stream read and write operations
The php_stream_read() and php_stream_write() functions now return
an ssize_t value, with negative results indicating failure. Functions
like fread() and fwrite() will return false in that case.

As a special case, EWOULDBLOCK and EAGAIN on non-blocking streams
should not be regarded as error conditions, and be reported as
successful zero-length reads/writes instead. The handling of EINTR
remains unclear and is internally inconsistent (e.g. some code-paths
will automatically retry on EINTR, while some won't).

I'm landing this now to make sure the stream wrapper ops API changes
make it into 7.4 -- however, if the user-facing changes turn out to
be problematic we have the option of clamping negative returns to
zero in php_stream_read() and php_stream_write() to restore the
old behavior in a relatively non-intrusive manner.
2019-07-22 17:17:28 +02:00
Peter Kokot
4b03e102c5 Remove HAVE_DSA_DEFAULT_METHOD
Last usage removed via 6a81363405.

Closes GH-4455
2019-07-22 16:02:55 +02:00
Christoph M. Becker
37043e07df Sync mysqlnd version with PHP version
Since mysqlnd is solely developed in the php-src repository, it makes
not much sense to have its own version number, particularly since
nobody cares to update it.  Therefore we use PHP's version number, but
stick with the "mysqlnd" prefix which can be important to distinguish
the mysqli driver (libmysqlclient vs. mysqlnd).
2019-07-15 14:20:58 +02:00
Pieter Hordijk
6ab04a6eef
Removed mysqlnd stats from phpinfo page
All information can already be retrieved using the APIs at https://www.php.net/manual/en/mysqlnd.stats.php. Closes https://bugs.php.net/bug.php?id=60594
2019-07-03 08:20:54 +02:00
Nikita Popov
7632a411e3 Add tracked arena allocator
Available under -DZEND_TRACK_ARENA_ALLOC. This will use the system
allocator combined with arena checkpointing & release semantics
and allows analyzing arena usage under asan/valgrind.

I've sacrificed the duplicate arena implementation in mysqlnd, as
the integration with mysqlnd alloc is not worth the code duplication
to me.
2019-06-28 12:44:18 +02:00
Nikita Popov
f365d0e00e Fix mysqlnd memory leak
The actual leak is observed in ext/pdo_mysql/tests/bug_74376.phpt.
The persistent connection leaks because a refcount decrement on a
result is missed. The refcount decrement is missed because
free_result_contents is used, rather than free_result.

Looking at other uses of free_result_contents, it looks like they
could also suffer from this problem. Apart from one case,
free_result_contents is always used to release the result entirely
(I've adjusted the one differing case to only free meta), so I'm
moving most of the logic from free_result into free_result_contents.
The only difference is now that free_result will skip_result first.
2019-06-28 09:18:32 +02:00
Nikita Popov
6bebe833a2 Fix use-after-free in stream freeing during shutdown
Streams will be freed in an unpredictable order during shutdown.
Ignore explicit calls to php_stream_close() entirely to avoid
use-after-free -- instead let the stream resource destructor
deal with it. We have to account for a few special cases:

 * Enclosed streams should be freed, as the resource destructor
   will forward to the enclosing stream.
 * Stream cookies also directly free streams, because we delegate
   to the cookie destruction if one exists.
 * Mysqlnd also directly frees streams, because it explicitly
   removes stream resources (because mysqlnd!)
2019-06-27 09:45:23 +02:00
Andrey Hristov
1da15600ae Merge branch 'PHP-7.3' into PHP-7.4 2019-06-21 16:33:01 +03:00
Andrey Hristov
8326f95fe3 Merge branch 'PHP-7.2' into PHP-7.3 2019-06-21 16:32:13 +03:00
Andrey Hristov
102c64e827 Add explicit cast to uint32_t.
It works even without it but explicit stuff is better. The compiler probably converts the 16-bit
uint16_t to uint32_t before doing the shift.
2019-06-21 16:31:56 +03:00
Nikita Popov
f65046b951 Fix shift UB in sint4korr() 2019-06-19 15:09:00 +02:00
Nikita Popov
22765160da Fix incorrect shift in mysqlnd_wireprotocol
This one looks like a genuine bug: We're shifting a uint16_t by
16 bits. On x86 that likely results in no shift happening.
2019-06-19 15:09:00 +02:00
Nikita Popov
cc89d26096 Fix ifdef position
Hopefully fixes the release build...
2019-06-12 13:50:30 +02:00
Nikita Popov
65ff4dddba Remove always true condition 2019-06-12 13:17:25 +02:00
Nikita Popov
52d80ccd24 Remove MYSQLND_LLU_SPEC/MYSQLND_LL_SPEC
No longer used, replaced by PRIu64/PRIi64.
2019-06-12 13:17:25 +02:00
Nikita Popov
e1e275eefd Fix mysqlnd printf modifiers
By moving the the standard macros...
2019-06-12 13:17:25 +02:00
Nikita Popov
3e4b9659d3 Fix warnings in mysqlnd_alloc.c
And also separate the PHP_DEBUG codepaths more, to avoids having an
ifdef every other line...
2019-06-12 13:17:25 +02:00
Nikita Popov
1c4e93e8bd Merge branch 'PHP-7.3' into PHP-7.4 2019-06-07 09:49:09 +02:00
Nikita Popov
a5f98139c9 Merge branch 'PHP-7.2' into PHP-7.3 2019-06-07 09:49:01 +02:00
Cameron Porter
7d1aa7534d Fixed bug #38546
Properly support binding boolean parameters with emulated prepared
statements disabled. Also add the necessary mysqlnd support for
MYSQL_TYPE_TINY.
2019-06-07 09:48:43 +02:00
Nikita Popov
a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Nikita Popov
2856afc70e Make "MySQL server has gone away" errors more consistent
Don't generate explicit warnings for these in two places, use usual
error handling mechanism. Additionally suppress a number of warnings
if the server has gone away.
2019-06-03 14:27:47 +02:00
Nikita Popov
71ce7d32ea Merge branch 'PHP-7.3' into PHP-7.4 2019-05-23 13:41:17 +02:00