You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

63 lines
1.8 KiB

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
[roberto@debian.org: backported to 5.4.45]
Bug: https://bugs.php.net/bug.php?id=71335
Origin: backport, https://git.php.net/?p=php-src.git;a=commitdiff;h=285cd3417fb61597345b829f5f573707bbdcd484
---
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
--- /dev/null
+++ php5.git/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
--- php5.git.orig/ext/wddx/wddx.c
+++ php5.git/ext/wddx/wddx.c
@@ -998,7 +998,8 @@
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));