Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions ext/phar/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,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);
Expand Down
14 changes: 7 additions & 7 deletions ext/phar/tests/022.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions ext/phar/tests/fseek_outside_bounds.phpt
Original file line number Diff line number Diff line change
@@ -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"
Loading