Bug #66638 [NEW]: Using SEEK_CUR to seek behind start in a produces incorrect result

From: Date: Mon, 03 Feb 2014 23:58:25 +0000
Subject: Bug #66638 [NEW]: Using SEEK_CUR to seek behind start in a produces incorrect result
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184144@lists.php.net to get a copy of this message
From: madhusudancs at gmail dot com Operating system: Linux (likely all) PHP version: master-Git-2014-02-03 (Git) Package: Streams related Bug Type: Bug Bug description:Using SEEK_CUR to seek behind start in a produces incorrect result Description: ------------ When using php://memory stream, attempting to seek behind the start position, produces incorrect results. Sample test case below (in the next field) Test case should print the entire stream (all the bytes in the stream, but it prints an empty string. Test script: --------------- <?php $fh = fopen('php://memory', 'w'); for ($ii = 0; $ii < 10; $ii++) { fwrite($fh, "[$ii] hello world. "); } $sz = 170; fseek($fh, $sz - 100, SEEK_SET); fseek($fh, -$sz, SEEK_CUR); var_dump(fread($fh, $sz)); ?> Expected result: ---------------- string(170) "[0] hello world. [1] hello world. [2] hello world. [3] hello world. [4] hello world. [5] hello world. [6] hello world. [7] hello world. [8] hello world. [9] hello world. " Actual result: -------------- string(0) "" -- Edit bug report at https://bugs.php.net/bug.php?id=66638&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66638&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66638&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66638&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66638&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66638&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66638&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66638&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66638&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66638&r=support Expected behavior: https://bugs.php.net/fix.php?id=66638&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66638&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66638&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66638&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66638&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66638&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66638&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66638&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66638&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66638&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66638&r=mysqlcfg

« previous php.bugs (#184144) next »