From:             
Operating system: Ubuntu
PHP version:      5.3SVN-2010-05-04 (SVN)
Package:          PCRE related
Bug Type:         Bug
Bug description:preg_match returns zero if it hits backtracking limit

Description:
------------
According to the documentation, pcre_match should return FALSE on error:



>From http://docs.php.net/manual/en/function.preg-match.php :

<<

Return Values



preg_match() returns the number of times pattern matches. That will be
either 0 times (no match) or 1 time because preg_match() will stop
searching after the first match. preg_match_all() on the contrary will
continue until it reaches the end of subject. preg_match() returns FALSE if
an error occurred.

>>



Instead, it returns 0 (integer zero) -- see Felipe's comment on
http://bugs.php.net/bug.php?id=51663&edit=2 for a check.



Note that pcretest does report an error in this same case:

$ pcretest

PCRE version 7.8 2008-09-05



  re> /(.+)+:/

data> \q10a:bbb

Error -8

data> 



Test script:
---------------
<?  

ini_set('pcre.backtrack_limit', 10);

print_r( preg_match('/(.+)+:/','a:bbb') === FALSE ? 'pass' : 'fail' );



Expected result:
----------------
pass

Actual result:
--------------
fail

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51741&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51741&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51741&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51741&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51741&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51741&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51741&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51741&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51741&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51741&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51741&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51741&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51741&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51741&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51741&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51741&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51741&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51741&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51741&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51741&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51741&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51741&r=mysqlcfg

Reply via email to