php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #65222 Allow big-values (float) in size/offset for file open/read/write/seek functions
Submitted: 2013-07-09 09:33 UTC Modified: 2013-07-09 11:18 UTC
Votes:34
Avg. Score:4.9 ± 0.4
Reproduced:7 of 7 (100.0%)
Same Version:3 (42.9%)
Same OS:3 (42.9%)
From: helpdesk at dekho-ji dot com Assigned:
Status: Open Package: Filesystem function related
PHP Version: 5.5.0 OS: All
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 — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
41 - 24 = ?
Subscribe to this entry?

 
 [2013-07-09 09:33 UTC] helpdesk at dekho-ji dot com
Description:
------------
Allow big-values (float) in size/offset for file open/read/write/seek functions

All file system functions currently are defined with INT params for size/offset/length/bytes flds. Can this be upgraded so that it now accepts long values (floats with 0 decimals). 

For ex - string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )
will become
string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, FLOAT $offset = -1 [, FLOAT $maxlen ]]]] )

For the end-users, this will be 100% backward compatible and will offer additional func when people specify float values.

Simple way to fix this -
1) I believe all file operations use fopen/fseek/fget as their base ? If yes, then these these funcs can be changed to allow float values. Everything will then work smoothly.
2) I currently use fseek SEEK_CUR with 2GB jump offsets and loop it till I finally reach the required BIG offset. It uses simple recursion. 5 lines of code. But if this can be done natively in core system, that will be great benefit for people dealing with huge size files and relevant operations.


Test script:
---------------
Allow big-values (float) in size/offset for file open/read/write/seek functions

All file system functions currently are defined with INT params for size/offset/length/bytes flds. Can this be upgraded so that it now accepts long values (floats with 0 decimals). 

For ex - string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )
will become
string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, FLOAT $offset = -1 [, FLOAT $maxlen ]]]] )

For the end-users, this will be 100% backward compatible and will offer additional func when people specify float values.

Simple way to fix this -
1) I believe all file operations use fopen/fseek/fget as their base ? If yes, then these these funcs can be changed to allow float values. Everything will then work smoothly.
2) I currently use fseek SEEK_CUR with 2GB jump offsets and loop it till I finally reach the required BIG offset. It uses simple recursion. 5 lines of code. But if this can be done natively in core system, that will be great benefit for people dealing with huge size files and relevant operations.


Expected result:
----------------
Allow big-values (float) in size/offset for file open/read/write/seek functions

All file system functions currently are defined with INT params for size/offset/length/bytes flds. Can this be upgraded so that it now accepts long values (floats with 0 decimals). 

For ex - string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )
will become
string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, FLOAT $offset = -1 [, FLOAT $maxlen ]]]] )

For the end-users, this will be 100% backward compatible and will offer additional func when people specify float values.

Simple way to fix this -
1) I believe all file operations use fopen/fseek/fget as their base ? If yes, then these these funcs can be changed to allow float values. Everything will then work smoothly.
2) I currently use fseek SEEK_CUR with 2GB jump offsets and loop it till I finally reach the required BIG offset. It uses simple recursion. 5 lines of code. But if this can be done natively in core system, that will be great benefit for people dealing with huge size files and relevant operations.


Actual result:
--------------
All file system functions currently are defined with INT params for size/offset/length/bytes flds. Can this be upgraded so that it now accepts long values (floats with 0 decimals). 

For ex - string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, int $offset = -1 [, int $maxlen ]]]] )
will become
string file_get_contents ( string $filename [, bool $use_include_path = false [, resource $context [, FLOAT $offset = -1 [, FLOAT $maxlen ]]]] )

For the end-users, this will be 100% backward compatible and will offer additional func when people specify float values.

Simple way to fix this -
1) I believe all file operations use fopen/fseek/fget as their base ? If yes, then these these funcs can be changed to allow float values. Everything will then work smoothly.
2) I currently use fseek SEEK_CUR with 2GB jump offsets and loop it till I finally reach the required BIG offset. It uses simple recursion. 5 lines of code. But if this can be done natively in core system, that will be great benefit for people dealing with huge size files and relevant operations.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-09 11:18 UTC] helpdesk at dekho-ji dot com
This code DOES NOT work, so ignore it -
2) I currently use fseek SEEK_CUR with 2GB jump offsets and loop it till I finally reach the required BIG offset. It uses simple recursion. 5 lines of code. But if this can be done natively in core system, that will be great benefit for people dealing with huge size files and relevant operations.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 11:01:30 2024 UTC