Bug #75894 [NEW]: php_stream_input_seek() broken
| From: | davide dot romanini at gmail dot com | Date: | Wed, 31 Jan 2018 16:28:08 +0000 |
| Subject: | Bug #75894 [NEW]: php_stream_input_seek() broken | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-213761@lists.php.net to get a copy of this message | ||
From: davide dot romanini at gmail dot com
Operating system:
PHP version: 7.1.14RC1
Package: Streams related
Bug Type: Bug
Bug description:php_stream_input_seek() broken
Description:
------------
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:
https://github.com/php/php-src/compare/PHP-7.1...davide-romanini:fix-php-stream-input-seek
Test script:
---------------
--POST--
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ante
ex, placerat nec sollicitudin vitae, ultricies molestie nisi. Maecenas
lacus magna, augue.
--FILE--
<?php
$i = fopen('php://input', 'r');
fseek($i, 5);
var_dump(fread($i, 10));
rewind($i);
var_dump(fread($i, 5));
fseek($i, -6, SEEK_END);
var_dump(fread($i, 6));
?>
--EXPECT--
string(10) " ipsum dol"
string(5) "Lorem"
string(6) "augue."
--
Edit bug report at https://bugs.php.net/bug.php?id=75894&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75894&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75894&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75894&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=75894&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=75894&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=75894&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=75894&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=75894&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=75894&r=support
Expected behavior: https://bugs.php.net/fix.php?id=75894&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=75894&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=75894&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=75894&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75894&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=75894&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=75894&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=75894&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=75894&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=75894&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=75894&r=mysqlcfg