|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-05-20 22:15 UTC] xanthor at xanthor dot tk
Description:
------------
This line crash PHP with a segmentation fault.
It use a 3-chars-long back reference, on a 2236+3 chars-long string
If the back references is only 2 chars long, it's ok.
If the long string is less that 2236+3 chars, it's ok too...
Reproduce code:
---------------
preg_match("/(((?<!aaa).)*)(?<!aaa)aaa/",str_repeat(' ',2236).'aaa',$z);
Expected result:
----------------
No crash, and true return by the preg_match
Actual result:
--------------
segmentation fault
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 20:00:01 2025 UTC |
Updating version : I've found an other expression which segfaults also PHP 5 : preg_match("/^((?<!a).)*/",str_repeat('b',21236),$z);preg_match("/(((?<!aaa).)*)(?<!aaa)aaa/",str_repeat(' ',10882).'aaa',$z); crashes PHP4.3.9RC2 But not on php-4.3.2-11.1.ent (WBEL 3.0), the length to trigger segmentation fault is about 19230. The most funny thing is that the more closer to the limit, the more likely you will get a random segmentation fault. Not only the above pattern will cause the error, preg_match("/^( )*$/",str_repeat(' ',19250)); will too.> It's not really useful since it doesn't exist. Try again.. You should have been a bit faster to look at it, while it was online. I re-paste it here : #0 0x080ad99c in match (eptr=0x8358fe4 ' ' <repeats 200 times>..., ecode=0x834faf5 "I", offset_top=6, md=0xbffaa264, ims=0, eptrb=0x0, flags=2) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:357 357 { (gdb) bt #0 0x080ad99c in match (eptr=0x8358fe4 ' ' <repeats 200 times>..., ecode=0x834faf5 "I", offset_top=6, md=0xbffaa264, ims=0, eptrb=0x0, flags=2) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:357 #1 0x080adb9b in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:747 #2 0x080b1222 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:589 #3 0x080b2327 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:1123 #4 0x080b1222 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:589 #5 0x080b2327 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:1123 #6 0x080b1222 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:589 #7 0x080b2327 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:1123 #8 0x080b1222 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:589 #9 0x080b2327 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:1123 #10 0x080b1222 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:589 #11 0x080b2327 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:1123 #12 0x080b1222 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:589 #13 0x080b2327 in match (eptr=Variable "eptr" is not available. ) at /home/xanthor/temp/web/php-4.4.1/ext/pcre/pcrelib/pcre_exec.c:1123 And same thing again and again...