From e201f01ac17243a1e5fb6a3911ed8e21b1619ac1 Mon Sep 17 00:00:00 2001 From: Stanislav Malyshev Date: Mon, 31 Aug 2015 21:06:03 -0700 Subject: [PATCH] Fix bug #70388 - SOAP serialize_function_call() type confusion --- ext/soap/soap.c | 96 ++++++++++++++++++++++++-------------------- ext/soap/tests/bug70388.phpt | 17 ++++++++ 2 files changed, 69 insertions(+), 44 deletions(-) create mode 100644 ext/soap/tests/bug70388.phpt Index: php5-5.6.11+dfsg/ext/soap/soap.c =================================================================== --- php5-5.6.11+dfsg.orig/ext/soap/soap.c 2015-09-25 11:24:30.867490136 -0400 +++ php5-5.6.11+dfsg/ext/soap/soap.c 2015-09-25 11:24:30.863490085 -0400 @@ -2921,8 +2921,10 @@ } zend_hash_internal_pointer_reset(default_headers); while (zend_hash_get_current_data(default_headers, (void**)&tmp) == SUCCESS) { - Z_ADDREF_PP(tmp); - zend_hash_next_index_insert(soap_headers, tmp, sizeof(zval *), NULL); + if(Z_TYPE_PP(tmp) == IS_OBJECT) { + Z_ADDREF_PP(tmp); + zend_hash_next_index_insert(soap_headers, tmp, sizeof(zval *), NULL); + } zend_hash_move_forward(default_headers); } } else { @@ -4346,11 +4348,18 @@ if (head) { zval** header; - zend_hash_internal_pointer_reset(soap_headers); - while (zend_hash_get_current_data(soap_headers,(void**)&header) == SUCCESS) { - HashTable *ht = Z_OBJPROP_PP(header); + for(zend_hash_internal_pointer_reset(soap_headers); + zend_hash_get_current_data(soap_headers,(void**)&header) == SUCCESS; + zend_hash_move_forward(soap_headers) + ) { + HashTable *ht; zval **name, **ns, **tmp; + if (Z_TYPE_PP(header) != IS_OBJECT) { + continue; + } + + ht = Z_OBJPROP_PP(header); if (zend_hash_find(ht, "name", sizeof("name"), (void**)&name) == SUCCESS && Z_TYPE_PP(name) == IS_STRING && zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&ns) == SUCCESS && @@ -4389,7 +4398,6 @@ xmlSetNs(h, nsptr); set_soap_header_attributes(h, ht, version); } - zend_hash_move_forward(soap_headers); } } Index: php5-5.6.11+dfsg/ext/soap/tests/bug70388.phpt =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ php5-5.6.11+dfsg/ext/soap/tests/bug70388.phpt 2015-09-25 11:24:30.863490085 -0400 @@ -0,0 +1,17 @@ +--TEST-- +Bug #70388 (SOAP serialize_function_call() type confusion / RCE) +--SKIPIF-- + +--FILE-- +notexisting()); +} catch(Exception $e) { + var_dump($e->getMessage()); + var_dump(get_class($e)); +} +?> +--EXPECTF-- +string(%d) "%s" +string(9) "SoapFault" \ No newline at end of file