Skip to content

Commit 266ecb6

Browse files
committed
Fix bug #73631 - Invalid read when wddx decodes empty boolean element
1 parent cf24961 commit 266ecb6

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ PHP NEWS
99
. Fixed bug #68447 (grapheme_extract take an extra trailing character).
1010
(SATŌ Kentarō)
1111

12+
- WDDX:
13+
. Fixed bug #73631 (Memory leak due to invalid wddx stack processing).
14+
(bughunter at fosec dot vn).
15+
1216
08 Dec 2016, PHP 5.6.29
1317

1418
- Mbstring:

ext/wddx/tests/bug73631.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #73631 (Memory leak due to invalid wddx stack processing)
3+
--SKIPIF--
4+
<?php if (!extension_loaded("wddx")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$xml = <<<EOF
8+
<?xml version="1.0" ?>
9+
<wddxPacket version="1.0">
10+
<number>1234</number>
11+
<binary><boolean/></binary>
12+
</wddxPacket>
13+
EOF;
14+
$wddx = wddx_deserialize($xml);
15+
var_dump($wddx);
16+
?>
17+
--EXPECTF--
18+
int(1234)
19+

ext/wddx/wddx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,11 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
811811
php_wddx_process_data(user_data, atts[i+1], strlen(atts[i+1]));
812812
break;
813813
}
814+
} else {
815+
ent.type = ST_BOOLEAN;
816+
SET_STACK_VARNAME;
817+
ZVAL_FALSE(&ent.data);
818+
wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
814819
}
815820
} else if (!strcmp(name, EL_NULL)) {
816821
ent.type = ST_NULL;

0 commit comments

Comments
 (0)