cvs: php-src(PHP_5_0) /ext/wddx wddx.c
| From: | Dmitry Stogov | Date: | Mon, 11 Apr 2005 11:58:36 +0000 |
| Subject: | cvs: php-src(PHP_5_0) /ext/wddx wddx.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-31347@lists.php.net to get a copy of this message | ||
dmitry Mon Apr 11 07:58:36 2005 EDT
Modified files: (Branch: PHP_5_0)
/php-src/ext/wddx wddx.c
Log:
Fixed SIGSEGV on serializing data with circular references
http://cvs.php.net/diff.php/php-src/ext/wddx/wddx.c?r1=1.111.2.1&r2=1.111.2.2&ty=u
Index: php-src/ext/wddx/wddx.c
diff -u php-src/ext/wddx/wddx.c:1.111.2.1 php-src/ext/wddx/wddx.c:1.111.2.2
--- php-src/ext/wddx/wddx.c:1.111.2.1 Mon Apr 11 05:28:11 2005
+++ php-src/ext/wddx/wddx.c Mon Apr 11 07:58:36 2005
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: wddx.c,v 1.111.2.1 2005/04/11 09:28:11 dmitry Exp $ */
+/* $Id: wddx.c,v 1.111.2.2 2005/04/11 11:58:36 dmitry Exp $ */
#include "php.h"
@@ -620,6 +620,7 @@
char tmp_buf[WDDX_BUF_LEN];
char *name_esc;
int name_esc_len;
+ HashTable *ht;
if (name) {
name_esc = php_escape_html_entities(name, name_len, &name_esc_len, 0, ENT_QUOTES, NULL
TSRMLS_CC);
@@ -647,11 +648,25 @@
break;
case IS_ARRAY:
+ ht = Z_ARRVAL_P(var);
+ if (ht->nApplyCount > 1) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "WDDX doesn't support circular
references");
+ return;
+ }
+ ht->nApplyCount++;
php_wddx_serialize_array(packet, var);
+ ht->nApplyCount--;
break;
case IS_OBJECT:
- php_wddx_serialize_object(packet, var);
+ ht = Z_OBJPROP_P(var);
+ if (ht->nApplyCount > 1) {
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "WDDX doesn't support circular
references");
+ return;
+ }
+ ht->nApplyCount++;
+ php_wddx_serialize_object(packet, var);
+ ht->nApplyCount--;
break;
}