Bug #67370 [Opn->Nab]: Fseek does not return error (-1) on read out of file
| From: | mike@php.net | Date: | Mon, 02 Jun 2014 08:23:13 +0000 |
| Subject: | Bug #67370 [Opn->Nab]: Fseek does not return error (-1) on read out of file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-186004@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67370&edit=1
ID: 67370
Updated by: mike@php.net
Reported by: roman4e at gmail dot com
Summary: Fseek does not return error (-1) on read out of file
-Status: Open
+Status: Not a bug
Type: Bug
Package: Filesystem function related
Operating System: linux mint 15
PHP Version: 5.5.13
Block user comment: N
Private report: N
New Comment:
One can set the file pointer beyond EOF, this is not a bug.
Previous Comments:
------------------------------------------------------------------------
[2014-06-02 07:47:01] roman4e at gmail dot com
Description:
------------
php v.5.5.5 (cli) (built: Mar 17 2014 12:31:03) (DEBUG)
fseek() does not return error (-1) on read out of file, returns 0
Test script:
---------------
$f = fopen("file","r"); // file must be several KBytes size
$page = 0;
while ( !fseek($f,$page,SEEK_SET) )
{
$page += 1024;
$str = fread($f,1024);
if ( $str === false )
die("error reading block");
}
echo "ok"
Expected result:
----------------
fseek should return -1;
Actual result:
--------------
file size of 76800
result of reading out of file. last parametr is type of data returned by fread
Pageoff = 75776 fseek=0 ftell=75776 read=1024 string
Pageoff = 76800 fseek=0 ftell=76800 read=0 string
Pageoff = 77824 fseek=0 ftell=77824 read=0 string
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67370&edit=1