From cc837614163084ce522b7c5a3cf241c388f38311 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 19 Oct 2025 22:13:12 +0200 Subject: [PATCH] phar: Fix file descriptor leak in phar_zip_flush() on failure. Closes GH-20228. --- NEWS | 1 + ext/phar/zip.c | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 020927bb5ff..4345f86f98e 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/ext/phar/zip.c b/ext/phar/zip.c index f1d0edd5bdf..63c56108ed9 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -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); }