tony2001 Tue Oct 4 07:19:11 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src NEWS
/php-src/ext/xmlrpc xmlrpc-epi-php.c
Log:
MHB5.1: fix #32179 (xmlrpc_encode() segfaults with recursive references)
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1760.2.488&r2=1.1760.2.489&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1760.2.488 php-src/NEWS:1.1760.2.489
--- php-src/NEWS:1.1760.2.488 Mon Oct 3 05:13:58 2005
+++ php-src/NEWS Tue Oct 4 07:19:10 2005
@@ -14,6 +14,7 @@
- Fixed bug #34449 (ext/soap: XSD_ANYXML functionality not exposed). (Dmitry)
- Fixed bug #34199 (if($obj)/if(!$obj) inconsistency because of cast handler).
(Dmitry, Alex)
+- Fixed bug #32179 (xmlrpc_encode() segfaults with recursive references).
(Tony)
05 Sep 2005, PHP 5.0.5
- Upgraded PCRE library to version 5.0. (Andrei)
http://cvs.php.net/diff.php/php-src/ext/xmlrpc/xmlrpc-epi-php.c?r1=1.37&r2=1.37.2.1&ty=u
Index: php-src/ext/xmlrpc/xmlrpc-epi-php.c
diff -u php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.37
php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.37.2.1
--- php-src/ext/xmlrpc/xmlrpc-epi-php.c:1.37 Thu Jan 8 03:17:47 2004
+++ php-src/ext/xmlrpc/xmlrpc-epi-php.c Tue Oct 4 07:19:11 2005
@@ -51,7 +51,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xmlrpc-epi-php.c,v 1.37 2004/01/08 08:17:47 andi Exp $ */
+/* $Id: xmlrpc-epi-php.c,v 1.37.2.1 2005/10/04 11:19:11 tony2001 Exp $ */
/**********************************************************************
* BUGS: *
@@ -520,28 +520,41 @@
unsigned long num_index;
zval** pIter;
char* my_key;
+ HashTable *ht = NULL;
+ ht = HASH_OF(val);
+ if (ht && ht->nApplyCount > 1) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "XML-RPC
doesn't support circular references");
+ return NULL;
+ }
+
convert_to_array(val);
-
xReturn = XMLRPC_CreateVector(key,
determine_vector_type(Z_ARRVAL_P(val)));
zend_hash_internal_pointer_reset(Z_ARRVAL_P(val));
- while(1) {
+ while(zend_hash_get_current_data(Z_ARRVAL_P(val),
(void**)&pIter) == SUCCESS) {
int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val),
&my_key, &num_index);
- if(res == HASH_KEY_IS_LONG) {
- if(zend_hash_get_current_data(Z_ARRVAL_P(val),
(void**)&pIter) == SUCCESS) {
- XMLRPC_AddValueToVector(xReturn,
PHP_to_XMLRPC_worker(0, *pIter, depth++));
- }
- }
- else if(res == HASH_KEY_NON_EXISTANT) {
- break;
+
+ switch (res) {
+ case HASH_KEY_NON_EXISTANT:
+ break;
+ case HASH_KEY_IS_STRING:
+ case HASH_KEY_IS_LONG:
+ ht = HASH_OF(*pIter);
+ if (ht) {
+ ht->nApplyCount++;
+ }
+ if (res == HASH_KEY_IS_LONG) {
+ XMLRPC_AddValueToVector(xReturn,
PHP_to_XMLRPC_worker(0, *pIter, depth++));
+ }
+ else {
+ XMLRPC_AddValueToVector(xReturn,
PHP_to_XMLRPC_worker(my_key, *pIter, depth++));
+ }
+ if (ht) {
+ ht->nApplyCount--;
+ }
+ break;
}
- else if(res == HASH_KEY_IS_STRING) {
- if(zend_hash_get_current_data(Z_ARRVAL_P(val),
(void**)&pIter) == SUCCESS) {
- XMLRPC_AddValueToVector(xReturn,
PHP_to_XMLRPC_worker(my_key, *pIter, depth++));
- }
- }
-
zend_hash_move_forward(Z_ARRVAL_P(val));
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php