#28953 [Fbk->Opn]: feof no longer detects SSL connections closed by the server
| From: | mlemos at acm dot org | Date: | Tue, 29 Jun 2004 17:56:06 +0000 |
| Subject: | #28953 [Fbk->Opn]: feof no longer detects SSL connections closed by the server | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-61512@lists.php.net to get a copy of this message | ||
ID: 28953
User updated by: mlemos at acm dot org
Reported By: mlemos at acm dot org
-Status: Feedback
+Status: Open
Bug Type: Sockets related
Operating System: *
PHP Version: 4.3.7
New Comment:
I am not sure if this was the problem, but I have updated the OpenSSL
installation (openssl-0.9.7b-133 now) with SuSE Linux YAST Online
Update program that applies patches that fix bugs and security
vulnerabilities and today I am no longer able to reproduce the problem.
Previous Comments:
------------------------------------------------------------------------
[2004-06-29 19:02:49] wez@php.net
If you're reading data from a M$ server you will encounter this
problem; there is not really anything we can do about it, since masking
the error will mask legitimate errors.
See Bug #23220
------------------------------------------------------------------------
[2004-06-29 17:41:28] iliaa@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
Works fine with latest CVS, the provided script returns the
following (correct) output:
connection opened
read 238 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 1000 bytes
read 777 bytes
reached the end of data
------------------------------------------------------------------------
[2004-06-29 05:41:05] mlemos at acm dot org
Description:
------------
It seems that there were changes introduced after PHP 4.3.6, the feof
function is no longer returning true when the server closes the SSL
socket connection after transmiting all the contents.
This seems to make it impossible to determine if there was a real
network error or the server closed the connection normally breaking the
compatibility of scripts that rely on feof to determine the end of
connection condition.
This seems to be a revival of bug 25939. It happens under PHp 4.3.2,
4.3.3, 4.3.4 and 4.3.7 . I does not happen under PHP 5.0.0RC3 .
Although I could only reproduce it for SSL connections. It may be
affecting normal TCP connections but I could not yet produce a test
script to demonstrate it consistently.
Reproduce code:
---------------
<?php
$socket=fsockopen("ssl://www.openssl.org", 443, $error);
if(!$socket)
{
echo "socket opening error\n";
exit;
}
echo "connection opened\n";
if(!fputs($socket, "GET / HTTP/1.1\r\nHost:
www.php.net\r\n\r\n"))
{
echo "socket writing error\n";
exit;
}
while(!feof($socket))
{
$data=fread($socket, 1000);
if(!$data)
{
echo "socket reading error\n";
exit;
}
echo "read ",strlen($data)," bytes\n";
}
echo "reached the end of data\n";
fclose($socket);
?>
Expected result:
----------------
connection opened
read 574 bytes
reached the end of data
Actual result:
--------------
connection opened
read 574 bytes
socket reading error
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28953&edit=1