mirror of
https://github.com/php/php-src.git
synced 2026-04-24 08:28:26 +02:00
Fix bug #68942 (Use after free vulnerability in unserialize() with DateTimeZone)
This commit is contained in:
@@ -39,6 +39,8 @@ PHP NEWS
|
||||
(Danack at basereality dot com)
|
||||
. Fixed bug #68925 (Mitigation for CVE-2015-0235 – GHOST: glibc gethostbyname
|
||||
buffer overflow). (Stas)
|
||||
. Fixed bug #68942 (Use after free vulnerability in unserialize() with
|
||||
DateTimeZone). (Stas)
|
||||
|
||||
- Date:
|
||||
. Fixed bug #45081 (strtotime incorrectly interprets SGT time zone). (Derick)
|
||||
|
||||
+10
-11
@@ -2779,12 +2779,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
|
||||
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:
|
||||
@@ -2799,7 +2796,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
|
||||
|
||||
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);
|
||||
|
||||
@@ -3716,9 +3712,8 @@ static int php_date_timezone_initialize_from_hash(zval **return_value, php_timez
|
||||
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_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) {
|
||||
convert_to_long(*z_timezone_type);
|
||||
if (SUCCESS == timezone_initialize(*tzobj, Z_STRVAL_PP(z_timezone) TSRMLS_CC)) {
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -3743,7 +3738,9 @@ PHP_METHOD(DateTimeZone, __set_state)
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -3759,7 +3756,9 @@ PHP_METHOD(DateTimeZone, __wakeup)
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Bug #68942 (Use after free vulnerability in unserialize() with DateTimeZone).
|
||||
--FILE--
|
||||
<?php
|
||||
$data = unserialize('a:2:{i:0;O:12:"DateTimeZone":2:{s:13:"timezone_type";a:2:{i:0;i:1;i:1;i:2;}s:8:"timezone";s:1:"A";}i:1;R:4;}');
|
||||
var_dump($data);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: DateTimeZone::__wakeup(): Timezone initialization failed in %s/bug68942.php on line %d
|
||||
@@ -0,0 +1,9 @@
|
||||
--TEST--
|
||||
Bug #68942 (Use after free vulnerability in unserialize() with DateTime).
|
||||
--FILE--
|
||||
<?php
|
||||
$data = unserialize('a:2:{i:0;O:8:"DateTime":3:{s:4:"date";s:26:"2000-01-01 00:00:00.000000";s:13:"timezone_type";a:2:{i:0;i:1;i:1;i:2;}s:8:"timezone";s:1:"A";}i:1;R:5;}');
|
||||
var_dump($data);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Invalid serialization data for DateTime object in %s/bug68942_2.php on line %d
|
||||
Reference in New Issue
Block a user