1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.5'

* PHP-8.5:
  Fix OOB gzseek() causing assertion failure
This commit is contained in:
Niels Dossche
2025-12-28 00:22:18 +01:00
2 changed files with 26 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
--TEST--
Test function gzseek() by seeking out of bounds
--EXTENSIONS--
zlib
--FILE--
<?php
$f = __DIR__."/004.txt.gz";
$h = gzopen($f, 'r');
var_dump(gzseek($h, -100, SEEK_CUR));
var_dump(gzseek($h, 0, SEEK_CUR));
var_dump(gztell($h));
gzclose($h);
?>
--EXPECT--
int(-1)
int(0)
int(0)

View File

@@ -108,9 +108,14 @@ static int php_gziop_seek(php_stream *stream, zend_off_t offset, int whence, zen
php_error_docref(NULL, E_WARNING, "SEEK_END is not supported");
return -1;
}
*newoffs = gzseek(self->gz_file, offset, whence);
return (*newoffs < 0) ? -1 : 0;
z_off_t new_offset = gzseek(self->gz_file, offset, whence);
if (new_offset < 0) {
return -1;
}
*newoffs = new_offset;
return 0;
}
static int php_gziop_close(php_stream *stream, int close_handle)