Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2f16221

Browse files
committed
Fix memory leak in phar tar temporary file error handling code
Closes GH-19740.
1 parent ebbed48 commit 2f16221

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

‎NEWS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ PHP NEWS
3939

4040
- Phar:
4141
. Fixed memory leaks when verifying OpenSSL signature. (Girgias)
42+
. Fix memory leak in phar tar temporary file error handling code. (nielsdos)
4243

4344
- Standard:
4445
. Fixed bug GH-16649 (UAF during array_splice). (alexandre-daubois)

‎ext/phar/tar.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
12111211
}
12121212

12131213
zend_hash_apply_with_argument(&phar->manifest, phar_tar_writeheaders, (void *) &pass);
1214+
/* TODO: memory leak and incorrect continuation if phar_tar_writeheaders fails? */
12141215

12151216
/* add signature for executable tars or tars explicitly set with setSignatureAlgorithm */
12161217
if (!phar->is_data || phar->sig_flags) {
@@ -1234,6 +1235,12 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
12341235
entry.fp = php_stream_fopen_tmpfile();
12351236
if (entry.fp == NULL) {
12361237
spprintf(error, 0, "phar error: unable to create temporary file");
1238+
1239+
efree(signature);
1240+
if (closeoldfile) {
1241+
php_stream_close(oldfile);
1242+
}
1243+
php_stream_close(newfile);
12371244
return EOF;
12381245
}
12391246
#ifdef WORDS_BIGENDIAN

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /