Skip to content

Commit 8693bae

Browse files
committed
Merge branch 'PHP-5.3' into PHP-5.4
2 parents ebefbdb + 8b87c6d commit 8693bae

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

ext/date/php_date.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,16 +2467,19 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat
24672467
if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
24682468
convert_to_long(*z_timezone_type);
24692469
if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
2470+
zend_error_handling error_handling;
2471+
2472+
zend_replace_error_handling(EH_THROW, NULL, &error_handling TSRMLS_CC);
24702473
convert_to_string(*z_timezone);
24712474

24722475
switch (Z_LVAL_PP(z_timezone_type)) {
24732476
case TIMELIB_ZONETYPE_OFFSET:
24742477
case TIMELIB_ZONETYPE_ABBR: {
24752478
char *tmp = emalloc(Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2);
24762479
snprintf(tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 2, "%s %s", Z_STRVAL_PP(z_date), Z_STRVAL_PP(z_timezone));
2477-
php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 0 TSRMLS_CC);
2480+
php_date_initialize(*dateobj, tmp, Z_STRLEN_PP(z_date) + Z_STRLEN_PP(z_timezone) + 1, NULL, NULL, 1 TSRMLS_CC);
24782481
efree(tmp);
2479-
return 1;
2482+
break;
24802483
}
24812484

24822485
case TIMELIB_ZONETYPE_ID:
@@ -2490,10 +2493,15 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat
24902493
tzobj->tzi.tz = tzi;
24912494
tzobj->initialized = 1;
24922495

2493-
php_date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 0 TSRMLS_CC);
2496+
php_date_initialize(*dateobj, Z_STRVAL_PP(z_date), Z_STRLEN_PP(z_date), NULL, tmp_obj, 1 TSRMLS_CC);
24942497
zval_ptr_dtor(&tmp_obj);
2495-
return 1;
2498+
break;
2499+
default:
2500+
zend_restore_error_handling(&error_handling TSRMLS_CC);
2501+
return 0;
24962502
}
2503+
zend_restore_error_handling(&error_handling TSRMLS_CC);
2504+
return 1;
24972505
}
24982506
}
24992507
}

ext/date/tests/bug62852.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #62852 (Unserialize invalid DateTime causes crash)
3+
--INI--
4+
date.timezone=GMT
5+
--FILE--
6+
<?php
7+
try {
8+
$datetime = unserialize('O:8:"DateTime":3:{s:4:"date";s:20:"10007-06-07 03:51:49";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}');
9+
var_dump($datetime);
10+
} catch (Exception $e) {
11+
var_dump($e->getMessage());
12+
}
13+
?>
14+
--EXPECTF--
15+
string(%d) "DateTime::__wakeup(): Failed to parse time string (%s) at position 12 (0): Double time specification"

0 commit comments

Comments
 (0)