From: d_kelsey at uk dot ibm dot com Operating system: Windows XP PHP version: 5.2.8 PHP Bug Type: Zlib Related Bug description: gzseek/fseek using SEEK_END produces strange results
Description: ------------ I have opened a .gz file using gzopen for reading. I can pass SEEK_END with offset of 0 (which would seek to the end of the file) using either fseek or gzseek as a whence. This returns -1 (a failure), but a subsequent gztell/ftell returns false, but I can still read the stream from the position it was last in. The issue is 1. is a whence of SEEK_END supported for a zlib stream ? If it is then SEEK_END is very broken as it doesn't move it to the end of the stream. 2. if not supported, I should get a warning saying invalid parameter. Also a subsequent call to gztell/ftell returns false.a further read and gztell/ftell returns an incorrect value I couldn't find any information to say it was not a valid value so assumed that it was valid. Reproduce code: --------------- <?php //004.txt.gz taken from zlib test directory //first 20 bytes are: "When you're taught t" $f = dirname(__FILE__)."/004.txt.gz"; $h = gzopen($f, 'r'); //read the first 10 var_dump(gzread($h, 10)); echo "move to the end\n"; echo "gzseek="; var_dump(gzseek( $h, 0, SEEK_END ) ); echo "tell="; var_dump(gztell($h)); echo "eof="; var_dump(gzeof($h)); //read the next 10 var_dump(gzread($h, 10)); echo "tell="; var_dump(gztell($h)); ?> Expected result: ---------------- If SEEK_END is not valid: string(10) "When you'r" move to the end gzseek= Warning: gzseek() SEEK_END not supported tell=int(10) eof=bool(false) string(10) "e taught t" tell=int(20) if SEEK_END is valid: string(10) "When you'r" move to the end gzseek=int(0) tell=int(176) eof=bool(true) string(0) "" tell=int(176) Actual result: -------------- string(10) "When you'r" move to the end gzseek=int(-1) tell=bool(false) eof=bool(false) string(10) "e taught t" tell=int(9) -- Edit bug report at http://bugs.php.net/?id=47152&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47152&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47152&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47152&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47152&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47152&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47152&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47152&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47152&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47152&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47152&r=support Expected behavior: http://bugs.php.net/fix.php?id=47152&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47152&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47152&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47152&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47152&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47152&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47152&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47152&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47152&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47152&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47152&r=mysqlcfg
