Commit graph

1676 commits

Author SHA1 Message Date
Niels Dossche
8930bf8c33 Fix GH-8979: Possible Memory Leak with SSL-enabled MySQL connections
The stream context inside `mysqlnd_vio::enable_ssl()` is leaking.
In particular: when `php_stream_context_set()` get called the refcount
of `context` is increased by 1, which means that `context` will now
have a refcount of 2. Later on we remove the context from the stream
by calling `php_stream_context_set(stream, NULL)` but that leaves our
`context` with a refcount of 1, and therefore it's never destroyed.
In my test case this yielded a leak of 1456 bytes per connection
(but could be more depending on your settings ofc).

Annoyingly, Valgrind doesn't find it because the context is still
in the `EG(regular_list)` and will thus be destroyed at the end of
the request. However, I still think this bug needs to be fixed because
as the users in the issue report already mentioned:
there can be long-running PHP scripts.

Fix it by decreasing the refcount to transfer the ownership.

Closes GH-10909.
2023-03-24 18:03:29 +01:00
Kamil Tekiela
ec1f58c871
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Add NEWS entry for #9841
  Add a temporary fix for insufficient buffer size in mysqlnd (#9835)
  mysqli_query throws warning despite using silenced error mode (#9842)
2022-10-27 18:31:38 +01:00
Kamil Tekiela
e713a8e8e5
Add a temporary fix for insufficient buffer size in mysqlnd (#9835) 2022-10-27 18:25:17 +01:00
Christoph M. Becker
7e14d2466a
Fix potential heap corruption due to alignment mismatch
The fix for bug 63327[1] changed the extra size of mysqlnd allocations
from `sizeof(size_t)` to the properly aligned values; however, the
allocation in `_mysqlnd_pestrdup()` has apparently been overlooked,
which (currently) causes detectable heap corruption when running
mysqli_get_client_stats.phpt on 32bit Windows versions.

[1] <338a47bb85>

Closes GH-9724.
2022-10-13 11:47:24 +02:00
Arnaud Le Blanc
d4b99542d5 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:23:34 +02:00
Arnaud Le Blanc
80232de0e4
Return immediately when FD_SETSIZE is exceeded (#9602) 2022-10-01 11:20:43 +02:00
Pierrick Charron
77ba689fd6
Merge branch 'PHP-8.0' into PHP-8.1 2022-06-10 12:44:39 -04:00
Pierrick Charron
df4dd82ea0
Fix bad integer promotion in mysqlnd big5 charset detection 2022-06-10 12:41:54 -04:00
Stanislav Malyshev
98e1291b7e Merge branch 'PHP-8.0' into PHP-8.1 2022-06-06 01:11:44 -06:00
Stanislav Malyshev
e864cb61a7 Merge branch 'PHP-7.4' into PHP-8.0 2022-06-06 01:11:13 -06:00
Stanislav Malyshev
58006537fc Fix bug #81719: mysqlnd/pdo password buffer overflow 2022-06-06 00:56:51 -06:00
Kamil Tekiela
ced5581eca
Fix mnd_malloc -> mnd_emalloc from previous merge 2022-03-31 10:53:58 +01:00
Kamil Tekiela
40b20d8215
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix regression from #8058
2022-03-31 10:32:59 +01:00
Kamil Tekiela
06e383b2f4
Fix regression from #8058
Closes GH-8181
2022-03-31 10:31:52 +01:00
Kamil Tekiela
2bae4e8dbb
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix bug GH-8058 - mysqlnd segfault when prepare fails
2022-02-14 12:02:57 +00:00
Kamil Tekiela
93a8d5cd17
Fix bug GH-8058 - mysqlnd segfault when prepare fails
Closes GH-8061
2022-02-14 11:45:17 +00:00
Kamil Tekiela
1605e6fd9f
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix coding style from previous commit
2022-01-20 11:18:03 +00:00
Kamil Tekiela
82b883034c
Fix coding style from previous commit 2022-01-20 11:17:18 +00:00
Kamil Tekiela
1f0661d3e5
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Strip MariaDB 10 prefix
2022-01-19 21:45:19 +00:00
Kamil Tekiela
5fc0db989e
Strip MariaDB 10 prefix
Closes GH-7972
2022-01-19 21:39:42 +00:00
Christoph M. Becker
ae9e98640a
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix bug where large bigints may be truncated
2021-12-30 19:10:36 +01:00
NathanFreeman
b3903515bf
Fix bug where large bigints may be truncated
Unless stringified results are requested, we need to parse large
bigints as unsigned, to avoid wrap-around behavior.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-7837.
2021-12-30 19:07:36 +01:00
Nikita Popov
d001682ac4 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fixed bug #81494
2021-10-08 15:02:29 +02:00
Nikita Popov
df940a6dc3 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #81494
2021-10-08 15:00:51 +02:00
Nikita Popov
fcabe693ba Fixed bug #81494
Use the proper error reporting mechanism rather than throwing a
warning. This requires something of a hack because we don't have
direct access to the connection object at this point.
2021-10-08 15:00:10 +02:00
Kamil Tekiela
a893a4901f
Implement mysqlnd_set_persistent_string (#7371) 2021-08-20 12:03:46 +01:00
Kamil Tekiela
d902b3a844
Replace macro with inline function (#7365) 2021-08-13 20:03:26 +01:00
Nikita Popov
b80767e219 Remove MYSQLND_SZ_T_SPEC
In favor of %zu, which msvc has supported for quite a while already.
2021-08-12 15:29:06 +02:00
Nikita Popov
8f5555605a Remove unused mysqlnd portability macros 2021-08-12 15:25:03 +02:00
Nikita Popov
277e169ef3 Remove mysqlnd local_tx functionality
These are not used in-tree and cause unnecessary complexity and
untestable failure modes.
2021-08-12 15:21:21 +02:00
Nikita Popov
1c675b9d0d Switch mysqlnd auth to EVP_PKEY API 2021-08-10 12:36:44 +02:00
Nikita Popov
d28f6e694d Move php_gcvt to zend_gcvt
Also move PHP_DOUBLE_MAX_LENGTH to ZEND_DOUBLE_MAX_LENGTH.
2021-08-02 14:51:46 +02:00
Kamil Tekiela
132d499424 Drop mysqlnd statistics triggers
This functionality is not used productively in PHP and it's not used in
any of the extensions to my knowledge. Since it looks like this functionality
isn't required by anyone, let's clean up mysqlnd and drop it.
2021-07-29 14:21:13 +01:00
Kamil Tekiela
fb85731c67 Remove get_parameter_metadata 2021-07-29 14:21:13 +01:00
Kamil Tekiela
254d1641bb Remove mysqlnd_field_type_name 2021-07-29 14:21:13 +01:00
Kamil Tekiela
d2ccea1381
Remove wrappers for *printf functions (#7313) 2021-07-28 10:24:46 +02:00
Kamil Tekiela
abacd91cc8
Merge branch 'PHP-8.0'
* PHP-8.0:
  Prevent mysqli::next_result from reporting errors from previous calls (#7304)
2021-07-27 11:57:39 +01:00
Kamil Tekiela
65e2dbd0de
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Prevent mysqli::next_result from reporting errors from previous calls (#7304)
2021-07-27 11:56:14 +01:00
Kamil Tekiela
d26069a2f1
Prevent mysqli::next_result from reporting errors from previous calls (#7304) 2021-07-27 11:50:28 +01:00
Nikita Popov
338a47bb85 Fix bug #63327
Use ZEND_MM_ALIGNED_SIZE for the extra size information.
I don't have a relevant system to test, but this should fix the
issue as long as required alignment is detected correctly.
2021-07-23 10:29:44 +02:00
Nikita Popov
efbb2198d4 Return value from ZEND_ATOL
Instead of assigning it as part of the macro itself, which makes
usage quite awkward.
2021-07-12 16:51:24 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Nikita Popov
c492c90a6e Fix mysqlnd debug formats on 32-bit 2021-06-16 17:08:20 +02:00
Nikita Popov
57f06b6058 Fix more mysqlnd debug printf formats
These didn't show up on my system...
2021-06-16 16:23:30 +02:00
Nikita Popov
3acdab864d Fix printf formats in mysql debug logging
Enable printf format verification and fix the reported errors.
2021-06-16 16:09:06 +02:00
Nikita Popov
635303aec5 Fixed bug #80761
When row data split across multiple packets, allocate a temporary
buffer that can be reallocated, and only copy into the row buffer
pool arena once we know the final size. This avoids quadratic
memory usage for very large results.

(cherry picked from commit 1fc4c89214)
2021-05-27 16:00:03 +02:00
Nikita Popov
b0961f2d04 Remove uses of TRUE/FALSE in mysqli/pdo_mysql
Replace with standard uses of true/false.
2021-05-26 15:07:23 +02:00
George Peter Banyard
aca6aefd85
Remove 'register' type qualifier (#6980)
The compiler should be smart enough to optimize this on its own
2021-05-14 13:38:01 +01:00
George Peter Banyard
c40231afbf
Mark various functions with void arguments.
This fixes a bunch of [-Wstrict-prototypes] warning,
because in C func() and func(void) have different semantics.
2021-05-12 14:55:53 +01:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00