|
|
20017b |
From 7b1898183032eeabc64a086ff040af991cebcd93 Mon Sep 17 00:00:00 2001
|
|
|
20017b |
From: Stanislav Malyshev <stas@php.net>
|
|
|
20017b |
Date: Sat, 31 Jan 2015 22:40:08 -0800
|
|
|
20017b |
Subject: [PATCH] Fix bug #68942 (Use after free vulnerability in unserialize()
|
|
|
20017b |
with DateTimeZone)
|
|
|
20017b |
|
|
|
20017b |
Conflicts:
|
|
|
20017b |
ext/date/php_date.c
|
|
|
20017b |
---
|
|
|
20017b |
ext/date/php_date.c | 10 +++-------
|
|
|
20017b |
ext/date/tests/bug68942_2.phpt | 9 +++++++++
|
|
|
20017b |
2 files changed, 12 insertions(+), 7 deletions(-)
|
|
|
20017b |
create mode 100644 ext/date/tests/bug68942_2.phpt
|
|
|
20017b |
|
|
|
20017b |
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
|
|
|
20017b |
index 92e9480..08bfd08 100644
|
|
|
20017b |
--- a/ext/date/php_date.c
|
|
|
20017b |
+++ b/ext/date/php_date.c
|
|
|
20017b |
@@ -2521,12 +2521,9 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
|
|
|
20017b |
timelib_tzinfo *tzi;
|
|
|
20017b |
php_timezone_obj *tzobj;
|
|
|
20017b |
|
|
|
20017b |
- if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS) {
|
|
|
20017b |
- convert_to_string(*z_date);
|
|
|
20017b |
- if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS) {
|
|
|
20017b |
- convert_to_long(*z_timezone_type);
|
|
|
20017b |
- if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS) {
|
|
|
20017b |
- convert_to_string(*z_timezone);
|
|
|
20017b |
+ if (zend_hash_find(myht, "date", 5, (void**) &z_date) == SUCCESS && Z_TYPE_PP(z_date) == IS_STRING) {
|
|
|
20017b |
+ if (zend_hash_find(myht, "timezone_type", 14, (void**) &z_timezone_type) == SUCCESS && Z_TYPE_PP(z_timezone_type) == IS_LONG) {
|
|
|
20017b |
+ if (zend_hash_find(myht, "timezone", 9, (void**) &z_timezone) == SUCCESS && Z_TYPE_PP(z_timezone) == IS_STRING) {
|
|
|
20017b |
|
|
|
20017b |
switch (Z_LVAL_PP(z_timezone_type)) {
|
|
|
20017b |
case TIMELIB_ZONETYPE_OFFSET:
|
|
|
20017b |
@@ -2541,7 +2538,6 @@ static int php_date_initialize_from_hash(php_date_obj **dateobj, HashTable *myht
|
|
|
20017b |
|
|
|
20017b |
case TIMELIB_ZONETYPE_ID: {
|
|
|
20017b |
int ret;
|
|
|
20017b |
- convert_to_string(*z_timezone);
|
|
|
20017b |
|
|
|
20017b |
tzi = php_date_parse_tzfile(Z_STRVAL_PP(z_timezone), DATE_TIMEZONEDB TSRMLS_CC);
|
|
|
20017b |
|
|
|
20017b |
diff --git a/ext/date/tests/bug68942_2.phpt b/ext/date/tests/bug68942_2.phpt
|
|
|
20017b |
new file mode 100644
|
|
|
20017b |
index 0000000..5b02567
|
|
|
20017b |
--- /dev/null
|
|
|
20017b |
+++ b/ext/date/tests/bug68942_2.phpt
|
|
|
20017b |
@@ -0,0 +1,9 @@
|
|
|
20017b |
+--TEST--
|
|
|
20017b |
+Bug #68942 (Use after free vulnerability in unserialize() with DateTime).
|
|
|
20017b |
+--FILE--
|
|
|
20017b |
+
|
|
|
20017b |
+$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;}');
|
|
|
20017b |
+var_dump($data);
|
|
|
20017b |
+?>
|
|
|
20017b |
+--EXPECTF--
|
|
|
20017b |
+Fatal error: Invalid serialization data for DateTime object in %s/bug68942_2.php on line %d
|
|
|
20017b |
--
|
|
|
20017b |
2.1.4
|
|
|
20017b |
|