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

Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  Fix assertion failure when fseeking a phar file out of bounds
This commit is contained in:
Niels Dossche
2025-11-15 14:33:58 +01:00
4 changed files with 34 additions and 9 deletions

1
NEWS
View File

@@ -26,6 +26,7 @@ PHP NEWS
. Fixed bug GH-20442 (Phar does not respect case-insensitiveness of
__halt_compiler() when reading stub). (ndossche, TimWolla)
. Fix broken return value of fflush() for phar file entries. (ndossche)
. Fix assertion failure when fseeking a phar file out of bounds. (ndossche)
- PHPDBG:
. Fixed ZPP type violation in phpdbg_get_executable() and phpdbg_end_oplog().

View File

@@ -428,11 +428,9 @@ static int phar_stream_seek(php_stream *stream, zend_off_t offset, int whence, z
zend_off_t temp_signed = (zend_off_t) temp;
if (temp_signed > data->zero + (zend_off_t) entry->uncompressed_filesize) {
*newoffset = -1; /* FIXME: this will invalidate the ZEND_ASSERT(stream->position >= 0); assertion in streams.c */
return -1;
}
if (temp_signed < data->zero) {
*newoffset = -1; /* FIXME: this will invalidate the ZEND_ASSERT(stream->position >= 0); assertion in streams.c */
return -1;
}
res = php_stream_seek(data->fp, temp_signed, SEEK_SET);

View File

@@ -80,28 +80,28 @@ int(1)
fseek($fp, -1, SEEK_END)int(0)
int(6)
fseek($fp, -8, SEEK_END)int(-1)
bool(false)
int(6)
fseek($fp, -7, SEEK_END)int(0)
int(0)
fseek($fp, 0, SEEK_END)int(0)
int(7)
fseek($fp, 1, SEEK_END)int(-1)
bool(false)
int(7)
fseek($fp, -8, SEEK_END)int(-1)
bool(false)
int(7)
fseek($fp, 6)int(0)
int(6)
fseek($fp, 8)int(-1)
bool(false)
int(6)
fseek($fp, -1)int(-1)
bool(false)
int(6)
next
int(4)
fseek($fp, -5, SEEK_CUR)int(-1)
bool(false)
int(4)
int(4)
fseek($fp, 5, SEEK_CUR)int(-1)
bool(false)
int(4)
int(4)
fseek($fp, -4, SEEK_CUR)int(0)
int(0)

View File

@@ -0,0 +1,26 @@
--TEST--
Assertion failure when fseeking outside of bounds of phar file
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
--FILE--
<?php
require_once __DIR__ . '/files/phar_oo_test.inc';
$phar = new Phar($fname);
$phar->setInfoClass('SplFileObject');
$f = $phar['a.php'];
var_dump($f->fseek(1, SEEK_SET));
var_dump($f->fseek(999999, SEEK_SET));
var_dump($f->fseek(999999, SEEK_CUR));
var_dump($f->ftell());
var_dump($f->fseek(1, SEEK_CUR));
var_dump($f->fread(3));
?>
--EXPECT--
int(0)
int(-1)
int(-1)
int(1)
int(0)
string(3) "php"