php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14356 PHP fsockopen() kills Apache.
Submitted: 2001-12-05 19:46 UTC Modified: 2001-12-05 20:24 UTC
From: phil_3iem at hotmail dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.0.6 OS: Debian
Private report: No CVE-ID: None
 [2001-12-05 19:46 UTC] phil_3iem at hotmail dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-05 20:24 UTC] sniper@php.net
Yeah, you can do this with this code too:

test.php:

<?php include('test.php'); ?>

It's not a bug. 

--Jani

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 10:01:31 2024 UTC