summaryrefslogtreecommitdiff
path: root/ext/wddx
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:59 -0400
commitce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (patch)
treeacdb9a8816483652a9db1a47db71df5df43707c5 /ext/wddx
parent10f5b47dc7c1cf2b9a00991629f43652710322d3 (diff)
downloadphp-ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61.tar.gz
Imported Upstream version 5.1.1upstream/5.1.1
Diffstat (limited to 'ext/wddx')
-rw-r--r--ext/wddx/config.m44
-rw-r--r--ext/wddx/config.w323
-rw-r--r--ext/wddx/php_wddx.h4
-rw-r--r--ext/wddx/php_wddx_api.h4
-rwxr-xr-xext/wddx/tests/bug34306.phpt12
-rw-r--r--ext/wddx/wddx.c40
6 files changed, 47 insertions, 20 deletions
diff --git a/ext/wddx/config.m4 b/ext/wddx/config.m4
index 724fad5a6..0c5228b0a 100644
--- a/ext/wddx/config.m4
+++ b/ext/wddx/config.m4
@@ -1,9 +1,9 @@
dnl
-dnl $Id: config.m4,v 1.10 2002/03/12 16:37:42 sas Exp $
+dnl $Id: config.m4,v 1.11 2005/05/29 23:16:45 sniper Exp $
dnl
PHP_ARG_ENABLE(wddx,whether to enable WDDX support,
-[ --enable-wddx Enable WDDX support.])
+[ --enable-wddx Enable WDDX support])
if test "$PHP_WDDX" != "no"; then
if test "$ext_shared" != "yes" && test "$enable_xml" = "no"; then
diff --git a/ext/wddx/config.w32 b/ext/wddx/config.w32
index 3952e6652..cdb79fb5f 100644
--- a/ext/wddx/config.w32
+++ b/ext/wddx/config.w32
@@ -1,4 +1,4 @@
-// $Id: config.w32,v 1.2 2003/12/22 13:16:41 wez Exp $
+// $Id: config.w32,v 1.2.4.1 2005/10/06 13:03:43 derick Exp $
// vim:ft=javascript
ARG_WITH("wddx", "WDDX support", "yes");
@@ -7,6 +7,7 @@ if (PHP_WDDX == "yes" && PHP_LIBXML == "yes") {
EXTENSION("wddx", "wddx.c");
AC_DEFINE("HAVE_WDDX", 1, "WDDX support");
ADD_EXTENSION_DEP('wddx', 'libxml');
+ CHECK_HEADER_ADD_INCLUDE("timelib_config.h", "CFLAGS_WDDX", "ext/date/lib");
}
diff --git a/ext/wddx/php_wddx.h b/ext/wddx/php_wddx.h
index a8247f396..c774654fa 100644
--- a/ext/wddx/php_wddx.h
+++ b/ext/wddx/php_wddx.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_wddx.h,v 1.17 2004/01/08 17:32:58 sniper Exp $ */
+/* $Id: php_wddx.h,v 1.18 2005/08/03 14:08:20 sniper Exp $ */
#ifndef PHP_WDDX_H
#define PHP_WDDX_H
diff --git a/ext/wddx/php_wddx_api.h b/ext/wddx/php_wddx_api.h
index 010aa8540..3a5ebda2f 100644
--- a/ext/wddx/php_wddx_api.h
+++ b/ext/wddx/php_wddx_api.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_wddx_api.h,v 1.22 2004/01/08 17:32:58 sniper Exp $ */
+/* $Id: php_wddx_api.h,v 1.23.2.2 2005/10/06 18:48:19 rrichards Exp $ */
#ifndef PHP_WDDX_API_H
#define PHP_WDDX_API_H
diff --git a/ext/wddx/tests/bug34306.phpt b/ext/wddx/tests/bug34306.phpt
new file mode 100755
index 000000000..2212dad91
--- /dev/null
+++ b/ext/wddx/tests/bug34306.phpt
@@ -0,0 +1,12 @@
+--TEST--
+#34306 (wddx_serialize_value() crashes with long array keys)
+--FILE--
+<?php
+
+$var = array('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa12345678901234567890123456789012345678901234567890ba12345678901234567890123456789012345678901234567890ba12345678901234567890123456789012345678901234567890ba12345678901234567890123456789012345678901234567890b12345678901234567891234567890123123121231211111' => 1);
+$buf = wddx_serialize_value($var, 'name');
+echo "OK\n";
+
+?>
+--EXPECT--
+OK
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 2216fb0ff..e801d60a6 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: wddx.c,v 1.111.2.3 2005/05/30 15:13:57 sniper Exp $ */
+/* $Id: wddx.c,v 1.119.2.5 2005/10/06 18:48:19 rrichards Exp $ */
#include "php.h"
@@ -34,7 +34,7 @@
#include "ext/standard/php_smart_str.h"
#include "ext/standard/html.h"
#include "ext/standard/php_string.h"
-#include "ext/standard/php_parsedate.h"
+#include "ext/date/php_date.h"
#define WDDX_BUF_LEN 256
#define PHP_CLASS_NAME_VAR "php_class_name"
@@ -422,7 +422,7 @@ static void php_wddx_serialize_number(wddx_packet *packet, zval *var)
tmp = *var;
zval_copy_ctor(&tmp);
convert_to_string(&tmp);
- sprintf(tmp_buf, WDDX_NUMBER, Z_STRVAL(tmp));
+ snprintf(tmp_buf, sizeof(tmp_buf), WDDX_NUMBER, Z_STRVAL(tmp));
zval_dtor(&tmp);
php_wddx_add_chunk(packet, tmp_buf);
@@ -524,7 +524,7 @@ static void php_wddx_serialize_object(wddx_packet *packet, zval *obj)
if (zend_hash_get_current_key_ex(HASH_OF(obj), &key, &key_len, &idx, 0, NULL) == HASH_KEY_IS_STRING) {
char *class_name, *prop_name;
- zend_unmangle_property_name(key, &class_name, &prop_name);
+ zend_unmangle_property_name_ex(key, key_len, &class_name, &prop_name);
php_wddx_serialize_var(packet, *ent, prop_name, strlen(prop_name)+1 TSRMLS_CC);
} else {
key_len = sprintf(tmp_buf, "%ld", idx);
@@ -617,15 +617,17 @@ static void php_wddx_serialize_array(wddx_packet *packet, zval *arr)
*/
void php_wddx_serialize_var(wddx_packet *packet, zval *var, char *name, int name_len TSRMLS_DC)
{
- char tmp_buf[WDDX_BUF_LEN];
+ char *tmp_buf;
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);
- sprintf(tmp_buf, WDDX_VAR_S, name_esc);
+ tmp_buf = emalloc(name_esc_len + sizeof(WDDX_VAR_S));
+ snprintf(tmp_buf, name_esc_len + sizeof(WDDX_VAR_S), WDDX_VAR_S, name_esc);
php_wddx_add_chunk(packet, tmp_buf);
+ efree(tmp_buf);
efree(name_esc);
}
@@ -728,7 +730,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
ALLOC_ZVAL(ent.data);
INIT_PZVAL(ent.data);
Z_TYPE_P(ent.data) = IS_STRING;
- Z_STRVAL_P(ent.data) = empty_string;
+ Z_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();
Z_STRLEN_P(ent.data) = 0;
wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
} else if (!strcmp(name, EL_BINARY)) {
@@ -738,7 +740,7 @@ static void php_wddx_push_element(void *user_data, const XML_Char *name, const X
ALLOC_ZVAL(ent.data);
INIT_PZVAL(ent.data);
Z_TYPE_P(ent.data) = IS_STRING;
- Z_STRVAL_P(ent.data) = empty_string;
+ Z_STRVAL_P(ent.data) = STR_EMPTY_ALLOC();
Z_STRLEN_P(ent.data) = 0;
wddx_stack_push((wddx_stack *)stack, &ent, sizeof(st_entry));
} else if (!strcmp(name, EL_CHAR)) {
@@ -997,10 +999,20 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
ent1->data->refcount--;
add_property_zval(ent2->data, ent1->varname, ent1->data);
EG(scope) = old_scope;
- } else
- zend_hash_update(target_hash,
- ent1->varname, strlen(ent1->varname)+1,
- &ent1->data, sizeof(zval *), NULL);
+ } else {
+ long l;
+ double d;
+
+ switch (is_numeric_string(ent1->varname, strlen(ent1->varname), &l, &d, 0)) {
+ case IS_DOUBLE:
+ l = (long) d;
+ case IS_LONG:
+ zend_hash_index_update(target_hash, l, &ent1->data, sizeof(zval *), NULL);
+ break;
+ default:
+ zend_hash_update(target_hash,ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);
+ }
+ }
efree(ent1->varname);
} else {
zend_hash_next_index_insert(target_hash,
@@ -1039,6 +1051,7 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len)
decoded = xml_utf8_decode(s, len, &decoded_len, "ISO-8859-1");
if (Z_STRLEN_P(ent->data) == 0) {
+ STR_FREE(Z_STRVAL_P(ent->data));
Z_STRVAL_P(ent->data) = estrndup(decoded, decoded_len);
Z_STRLEN_P(ent->data) = decoded_len;
} else {
@@ -1054,6 +1067,7 @@ static void php_wddx_process_data(void *user_data, const XML_Char *s, int len)
case ST_BINARY:
if (Z_STRLEN_P(ent->data) == 0) {
+ STR_FREE(Z_STRVAL_P(ent->data));
Z_STRVAL_P(ent->data) = estrndup(s, len + 1);
} else {
Z_STRVAL_P(ent->data) = erealloc(Z_STRVAL_P(ent->data), Z_STRLEN_P(ent->data) + len + 1);