Commit graph

230 commits

Author SHA1 Message Date
Niels Dossche
eb151e39b0
Properly handle reference return value from __toString()
It's possible to return a reference from __toString(), but this is not
handled and results in a (confusing) error telling that the return value
must be a string.
Properly handle this by unwrapping the reference.

Closes GH-18810.
2025-06-10 19:15:53 +02:00
Niels Dossche
ef10339fe7
Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix memory leak in phpdbg calling registered function
  Partially fix GH-17387
2025-01-30 19:32:28 +01:00
Niels Dossche
29bafa6323
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix memory leak in phpdbg calling registered function
  Partially fix GH-17387
2025-01-30 19:31:38 +01:00
ndossche
62bbfdebaa
Fix memory leak in phpdbg calling registered function
Closes GH-17635.
2025-01-30 19:28:26 +01:00
Niels Dossche
2860c3d641
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix crashes in function registration + test
2025-01-06 21:31:03 +01:00
Niels Dossche
1235c74828
Fix crashes in function registration + test
Internal function won't need their refcount increased as they outlive
the debugger session, and userland functions won't be unloaded either.
So no refcount management is necessary for registered functions.
2025-01-06 21:30:34 +01:00
Gina Peter Banyard
e2e7b46542 sapi/phpdbg: Grab the function pointer directly
Allocating a string zval to let zend_call_function() do the same thing is slightly pointless
2025-01-06 20:17:25 +00:00
Niels Dossche
a58c6d56bb Make docs consistent with help text 2025-01-06 20:17:25 +00:00
Niels Dossche
8cb15f6203 Fix crashes in function registration + test
Internal function won't need their refcount increased as they outlive
the debugger session, and userland functions won't be unloaded either.
So no refcount management is necessary for registered functions.
2025-01-06 20:17:25 +00:00
Arnaud Le Blanc
443aa29dbe
Support stack limit in phpdbg SAPI
Fixes GH-16041
Closes GH-16055
2024-10-03 15:22:51 +02:00
Christoph M. Becker
3c1af3febb
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16181: phpdbg: exit in exception handler reports fatal error
2024-10-03 11:39:03 +02:00
Christoph M. Becker
95c97c81b7
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-16181: phpdbg: exit in exception handler reports fatal error
2024-10-03 11:37:15 +02:00
Christoph M. Becker
f14e5cfaaa
Fix GH-16181: phpdbg: exit in exception handler reports fatal error
When running PHP code, we must not handle `UnwindExit` exceptions, but
rather have to ignore them.

