[Pkg-php-commits] [php/debian-sid] Avoid possible memory dumps via PG on restored ini values (Closes: #540605)

Raphael Geissert geissert at debian.org
Thu Aug 13 19:35:24 UTC 2009


Patch cherry-picked from upstream.
Thanks to Michael S. Gilbert for the report.
---
 debian/patches/check_ini_on_modify_status.patch |   26 +++++++++++++++++++++++
 debian/patches/series                           |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)
 create mode 100644 debian/patches/check_ini_on_modify_status.patch

diff --git a/debian/patches/check_ini_on_modify_status.patch b/debian/patches/check_ini_on_modify_status.patch
new file mode 100644
index 0000000..e433317
--- /dev/null
+++ b/debian/patches/check_ini_on_modify_status.patch
@@ -0,0 +1,26 @@
+Index: php/Zend/zend_ini.c
+===================================================================
+--- php.orig/Zend/zend_ini.c
++++ php/Zend/zend_ini.c
+@@ -46,15 +46,20 @@ static int zend_remove_ini_entries(zend_
+ 
+ static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS_DC) /* {{{ */
+ {
++	int result = FAILURE;
+ 	if (ini_entry->modified) {
+ 		if (ini_entry->on_modify) {
+ 			zend_try {
+ 			/* even if on_modify bails out, we have to continue on with restoring,
+ 				since there can be allocated variables that would be freed on MM shutdown
+ 				and would lead to memory corruption later ini entry is modified again */
+-				ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC);
++				result = ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC);
+ 			} zend_end_try();
+ 		}
++		if(stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE) {
++			/* runtime failure is OK */
++			return 1;
++		}
+ 		if (ini_entry->value != ini_entry->orig_value) {
+ 			efree(ini_entry->value);
+ 		}
diff --git a/debian/patches/series b/debian/patches/series
index cd49127..e78f3c5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -40,3 +40,4 @@ mssql-null-exception.patch
 exif_read_data-segfault.patch
 sybase-alias.patch
 strcmp_null-OnUpdateErrorLog.patch
+check_ini_on_modify_status.patch
-- 
1.5.6.5




More information about the Pkg-php-commits mailing list