Bug #71720 [NEW]: Segfault in preg_match()
From: hanno at hboeck dot de
Operating system: Linux
PHP version: 5.6.19
Package: PCRE related
Bug Type: Bug
Bug description:Segfault in preg_match()
Description:
------------
Trying to match a certain regular expressions with large enough inputs
can crash php. The example below is a simplified testcase, but this
happened on a real production system with real code (feedwordpress).
(On different systems the size I had to use to crash was different, but
15000 was large enough to crash on all systems I tested)
This happens with 5.6.18 and 5.5.32. Interesting: With php 7 I can only
reproduce it on some systems, on others it never crashes, even with
insanely large inputs.
There are existing bug reports that indicate they relate to a similar
problem, but they all refer to windows. It's a stack exhaustion,
probably related to pcre's limits. I think the limits should be set in a
way that they don't crash in default situations.
Test script:
---------------
<?php preg_match("/(0)*/",str_repeat("0",15000));
Expected result:
----------------
Don't segfault.
Actual result:
--------------
Segfault.
--
Edit bug report at https://bugs.php.net/bug.php?id=71720&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71720&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71720&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71720&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71720&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71720&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71720&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71720&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71720&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71720&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71720&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71720&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71720&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71720&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71720&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71720&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71720&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71720&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71720&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71720&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71720&r=mysqlcfg
Thread (4 messages)
- hanno at hboeck dot de