|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-02-20 16:26 UTC] sthapa at site5 dot com
Description:
------------
is_utf8() crashes on text
Reproduce code:
---------------
<?php
echo "Start Test, the data follows.<br><br>\n";
if ($fp = fopen("text.txt", "r")) {
$contents = fread($fp, filesize("text.txt"));
echo "$contents";
fclose($fp);
}
echo "\n<br><br>The data is about to be passed to preg_match(). If you do not see the word 'Success' after this line, the program has crashed.<br>\n";
$truefalsetest=preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $contents);
echo "Success. Return value of preg_match() = $truefalsetest.";
?>
Expected result:
----------------
Output with the success message. Error appears when using either php 5.1.1 or php 4.4.2 both using suExec. Testing this on freebsd systems don't cause the crash and do work correctly.
Actual result:
--------------
Core file and output doesn't have the success message.
root@xxx [/user/dir]# gdb php5.bin core.11662
GNU gdb Red Hat Linux (6.3.0.0-1.63rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...php5.bin: No such file or directory.
Core was generated by `php5.bin'.
Program terminated with signal 11, Segmentation fault.
#0 0x080a5c4c in ?? ()
(gdb) bt
#0 0x080a5c4c in ?? ()
Error accessing memory address 0xbf523ef0: No such file or directory.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 09:00:02 2025 UTC |
I have the same problem. Simply try the following simpler test case: $count = 500; $string = str_repeat("a", $count); echo preg_match('/\A( [\x09\x0A\x0D\x20-\x7E] | [\xC2-\xDF][\x80-\xBF] | \xE0[\xA0-\xBF][\x80-\xBF] | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} | \xED[\x80-\x9F][\x80-\xBF] | \xF0[\x90-\xBF][\x80-\xBF]{2} | [\xF1-\xF3][\x80-\xBF]{3} | \xF4[\x80-\x8F][\x80-\xBF]{2} )*\z/x', $string); If is doesn't crash, try increasing the $count variable. This bug seems to be related (if not the same) with http://bugs.php.net/bug.php?id=27070 I'm sorry but I can't believe this bug has been around for 5 years. Tested on PHP 5.3.0 and Windows 7 64bitsI reduced the test case to this: $count = 203; $string = str_repeat("a", $count); echo preg_match('/^(a)+$/', $s, $m); Crashes for count > 202 on Windows 7, apache 2.2 and php 5.3.8 (all 64 bits). But it's working with the CLI, using the same php.ini. Adding the pcre.* directives in php.ini didn't help.