b74969
From 51856a76f87ecb24fe1385342be43610fb6c86e4 Mon Sep 17 00:00:00 2001
b74969
From: Dmitry Stogov <dmitry@zend.com>
b74969
Date: Thu, 19 Mar 2015 11:36:01 +0300
b74969
Subject: [PATCH] Fixed bug #69152
b74969
b74969
---
b74969
 ext/soap/soap.c | 6 ++++++
b74969
 1 file changed, 6 insertions(+)
b74969
b74969
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
b74969
index d460c17..41aa1ad 100644
b74969
--- a/ext/soap/soap.c
b74969
+++ b/ext/soap/soap.c
b74969
@@ -919,6 +919,12 @@ PHP_METHOD(SoapFault, __toString)
b74969
 
b74969
 	zend_call_function(&fci, NULL TSRMLS_CC);
b74969
 
b74969
+	convert_to_string(faultcode);
b74969
+	convert_to_string(faultstring);
b74969
+	convert_to_string(file);
b74969
+	convert_to_long(line);
b74969
+	convert_to_string(trace);
b74969
+
b74969
 	len = spprintf(&str, 0, "SoapFault exception: [%s] %s in %s:%ld\nStack trace:\n%s",
b74969
 	               Z_STRVAL_P(faultcode), Z_STRVAL_P(faultstring), Z_STRVAL_P(file), Z_LVAL_P(line),
b74969
 	               Z_STRLEN_P(trace) ? Z_STRVAL_P(trace) : "#0 {main}\n");
b74969
-- 
b74969
2.1.4
b74969
b74969
From fb83c76deec58f1fab17c350f04c9f042e5977d1 Mon Sep 17 00:00:00 2001
b74969
From: Stanislav Malyshev <stas@php.net>
b74969
Date: Sun, 22 Mar 2015 18:17:47 -0700
b74969
Subject: [PATCH] Check that the type is correct
b74969
b74969
---
b74969
 ext/standard/incomplete_class.c | 2 +-
b74969
 1 file changed, 1 insertion(+), 1 deletion(-)
b74969
b74969
diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c
b74969
index 1816ac4..30c82e6 100644
b74969
--- a/ext/standard/incomplete_class.c
b74969
+++ b/ext/standard/incomplete_class.c
b74969
@@ -144,7 +144,7 @@ PHPAPI char *php_lookup_class_name(zval *object, zend_uint *nlen)
b74969
 
b74969
 	object_properties = Z_OBJPROP_P(object);
b74969
 
b74969
-	if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS) {
b74969
+	if (zend_hash_find(object_properties, MAGIC_MEMBER, sizeof(MAGIC_MEMBER), (void **) &val) == SUCCESS && Z_TYPE_PP(val) == IS_STRING) {
b74969
 		retval = estrndup(Z_STRVAL_PP(val), Z_STRLEN_PP(val));
b74969
 
b74969
 		if (nlen) {
b74969
-- 
b74969
2.1.4
b74969
b74969
From a894a8155fab068d68a04bf181dbaddfa01ccbb0 Mon Sep 17 00:00:00 2001
b74969
From: Stanislav Malyshev <stas@php.net>
b74969
Date: Sun, 5 Apr 2015 17:30:59 -0700
b74969
Subject: [PATCH] More fixes for bug #69152
b74969
b74969
---
b74969
 Zend/zend_exceptions.c                     |  3 +++
b74969
 ext/standard/tests/serialize/bug69152.phpt | 16 ++++++++++++++++
b74969
 2 files changed, 19 insertions(+)
b74969
 create mode 100644 ext/standard/tests/serialize/bug69152.phpt
b74969
b74969
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
b74969
index bf90ae7..1ca2ead 100644
b74969
--- a/Zend/zend_exceptions.c
b74969
+++ b/Zend/zend_exceptions.c
b74969
@@ -536,6 +536,9 @@ ZEND_METHOD(exception, getTraceAsString)
b74969
 	str = &res;
b74969
 
b74969
 	trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
b74969
+	if(Z_TYPE_P(trace) != IS_ARRAY) {
b74969
+		RETURN_FALSE;
b74969
+	}
b74969
 	zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)_build_trace_string, 3, str, len, &num);
b74969
 
b74969
 	s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 7 + 1);
b74969
diff --git a/ext/standard/tests/serialize/bug69152.phpt b/ext/standard/tests/serialize/bug69152.phpt
b74969
new file mode 100644
b74969
index 0000000..4e74168
b74969
--- /dev/null
b74969
+++ b/ext/standard/tests/serialize/bug69152.phpt
b74969
@@ -0,0 +1,16 @@
b74969
+--TEST--
b74969
+Bug #69152: Type Confusion Infoleak Vulnerability in unserialize()
b74969
+--FILE--
b74969
+
b74969
+$x = unserialize('O:9:"exception":1:{s:16:"'."\0".'Exception'."\0".'trace";s:4:"ryat";}');
b74969
+echo $x;
b74969
+$x =  unserialize('O:4:"test":1:{s:27:"__PHP_Incomplete_Class_Name";R:1;}');
b74969
+$x->test();
b74969
+
b74969
+?>
b74969
+--EXPECTF--
b74969
+exception 'Exception' in %s:%d
b74969
+Stack trace:
b74969
+#0 {main}
b74969
+
b74969
+Fatal error: main(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "unknown" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition  in %s on line %d
b74969
-- 
b74969
2.1.4
b74969