#39387 [Asn->Bgs]: preg_match/replace segfaults on certain user data.
| From: | nlopess@php.net | Date: | Fri, 01 Dec 2006 20:23:33 +0000 |
| Subject: | #39387 [Asn->Bgs]: preg_match/replace segfaults on certain user data. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105755@lists.php.net to get a copy of this message | ||
ID: 39387
Updated by: nlopess@php.net
Reported By: php at vicaya dot com
-Status: Assigned
+Status: Bogus
Bug Type: PCRE related
Operating System: Linux/amd64
PHP Version: 5.2.0
Assigned To: andrei
New Comment:
another stack overflow problem. you can use the new ini settings to
prevent the segfault or increase the stack size.
Previous Comments:
------------------------------------------------------------------------
[2006-11-05 00:49:43] php at vicaya dot com
Description:
------------
Both PHP 5.2.0 (pcre 6.7) and 5.1.6 (pcre 6.6) have this problem:
A working pattern segfaults on certain user data. Could be stack
overflow in pcre_exec/match.
This patterns is almost straight from the documentation:
/\{(?:(?>[^{}]+)|(?R))+\}/Us
Basically to match nested {} (instead of parentheses)
I found a simple workaround to the particular problem I have, but the
code should not segfault.
Note if you change the 12000 in the code to anything less than 8158, it
will produce the correct result.
Reproduce code:
---------------
<?= preg_match('/{(?:(?>[^{}]+)|(?R))+}/Us',
'{open'. str_repeat('.', 12000) .'{open}'), "\n"?>
Expected result:
----------------
1
Actual result:
--------------
Segmentation fault
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39387&edit=1