Bug #75894 [Opn->Fbk]: php_stream_input_seek() broken

From: Date: Tue, 20 Jul 2021 09:59:22 +0000
Subject: Bug #75894 [Opn->Fbk]: php_stream_input_seek() broken
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235199@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75894&edit=1 ID: 75894 Updated by: cmb@php.net Reported by: davide dot romanini at gmail dot com Summary: php_stream_input_seek() broken -Status: Open +Status: Feedback Type: Bug Package: Streams related PHP Version: 7.1.14RC1 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > Basically the stream works only when used forward-only, > consume-once (eg: file_get_contents('php://input')). This is actually what I would expect. Maybe that needs to be documented more clearly? Wrt. your patch – did you consider to make a pull request[1]? [1] <https://github.com/php/php-src/pulls> Previous Comments: ------------------------------------------------------------------------ [2018-01-31 16:28:07] davide dot romanini at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=75894&edit=1

« previous php.bugs (#235199) next »