From: Stanislav Malyshev Date: Thu, 11 Aug 2016 06:43:56 +0000 (-0700) Subject: Fix for bug #72790 and bug #72799 X-Git-Tag: php-5.6.26RC1~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a34bd6d1e6b4d31221c50bcf477c9508553a646;p=php Fix for bug #72790 and bug #72799 --- diff --git a/ext/wddx/tests/bug72790.phpt b/ext/wddx/tests/bug72790.phpt new file mode 100644 index 0000000000..a60524bdaf --- /dev/null +++ b/ext/wddx/tests/bug72790.phpt @@ -0,0 +1,35 @@ +--TEST-- +Bug 72790: wddx_deserialize null dereference with invalid xml +--SKIPIF-- + +--FILE-- + + + + |array> + + + + + + + + + + + + +XML; + +$array = wddx_deserialize($xml); +var_dump($array); +?> +--EXPECT-- +NULL \ No newline at end of file diff --git a/ext/wddx/tests/bug72799.phpt b/ext/wddx/tests/bug72799.phpt new file mode 100644 index 0000000000..5861d5538f --- /dev/null +++ b/ext/wddx/tests/bug72799.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #72799: wddx_deserialize null dereference in php_wddx_pop_element +--SKIPIF-- + +--FILE-- + + + + + + 1998-06-12T04:32:12+00 + + + +XML; + +$array = wddx_deserialize($xml); +var_dump($array); +?> +--EXPECT-- +NULL \ No newline at end of file diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c index 1b2d103af1..d7bd295832 100644 --- a/ext/wddx/wddx.c +++ b/ext/wddx/wddx.c @@ -946,10 +946,10 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) if (!ent1->data) { if (stack->top > 1) { stack->top--; + efree(ent1); } else { stack->done = 1; } - efree(ent1); return; } @@ -988,7 +988,7 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name) wddx_stack_top(stack, (void**)&ent2); /* if non-existent field */ - if (ent2->type == ST_FIELD && ent2->data == NULL) { + if (ent2->data == NULL) { zval_ptr_dtor(&ent1->data); efree(ent1); return; @@ -1179,9 +1179,13 @@ int php_wddx_deserialize_ex(char *value, int vallen, zval *return_value) if (stack.top == 1) { wddx_stack_top(&stack, (void**)&ent); - *return_value = *(ent->data); - zval_copy_ctor(return_value); - retval = SUCCESS; + if(ent->data == NULL) { + retval = FAILURE; + } else { + *return_value = *(ent->data); + zval_copy_ctor(return_value); + retval = SUCCESS; + } } else { retval = FAILURE; }