#23616 [Opn->Ver]: preg_match() segfault

From: Date: Tue, 13 May 2003 20:42:14 +0000
Subject: #23616 [Opn->Ver]: preg_match() segfault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-39552@lists.php.net to get a copy of this message
ID: 23616 Updated by: sniper@php.net Reported By: cestmir at nustep dot net -Status: Open +Status: Verified Bug Type: PCRE related Operating System: Linux Debian, Win32 -PHP Version: 4.3.1 +PHP Version: 4.3.2-RC3-dev Previous Comments: ------------------------------------------------------------------------ [2003-05-13 15:33:33] cestmir at nustep dot net This code causes a segfault both on Linux and Win32 builds. <?php function utf8IsValidString($AStr) { $ptrASCII = '[\x00-\x7F]'; $ptr2Octet = '[\xC2-\xDF][\x80-\xBF]'; $ptr3Octet = '[\xE0-\xEF][\x80-\xBF]{2}'; $ptr4Octet = '[\xF0-\xF4][\x80-\xBF]{3}'; $ptr5Octet = '[\xF8-\xFB][\x80-\xBF]{4}'; $ptr6Octet = '[\xFC-\xFD][\x80-\xBF]{5}'; return preg_match("/^($ptrASCII|$ptr2Octet|$ptr3Octet|$ptr4Octet|$ptr5Octet|$ptr6Octet)*$/s", $AStr); } // read text $handle = fopen('utf8text.txt', 'r'); $stat = fstat($handle); $str = fread($handle, $stat['size']); fclose($handle); // execute PCRE match var_dump(utf8IsValidString("some short text \xC4\xBE\xC5\xA1")); // ok var_dump(utf8IsValidString($str)); // segfault ?> This code including data file to reproduce bug can be found here: http://www.omikron.sk/downloads/pcre_crash.tar ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=23616&edit=1

« previous php.bugs (#39552) next »