Skip to content

Commit

Permalink
Fix GH-16780: gzseek aborts on non seekable stream.
Browse files Browse the repository at this point in the history
the stream flags is set to non seekable, thus we bail out early
in the process.
  • Loading branch information
devnexen committed Nov 13, 2024
1 parent 45487c6 commit 039cab2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions main/streams/streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,11 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
}
}

/* the stream is not properly seekable */
if (stream->flags & PHP_STREAM_FLAG_NO_SEEK) {
goto fail;
}

/* handle the case where we are in the buffer */
if ((stream->flags & PHP_STREAM_FLAG_NO_BUFFER) == 0) {
switch(whence) {
Expand Down Expand Up @@ -1393,6 +1398,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
return 0;
}

fail:
php_error_docref(NULL, E_WARNING, "Stream does not support seeking");

return -1;
Expand Down

0 comments on commit 039cab2

Please sign in to comment.