Skip to content

Segfault in mb_strrpos / mb_strripos when using negative offset and ASCII encoding #11217

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

Closed
rgeraads opened this issue May 10, 2023 · 0 comments

Comments

@rgeraads
Copy link
Contributor

Description

The following code:

<?php
var_dump(mb_strrpos('foo', 'foo', -1, 'ASCII'));
var_dump(mb_strripos('foo', 'foo', -1, 'ASCII'));

Resulted in this output:

Segmentation fault

But I expected this output instead:

bool(false)
bool(false)

https://3v4l.org/BlLRn

PHP Version

PHP 8.2.0

Operating System

No response

@iluuu1994 iluuu1994 self-assigned this May 10, 2023
rgeraads added a commit to rgeraads/php-src that referenced this issue May 10, 2023
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue May 10, 2023
iluuu1994 pushed a commit to iluuu1994/php-src that referenced this issue May 10, 2023
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue May 10, 2023
…ve offset

We're setting the encoding from PHP_FUNCTION(mb_strpos), but mbfl_strpos would
discard it, setting it to mbfl_encoding_pass, making zend_memnrstr fail due to a
null-pointer exception.

Fixes phpGH-11217
iluuu1994 pushed a commit to iluuu1994/php-src that referenced this issue May 10, 2023
iluuu1994 added a commit to iluuu1994/php-src that referenced this issue May 10, 2023
…ve offset

We're setting the encoding from PHP_FUNCTION(mb_strpos), but mbfl_strpos would
discard it, setting it to mbfl_encoding_pass, making zend_memnrstr fail due to a
null-pointer exception.

Fixes phpGH-11217
iluuu1994 pushed a commit to iluuu1994/php-src that referenced this issue May 10, 2023
iluuu1994 pushed a commit that referenced this issue May 15, 2023
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.

3 participants