Bug #60423 [Opn->Fbk]: Segmentation fault with the UTF-8 check regexp in some cases
| From: | laruence@php.net | Date: | Thu, 01 Dec 2011 14:46:10 +0000 |
| Subject: | Bug #60423 [Opn->Fbk]: Segmentation fault with the UTF-8 check regexp in some cases | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165620@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60423&edit=1
ID: 60423
Updated by: laruence@php.net
Reported by: amal dot samally at gmail dot com
Summary: Segmentation fault with the UTF-8 check regexp in
some cases
-Status: Open
+Status: Feedback
Type: Bug
Package: PCRE related
Operating System: Linux
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php
for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php
for Win32
Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-12-01 10:57:33] amal dot samally at gmail dot com
I think not.
Also changing pcre.backtrack_limit / pcre.recursion_limit do not give anything.
------------------------------------------------------------------------
[2011-12-01 10:10:52] laruence@php.net
see #41638, may be the same.
------------------------------------------------------------------------
[2011-12-01 09:04:37] amal dot samally at gmail dot com
Description:
------------
I'm using the regexp to test whether a string is a valid UTF-8 encoded string.
But in some cases it causes a segmentation fault.
Examples of strings that cause the error:
http://samally.ru/php_pcre_segmentation_fault/test1.txt
http://samally.ru/php_pcre_segmentation_fault/test2.txt
Test script:
---------------
$string = file_get_contents('http://samally.ru/php_pcre_segmentation_fault/test1.txt');
// $string = file_get_contents('http://samally.ru/php_pcre_segmentation_fault/test2.txt');
// Tests whether a string is a valid UTF-8 encoded string.
// @link http://w3.org/International/questions/qa-forms-utf-8.html
$r = preg_match('~^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII without control characters
| [\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
)*$~DSXx', $string);
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60423&edit=1