Bug #52335 [NEW]: fseek() on memory stream behavior different then file
| From: | jbondc at openmv dot com | Date: | Wed, 14 Jul 2010 11:18:20 +0000 |
| Subject: | Bug #52335 [NEW]: fseek() on memory stream behavior different then file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-152398@lists.php.net to get a copy of this message | ||
From:
Operating system: FreeBSD 7.2
PHP version: 5.2.14RC2
Package: Streams related
Bug Type: Bug
Bug description:fseek() on memory stream behavior different then file
Description:
------------
May not be a bug but a documentation issue
With a file, fseek() to an offset that doesn't exist results in NULL bytes
added.
Using a memory stream, fseek() just fails.
Which one is the expected behavior? Also for streamWrapper::stream_seek()
Test script:
---------------
$sp = fopen("php://memory", 'w+');
fseek($sp, 1024); // fails why?
echo fwrite($sp, "abc"); // 3
fseek($sp, 1024); //
echo fread($sp, 3); // NULL..
$sp = fopen("/tmp/foo", 'w+');
fseek($sp, 1024);
echo fwrite($sp, "abc"); // 3
fseek($sp, 1024);
echo fread($sp, 3); // abc
Expected result:
----------------
3abc3abc
Actual result:
--------------
33abc
--
Edit bug report at http://bugs.php.net/bug.php?id=52335&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52335&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52335&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52335&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=52335&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52335&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=52335&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=52335&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=52335&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=52335&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=52335&r=support
Expected behavior: http://bugs.php.net/fix.php?id=52335&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=52335&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=52335&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=52335&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52335&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52335&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=52335&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=52335&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=52335&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=52335&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=52335&r=mysqlcfg