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 eb4b281
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main/streams/streams.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,9 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)

switch(whence) {
case SEEK_CUR:
ZEND_ASSERT(stream->position >= 0);
if (UNEXPECTED(stream->position == -1)) {
goto fail;
}
if (UNEXPECTED(offset > ZEND_LONG_MAX - stream->position)) {
offset = ZEND_LONG_MAX;
} else {
Expand Down Expand Up @@ -1393,6 +1395,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 eb4b281

Please sign in to comment.