#37125 [Opn->Fbk]: "str_replace" causes system overflow when using regexp's as replace

From: Date: Tue, 18 Apr 2006 18:09:47 +0000
Subject: #37125 [Opn->Fbk]: "str_replace" causes system overflow when using regexp's as replace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-95947@lists.php.net to get a copy of this message
ID: 37125 Updated by: tony2001@php.net Reported By: realbora at gmx dot de -Status: Open +Status: Feedback -Bug Type: *General Issues +Bug Type: Strings related Operating System: windows 2000 PHP Version: 5.1.2 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2006-04-18 18:04:41] realbora at gmx dot de Description: ------------ "str_replace" causes buffer overflow when using regexp's as replace! When using regexp`s as the replacement in "str_replace" a system hangup can cause. Not ever, but in general is this the failure. Reproduce code: --------------- $regExp=array(":","-","{","}","(",")","~","[","]","#","|"); $sql2=mysql_query('select * from smilies;'); for($i=0;$temp2=mysql_fetch_array($sql2);$i++){ $smilie[$i]=$temp2['smilie']; for($j=0;$j<=count($regExp);$j++){ $smilie[$i]=str_replace($regExp[$j],"\\"."\\".$regExp[$j],$smilie[$i]); } $file[$i]='<img border="0" src="./bilder/smilies/'.$temp2['file'].'">'; $neu_post=preg_replace("/$smilie[$i]/",$file[$i],$neu_post); echo $smilie[$i].'<br>'; $neu_post1=substr($neu_post, 0, 60+$x); } Expected result: ---------------- Memoryuse grows very fast until system hangup. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37125&edit=1

« previous php.bugs (#95947) next »