File php-CVE-2015-0273.patch of Package php5
https://bugs.php.net/patch-display.php?bug=68942&patch=patch-5.5&revision=1422773779
commit 3e7a35a48fad013d7ad32b836d70f1604dff6747
Author: Stanislav Malyshev <stas@php.net>
Date: Sat Jan 31 22:40:08 2015 -0800
Fix bug #68942 (Use after free vulnerability in unserialize() with DateTimeZone)
Index: ext/date/php_date.c
===================================================================
--- ext/date/php_date.c.orig 2014-10-01 11:17:38.000000000 +0200
+++ ext/date/php_date.c 2015-02-25 10:18:24.768104857 +0100
@@ -2804,12 +2804,9 @@
timelib_tzinfo *tzi;
php_timezone_obj *tzobj;
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
- convert_to_string(*z_date);
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- convert_to_long(*z_timezone_type);
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_string(*z_timezone);
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
switch (Z_LVAL_PP(z_timezone_type)) {
case TIMELIB_ZONETYPE_OFFSET:
@@ -2824,7 +2821,6 @@
case TIMELIB_ZONETYPE_ID: {
int ret;
- convert_to_string(*z_timezone);
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
@@ -3740,9 +3736,8 @@
zval **z_timezone = NULL;
zval **z_timezone_type = NULL;
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
- convert_to_long(*z_timezone_type);
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
return SUCCESS;
}
@@ -3767,7 +3762,9 @@
php_date_instantiate(date_ce_timezone, return_value TSRMLS_CC);
tzobj = (php_timezone_obj *) zend_object_store_get_object(return_value TSRMLS_CC);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */
@@ -3783,7 +3780,9 @@
myht = Z_OBJPROP_P(object);
- php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC);
+ if(php_date_timezone_initialize_from_hash(&return_value, &tzobj, myht TSRMLS_CC) != SUCCESS) {
+ php_error_docref(NULL, E_ERROR, "Timezone initialization failed");
+ }
}
/* }}} */