Commit Graph

163 Commits

Author SHA1 Message Date
Niels Dossche
8c19efdc97
Fix GH-15023: Memory leak in Zend/zend_ini.c
Closes GH-15024.
2024-07-19 14:57:19 +02:00
Jakub Zelenka
c776f79578
Merge branch 'PHP-8.1' into PHP-8.2 2023-10-14 18:41:48 +01:00
Jakub Zelenka
0217be4d5b
Fix GH-12232: FPM: segfault dynamically loading extension without opcache
Also fixes incorrect assertion in ini init that php_dl is always
temporary.

Closes GH-12277
2023-10-14 18:38:21 +01:00
George Peter Banyard
d229a480ad Fix GH-11876: ini_parse_quantity() accepts invalid quantities
Closes GH-11910
2023-08-30 21:22:13 +01:00
George Peter Banyard
f6ec807871
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  ext/curl/interface: fix zend_result return value
  Zend/zend_ini: fix zend_result return values
2023-02-21 13:53:48 +00:00
Max Kellermann
d51eb1d74c
Zend/zend_ini: fix zend_result return values
The value "1" was illegal.

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-02-21 13:40:54 +00:00
George Peter Banyard
0d19ae4068
Add support for binary and octal number prefixes for INI settings
Closes GH-9560
2022-09-30 11:56:39 +01:00
George Peter Banyard
3e362f51ac Add zend_string INI validators
Currently we only have validators for char* which is rather annoying as INI settings are saved as zend_string* in the first place

