ID:               47171
 Updated by:       [email protected]
 Reported By:      d_kelsey at uk dot ibm dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Zlib Related
 Operating System: Windows
 PHP Version:      5.2.8
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




Previous Comments:
------------------------------------------------------------------------

[2009-01-20 17:25:01] d_kelsey at uk dot ibm dot com

The provided test only covers the read scenario, but similar issues
result when opening a zlib stream for write as well.

------------------------------------------------------------------------

[2009-01-20 17:24:00] d_kelsey at uk dot ibm dot com

Description:
------------
When attempting to seek a zlib stream outside the range of the file eg
-50 or 2000 (and the uncompressed length is < 2000) in either read or
write mode, after the seek operation a gztell call returns false. In
most cases the file pointer doesn't move so I can perform further reads
or writes but the tell value returns now an invalid value. 

If a attempt to seek forward in read mode beyond the end of the
uncompressed stream it looks like the file pointer remains at the end of
the stream as a subsequent read returns nothing.

In all cases I would expect
- seek & gzseek to return -1
- the file pointer to remain where it was
- the tell to return the same value as before the seek

In other words the operation fails and nothing changes.

Reproduce code:
---------------
<?php
$f = dirname(__FILE__)."/004.txt.gz";
$h = gzopen($f, 'r'); 
echo "move to the 40th byte\n";
echo "seek=";
var_dump(gzseek( $h, 40 ) );
echo "tell=".gztell($h)."\n";
echo "try to move beyond the file\n";
echo "seek=";
var_dump(gzseek( $h, 1000 ) );
echo "tell=";
var_dump(gztell($h));
var_dump(gzread($h, 10));
echo "tell=";
var_dump(gztell($h));
echo "\nrewinding and try to move to before the start\n";
gzrewind($h);
echo "tell=".gztell($h)."\n";
echo "gzseek=";
var_dump(gzseek( $h, -5 ) );
echo "tell=";
var_dump(gztell($h));
var_dump(gzread($h, 10));
echo "tell=";
var_dump(gztell($h));
gzclose($h);
?>

Expected result:
----------------
move to the 40th byte
seek=int(0)
tell=40
try to move beyond the file
seek=int(-1)
tell=int(40)
string(10) "iny flying"
tell=int(50)

rewinding and try to move to before the start
tell=0
gzseek=int(-1)
tell=int(0)
string(10) "When you'r"
tell=int(10)

Actual result:
--------------
move to the 40th byte
seek=int(0)
tell=40
try to move beyond the file
seek=int(-1)
tell=bool(false)
string(0) ""
tell=bool(false)

rewinding and try to move to before the start
tell=0
gzseek=int(-1)
tell=bool(false)
string(10) "When you'r"
tell=int(9)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=47171&edit=1

Reply via email to