php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15247 preg_match('/(.|\n)*/',$a,$b) crashes
Submitted: 2002-01-27 14:59 UTC Modified: 2002-02-04 02:00 UTC
From: beavergr at pilot dot msu dot edu Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.0.6 OS: Win98
Private report: No CVE-ID: None
 [2002-01-27 14:59 UTC] beavergr at pilot dot msu dot edu
if the size of $a is very large, php crashes.  I replaced (.|\n)* with the better [\w\W]* and it stopped crashing.  I'm not positive what the size limit is, the script that produced the crash is quite large and complex.

print_r(get_loaded_extensions()) produces
Array ( [0] => standard [1] => bcmath [2] => Calendar [3] => com [4] => variant [5] => ftp [6] => mysql [7] => odbc [8] => pcre [9] => session [10] => xml [11] => wddx [12] => gd [13] => pdf [14] => pgsql [15] => zlib [16] => Zend Optimizer [17] => apache )

I'm using Apache 1.3.20

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-27 15:08 UTC] sander@php.net
Do you have any idea of the size of $a?  1MB? 10MB? 100MB? 1GB? 1TB??? :)
Does it help if you leave out the third argument (currently $b)?
Also, can you try 4.1.1?
 [2002-01-27 15:10 UTC] derick@php.net
I think this is a limit of the preg functions, it would really help if you could supply a script that reproduces it, and stands on it's own.

Derick
 [2002-01-27 19:02 UTC] beavergr at pilot dot msu dot edu
Sorry, here's a script that crashes.  If you change "$i<127" to "$i<126" it no longer crashes.  I hope this is useful!

As a postscript, I tried upgrading to 4.1.1, and couldn't find any configuration that worked with Apache 1.3.20 or 1.3.22.  Also, the web server that hosts us still uses 4.0.6

<?php
$read = '&test(blah){';
for($i=0;$i<127;$i++)
{
	$read .= md5('hoogie');
}

preg_match("/(&test\([^\)]+\)[\n\r\t]*\{)((?:.|\n|\r|\t)*)/",$read,$test);
var_dump($test);
?>
 [2002-02-04 02:00 UTC] yohgaki@php.net
The version of PHP that this bug was reported in is too old. Please
try to reproduce this bug in the latest version of PHP (available
from http://www.php.net/downloads.php

If you are still able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 07:01:32 2024 UTC