Closes GH-9328
2022-09-06 10:41:47 +01:00
Ayesh Karunaratne
9f8e5182a1
INI parser: Fix typo /multipler/multiplier
Closes GH-8987.
2022-07-13 12:16:26 +02:00
Arnaud Le Blanc
827754ac22
Fix type (#8814) 2022-06-17 15:23:21 +02: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
Arnaud Le Blanc
0a5a761104 Merge branch 'PHP-8.1' 2022-05-06 15:29:21 +02:00
Arnaud Le Blanc
f07a08df5c
Fix unregistering ini entries of dynamically loaded extension (#8435)
Fixes GH-8185
2022-05-06 15:25:44 +02: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
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
George Peter Banyard
09efad615b
Use zend_string_equals_(literal_)ci() API more often
Also drive-by usage of zend_ini_parse_bool()

Closes GH-6844
2021-04-09 02:34:50 +01:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
George Peter Banyard
fa8d9b1183 Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded
Use bool argument types instead of int for boolean arguments
Use bool return type for functions which return true/false (1/0)
Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics

Closes GH-6002
2020-08-28 15:41:27 +02:00
George Peter Banyard
1b2ec73c1d Drop various unused macros/APIs
Also convert_libmagic_pattern() to return a zend_string*

Closes GH-6029
2020-08-26 12:59:43 +02:00
Christoph M. Becker
13419befff Merge branch 'PHP-7.4' into master
* PHP-7.4:
  Fix wrong datatype
2020-08-21 15:30:07 +02:00
Christoph M. Becker
8f9f308bb9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix wrong datatype
2020-08-21 15:28:37 +02:00
Manuel Mausz
46d62e5464 Fix wrong datatype
ini_entry->modifiable is of type uint8_t and so should be the temp. variable. Especially important after 4b77a158.

Closes GH-6028
2020-08-21 15:28:12 +02:00
Derick Rethans
fc7650944a Merge branch 'PHP-7.4' 2020-07-09 09:51:15 +01:00
Derick Rethans
972383fda4 Revert "Partial fixed bug #79649 (Altering disable_functions from module init corrupts memory)"
This reverts commit a297c09da5.
2020-07-09 09:50:25 +01:00
Xinchen Hui
28b4761ecb Merge branch 'PHP-7.4'
* PHP-7.4:
  Partial fixed bug #79649 (Altering disable_functions from module init corrupts memory)
2020-06-10 11:21:13 +08:00
Xinchen Hui
a297c09da5 Partial fixed bug #79649 (Altering disable_functions from module init corrupts memory)
In module startup stage, we should not initiliaze
EG(modified_ini_directives) as it use zend MM, the zend MM will be
restart at the end of modules startup stage,

by say "partial", because this issue still exists if altering ZEND_USER
inis, we should add a zend_ini_deactive at the end of modules startup
stage, but it brings some new cost, and I think no one would do things
like that
2020-06-10 11:16:42 +08:00
Nikita Popov
41c7d28c11 Add macro to get ini target address 2020-04-27 10:30:00 +02:00
Nikita Popov
33ef3d64da Use separate typedef for bucket comparison function
Avoid performing the same casting dance inside each sort compare
function.
2020-03-04 12:46:06 +01:00
Michael Voříšek
f15b5ff353 Add const modifier for name strings
Closes GH-5173.
2020-02-13 14:44:06 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
a81202ac49 Adios, yearly copyright ranges 2019-01-30 11:48:28 +01:00
Dmitry Stogov
cec091176c Replace zend_hash_apply... with ZEND_HASH_FOREACH... 2018-12-19 02:49:56 +03:00
Nikita Popov
7674a542aa Remove commented zend_ini_displayer_cb 2018-12-04 19:02:13 +01:00
Gabriel Caruso
cdd8368d6f Clean up unnecessary ternary expressions and simplify some returns
- Simplify conditions
- Use ZEND_HASH_APPLY_* instead of hard-coded booleans
- Use ZEND_NORMALIZE_BOOL
- Drop sign in favor of ZEND_NORMALIZE_BOOL
2018-12-03 01:22:14 +01:00
Zeev Suraski
9afce019e0 Future-proof email addresses 2018-11-01 18:35:32 +02:00
Zeev Suraski
54dc07f3dc Update email addresses. We're still @Zend, but future proofing it... 2018-11-01 17:20:07 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Dmitry Stogov
6c035f53f1 Separate duplicated code into a zend_ini_parse_bool() function. 2018-03-05 11:51:58 +03:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Dmitry Stogov
dc47171523 Avoid temporary string creation and destruction. 2017-12-11 18:18:30 +03:00
Anatol Belski
80d6eb6806 Fix unsigned comparisons and remove dead code
Fix unsigned comparison

Cleanup never executed block

Fix unsigned comparison

Fix unsigned comparison, diff can't be < 0

Fix unsigned comparison

Fix unsigned comparison

Remove dead code
2017-11-17 22:38:44 +01:00
Dmitry Stogov
9731a22eba Use Zend MM heap for non-persistent ini entry values. 2017-11-08 12:01:59 +03:00
Dmitry Stogov
974a8f8ad2 Use internet strings for EG(ini_entries) 2017-10-31 02:16:46 +03:00
Anatol Belski
793ca716fb Fix datatypes and compiler warnings
Switch to size_t

Not critical as an unsigned is already used, but fixes a couple of
warnings in other areas.

Normalize signature

It's a function with the usual compare semantics, returning a platform
specific at least produces unnecessary warnings elsewhere and is otherwise
inappropriate.

Fix return value

Drop unused var

Fix compiler warnings

Fix compiler warning

Fix var name in arginfo

Fix cast
2017-10-23 08:56:57 +02:00
Anatol Belski
0d1eeeb68d move zend_ato*() to size_t and remove casts 2017-07-28 14:59:31 +02:00
Anatol Belski
bc5811f361 further sync for vim mode lines 2017-07-04 18:12:45 +02:00
Anatol Belski
c698299550 Interned strings unification for TS/NTS
Hereby, interned strings are supported in thread safe PHP. The patch
implements two types of interned strings

- interning per process, strings are not freed till process end
- interning per request, strings are freed at request end

There is no runtime interning.

With Opcache, all the permanent iterned strings are copied into SHM on
startup, additional copying into SHM might happen on demand.
2017-03-04 10:39:13 +01:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00
Anatol Belski
b204b3abd1 further normalizations, uint vs uint32_t
fix merge mistake

yet one more replacement run
2016-11-26 17:29:01 +01:00