Commit Graph

1695 Commits

Author SHA1 Message Date
Niels Dossche
337973fccc Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-8979: Possible Memory Leak with SSL-enabled MySQL connections
2023-03-24 18:06:53 +01:00
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
646b8f6b5c
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  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:34:14 +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
3193c037d2
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix potential heap corruption due to alignment mismatch
2022-10-13 11:48:07 +02: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
246d13cd99 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  [ci skip] NEWS
  Return immediately when FD_SETSIZE is exceeded (#9602)
2022-10-01 11:24:23 +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
bad26b7560
Merge branch 'PHP-8.1' 2022-06-10 12:45:30 -04: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
70d03423c7 Merge branch 'PHP-8.1' 2022-06-06 01:11:49 -06: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
George Peter Banyard
d08451b2ca
Replace php_stdint.h header with standard headers (#8613) 2022-05-29 11:20:56 +01:00
Kamil Tekiela
15129ab688
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix mnd_malloc -> mnd_emalloc from previous merge
2022-03-31 10:54:38 +01:00
Kamil Tekiela
ced5581eca
Fix mnd_malloc -> mnd_emalloc from previous merge 2022-03-31 10:53:58 +01:00
Kamil Tekiela
6a4618f7c2
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix regression from #8058
2022-03-31 10:33:56 +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
b582427ff5
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug GH-8058 - mysqlnd segfault when prepare fails
2022-02-14 12:04:11 +00: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
2a0bc0bbfc
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix coding style from previous commit
2022-01-20 11:18:41 +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
262d4c220b
Merge branch 'PHP-8.1'
* PHP-8.1:
  Strip MariaDB 10 prefix
  Fix news entry for 8.1.2
2022-01-19 21:45:36 +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
15233a47b2
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug where large bigints may be truncated
2021-12-30 19:11:22 +01: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
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Kamil Tekiela
885dca3762 Remove mysqlnd_unbuffered_skip_result and voidify skip_result 2021-10-22 11:10:53 +01:00
Kamil Tekiela
ad5f4715a6 (mysqlnd_conn_data, restart_psession) never fails 2021-10-22 11:10:53 +01:00
Kamil Tekiela
6be1790651 Reset cannot fail. It was used in a condition, but it doesn't have to be. 2021-10-22 11:10:53 +01:00
Kamil Tekiela
e7a815d19b (mysqlnd_conn_data, end_psession) never fails 2021-10-22 11:10:53 +01:00
Kamil Tekiela
45607225ea pfc & vio init methods cannot fail
These methods cannot fail the way they are currently designed. They only
call set_client_option which could fail only with wrong arguments. Since
this is an internal call, the arguments should never change. Either way
set_client_option should not cause init to fail.
2021-10-22 11:10:53 +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