#39387 [Opn->Asn]: preg_match/replace segfaults on certain user data.

From: Date: Tue, 07 Nov 2006 14:37:34 +0000
Subject: #39387 [Opn->Asn]: preg_match/replace segfaults on certain user data.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104516@lists.php.net to get a copy of this message
ID: 39387 Updated by: bjori@php.net Reported By: php at vicaya dot com -Status: Open +Status: Assigned Bug Type: PCRE related Operating System: Linux/amd64 PHP Version: 5.2.0 -Assigned To: +Assigned To: andrei 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

« previous php.bugs (#104516) next »