Skip to content

Commit ca3e379

Browse files
committed
ext/phar: offsetExists should return false when file entry is not based on PharFileInfo
1 parent 36ca42e commit ca3e379

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ext/phar/phar_object.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,6 +3527,10 @@ PHP_METHOD(Phar, offsetExists)
35273527
}
35283528
RETURN_TRUE;
35293529
} else {
3530+
/* If the info class is not based on PharFileInfo, directories are not directly instantiable */
3531+
if (UNEXPECTED(!instanceof_function(phar_obj->spl.info_class, phar_ce_entry))) {
3532+
RETURN_FALSE;
3533+
}
35303534
if (zend_hash_str_exists(&phar_obj->archive->virtual_dirs, fname, (uint32_t) fname_len)) {
35313535
RETURN_TRUE;
35323536
}

ext/phar/tests/phar_oo_011.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ object(PharFileInfo)#%d (2) {
4949
}
5050
bool(true)
5151
phar:///%s/phar_oo_011.phar.php/hi/f.php
52-
bool(true)
52+
bool(false)
5353
LogicException: Cannot use SplFileObject with directories
5454
bool(true)
5555
hi

0 commit comments

Comments
 (0)