Bug #14356: PHP fsockopen() kills Apache.
| From: | phil_3iem at hotmail dot com | Date: | Thu, 06 Dec 2001 00:46:06 +0000 |
| Subject: | Bug #14356: PHP fsockopen() kills Apache. | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-72704@lists.php.net to get a copy of this message | ||
From: phil_3iem@hotmail.com
Operating system: Debian
PHP version: 4.0.6
PHP Bug Type: Reproducible crash
Bug description: PHP fsockopen() kills Apache.
Using fsockopen() on a page to call itself causes the apache server to stop
taking request. Wehn you look at ps there are as many httpd processes
running as the server is allowed to run. (based on http.conf)
Here is the code I created that takes down Apache.
<code>
<?php
$fp = fsockopen ($HTTP_HOST, $SERVER_PORT, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)<br>\n";
}
else
{
fputs ($fp, "GET $REQUEST_URI HTTP/1.0\r\nHost: $HTTP_HOST\r\n\r\n");
while (!feof($fp))
{
echo fgets ($fp,128);
}
fclose ($fp);
}
?>
</code>
The only way to bring Apache back is to kill the server and restart it.
This can be a major problem with service providers that offer PHP since all
of their sites will go down once this script is run. It seems like there
is a problem with PHPs connect() call. The time out NEVER works and I have
tried this on Debian and FreeBSD using the PHP module in Apache.
pHil
--
Edit bug report at: http://bugs.php.net/?id=14356&edit=1