Skip to content

Commit 8c88b6e

Browse files
bor0smalyshev
authored andcommitted
Fix bug #66721
Add NULL check to php_date_parse_tzfile's retval
1 parent 442264f commit 8c88b6e

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ PHP NEWS
1111
. Fixed bug #67024 (getimagesize should recognize BMP files with negative
1212
height). (Gabor Buella)
1313

14+
- Date:
15+
. Fixed bug #66721 (__wakeup of DateTime segfaults when invalid object data is
16+
supplied). (Boro Sitnikovski)
17+
1418
- Embed:
1519
. Fixed bug #65715 (php5embed.lib isn't provided anymore). (Anatol)
1620

ext/date/php_date.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,6 +2587,10 @@ static int php_date_initialize_from_hash(zval **return_value, php_date_obj **dat
25872587

25882588
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
25892589

2590+
if (tzi == NULL) {
2591+
return 0;
2592+
}
2593+
25902594
ALLOC_INIT_ZVAL(tmp_obj);
25912595
tzobj = zend_object_store_get_object(php_date_instantiate(date_ce_timezone, tmp_obj TSRMLS_CC) TSRMLS_CC);
25922596
tzobj->type = TIMELIB_ZONETYPE_ID;

ext/date/tests/bug66721.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Test for bug #66721: __wakeup of DateTime segfaults when invalid object data is supplied
3+
--CREDITS--
4+
Boro Sitnikovski <buritomath@yahoo.com>
5+
--FILE--
6+
<?php
7+
$y = 'O:8:"DateTime":3:{s:4:"date";s:19:"2014-02-15 02:00:51";s:13:"timezone_type";i:3;s:8:"timezone";s:10:"1234567890";}';
8+
var_dump(unserialize($y));
9+
?>
10+
--EXPECTF--
11+
Fatal error: Invalid serialization data for DateTime object in %s on line %d

0 commit comments

Comments
 (0)