mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
phar: Fix memory leaks when creating temp file fails when applying zip signature
Also fixes up the error propagation at the call site which jumped to the wrong place in the error handling code. Closes GH-20057.
This commit is contained in:
2
NEWS
2
NEWS
@@ -38,6 +38,8 @@ PHP NEWS
|
|||||||
- Phar:
|
- Phar:
|
||||||
. Fix memory leak and invalid continuation after tar header writing fails.
|
. Fix memory leak and invalid continuation after tar header writing fails.
|
||||||
(nielsdos)
|
(nielsdos)
|
||||||
|
. Fix memory leaks when creating temp file fails when applying zip signature.
|
||||||
|
(nielsdos)
|
||||||
|
|
||||||
- SimpleXML:
|
- SimpleXML:
|
||||||
. Fixed bug GH-19988 (zend_string_init with NULL pointer in simplexml (UB)).
|
. Fixed bug GH-19988 (zend_string_init with NULL pointer in simplexml (UB)).
|
||||||
|
|||||||
@@ -1192,7 +1192,9 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
|
|||||||
entry.fp_type = PHAR_MOD;
|
entry.fp_type = PHAR_MOD;
|
||||||
entry.is_modified = 1;
|
entry.is_modified = 1;
|
||||||
if (entry.fp == NULL) {
|
if (entry.fp == NULL) {
|
||||||
|
efree(signature);
|
||||||
spprintf(pass->error, 0, "phar error: unable to create temporary file for signature");
|
spprintf(pass->error, 0, "phar error: unable to create temporary file for signature");
|
||||||
|
php_stream_close(newfile);
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1456,11 +1458,12 @@ fperror:
|
|||||||
|
|
||||||
phar_metadata_tracker_try_ensure_has_serialized_data(&phar->metadata_tracker, phar->is_persistent);
|
phar_metadata_tracker_try_ensure_has_serialized_data(&phar->metadata_tracker, phar->is_persistent);
|
||||||
if (temperr) {
|
if (temperr) {
|
||||||
|
temperror:
|
||||||
if (error) {
|
if (error) {
|
||||||
spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr);
|
spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr);
|
||||||
}
|
}
|
||||||
efree(temperr);
|
efree(temperr);
|
||||||
temperror:
|
notemperror:
|
||||||
php_stream_close(pass.centralfp);
|
php_stream_close(pass.centralfp);
|
||||||
nocentralerror:
|
nocentralerror:
|
||||||
php_stream_close(pass.filefp);
|
php_stream_close(pass.filefp);
|
||||||
@@ -1488,7 +1491,7 @@ nocentralerror:
|
|||||||
if (error) {
|
if (error) {
|
||||||
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname);
|
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname);
|
||||||
}
|
}
|
||||||
goto temperror;
|
goto notemperror;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user