Commit graph

1678 commits

Author SHA1 Message Date
Daniil Gentili
10b2b4a52c
Fix memory leak in standard syslog device handling
The BG(syslog_device) is leaked in RINIT.

Closes GH-12501
2023-11-09 13:29:09 +00:00
David Carlier
44f9c226aa following-up on GH-12551: removing inet_ntoa usage
Close GH-12554
2023-11-06 12:05:56 +00:00
Arnaud Le Blanc
d0731934b7
Expose time spent collecting cycles in gc_status() (#11523) 2023-07-16 12:34:28 +02:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Christoph M. Becker
c8955c078a
Revert GH-10220
Cf. <https://github.com/php/php-src/pull/10220#issuecomment-1383739816>.

This reverts commit ecc880f491.
This reverts commit 588a07f737.
This reverts commit f377e15751.
This reverts commit b4ba16fe18.
This reverts commit 694ec1deea.
This reverts commit 6b34de8eba.
This reverts commit aa1cd02a43.
This reverts commit 308fd311ea.
This reverts commit 16203b53e1.
This reverts commit 738fb5ca54.
This reverts commit 9fdbefacd3.
This reverts commit cd4a7c1d90.
This reverts commit 928685eba2.
This reverts commit 01e5ffc85c.
2023-01-16 12:27:33 +01:00
Max Kellermann
308fd311ea ext/{standard,json,random,...}: add missing includes 2023-01-10 14:19:03 +00:00
David CARLIER
faef55d638
standard/basic_functions.c remove x bit on this file (#10069) 2022-12-09 08:38:52 +00:00
Christoph M. Becker
75f372295e
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-9905: constant() behaves inconsistent when class is undefined
2022-11-09 15:23:51 +01:00
Christoph M. Becker
4b1feda574
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-9905: constant() behaves inconsistent when class is undefined
2022-11-09 15:23:21 +01:00
Christoph M. Becker
b2186ca7c4
Fix GH-9905: constant() behaves inconsistent when class is undefined
Directly referring to a constant of an undefined throws an exception;
there is not much point in `constant()` raising a fatal error in this
case.

Closes GH-9907.
2022-11-09 15:21:50 +01:00
George Peter Banyard
66661ae682
Remove most usages of zend_fcall_info_args()
This reallocates the PHP array when one can just use the named_params fields to pass the positional arguments instead.

Only usage of zend_fcall_info_args(_ex) remains in PDO.
2022-10-21 18:31:40 +01:00
Máté Kocsis
a4fd2609ce
Declare ext/standard constants in stubs - part 9 (#9717) 2022-10-13 13:13:36 +02:00
Máté Kocsis
c59e94fc9d
Declare ext/stanard constants in stubs - part 11 (#9728) 2022-10-12 12:07:03 +02:00
Máté Kocsis
433ed0973a
Declare ext/standard constants in stubs - part 10 (#9719) 2022-10-12 08:16:19 +02:00
Máté Kocsis
ed0f1f04b9
Declare ext/standard constants in stubs - part 8 (#9615) 2022-09-30 13:51:18 +02:00
Nikita Popov
0b2fe40d23 Drop dead ENABLE_TEST_CLASS check 2022-09-21 21:28:21 +02:00
Máté Kocsis
3227d04fa9
Declare ext/standard constants in stubs - part 7 (#9505) 2022-09-08 13:57:07 +02:00
Máté Kocsis
cfa72ff3af
Declare ext/standard constants in stubs - part 6
Closes GH-9467
2022-09-02 16:07:25 +02:00
Máté Kocsis
6f2f228e4a
Declare ext/standard constants in stubs - part 5
Closes GH-9466
2022-09-02 15:04:49 +02:00
Máté Kocsis
64b962b241
Declare ext/standard constants in stubs - part 4
Closes GH-9465
2022-09-02 12:41:51 +02:00
Máté Kocsis
ef72d53397
Declare ext/standard constants in stubs - part 3 (#9427) 2022-08-26 14:47:34 +02:00
Go Kudo
4d8dd8d258
Implement Random Extension
https://wiki.php.net/rfc/rng_extension
https://wiki.php.net/rfc/random_extension_improvement
2022-07-19 10:27:38 +01:00
Dennis Snell
492af9f88e
Add ini_parse_quantity function to convert ini quantities shorthand notation to int (#8454) 2022-07-10 14:48:52 +02:00
David Carlier
dfbb425295 Use safe_*erealloc* flavor in few places to mitigate possible overflows. 2022-07-04 14:41:04 +01:00
Arnaud Le Blanc
efc8f0ebf8
Deprecate zend_atol() / add zend_ini_parse_quantity() (#7951)
Add zend_ini_parse_quantity() and deprecate zend_atol(), zend_atoi()

zend_atol() and zend_atoi() don't just do number parsing.
They also check for a 'K', 'M', or 'G' at the end of the string,
and multiply the parsed value out accordingly.

Unfortunately, they ignore any other non-numerics between the
numeric component and the last character in the string.
This means that numbers such as the following are both valid
and non-intuitive in their final output.

* "123KMG" is interpreted as "123G" -> 132070244352
* "123G " is interpreted as "123 " -> 123
* "123GB" is interpreted as "123B" -> 123
* "123 I like tacos." is also interpreted as "123." -> 123

Currently, in php-src these functions are used only for parsing ini values.

In this change we deprecate zend_atol(), zend_atoi(), and introduce a new
function with the same behavior, but with the ability to report invalid inputs
to the caller. The function's name also makes the behavior less unexpected:
zend_ini_parse_quantity().

Co-authored-by: Sara Golemon <pollita@php.net>
2022-06-17 14:12:53 +02:00
Máté Kocsis
debd38f851 Add support for sensitive parameters in stubs 2022-06-04 18:15:05 +02:00
Máté Kocsis
14da1cb909
Add support for class constants in stubs (#7434) 2022-05-22 22:27:23 +02:00
George Peter Banyard
5171cb435a Fix [-Wundef] warnings in standard extension 2022-04-01 15:48:41 +01:00
Nikita Popov
e32642c541 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug #81598: Use C.UTF-8 as LC_CTYPE locale by default
2021-12-05 21:04:10 +01:00
Nikita Popov
26e424465c Fix bug #81598: Use C.UTF-8 as LC_CTYPE locale by default
Unfortunately, libedit is locale based and does not accept UTF-8
input when the C locale is used. This patch switches the default
locale to C.UTF-8 instead (if it is available). This makes libedit
work and I believe it shouldn't affect behavior of single-byte
locale-dependent functions that PHP otherwise uses.

Closes GH-7635.
2021-12-05 21:03:27 +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
Nikita Popov
fabcc9a350 Fix long-term shutdown/tick fci/fcc storage
Normally incrementing the refcount on just function_name is
sufficient. However, if the callable is of the form 'X::y' inside
an instance method, this will capture $this in fcc.object, which
also needs to be retained.

The fci_addref/fci_release helpers should likely be exported as
a general API, as we may have this problem in other places as
well.

Fixes oss-fuzz #39778.
2021-10-11 12:19:29 +02:00
Nikita Popov
51a504c8be Avoid string copy in get_cfg_var()
basic_functions.c already has a macro for returning an ini
value to userland, so make use of it for get_cfg_var() as well,
after generalizing it to not write to return_value in particular.
2021-08-27 15:34:46 +02:00
Nikita Popov
ef5558a8cd
Use zend_string for putenv key (#7379)
A zend_string will be created anyway for the hash key,
so we may as well create one in the first place.
2021-08-17 12:29:04 +02:00
Nikita Popov
b56699b8f0 Use system allocator for putenv value
The putenv value is stored in environ. If for some reason we
fail to restore it on shutdown, make sure that we fail gracefully
by using a system allocated value, rather than a ZMM allocated one.

This is an additional mitigation for bug #81316 style issues if
all else fails.
2021-08-17 11:03:14 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
George Peter Banyard
e7135cb817
Use zend_string_equals_* API in a couple of more place
Closes GH-6979
2021-05-14 13:45:17 +01:00
Nikita Popov
4f46bec5d4 Initialize zpp varargs variables
These are not initialized if no args are passed.
2021-05-10 19:19:26 +02:00
Aaron Piotrowski
39fa55a4c9
Switch register_tick_function back to zend_parse_parameters
No reason to use fast ZPP in register_tick_function, so let’s keep the binary size down just a bit.
2021-05-10 10:17:29 -05:00
George Peter Banyard
a9695cc615
Refactor register shutdown function mechanism
Use FCI/FCC structure instead of custom implementation which does the same.
This also fixes the "bug" which prevented static methods from being shutdown functions.

Closes GH-5829

Co-authored-by: Aaron Piotrowski <aaron@trowski.com>
2021-05-10 15:54:59 +01:00
Aaron Piotrowski
66bfad57de
Remove unnecessay NULL
Z_PARAM_FUNC already sets params to NULL.
2021-05-09 14:55:05 -05:00
Aaron Piotrowski
0189585c9e
Fix tick function with arguments
Tick function arguments need to be copied to fci params.
2021-05-09 14:08:20 -05:00
Aaron Piotrowski
7ec048f96d
Do not free tick function entry
This memory is freed by zend_llist.
2021-05-09 11:44:32 -05:00
George Peter Banyard
05e6f3ebde
Refactor register_tick_function mechanism (#5828) 2021-05-08 10:09:09 +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
Nikita Popov
dc7030300c Use interned strings for error_get_last()
We have known strings for all the array keys, use them.
2021-04-23 11:05:14 +02:00
Nikita Popov
b66eb866c9 Convert last_error_file to zend_string 2021-04-23 11:05:14 +02:00
Nikita Popov
4ce5d2ea88 Add known strings for jit autoglobals
We always create interned strings for all autoglobals anyway, so
we might as well add known strings to make them more widely usable.
2021-04-09 15:37:59 +02:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Máté Kocsis
4c6533c257
Generate class entries from stubs for com, standard, xmlreader, xmlwriter, xsl, zip, Zend
Closes GH-6706
2021-02-22 15:24:03 +01:00