Skip to content

Commit eb4b281

Browse files
committed
Fix GH-16780: gzseek aborts on non seekable stream.
the stream flags is set to non seekable, thus we bail out early in the process.
1 parent 45487c6 commit eb4b281

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

main/streams/streams.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1354,7 +1354,9 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
13541354

13551355
switch(whence) {
13561356
case SEEK_CUR:
1357-
ZEND_ASSERT(stream->position >= 0);
1357+
if (UNEXPECTED(stream->position == -1)) {
1358+
goto fail;
1359+
}
13581360
if (UNEXPECTED(offset > ZEND_LONG_MAX - stream->position)) {
13591361
offset = ZEND_LONG_MAX;
13601362
} else {
@@ -1393,6 +1395,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
13931395
return 0;
13941396
}
13951397

1398+
fail:
13961399
php_error_docref(NULL, E_WARNING, "Stream does not support seeking");
13971400

13981401
return -1;

0 commit comments

Comments
 (0)