Bug #70766 [Opn->Nab]: A simple code that file happen to changed into a buffer loop!
| From: | ab@php.net | Date: | Sun, 25 Oct 2015 09:52:39 +0000 |
| Subject: | Bug #70766 [Opn->Nab]: A simple code that file happen to changed into a buffer loop! | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-196793@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70766&edit=1
ID: 70766
Updated by: ab@php.net
Reported by: a dot x dot l at live dot com
Summary: A simple code that file happen to changed into a
buffer loop!
-Status: Open
+Status: Not a bug
Type: Bug
Package: Session related
Operating System: win,*nix
PHP Version: 5.4.45
Block user comment: N
Private report: N
New Comment:
Looks like your script creates a request loop to the script self. You also omit several error checks
that are essential for the script to terminate in order to correspond to your intended behavior. If
you still think it's a bug in PHP, please create a simpler script reproducing the issue.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-10-22 06:11:30] a dot x dot l at live dot com
Description:
------------
Will, while i was coding a simple PHP code for practice I run into this bug witch i found out that
it start making many sessions by it self and start looping until the Apache process is full(The code
have no loops).
I tested it on windows, *nix in v 5.4.* I believe its the same on other versions.
Test script:
---------------
<?php
function p404curl($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, "Chrome/36.0.1985.125");
return curl_exec($ch);
}
if (strtolower(substr(PHP_OS,0,3))=="win")
$sys='win';
else
$sys='unix';
$me = basename(__FILE__ );
$uul = $_SERVER['PHP_SELF'];
$rew = md5(time());
$uul = str_replace($_SERVER['REQUEST_URI'],$rew,$uul);
$uul= 'http://'.$_SERVER['HTTP_HOST'].$uul;
$uul1 = $_SERVER['REQUEST_URI'];
$uul = str_replace($rew,$_SERVER['REQUEST_URI'],$uul);
$d404 = 'e';
if ($sys == 'win'){
if (!isset($_SESSION['hidden']) ||
!file_exists('C:\\Users\\Default\\AppData\\Local\\Temp\\'.md5($uul1))){
$p404 = p404curl($uul) or $d404;
file_put_contents("C:\\Users\\Default\\AppData\\Local\\Temp\\".md5($uul1),$p404);
$_SESSION['hidden'] = md5($uul1);
}else{
$p404 = file_get_contents('C:\\Users\\Default\\AppData\\Local\\Temp\\'.md5($uul1));
}
}else{
if (!isset($_SESSION['hidden']) || !file_exists('/tmp/'.md5($uul1))){
$p404 = p404curl($uul) or $d404;
file_put_contents('/tmp/'.md5($uul1),$p404);
$_SESSION['hidden'] = md5($uul1);
}else{
$p404 = file_get_contents('/tmp/'.md5($uul1));
}
}
echo $p404;
die();
Expected result:
----------------
nothing the web page will keep on loading and the server will be down, because apache will be full.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70766&edit=1