From eb4b28178dcfea944b46c0dbb2923ce482a7bea8 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 13 Nov 2024 19:54:43 +0000 Subject: [PATCH] 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. --- main/streams/streams.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/streams/streams.c b/main/streams/streams.c index 4c66d8aadc39b..e560b9d17e438 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -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 { @@ -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;