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
 [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

Pull Requests

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: Thu Dec 05 02:01:30 2024 UTC