Re: Bug #3384: Problems with the XML module

From: Date: Sat, 05 Feb 2000 16:34:38 +0000
Subject: Re: Bug #3384: Problems with the XML module
References: 1 2  Groups: php.dev 
Request: Send a blank email to php-dev+get-15222@lists.php.net to get a copy of this message
hi just had a look at your patch - and i will not apply it without further explanation. - what is the reason to take out the thisfunc stuff? - why does xml_call_handler no longer returns a pval* short - what does this patch solve? any short testcase you could send me that shows the problem? please don't take it personal - but if there's a bug i'd also like to fix it for 4.0 - you changes a lot around i i cannot identify the source of the problem. usually a bugfix patch is a few lines... we're going to release 3.0.15 + 4.0b4 soon - plz try to get back to me soon. (if there's a bug in xml.c i'd like to see the fixed in) tc On Thu, Feb 03, 2000 at 01:39:54PM +0000, Drew Wells wrote: > As requested, here is the patch of just the stuff that needs changing. > I did it against the CVS version. > > Rgds Drew > > thies@digicol.de said: > > > On Wed, Feb 02, 2000 at 11:38:14AM -0000, drew@elysium.ltd.uk wrote: > > > From: drew@elysium.ltd.uk > > > Operating system: RH 6.1 > > > PHP version: 3.0.14 > > > PHP Bug Type: Other > > > Bug description: Problems with the XML module > > > > > > I have been getting Segmentation faults in Apache children using the XML module. I > > > have modified the source for the XML module to try and make it more stable. I have included the > > > diff for my changes. On the same note, I dont use the DAV module but it looks very similar to the > > > XML module, so the changes I have made to the XML module might well apply to it. > > > > > > The diff is VERY long, so if you need it E-Mailed to someone please let me know. > > > > please create a patch against the latest CVS version and send > > that. you (or you editor) have changed a lot of whitespace > > and indention stuff that should not get committed this way. > > that's why your diff is soo long. > > > > plz try to send us just what needs to be changed as an > > appieable patch. > > > > thanx > > tc > > Content-Description: XML Patch > *** php-3.0.14.orig/functions/xml.c Sat Jan 1 04:31:17 2000 > --- php-3.0.14/functions/xml.c Thu Feb 3 14:28:16 2000 > *************** > *** 89,95 **** > inline static char xml_decode_us_ascii(unsigned short); > static XML_Char *xml_utf8_encode(const char *, int, int *, const XML_Char *); > static char *xml_utf8_decode(const XML_Char *, int, int *, const XML_Char *); > ! static pval *xml_call_handler(xml_parser *, char *, int, pval **); > static pval *php3i_xmlcharpval(const XML_Char *, int, const XML_Char *); > static int php3i_xmlcharlen(const XML_Char *); > static void php3i_add_to_info(xml_parser *parser,char *name); > --- 89,95 ---- > inline static char xml_decode_us_ascii(unsigned short); > static XML_Char *xml_utf8_encode(const char *, int, int *, const XML_Char *); > static char *xml_utf8_decode(const XML_Char *, int, int *, const XML_Char *); > ! static int xml_call_handler(xml_parser *, char *, int, pval **); > static pval *php3i_xmlcharpval(const XML_Char *, int, const XML_Char *); > static int php3i_xmlcharlen(const XML_Char *); > static void php3i_add_to_info(xml_parser *parser,char *name); > *************** > *** 321,354 **** > /* }}} */ > /* {{{ xml_call_handler() */ > > ! static pval * > xml_call_handler(xml_parser *parser, char *funcName, int argc, pval **argv) > { > if (parser && funcName) { > ! pval *retval, *func; > ! int i; > ! HashTable *function_table; > > - func = php3i_string_pval(funcName); > - retval = emalloc(sizeof(pval)); > /* We cannot call internal variables from a function module as > it breaks any chance of compiling it as a module on windows. > Instead, we create a callback function. */ > ! function_table=php3i_get_function_table(); > ! if (call_user_function(function_table, NULL, func, retval, argc, argv) == FAILURE) { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! return NULL; > ! } > php3tls_pval_destructor(func); > efree(func); > for (i = 0; i < argc; i++) { > php3tls_pval_destructor(argv[i]); > efree(argv[i]); > } > ! return retval; > } > ! return NULL; > } > > /* }}} */ > --- 321,353 ---- > /* }}} */ > /* {{{ xml_call_handler() */ > > ! static int > xml_call_handler(xml_parser *parser, char *funcName, int argc, pval **argv) > { > if (parser && funcName) { > ! int i, ret; > ! pval retval; > ! pval *func = php3i_string_pval(funcName); > > /* We cannot call internal variables from a function module as > it breaks any chance of compiling it as a module on windows. > Instead, we create a callback function. */ > ! > ! ret = call_user_function(&GLOBAL(function_table), NULL, func, &retval, argc, argv); > php3tls_pval_destructor(func); > efree(func); > + > + if (ret == FAILURE) > + return 0; > + > for (i = 0; i < argc; i++) { > php3tls_pval_destructor(argv[i]); > efree(argv[i]); > } > ! convert_to_long(&retval); > ! return retval.value.lval; > } > ! return 0; > } > > /* }}} */ > *************** > *** 578,584 **** > XML_TLS_VARS; > > if (parser) { > ! pval *retval, *args[3]; > > parser->level++; > > --- 577,583 ---- > XML_TLS_VARS; > > if (parser) { > ! pval *args[3]; > > parser->level++; > > *************** > *** 609,619 **** > } > attributes += 2; > } > ! > ! if ((retval = xml_call_handler(parser, parser->startElementHandler, 3, args))) { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! } > } > > if (parser->data) { > --- 608,614 ---- > } > attributes += 2; > } > ! xml_call_handler(parser, parser->startElementHandler, 3, args); > } > > if (parser->data) { > *************** > *** 677,683 **** > XML_TLS_VARS; > > if (parser) { > ! pval *retval, *args[2]; > > if (parser->case_folding) { > name = _php3_strtoupper(estrdup(name)); > --- 672,678 ---- > XML_TLS_VARS; > > if (parser) { > ! pval *args[2]; > > if (parser->case_folding) { > name = _php3_strtoupper(estrdup(name)); > *************** > *** 687,696 **** > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_string_pval(name); > > ! if ((retval = xml_call_handler(parser, parser->endElementHandler, 2, args))) { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! } > } > > if (parser->data) { > --- 682,688 ---- > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_string_pval(name); > > ! xml_call_handler(parser, parser->endElementHandler, 2, args); > } > > if (parser->data) { > *************** > *** 732,746 **** > XML_TLS_VARS; > > if (parser) { > ! pval *retval, *args[2]; > > if (parser->characterDataHandler) { > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(s, len, parser->target_encoding); > ! if ((retval = xml_call_handler(parser, parser->characterDataHandler, 2, args))) { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! } > } > > if (parser->data) { > --- 724,735 ---- > XML_TLS_VARS; > > if (parser) { > ! pval *args[2]; > > if (parser->characterDataHandler) { > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(s, len, parser->target_encoding); > ! xml_call_handler(parser, parser->characterDataHandler, 2, args); > } > > if (parser->data) { > *************** > *** 811,825 **** > XML_TLS_VARS; > > if (parser && parser->processingInstructionHandler) { > ! pval *retval, *args[3]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(target, 0, parser->target_encoding); > args[2] = php3i_xmlcharpval(data, 0, parser->target_encoding); > ! if ((retval = xml_call_handler(parser, parser->processingInstructionHandler, 3, args))) > { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! } > } > } > > --- 800,811 ---- > XML_TLS_VARS; > > if (parser && parser->processingInstructionHandler) { > ! pval *args[3]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(target, 0, parser->target_encoding); > args[2] = php3i_xmlcharpval(data, 0, parser->target_encoding); > ! xml_call_handler(parser, parser->processingInstructionHandler, 3, args); > } > } > > *************** > *** 832,845 **** > XML_TLS_VARS; > > if (parser && parser->defaultHandler) { > ! pval *retval, *args[2]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(s, len, parser->target_encoding); > ! if ((retval = xml_call_handler(parser, parser->defaultHandler, 2, args))) { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! } > } > } > > --- 818,828 ---- > XML_TLS_VARS; > > if (parser && parser->defaultHandler) { > ! pval *args[2]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(s, len, parser->target_encoding); > ! xml_call_handler(parser, parser->defaultHandler, 2, args); > } > } > > *************** > *** 857,863 **** > XML_TLS_VARS; > > if (parser && parser->unparsedEntityDeclHandler) { > ! pval *retval, *args[5]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(entityName, 0, parser->target_encoding); > --- 840,846 ---- > XML_TLS_VARS; > > if (parser && parser->unparsedEntityDeclHandler) { > ! pval *args[6]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(entityName, 0, parser->target_encoding); > *************** > *** 865,874 **** > args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding); > args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding); > args[5] = php3i_xmlcharpval(notationName, 0, parser->target_encoding); > ! if ((retval = xml_call_handler(parser, parser->unparsedEntityDeclHandler, 6, args))) { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! } > } > } > > --- 848,854 ---- > args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding); > args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding); > args[5] = php3i_xmlcharpval(notationName, 0, parser->target_encoding); > ! xml_call_handler(parser, parser->unparsedEntityDeclHandler, 6, args); > } > } > > *************** > *** 886,902 **** > XML_TLS_VARS; > > if (parser && parser->notationDeclHandler) { > ! pval *retval, *args[5]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(notationName, 0, parser->target_encoding); > args[2] = php3i_xmlcharpval(base, 0, parser->target_encoding); > args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding); > args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding); > ! if ((retval = xml_call_handler(parser, parser->notationDeclHandler, 5, args))) { > ! php3tls_pval_destructor(retval); > ! efree(retval); > ! } > } > } > > --- 866,879 ---- > XML_TLS_VARS; > > if (parser && parser->notationDeclHandler) { > ! pval *args[5]; > > args[0] = php3i_long_pval(parser->index); > args[1] = php3i_xmlcharpval(notationName, 0, parser->target_encoding); > args[2] = php3i_xmlcharpval(base, 0, parser->target_encoding); > args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding); > args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding); > ! xml_call_handler(parser, parser->notationDeclHandler, 5, args); > } > } > > *************** > *** 922,934 **** > args[2] = php3i_xmlcharpval(base, 0, parser->target_encoding); > args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding); > args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding); > ! if ((retval = xml_call_handler(parser, parser->externalEntityRefHandler, 5, args))) { > ! convert_to_long(retval); > ! ret = retval->value.lval; > ! efree(retval); > ! } else { > ! ret = 0; > ! } > } > return ret; > } > --- 899,905 ---- > args[2] = php3i_xmlcharpval(base, 0, parser->target_encoding); > args[3] = php3i_xmlcharpval(systemId, 0, parser->target_encoding); > args[4] = php3i_xmlcharpval(publicId, 0, parser->target_encoding); > ! ret = xml_call_handler(parser, parser->externalEntityRefHandler, 5, args); > } > return ret; > } > *************** > *** 947,953 **** > int id, argc; > pval *encodingArg = NULL; > XML_Char *encoding; > - char thisfunc[] = "xml_parser_create"; > XML_TLS_VARS; > > argc = ARG_COUNT(ht); > --- 918,923 ---- > *************** > *** 971,978 **** > encodingArg->value.str.len) == 0) { > encoding = "US-ASCII"; > } else { /* UTF-16 not supported */ > ! php3_error(E_WARNING, "%s: unsupported source encoding \"%s\"", > ! thisfunc, encodingArg->value.str.val); > RETURN_FALSE; > } > } else { > --- 941,948 ---- > encodingArg->value.str.len) == 0) { > encoding = "US-ASCII"; > } else { /* UTF-16 not supported */ > ! php3_error(E_WARNING, "xml_parser_create: unsupported source encoding > \"%s\"", > ! encodingArg->value.str.val); > RETURN_FALSE; > } > } else { > *************** > *** 984,990 **** > parser->target_encoding = encoding; > XML_SetUserData(parser->parser, parser); > id = php3_list_insert(parser, XML_GLOBAL(php3_xml_module).le_xml_parser); > ! parser = xml_get_parser(id, thisfunc, list); > parser->index = id; > parser->case_folding = 1; > > --- 954,960 ---- > parser->target_encoding = encoding; > XML_SetUserData(parser->parser, parser); > id = php3_list_insert(parser, XML_GLOBAL(php3_xml_module).le_xml_parser); > ! parser = xml_get_parser(id, "xml_parser_create", list); > parser->index = id; > parser->case_folding = 1; > > *************** > *** 1360,1366 **** > { > xml_parser *parser; > pval *pind, *opt, *val; > - char thisfunc[] = "xml_parser_set_option"; > XML_TLS_VARS; > > if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &pind, &opt, &val) == FAILURE) { > --- 1330,1335 ---- > *************** > *** 1368,1374 **** > } > convert_to_long(pind); > convert_to_long(opt); > ! parser = xml_get_parser(pind->value.lval, thisfunc, list); > if (parser == NULL) { > RETURN_FALSE; > } > --- 1337,1343 ---- > } > convert_to_long(pind); > convert_to_long(opt); > ! parser = xml_get_parser(pind->value.lval, "xml_parser_set_option", list); > if (parser == NULL) { > RETURN_FALSE; > } > *************** > *** 1388,1402 **** > case PHP3_XML_OPTION_TARGET_ENCODING: { > xml_encoding *enc = xml_get_encoding(val->value.str.val); > if (enc == NULL) { > ! php3_error(E_WARNING, "%s: unsupported target encoding \"%s\"", > ! thisfunc, val->value.str.val); > RETURN_FALSE; > } > parser->target_encoding = enc->name; > break; > } > default: > ! php3_error(E_WARNING, "%s: unknown option", thisfunc); > RETURN_FALSE; > break; > } > --- 1357,1371 ---- > case PHP3_XML_OPTION_TARGET_ENCODING: { > xml_encoding *enc = xml_get_encoding(val->value.str.val); > if (enc == NULL) { > ! php3_error(E_WARNING, "xml_parser_set_option: unsupported target encoding > \"%s\"", > ! val->value.str.val); > RETURN_FALSE; > } > parser->target_encoding = enc->name; > break; > } > default: > ! php3_error(E_WARNING, "xml_parser_set_option: unknown option"); > RETURN_FALSE; > break; > } > *************** > *** 1410,1416 **** > { > xml_parser *parser; > pval *pind, *opt; > - char thisfunc[] = "xml_parser_get_option"; > XML_TLS_VARS; > > if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &opt) == FAILURE) { > --- 1379,1384 ---- > *************** > *** 1418,1424 **** > } > convert_to_long(pind); > convert_to_long(opt); > ! parser = xml_get_parser(pind->value.lval, thisfunc, list); > if (parser == NULL) { > RETURN_FALSE; > } > --- 1386,1392 ---- > } > convert_to_long(pind); > convert_to_long(opt); > ! parser = xml_get_parser(pind->value.lval, "xml_parser_get_option", list); > if (parser == NULL) { > RETURN_FALSE; > } > *************** > *** 1430,1436 **** > RETURN_STRING(parser->target_encoding, 1); > break; > default: > ! php3_error(E_WARNING, "%s: unknown option", thisfunc); > RETURN_FALSE; > break; > } > --- 1398,1404 ---- > RETURN_STRING(parser->target_encoding, 1); > break; > default: > ! php3_error(E_WARNING, "xml_parser_get_option: unknown option"); > RETURN_FALSE; > break; > } -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany

« previous php.dev (#15222) next »