|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75894 php_stream_input_seek() broken
Submitted: 2018-01-31 16:28 UTC Modified: -
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: davide dot romanini at gmail dot com Assigned:
Status: Open Package: Streams related
PHP Version: 7.1.14RC1 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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
18 + 20 = ?
Subscribe to this entry?

 [2018-01-31 16:28 UTC] davide dot romanini at gmail dot com
The php://input stream behaves differently from other standard streams. In particular, seeking is completely broken. Basically the stream works only when used forward-only, consume-once (eg: file_get_contents('php://input')).

I didn't found the bug reported here (I searched under streams related bugs using the 'seek' keyword). 

I sketched a possible fix with tests here:

Test script:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ante ex, placerat nec sollicitudin vitae, ultricies molestie nisi. Maecenas lacus magna, augue.
$i = fopen('php://input', 'r');
fseek($i, 5);
var_dump(fread($i, 10));
var_dump(fread($i, 5));
fseek($i, -6, SEEK_END);
var_dump(fread($i, 6));
string(10) " ipsum dol"
string(5) "Lorem"
string(6) "augue."


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat May 15 15:01:25 2021 UTC