Closes GH-16182.
2024-10-03 11:36:13 +02:00
Gina Peter Banyard
a79c70f574
[RFC] Convert exit (and die) from language constructs to functions (#13483)
RFC: https://wiki.php.net/rfc/exit-as-function
2024-08-14 12:44:12 +01:00
David Carlier
667a5651ca
Merge branch 'PHP-8.3' 2024-08-09 21:15:07 +01:00
David Carlier
de5c760c69
Merge branch 'PHP-8.2' into PHP-8.3 2024-08-09 21:12:34 +01:00
David Carlier
9aeb6761b5
Fix GH-15210: phpdbg_print_changed_zvals working on a real copy instead.
Close GH-15229
2024-08-09 21:12:11 +01:00
Niels Dossche
dd0f2abc80 Use param->len instead of strlen 2023-12-18 13:53:57 +00:00
Niels Dossche
e6e0231a98 Use asprintf return value for the size 2023-12-18 13:53:57 +00:00
Niels Dossche
b198d0cc0c Use precomputed length for phpdbg_try_file_init() 2023-12-18 13:53:57 +00:00
Niels Dossche
61b7370b6d Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12929: SimpleXMLElement with stream_wrapper_register can segfault
  Fix getting the address of an uninitialized property of a SimpleXMLElement resulting in a crash
  Fix GH-12962: Double free of init_file in phpdbg_prompt.c
2023-12-17 11:52:48 +01:00
Niels Dossche
4fc336c784 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix getting the address of an uninitialized property of a SimpleXMLElement resulting in a crash
  Fix GH-12962: Double free of init_file in phpdbg_prompt.c
2023-12-17 11:50:42 +01:00
Niels Dossche
a6d17bffe1 Fix GH-12962: Double free of init_file in phpdbg_prompt.c
See GH-12962 for analysis.

Closes GH-12963.
2023-12-17 11:46:02 +01:00
Niels Dossche
d882c5d580 Merge branch 'PHP-8.3'
* PHP-8.3:
  Use __DIR__-relative path in tests
  Fix GH-12675: MEMORY_LEAK in phpdbg_prompt.c
2023-11-15 22:01:05 +01:00
Niels Dossche
c83632a503 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Use __DIR__-relative path in tests
  Fix GH-12675: MEMORY_LEAK in phpdbg_prompt.c
2023-11-15 22:00:44 +01:00
Niels Dossche
4f1103ef3b Fix GH-12675: MEMORY_LEAK in phpdbg_prompt.c
Have to use file_put_contents() instead of --FILE-- because we have to
actually load it using the exec command, *and* have to make multiple
files, and note that we can only load files relative from the current
directory, so we can't rely on files being in the sapi/phpdbg/tests
folder.

Closes GH-12680.
2023-11-15 21:59:55 +01:00
Niels Dossche
8a812c3fda Fix GH-12215: Module entry being overwritten causes type errors in ext/dom (PHP 8.4)
When we try to load an extension multiple times, we still overwrite the
type, module number, and handle. If the module number is used to
indicate module boundaries (e.g. in reflection and in dom, see e.g.
dom_objects_set_class_ex), then all sorts of errors can happen.

In the case of ext/dom, OP's error happens because the following
happens:
- The property handler is set up incorrectly in
  dom_objects_set_class_ex() because the wrong module number is
  specified. The class highest in the hierarchy is DOMNode, so the
  property handler is incorrectly set to that of DOMNode instead of
  DOMDocument.
- The documentElement property doesn't exist on DOMNode, it only exists
  on DOMDocument, so it tries to read using zend_std_read_property().
  As there is no user property called documentElement, that read
  operation returns an undef value.
  However, the type is still checked, resulting in the strange exception.

Solve this by changing the API such that the data is only overwritten if
it's owned data.

Closes GH-12246.
2023-09-20 21:02:51 +02:00
George Peter Banyard
d5ad75108e
More usage of known zend_str instead of C string (#11381) 2023-06-08 13:03:29 +01:00
Max Kellermann
7029fd08b1
Zend/zend_extensions: make zend_extension_version_info const (#10592)
A zend_extension_version_info is never written to.
2023-02-20 13:20:54 +00:00
George Peter Banyard
b505562a45 Merge branch 'PHP-8.2' 2022-12-23 13:59:39 +00:00
George Peter Banyard
0100dbdaf8 Merge branch 'PHP-8.1' into PHP-8.2 2022-12-23 13:57:58 +00:00
Niels Dossche
5f1311a92c Fix undefined behaviour in phpdbg_load_module_or_extension
If zend_register_module_ex were to return NULL, then module_entry will
be set to NULL, and the if's body will load module_entry->name. Since
module_entry is NULL, loading the name would cause a NULL pointer
dereference. However, since a NULL pointer dereference is undefined
behaviour, the compiler is free to remove the check.
Fix it by using *name instead of module_entry->name.

Closes GH-10157

Signed-off-by: George Peter Banyard <girgias@php.net>
2022-12-23 13:55:50 +00: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
Levi Morrison
280fd680c8
Make vm_interrupt and timed_out atomic (#8327)
This is done by adding a new zend_atomic_bool type. The type
definition is only available for compiler alignment and size info; it
should be treated as opaque and only the zend_atomic_bool_* family of
functions should be used.

Note that directly using atomic_bool is complicated. All C++ compilers
stdlibs that I checked typedef atomic_bool to std::atomic<bool>, which
can't be used in an extern "C" section, and there's at least one usage
of this in core, and probably more outside of it.

So, instead use platform specific functions, preferring compiler
intrinsics.
2022-06-01 09:43:25 -06:00
George Peter Banyard
2ecd46f48f
Initialise zend_stat_t to fix MSAN build 2022-05-22 16:06:27 +01:00
codinghuang
5bda4cd25a Support specifying start position in compile_string
Add additional zend_compile_position argument, which can be either
AT_SHEBANG, AT_OPEN_TAG or AFTER_OPEN_TAG. The previous behavior
corresponds to AFTER_OPEN_TAG.

Closes GH-7462.
2021-09-30 10:21:33 +02:00
Joe Watkins
60fbd6df95
replace phpdbg custom opcode dumper with O+ dump (#7227) 2021-07-13 15:32:14 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Joe Watkins
6318040df2
remove specialized printing from phpdbg (#7156) 2021-06-17 14:22:33 +02:00
Joe Watkins
2c33578c58
Fix #81135 unknown help topic in phpdbg fails assertion 2021-06-13 22:19:14 +02:00
Joe Watkins
766e6b0856
ditch remote 2021-06-13 21:08:35 +02:00
Joe Watkins
cded43fd8d
drop phpdbg web helper extension and wait command (#7144) 2021-06-13 14:02:11 +02: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
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
Nikita Popov
4a8b93425d Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix potential file collision in dom tests
  Fix bug #80757 (Exit code is 0 when could not open file)
  Update NEWS
2021-02-24 21:31:03 +01:00
Felipe Pena
aaea81de7c Merge branch 'PHP-7.4' into PHP-8.0 2021-02-24 19:07:22 +00:00
Felipe Pena
3ec37a74a2 Fix bug #80757 (Exit code is 0 when could not open file) 2021-02-24 18:50:27 +00: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
codinghuang
3c6ab4b3ea Add const modifier for zend_extension members
Closes GH-6462.
2020-12-01 10:40:26 +01:00