-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
mb_convert_encoding crashes PHP on Windows #10627
Comments
Reproducing this depends on getting the exact google.com version as you got, which is locale dependent. I can't reproduce it with the version google.com gives me here. <?php
$f = fopen('https://www.google.com/', 'r');
$o = fopen('out.html', 'w');
while ($l = fread($f, 1024)) {
fwrite($o, $l);
}
fclose($f);
fclose($o); |
Here it is. Also, on CentOS with php-fpm this is the result:
|
Thank you! I can repro it on 8.2, not on 8.1. However, the bug really is there in 8.1. It's just that the encoding handling changed in 8.2 so that we can actually trigger it with your PoC in 8.2. I found the root cause being missing error handling and I'll work on a fix now. |
Fixes phpGH-10627 The php_mb_convert_encoding() function can return NULL on error, but this case was not handled, which led to a NULL pointer dereference and hence a crash.
* PHP-8.1: Fix GH-10627: mb_convert_encoding crashes PHP on Windows ext/mbstring: fix new_value length check
* PHP-8.2: Fix GH-10627: mb_convert_encoding crashes PHP on Windows ext/mbstring: fix new_value length check
Description
The following code:
Resulted in this output:
DebugDiag Analysis Report
php-cgi.exe_230219_162706_MultipleRules.zip
PHP Version
8.2.3
Operating System
Windows 10
The text was updated successfully, but these errors were encountered: