ID:               49706
 Comment by:       doughton at hiden dot co dot uk
 Reported By:      alex at innovacomputing dot com
 Status:           No Feedback
 Bug Type:         Streams related
 Operating System: Debian 5.0.3/amd64
 PHP Version:      5.2.11
 New Comment:

Problem is manifesting itself in Mantis 1.1.0a1 with mail reporting
script running on SunOS
Machine hardware:   sun4u
OS version:         5.10
Processor type:     sparc
Hardware:           SUNW,Ultra-250


 feof erroneously returns true when reading from a socket to the POP3
server ( Qpopper version 4.1b18). This results in readLine in socket.php
randomly returning an empty string when called from _recvLn() in
POP3.PHP , so this breaks all the functions in POP3.PHP

Commenting out feof in readLine fixes this problem:
 function readLine()
    {
        if (!is_resource($this->fp)) {
            return $this->raiseError('not connected');
        }

        $line = '';
        $timeout = time() + $this->timeout;
        while (/* !feof($this->fp) && */ (!$this->timeout || time() <
$timeout)) {
            $line .= @fgets($this->fp, $this->lineLength);
            if (substr($line, -1) == "\n") {
                return rtrim($line, "\r\n");
            }
        }
        return $line;
    }
 
As feof( ) seems to randomly return true I suspect a timing issue,
probably depends on whether the mail server has written to the socket
before feof is called - our mail server resides on another server.

Could this be related to the fix for PHP bug 49072 (feof never returns
true for damaged file in zip). http://bugs.php.net/bug.php?id=49072 ?


It is fixed in the latest version ( 5.12 release candidate 2 ).


Previous Comments:
------------------------------------------------------------------------

[2009-10-11 01:00:00] php-bugs at lists dot php dot net

No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".

------------------------------------------------------------------------

[2009-10-03 09:59:17] paj...@php.net

Please try a 5.3 snapshot as well.

------------------------------------------------------------------------

[2009-09-29 10:54:35] sjo...@php.net

Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/



------------------------------------------------------------------------

[2009-09-29 07:21:28] tantaoui at gmail dot com

It works correctly for me in 5.2.10 but not in 5.2.11 under Windows
Server 2003. it seems to be OK in 5.2.12 (snapshot)

------------------------------------------------------------------------

[2009-09-29 06:20:08] alex at innovacomputing dot com

Description:
------------
feof() seems to have broken on socket streams somewhere between version
5.2.9 and 5.2.11.

When running the code included in this bug report on PHP 5.2.9, it
returns "bool(false)", which is the correct behavior.  However, when
upgrading to PHP 5.2.11, feof() will incorrectly return "bool(true)".

Note that I've only been able to reproduce this on a 64-bit server. 
PHP 5.2.11 on the 32-bit server that I've also tested with correctly
returns "bool(false)".

Reproduce code:
---------------
<?php
list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM,
STREAM_IPPROTO_IP);
fwrite($a, 'Test');
var_dump(feof($b));


Expected result:
----------------
bool(false)

Actual result:
--------------
bool(true)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=49706&edit=1

Reply via email to