php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77146 feof not reached
Submitted: 2018-11-13 12:53 UTC Modified: 2018-11-13 13:47 UTC
From: samuel dot chemla at orange dot com Assigned:
Status: Verified Package: Streams related
PHP Version: 7.1.24 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: samuel dot chemla at orange dot com
New email:
PHP Version: OS:

 

 [2018-11-13 12:53 UTC] samuel dot chemla at orange dot com
Description:
------------
feof return false when it should return true.
See script below.

This bug is only on 7.0.32.

I tested on 7.2.9 and it works perfectly.

I filled this report because not reaching eof may be dangerous.

Test script:
---------------
$data = "foo";
$stream = fopen('php://memory', 'r+');
fwrite($stream, $data);
fseek($stream, 0);
if ($data !== fread($stream, strlen($data)+1)) {
    throw new \Exception("Invalid data");
}
if (strlen($data) !== ftell($stream)) {
    throw new \Exception("Invalid tell");
}
if (feof($stream) !== true) {
    throw new \Exception("Invalid eof");
}

Expected result:
----------------
<No exception>

Actual result:
--------------
\Exception("Invalid eof") raised

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-13 13:22 UTC] tpojka at gmail dot com
For sake of consistency it should be in line:

$data = "foo";
$stream = fopen('php://memory', 'r+');
fwrite($stream, $data);
fseek($stream, 0);
if ($data !== fread($stream, strlen($data)+1)) {
    throw new \Exception("Invalid read");
}
if (strlen($data) !== ftell($stream)) {
    throw new \Exception("Invalid tell");
}
if (feof($stream) !== true) {
    throw new \Exception("Invalid eof");
}
 [2018-11-13 13:47 UTC] cmb@php.net
-Status: Open +Status: Verified -Operating System: Windows 7 x64 +Operating System: * -PHP Version: 7.0.32 +PHP Version: 7.1.24
 [2018-11-13 13:47 UTC] cmb@php.net
Active support for PHP 7.0 ended long ago[1], but since this
affects PHP 7.1 as well[2], the report is valid.

[1] <http://php.net/supported-versions.php>
[2] <https://3v4l.org/frnT2>
 [2018-11-13 13:55 UTC] samuel dot chemla at orange dot com
;-)

I reported on 7.0 because I mainly work on debian (PHP 7.0), and we have to show love for debian ;-)

Anyway, I just tested on a ubuntu 16.04 with 7.0.13 and it is also affected, so it is not Windows related.
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Thu Dec 13 09:01:26 2018 UTC