Bug #60423 [NEW]: Segmentation fault with the UTF-8 check regexp in some cases
| From: | amal dot samally at gmail dot com | Date: | Thu, 01 Dec 2011 09:04:37 +0000 |
| Subject: | Bug #60423 [NEW]: Segmentation fault with the UTF-8 check regexp in some cases | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-165610@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.3.8
Package: PCRE related
Bug Type: Bug
Bug description:Segmentation fault with the UTF-8 check regexp in some cases
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 bug report at https://bugs.php.net/bug.php?id=60423&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60423&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60423&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60423&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=60423&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60423&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=60423&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=60423&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=60423&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=60423&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=60423&r=support
Expected behavior: https://bugs.php.net/fix.php?id=60423&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=60423&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=60423&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=60423&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60423&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60423&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=60423&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=60423&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=60423&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=60423&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=60423&r=mysqlcfg