ID: 37587
User updated by: alan at akbkhome dot com
Reported By: alan at akbkhome dot com
Status: Open
Bug Type: WDDX related
Operating System: linux
PHP Version: 5CVS-2006-05-25 (CVS)
New Comment:
probably worth changing all the
for (i=0;att[i];i++)
to
for (i=0;att && att[i];i++)
in that whole function.
Previous Comments:
------------------------------------------------------------------------
[2006-05-25 05:04:01] alan at akbkhome dot com
Description:
------------
<var> with out attributes causes segfault due to no checking on att
patch to fix:
? run-tests.php
cvs diff: Diffing .
Index: wddx.c
===================================================================
RCS file: /repository/php-src/ext/wddx/wddx.c,v
retrieving revision 1.119.2.10
diff -u -r1.119.2.10 wddx.c
--- wddx.c 23 Apr 2006 16:02:05 -0000 1.119.2.10
+++ wddx.c 25 May 2006 05:00:10 -0000
@@ -811,14 +811,15 @@
wddx_stack_push((wddx_stack *)stack, &ent,
sizeof(st_entry));
} else if (!strcmp(name, EL_VAR)) {
int i;
-
- for (i = 0; atts[i]; i++) {
- if (!strcmp(atts[i], EL_NAME) && atts[++i] &&
atts[i][0]) {
- char *decoded;
- int decoded_len;
- decoded = xml_utf8_decode(atts[i],
strlen(atts[i]), &decoded_len, "ISO-8859-1");
- stack->varname = decoded;
- break;
+ if (atts) {
+ for (i = 0; atts[i]; i++) {
+ if (!strcmp(atts[i], EL_NAME) &&
atts[++i] && atts[i][0]) {
+ char *decoded;
+ int decoded_len;
+ decoded =
xml_utf8_decode(atts[i], strlen(atts[i]), &decoded_len, "ISO-8859-1");
+ stack->varname = decoded;
+ break;
+ }
}
}
} else if (!strcmp(name, EL_RECORDSET)) {
Reproduce code:
---------------
php -r
'var_dump(wddx_deserialize(file_get_contents("http://www.akbkhome.com/svn/hebehaven2/templates/backend/members_edit.html.rules.wddx")));
Expected result:
----------------
a nice printout
Actual result:
--------------
segfault
backtrace basically says att = 0x0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37587&edit=1