php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80070 mb_http_input("UTF-8"); does crash php8.0.0beta3
Submitted: 2020-09-07 05:27 UTC Modified: 2020-09-07 08:05 UTC
From: call dot user dot func at gmail dot com Assigned: nikic (profile)
Status: Closed Package: mbstring related
PHP Version: 8.0.0beta3 OS: Windows 10
Private report: No CVE-ID: None
 [2020-09-07 05:27 UTC] call dot user dot func at gmail dot com
Description:
------------
Starting with php8.0.0beta3 on windows (all prev. versions work as expected), php does crash on line mb_http_input() with enabled mbstring extension:

error_reporting(E_ALL);
mb_http_input("UTF-8");
echo mb_substr("foo", 0, 1);

This is in command line and apache module. Apache does crash the thread with no clear error log. PHP CLI just crash without error, at least i can't find any.

Are there any dependency that we must update with beta3? As i can read here: https://github.com/php/php-src/blob/php-8.0.0beta3/NEWS - I see there is a Fixed bug #55847 (DOTNET .NET 4.0 GAC new location). (cmb)

Maybe something happened here?

Test script:
---------------
<?php
error_reporting(E_ALL);
mb_http_input("UTF-8");
echo mb_substr("foo", 0, 1);


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-07 06:00 UTC] requinix@php.net
-Status: Open +Status: Verified -Package: Reproducible crash +Package: mbstring related
 [2020-09-07 06:00 UTC] requinix@php.net
valgrind of php -r 'mb_http_input("UTF-8");'

==50== Process terminating with default action of signal 11 (SIGSEGV)
==50==  Access not within mapped region at address 0x8
==50==    at 0x4D0A03: zif_mb_http_input (mbstring.c:1379)
==50==    by 0x7ECC63: ZEND_DO_ICALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1234)
==50==    by 0x85D411: execute_ex (zend_vm_execute.h:55325)
==50==    by 0x861DE3: zend_execute (zend_vm_execute.h:59932)
==50==    by 0x79E3A8: zend_eval_stringl (zend_execute_API.c:1177)
==50==    by 0x79E5A2: zend_eval_stringl_ex (zend_execute_API.c:1218)
==50==    by 0x79E617: zend_eval_string_ex (zend_execute_API.c:1228)
==50==    by 0x8A1656: do_cli (php_cli.c:979)
==50==    by 0x8A25A1: main (php_cli.c:1336)
 [2020-09-07 08:02 UTC] nikic@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: nikic
 [2020-09-07 08:02 UTC] nikic@php.net
This has already been fixed in https://github.com/php/php-src/commit/d57f9e5ea41aac7e40d37b6335cd2e03bf3b73fa.

However, after seeing your code I also changed it to throw a ValueError: https://github.com/php/php-src/commit/623bf96e7e37a05622df163a228c8e1c3f7d0b02

mb_http_input() is a function to get the input encoding, not to set it. Passing an encoding to it doesn't make sense.
 [2020-09-07 08:05 UTC] call dot user dot func at gmail dot com
Thanks for fast reply. Also i'm surprised why we had that wrong parameter. Never thought about it until today. I guess we had it because in next line we do mb_http_output() which accepts an encoding parameter.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 05:01:30 2024 UTC