|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-04-11 10:51 UTC] legolas558 at users dot sourceforge dot net
Description:
------------
I have tested the below script with PHP 4.4.4.4 and there was no problem; now with PHP 4.4.6 there is a crash (probably a segmentation fault) and a server error (500) is returned. I could not provide a win32 backtrace however you can easily generate it using the testcase.
Reproduce code:
---------------
<?php
// by legolas558
$regex = '/(insert|drop|create|select|delete|update)([^;\']*('."('[^']*')+".')?)*(;|$)/i';
$sql = 'SELECT * FROM #__components';
//$sql = ''; // does not cause error
if (preg_match($regex,$sql, $m)) echo 'matched';
else echo 'not matched';
?>
Expected result:
----------------
matched
Actual result:
--------------
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 03:00:01 2025 UTC |
I found a workaround for my own problem, maybe it will help other users or help individuating the bug. <?php // by legolas558 $regex = "(?i:begin|start)\\s+([^']*('[^']*')*)*"; $old_php_regex = "/".$regex."/"; // notice the greedy/ungreedy change which actually works around the segmentation fault $bug41050_regex = "/".$regex."?/"; // test case $subject = "begin\nnon string 'string' other non string"; // will work on any PHP - also the latest versions with PCRE7 preg_match_all($bug41050_regex, $subject, $m); echo '<pre>';var_dump($m);echo '</pre>'; unset($m); // will cause a segmentation fault (and so a 500 server error) if used on PHP versions compiled with PCRE7 // preg_match_all($old_php_regex, $subject, $m); echo '<pre>';var_dump($m);echo '</pre>'; ?>