Skip to content

Commit 285cd34

Browse files
committed
Fix bug #71335: Type Confusion in WDDX Packet Deserialization
1 parent 635ba1f commit 285cd34

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

ext/wddx/tests/bug71335.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #71335 (Type Confusion in WDDX Packet Deserialization)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("wddx")) print "skip";
6+
?>
7+
--FILE--
8+
<?php
9+
$x = "<?xml version='1.0'?>
10+
<wddxPacket version='1.0'>
11+
<header/>
12+
<data>
13+
<struct>
14+
<var name='php_class_name'>
15+
<string>stdClass</string>
16+
</var>
17+
<var name='php_class_name'>
18+
<string>stdClass</string>
19+
</var>
20+
</struct>
21+
</data>
22+
</wddxPacket>";
23+
24+
$d = wddx_deserialize($x);
25+
var_dump($d);
26+
?>
27+
DONE
28+
--EXPECTF--
29+
object(stdClass)#%d (1) {
30+
["php_class_name"]=>
31+
string(8) "stdClass"
32+
}
33+
DONE

ext/wddx/wddx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,8 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
978978

979979
if (ent1->varname) {
980980
if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&
981-
Z_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) && ent2->type == ST_STRUCT) {
981+
Z_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&
982+
ent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {
982983
zend_bool incomplete_class = 0;
983984

984985
zend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));

0 commit comments

Comments
 (0)