Bug #67370 [NEW]: Fseek does not return error (-1) on read out of file
| From: | roman4e at gmail dot com | Date: | Mon, 02 Jun 2014 07:47:02 +0000 |
| Subject: | Bug #67370 [NEW]: Fseek does not return error (-1) on read out of file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186001@lists.php.net to get a copy of this message | ||
From: roman4e at gmail dot com
Operating system: linux mint 15
PHP version: 5.5.13
Package: Filesystem function related
Bug Type: Bug
Bug description:Fseek does not return error (-1) on read out of file
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 bug report at https://bugs.php.net/bug.php?id=67370&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=67370&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=67370&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=67370&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=67370&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=67370&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=67370&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=67370&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=67370&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=67370&r=support
Expected behavior: https://bugs.php.net/fix.php?id=67370&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=67370&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=67370&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=67370&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=67370&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=67370&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=67370&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=67370&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=67370&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=67370&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=67370&r=mysqlcfg