Skip to content

Commit cc83761

Browse files
committed
phar: Fix file descriptor leak in phar_zip_flush() on failure.
Closes phpGH-20228.
1 parent 4043e5f commit cc83761

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ PHP NEWS
5656
. Fix potential buffer length truncation due to usage of type int instead
5757
of type size_t. (Girgias)
5858
. Fix memory leak when openssl polyfill returns garbage. (nielsdos)
59+
. Fix file descriptor leak in phar_zip_flush() on failure. (nielsdos)
5960

6061
- Random:
6162
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)

ext/phar/zip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
12461246
return EOF;
12471247
}
12481248
if (phar->alias_len != php_stream_write(entry.fp, phar->alias, phar->alias_len)) {
1249+
php_stream_close(entry.fp);
12491250
if (error) {
12501251
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
12511252
}

0 commit comments

Comments
 (0)