Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleXMLElement with stream_wrapper_register can segfault #12929

Closed
mvorisek opened this issue Dec 11, 2023 · 5 comments
Closed

SimpleXMLElement with stream_wrapper_register can segfault #12929

mvorisek opened this issue Dec 11, 2023 · 5 comments

Comments

@mvorisek
Copy link
Contributor

mvorisek commented Dec 11, 2023

Description

repro: https://3v4l.org/sR5ZB

inspired by #12926 and https://github.com/php/php-src/pull/12546/files

SimpleXMLIterator , SodiumException, IntlChar have the same issue

because of https://github.com/php/php-src/blob/php-8.3.0/run-tests.php#L2077 the run-tests.php test should be improved to allow to specify something like * in EXTENSIONS section, as currently the https://github.com/php/php-src/pull/12546/files is not really tested with all ext

PHP Version

8.1.0 - 8.1.7, 8.3.0

Operating System

any

@nielsdos
Copy link
Member

Can confirm, at least for SimpleXML it's because in 8.3 I added the invalidation code which accesses node->doc but apparently node can be NULL after GET_NODE because that macro doesn't perform the return...
The locations of GET_NODE have to be checked on 8.2+.

@nielsdos
Copy link
Member

SodiumException, IntlChar have the same issue

I can't reproduce it for these two classes though, not on my local machine and not in 3v4l...

Anyway PR is up to fix SimpleXML.

@mvorisek
Copy link
Contributor Author

SodiumException, IntlChar have the same issue

I can't reproduce it for these two classes though, not on my local machine and not in 3v4l...

3v4l repro: https://3v4l.org/pDpKO

@nielsdos
Copy link
Member

3v4l repro: https://3v4l.org/pDpKO

But that doesn't segfault/crash right? https://3v4l.org/shafO I added a var_dump at the end and it prints, I don't see a code 139.

@mvorisek
Copy link
Contributor Author

I can confirm this is present for the XML classes only, at least today :)

nielsdos added a commit that referenced this issue Dec 17, 2023
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants