Bug #77146 [Com]: feof not reached

From: Date: Tue, 13 Nov 2018 13:55:22 +0000
Subject: Bug #77146 [Com]: feof not reached
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217930@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77146&edit=1 ID: 77146 Comment by: samuel dot chemla at orange dot com Reported by: samuel dot chemla at orange dot com Summary: feof not reached Status: Verified Type: Bug Package: Streams related Operating System: * PHP Version: 7.1.24 Block user comment: N Private report: N New Comment: ;-) 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. Previous Comments: ------------------------------------------------------------------------ [2018-11-13 13:47:05] 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:22:13] 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 12:53:08] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77146&edit=1

« previous php.bugs (#217930) next »