php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51997 fseek($fp, 0, SEEK_CUR) generates needless warning when seeking isn't supported
Submitted: 2010-06-05 01:39 UTC Modified: 2011-06-05 23:57 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: andrew at bramp dot freeserve dot co dot uk Assigned: cataphract (profile)
Status: Closed Package: Streams related
PHP Version: 5.3.2 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrew at bramp dot freeserve dot co dot uk
New email:
PHP Version: OS:

 

 [2010-06-05 01:39 UTC] andrew at bramp dot freeserve dot co dot uk
Description:
------------
This is such a minor "bug" which can easily be fixed with one minor change.

The bzip stream for example, does not support seeking, however this is an 
"emulation" in main/streams/streams.c that allows the SEEK_CUR to work with 
positive values by just continue to read for the seek duration.

The bug is if you use SEEK_CUR with a value of zero, a warning pops up saying 
seek is not supported. I know using a value of zero is perhaps wrong, but by 
changing line 1150 of main/streams/streams.c from:

if (whence == SEEK_CUR && offset > 0) {
to:
if (whence == SEEK_CUR && offset >= 0) {

then this warning does not appear, and everything works as expected.

I have not tested this change, but it looks innocent enough. Until then I'm 
writing my PHP code with a if ($offset > 0) fseek($fp, $offset, SEEK_CUR);

thanks.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-12 18:02 UTC] cataphract@php.net
-Assigned To: +Assigned To: cataphract
 [2011-06-05 23:57 UTC] iliaa@php.net
Automatic comment from SVN on behalf of iliaa
Revision: http://svn.php.net/viewvc/?view=revision&revision=311849
Log: Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning).
 [2011-06-05 23:57 UTC] iliaa@php.net
-Status: Assigned +Status: Closed
 [2011-06-05 23:57 UTC] iliaa@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2012-04-18 09:50 UTC] laruence@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6b85eb58b27a60cfc4d78ad0a85afeda373132c5
Log: Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning).
 [2012-07-24 23:41 UTC] rasmus@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6b85eb58b27a60cfc4d78ad0a85afeda373132c5
Log: Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning).
 [2013-11-17 09:37 UTC] laruence@php.net
Automatic comment on behalf of iliaa
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6b85eb58b27a60cfc4d78ad0a85afeda373132c5
Log: Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 08:01:29 2025 UTC