php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28996 fsockopen(unix_socket) and file descriptors leaking
Submitted: 2004-07-02 18:30 UTC Modified: 2004-07-02 19:27 UTC
From: b dot mourgues at newtech dot fr Assigned:
Status: Closed Package: Sockets related
PHP Version: 4CVS-2004-07-02 (stable) OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: b dot mourgues at newtech dot fr
New email:
PHP Version: OS:

 

 [2004-07-02 18:30 UTC] b dot mourgues at newtech dot fr
Description:
------------
When using fsockopen with non "available" unix socket, fsockopen returns FALSE (no file descriptor), but an unix socket remains opened in webserver process running php.

run
watch -n 1 'lsof -U | grep ^apache | wc -l'

while opening the following page (replacing "apache" by the real name of your webserver).

Suggestion : in file main/network.c, in function _php_stream_sock_open_unix, when php_connect_nonb fails, closesocket(socketd) should be invoked before returning NULL.

Reproduce code:
---------------
<?php
        $PHPfd = fsockopen("/dev/null", 0, $PHPerrno, $PHPerrstr);
        if($PHPfd)
        {
                fclose($PHPfd);
        }
?>

<html><head><title>fsockopen</title></head>
<body>
<pre>
PID : <?php print getmypid() . " ".  $PHPerrstr . "."; ?>
</pre>
</body></html>


Expected result:
----------------
When fsockopen returns FALSE, no file descriptor created by this function should remain opened


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-02 19:27 UTC] wez@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

The next snapshot from snaps.php.net will contain the fix.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 06 02:01:29 2024 UTC