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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: VJTD3 at VJTD3 dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 00:01:36 2025 UTC