blob: f258b77e110e6bc7e6cd639aed50107ff3ca0e72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
Backported from 5.5 for 5.4 by Remi Collet
From 285cd3417fb61597345b829f5f573707bbdcd484 Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Wed, 13 Jan 2016 16:43:04 -0800
Subject: [PATCH] Fix bug #71335: Type Confusion in WDDX Packet Deserialization
---
ext/wddx/tests/bug71335.phpt | 33 +++++++++++++++++++++++++++++++++
ext/wddx/wddx.c | 3 ++-
2 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 ext/wddx/tests/bug71335.phpt
diff --git a/ext/wddx/tests/bug71335.phpt b/ext/wddx/tests/bug71335.phpt
new file mode 100644
index 0000000..57a7f14
--- /dev/null
+++ b/ext/wddx/tests/bug71335.phpt
@@ -0,0 +1,33 @@
+--TEST--
+Bug #71335 (Type Confusion in WDDX Packet Deserialization)
+--SKIPIF--
+<?php
+if (!extension_loaded("wddx")) print "skip";
+?>
+--FILE--
+<?php
+$x = "<?xml version='1.0'?>
+<wddxPacket version='1.0'>
+<header/>
+ <data>
+ <struct>
+ <var name='php_class_name'>
+ <string>stdClass</string>
+ </var>
+ <var name='php_class_name'>
+ <string>stdClass</string>
+ </var>
+ </struct>
+ </data>
+</wddxPacket>";
+
+$d = wddx_deserialize($x);
+var_dump($d);
+?>
+DONE
+--EXPECTF--
+object(stdClass)#%d (1) {
+ ["php_class_name"]=>
+ string(8) "stdClass"
+}
+DONE
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index b9dd1fa..7267ee1 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -978,7 +978,8 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
if (ent1->varname) {
if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&
- Z_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) && ent2->type == ST_STRUCT) {
+ Z_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&
+ ent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {
zend_bool incomplete_class = 0;
zend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));
|