Commit f59f30cbc53 for php
commit f59f30cbc534137ef607c5e1228e0baa67392ffa
Merge: 0206272ec24 edfc0da2dfd
Author: David Carlier <devnexen@gmail.com>
Date: Mon Nov 23 20:49:01 2026 +0000
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/phar: unset() of an entry with an open handle use-after-free.
# Conflicts:
# ext/phar/phar.c
diff --cc ext/phar/phar.c
index d85a2c2d2df,1bdc2d80336..202bea30d62
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@@ -427,10 -493,8 +493,8 @@@ void phar_entry_remove(phar_entry_data
phar = idata->phar;
if (idata->internal_file->fp_refcount < 2 && idata->internal_file->fileinfo_lock_count == 0) {
- if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) {
- php_stream_close(idata->fp);
- }
+ phar_entry_data_release_fp(idata);
- zend_hash_str_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len);
+ zend_hash_del(&idata->phar->manifest, idata->internal_file->filename);
idata->phar->refcount--;
efree(idata);
} else {
@@@ -2689,21 -2743,9 +2751,9 @@@ int phar_flush_ex(phar_archive_data *ph
/* remove this from the new phar */
continue;
}
- if (entry->fp_refcount) {
- /* open file pointers refer to this fp, do not free the stream */
- switch (entry->fp_type) {
- case PHAR_FP:
- free_fp = false;
- break;
- case PHAR_UFP:
- free_ufp = false;
- default:
- break;
- }
- }
/* after excluding deleted files, calculate manifest size in bytes and number of entries */
++new_manifest_count;
- phar_add_virtual_dirs(phar, entry->filename, entry->filename_len);
+ phar_add_virtual_dirs(phar, ZSTR_VAL(entry->filename), ZSTR_LEN(entry->filename));
if (entry->is_dir) {
/* we use this to calculate API version, 1.1.1 is used for phars with directories */
diff --cc ext/phar/zip.c
index 31bc464d19e,de294c9cde7..cca65b31908
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@@ -1142,21 -1140,9 +1141,9 @@@ continue_dir
entry->is_modified = 0;
} else {
entry->is_modified = 0;
- if (entry->fp_refcount) {
- /* open file pointers refer to this fp, do not free the stream */
- switch (entry->fp_type) {
- case PHAR_FP:
- p->free_fp = 0;
- break;
- case PHAR_UFP:
- p->free_ufp = 0;
- default:
- break;
- }
- }
if (!entry->is_dir && entry->compressed_filesize && (!p->old || SUCCESS != php_stream_copy_to_stream_ex(p->old, p->filefp, entry->compressed_filesize, NULL))) {
- spprintf(p->error, 0, "unable to copy contents of file \"%s\" while creating zip-based phar \"%s\"", entry->filename, entry->phar->fname);
+ spprintf(p->error, 0, "unable to copy contents of file \"%s\" while creating zip-based phar \"%s\"", ZSTR_VAL(entry->filename), entry->phar->fname);
return ZEND_HASH_APPLY_STOP;
}
}