Browse Source
Merge branch 'PHP-8.5'
* PHP-8.5:
phar: Fix memory leaks when creating temp file fails when applying zip signature
pull/18068/merge
Niels Dossche
2 weeks ago
No known key found for this signature in database
GPG Key ID: B8A8AD166DF0E2E5
1 changed files with
5 additions and
2 deletions
-
ext/phar/zip.c
|
|
@ -1222,7 +1222,9 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas |
|
|
|
entry.fp_type = PHAR_MOD; |
|
|
|
entry.is_modified = 1; |
|
|
|
if (entry.fp == NULL) { |
|
|
|
efree(signature); |
|
|
|
spprintf(pass->error, 0, "phar error: unable to create temporary file for signature"); |
|
|
|
php_stream_close(newfile); |
|
|
|
return FAILURE; |
|
|
|
} |
|
|
|
|
|
|
@ -1440,11 +1442,12 @@ fperror: |
|
|
|
|
|
|
|
phar_metadata_tracker_try_ensure_has_serialized_data(&phar->metadata_tracker, phar->is_persistent); |
|
|
|
if (temperr) { |
|
|
|
temperror: |
|
|
|
if (error) { |
|
|
|
spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr); |
|
|
|
} |
|
|
|
efree(temperr); |
|
|
|
temperror: |
|
|
|
notemperror: |
|
|
|
php_stream_close(pass.centralfp); |
|
|
|
nocentralerror: |
|
|
|
php_stream_close(pass.filefp); |
|
|
@ -1472,7 +1475,7 @@ nocentralerror: |
|
|
|
if (error) { |
|
|
|
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname); |
|
|
|
} |
|
|
|
goto temperror; |
|
|
|
goto notemperror; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|