Bug #75236 [NEW]: infinite loop when printing an error-message
| From: | lzsiga at freemail dot c3 dot hu | Date: | Wed, 20 Sep 2017 16:27:41 +0000 |
| Subject: | Bug #75236 [NEW]: infinite loop when printing an error-message | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-211274@lists.php.net to get a copy of this message | ||
From: lzsiga at freemail dot c3 dot hu
Operating system: AIX, Linux
PHP version: 7.1.9
Package: Reproducible crash
Bug Type: Bug
Bug description:infinite loop when printing an error-message
Description:
------------
Printing an error message with settings 'html_errors=true' and
'default_charset=ISO-8859-2' leads to infinite loop.
Components of the loop:
determine_charset -> php_error_docref0 -> php_verror ->
php_escape_html_entities -> php_escape_html_entities_ex ->
determine_charset
This bug was introduced in version 7.1.9, main/main.c line 765
before: replace_buffer = php_escape_html_entities((unsigned
char*)buffer, buffer_len, 0, ENT_COMPAT, NULL);
after: php_escape_html_entities((unsigned char*)buffer, buffer_len, 0,
ENT_COMPAT, SG(default_charset));
(A note: The problem could be solved if htmlentities didn't verify
UTF8-validity and silently ignored 'charset' parameter. See also:
https://bugs.php.net/bug.php?id=47494 )
Test script:
---------------
#!/usr/local/bin/php
<?php
ini_set('html_errors', true);
ini_set('default_charset', 'ISO-8859-2');
printf ("before getfilecontent\n");
file_get_contents ('no/suchfile');
printf ("after getfilecontent\n");
?>
Expected result:
----------------
before getfilecontent
PHP Warning: file_get_contents(no/suchfile): failed to open stream: No
such file or directory in /local/home/projects/devel/phptest/loopy.php
on line 8
<br />
<b>Warning</b>: file_get_contents(no/suchfile): failed to open stream:
No such file or directory in
<b>/local/home/projects/devel/phptest/loopy.php</b> on line <b>8</b><br
/>
after getfilecontent
Actual result:
--------------
before getfilecontent
Segmentation fault
--
Edit bug report at https://bugs.php.net/bug.php?id=75236&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75236&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75236&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75236&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75236&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75236&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75236&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75236&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75236&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75236&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75236&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75236&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75236&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75236&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75236&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75236&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75236&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75236&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75236&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75236&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75236&r=mysqlcfg