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

phar: Fix file descriptor leak in phar_zip_flush() on failure.

Closes GH-20228.
This commit is contained in:
Niels Dossche
2025-10-19 22:13:12 +02:00
parent 4043e5fdfc
commit cc83761416
2 changed files with 2 additions and 0 deletions

1
NEWS
View File

@@ -56,6 +56,7 @@ PHP NEWS
. Fix potential buffer length truncation due to usage of type int instead
of type size_t. (Girgias)
. Fix memory leak when openssl polyfill returns garbage. (nielsdos)
. Fix file descriptor leak in phar_zip_flush() on failure. (nielsdos)
- Random:
. Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos)

View File

@@ -1246,6 +1246,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
return EOF;
}
if (phar->alias_len != php_stream_write(entry.fp, phar->alias, phar->alias_len)) {
php_stream_close(entry.fp);
if (error) {
spprintf(error, 0, "unable to set alias in zip-based phar \"%s\"", phar->fname);
}