php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39387 preg_match/replace segfaults on certain user data.
Submitted: 2006-11-05 00:49 UTC Modified: 2006-12-01 20:23 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: php at vicaya dot com Assigned: andrei (profile)
Status: Not a bug Package: PCRE related
PHP Version: 5.2.0 OS: Linux/amd64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at vicaya dot com
New email:
PHP Version: OS:

 

 [2006-11-05 00:49 UTC] 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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-01 20:23 UTC] nlopess@php.net
another stack overflow problem. you can use the new ini settings to prevent the segfault or increase the stack size.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 07:01:27 2024 UTC