Skip to content

Commit ffc548d

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: phar: Fix memleak+UAF when opening temp stream in buildFromDirectory() fails
2 parents 5e58833 + 5a7c84f commit ffc548d

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ PHP NEWS
3333
. Fix a bunch of memory leaks in phar_parse_zipfile() error handling.
3434
(nielsdos)
3535
. Fix file descriptor/memory leak when opening central fp fails. (nielsdos)
36+
. Fix memleak+UAF when opening temp stream in buildFromDirectory() fails.
37+
(nielsdos)
3638

3739
- Random:
3840
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)

ext/phar/phar_object.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,10 @@ PHP_METHOD(Phar, buildFromDirectory)
17921792
pass.ret = return_value;
17931793
pass.fp = php_stream_fopen_tmpfile();
17941794
if (pass.fp == NULL) {
1795+
zval_ptr_dtor(&iteriter);
1796+
if (apply_reg) {
1797+
zval_ptr_dtor(&regexiter);
1798+
}
17951799
zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" unable to create temporary file", phar_obj->archive->fname);
17961800
RETURN_THROWS();
17971801
}

0 commit comments

Comments
 (0)