php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52228 fseek failure to seek
Submitted: 2010-07-01 22:00 UTC Modified: 2010-07-01 22:04 UTC
From: VJTD3 at VJTD3 dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: Irrelevant OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
48 - 20 = ?
Subscribe to this entry?

 
 [2010-07-01 22:00 UTC] VJTD3 at VJTD3 dot com
Description:
------------
2147483647 or PHP_INT_MAX on the system is the max integer. fseek fails with files over PHP_INT_MAX+2 in size. binary math would resolve the fseek issue internally.

Test script:
---------------
reading a file of 20 gigabytes (or anything larger then PHP_INT_MAX+2) is successful with:

<?php

 $handle = fopen('20gbfile', 'r');
 while (!feof($handle)) {
  echo fread($handle, PHP_INT_MAX);
 }
 fclose($handle);

?>

however fseek fails:

<?php

 $handle = fopen('20gbfile', 'r');
 echo fread($handle, PHP_INT_MAX);
 echo fread($handle, 2);
 fseek($handle, -1, SEEK_CUR);
 echo fread($handle, 1);
 fclose($handle);

?>

Expected result:
----------------
echo the byte from position PHP_INT_MAX+1

Actual result:
--------------
crash/fail

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-01 22:04 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2010-07-01 22:04 UTC] pajoye@php.net
We already have feature requests for that.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Sep 21 17:01:23 2020 UTC