mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Add missing filter cleanups on phar failure
Closes GH-18609.
This commit is contained in:
parent
8e2c2be7a5
commit
910aeaafc1
3 changed files with 12 additions and 0 deletions
2
NEWS
2
NEWS
|
@ -2,6 +2,8 @@ PHP NEWS
|
||||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||
?? ??? ????, PHP 8.3.23
|
?? ??? ????, PHP 8.3.23
|
||||||
|
|
||||||
|
- Phar:
|
||||||
|
. Add missing filter cleanups on phar failure. (nielsdos)
|
||||||
|
|
||||||
05 Jun 2025, PHP 8.3.22
|
05 Jun 2025, PHP 8.3.22
|
||||||
|
|
||||||
|
|
|
@ -1704,6 +1704,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
|
||||||
php_stream_filter_append(&temp->writefilters, filter);
|
php_stream_filter_append(&temp->writefilters, filter);
|
||||||
|
|
||||||
if (SUCCESS != php_stream_copy_to_stream_ex(fp, temp, PHP_STREAM_COPY_ALL, NULL)) {
|
if (SUCCESS != php_stream_copy_to_stream_ex(fp, temp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||||
|
php_stream_filter_remove(filter, 1);
|
||||||
if (err) {
|
if (err) {
|
||||||
php_stream_close(temp);
|
php_stream_close(temp);
|
||||||
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\", ext/zlib is buggy in PHP versions older than 5.2.6")
|
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\", ext/zlib is buggy in PHP versions older than 5.2.6")
|
||||||
|
@ -1750,6 +1751,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
|
||||||
php_stream_filter_append(&temp->writefilters, filter);
|
php_stream_filter_append(&temp->writefilters, filter);
|
||||||
|
|
||||||
if (SUCCESS != php_stream_copy_to_stream_ex(fp, temp, PHP_STREAM_COPY_ALL, NULL)) {
|
if (SUCCESS != php_stream_copy_to_stream_ex(fp, temp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||||
|
php_stream_filter_remove(filter, 1);
|
||||||
php_stream_close(temp);
|
php_stream_close(temp);
|
||||||
MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file")
|
MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file")
|
||||||
}
|
}
|
||||||
|
@ -2833,6 +2835,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
|
||||||
}
|
}
|
||||||
entry->cfp = shared_cfp;
|
entry->cfp = shared_cfp;
|
||||||
if (!entry->cfp) {
|
if (!entry->cfp) {
|
||||||
|
php_stream_filter_free(filter);
|
||||||
if (error) {
|
if (error) {
|
||||||
spprintf(error, 0, "unable to create temporary file");
|
spprintf(error, 0, "unable to create temporary file");
|
||||||
}
|
}
|
||||||
|
@ -2847,6 +2850,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
|
||||||
entry->header_offset = php_stream_tell(entry->cfp);
|
entry->header_offset = php_stream_tell(entry->cfp);
|
||||||
php_stream_flush(file);
|
php_stream_flush(file);
|
||||||
if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
|
if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
|
||||||
|
php_stream_filter_free(filter);
|
||||||
if (closeoldfile) {
|
if (closeoldfile) {
|
||||||
php_stream_close(oldfile);
|
php_stream_close(oldfile);
|
||||||
}
|
}
|
||||||
|
@ -2858,6 +2862,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int conv
|
||||||
}
|
}
|
||||||
php_stream_filter_append((&entry->cfp->writefilters), filter);
|
php_stream_filter_append((&entry->cfp->writefilters), filter);
|
||||||
if (SUCCESS != php_stream_copy_to_stream_ex(file, entry->cfp, entry->uncompressed_filesize, NULL)) {
|
if (SUCCESS != php_stream_copy_to_stream_ex(file, entry->cfp, entry->uncompressed_filesize, NULL)) {
|
||||||
|
php_stream_filter_remove(filter, 1);
|
||||||
if (closeoldfile) {
|
if (closeoldfile) {
|
||||||
php_stream_close(oldfile);
|
php_stream_close(oldfile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -642,6 +642,7 @@ foundit:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entry.uncompressed_filesize || !actual_alias) {
|
if (!entry.uncompressed_filesize || !actual_alias) {
|
||||||
|
php_stream_filter_remove(filter, 1);
|
||||||
pefree(entry.filename, entry.is_persistent);
|
pefree(entry.filename, entry.is_persistent);
|
||||||
PHAR_ZIP_FAIL("unable to read in alias, truncated");
|
PHAR_ZIP_FAIL("unable to read in alias, truncated");
|
||||||
}
|
}
|
||||||
|
@ -674,6 +675,7 @@ foundit:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entry.uncompressed_filesize || !actual_alias) {
|
if (!entry.uncompressed_filesize || !actual_alias) {
|
||||||
|
php_stream_filter_remove(filter, 1);
|
||||||
pefree(entry.filename, entry.is_persistent);
|
pefree(entry.filename, entry.is_persistent);
|
||||||
PHAR_ZIP_FAIL("unable to read in alias, truncated");
|
PHAR_ZIP_FAIL("unable to read in alias, truncated");
|
||||||
}
|
}
|
||||||
|
@ -968,6 +970,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{
|
||||||
entry->cfp = php_stream_fopen_tmpfile();
|
entry->cfp = php_stream_fopen_tmpfile();
|
||||||
|
|
||||||
if (!entry->cfp) {
|
if (!entry->cfp) {
|
||||||
|
php_stream_filter_free(filter);
|
||||||
spprintf(p->error, 0, "unable to create temporary file for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
|
spprintf(p->error, 0, "unable to create temporary file for file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
|
||||||
return ZEND_HASH_APPLY_STOP;
|
return ZEND_HASH_APPLY_STOP;
|
||||||
}
|
}
|
||||||
|
@ -975,6 +978,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{
|
||||||
php_stream_flush(efp);
|
php_stream_flush(efp);
|
||||||
|
|
||||||
if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
|
if (-1 == phar_seek_efp(entry, 0, SEEK_SET, 0, 0)) {
|
||||||
|
php_stream_filter_free(filter);
|
||||||
spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
|
spprintf(p->error, 0, "unable to seek to start of file \"%s\" to zip-based phar \"%s\"", entry->filename, entry->phar->fname);
|
||||||
return ZEND_HASH_APPLY_STOP;
|
return ZEND_HASH_APPLY_STOP;
|
||||||
}
|
}
|
||||||
|
@ -982,6 +986,7 @@ static int phar_zip_changed_apply_int(phar_entry_info *entry, void *arg) /* {{{
|
||||||
php_stream_filter_append((&entry->cfp->writefilters), filter);
|
php_stream_filter_append((&entry->cfp->writefilters), filter);
|
||||||
|
|
||||||
if (SUCCESS != php_stream_copy_to_stream_ex(efp, entry->cfp, entry->uncompressed_filesize, NULL)) {
|
if (SUCCESS != php_stream_copy_to_stream_ex(efp, entry->cfp, entry->uncompressed_filesize, NULL)) {
|
||||||
|
php_stream_filter_remove(filter, 1);
|
||||||
spprintf(p->error, 0, "unable to copy compressed file contents of file \"%s\" while creating new phar \"%s\"", entry->filename, entry->phar->fname);
|
spprintf(p->error, 0, "unable to copy compressed file contents of file \"%s\" while creating new phar \"%s\"", entry->filename, entry->phar->fname);
|
||||||
return ZEND_HASH_APPLY_STOP;
|
return ZEND_HASH_APPLY_STOP;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue